javasgl

step by step


  • Home

  • Archives

  • Tags

  • Categories

  • About

  • Search

Virtualenv 使用

Posted on 2017-11-30 | In python | Visitors

一般情况下,大多数系统上安装的 python 版本为 2.x 的。但是有时候我们需要同时使用 python3.x 和 python2.x,这里推荐使用 virtualenv 来管理两个甚至是多个不同版本的 python。

安装 python3

mac系统安装python3,很简单, brew install python3, 升级也很简单,brew upgrade python3。注意可能需要 sudo。

安装 virtualenv

可以用过 pip来安装,pip install virtualenv

创建一个python环境

例如创建一个 python3 的环境,virtualenv --python=python3 /usr/local/python3

激活

执行source /usr/local/python3/bin/activate即可

git 推送大文件buffer设置

Posted on 2017-11-15 | In tools | Visitors

git默认的 http.postBuffer大小为1M。所以偶尔遇到比较大的文件或者项目时,会报出以下错误:

1
2
3
error: RPC failed; result=22, HTTP code = 411
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

这时可以通过设置 http.postBuffer来解决。下面设置为100M。

1
git config --global http.postBuffer=104857600

Buffered Channel + sync.WaitGroup 实现对 goroutinue 并发数的限制

Posted on 2017-09-18 | In go | Visitors

写过爬虫的都应该考虑这个问题:不能毫无节制、毫无节操的无限制的并发爬取目标网站的内容,不然很容易被对方识别出来从而被封。

Go 的 goroutinue 机制使用起来非常简单,所以很多人比如我就喜欢用 Go 来写写爬虫。那么如何限制 goroutinue 并发数呢?

下面提供一种 Buffered Channel + sync.WaitGroup 实现对 goroutinue 并发数进行控制的思路。这种方式其实在 D&K 所著的《The Go Programing Language》一书中的第八章(goroutinue and channels) 中也有提到。

Read more »

http压力测试工具--wrk

Posted on 2017-09-17 | In tools | Visitors

发现一个新的 http 压力测试工具 wrk ,简单好用。下载地址:https://github.com/wg/wrk 。类似于之前个人经常使用的一些压测工具,详细请移步 压力测试工具ab、webbench、http_load、siege简单使用。

wrk 使用非常简单,参数不多,但是足够自己简单压测一些 http 服务了。下面简单介绍下如何安装和使用。

Read more »

python threading 多线程简单使用

Posted on 2017-09-05 | In python | Visitors

之前一个项目,使用 Flask 框架写了一个网络图片抓取的程序,当时时间紧急,多张图片下载的时候,就简简单单的使用 for in 循环去获取网络图片内容。后来有空了,看了下 python 的多线程的使用,挺简单的,就用 threading 重新改造了下这个程序,让其支持多线程。

Read more »
1…456…12
javasgl

javasgl

A journey of a thousand miles begins with single step

60 posts
13 categories
94 tags
RSS
GitHub Wechat
© 2020 javasgl
Powered by Hexo
Theme - NexT.Mist
0%