自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

hello_ufo的专栏

要做工程师,不要做码农

  • 博客(13)
  • 资源 (2)
  • 收藏
  • 关注

原创 sunday 算法python实现

同为字符串查找的算法, Sunday真的比KMP简单太多了。理解也很简单:假设有 字符串 A, 待比较字符串 B, 需要查找 A是否包含B。对齐A的i位置和B的0位置, i从0开始。如果A[i] 元素和B[0]相同,就继续比较A的下一个元素和B的下一个值, 就是看A这段字符串是不是B, 如果是就退出结束了。当然事情可能没这么简单, 如果A这段字符串跟B不一样, 那我们就得把B往后移动了,对...

2019-06-27 16:43:27 1155

原创 golang 可视化调试工具——debugcharts

一个可以实时查看golang程序内存、CPU、GC、协程等变化情况的可视化工具,很好用。安装:go get -v -u github.com/mkevac/debugcharts使用:跟pprof一样, import就行了这里是官方的例子:package mainimport ( "fmt" "log" "net/http" "runtime" "time" _ ...

2019-06-20 14:40:42 2266

翻译 golang HTTP Response Body的内存泄漏问题

在爬虫类的场景中, 我们需要做大量的并发http请求,所以经常需要打开和关闭大量http连接。 如果没有正确处理http连接, 很容易导致内存的泄漏。package mainimport ( "fmt" "net/http" "io/ioutil")func main() { resp, err := http.Get("https://api....

2019-06-20 11:21:03 6956 2

原创 golang 使用agouti驱动phantomjs、headless chrome

借助agouti库我们可以在golang下实现对动态网页的爬取。安装:go get -u -v github.com/sclevine/agouti1. phantomjspackage mainimport ( "fmt" "math/rand" "time" "github.com/sclevine/agouti")var UserAgentList = [....

2019-06-19 17:04:16 1837

原创 python 坑爹的字符编码

Unicode 的历史:(摘自python文档Howto部分)1968年,美国的ACSII(the American Standard Code for Information Interchange)提出了使用0-127的表示字符。但是,这没有考虑到重音字 母, 比如‘é’之类的。1980年代,所有的个人电脑都是8位, 可以表示0-255的所有字符。也出现了对应于不同语言的编码, 比如俄语...

2019-06-04 16:37:07 134

原创 Pyinstaller 编译后的python文件, 运行错误:ImportError: No module named 'gevent.__hub_local'

系统: Ubuntu 14.04.5 LTSpyinstaller: 3.3.1gevent: 1.3.5将python脚本通过pyinstaller编译成可执行文件后,运行报错:Traceback (most recent call last): File "cloud_unique.py", line 5, in <module> import geve...

2019-06-04 16:23:40 10978 1

原创 selenium 使用headless Chrome 实现整个网页截图

#!/usr/bin/pythonfrom selenium import webdriverfrom selenium.webdriver.chrome.options import Optionsimport timeurl = "https://www.sina.com.cn"chrome_options = Options()chrome_options.add_argume...

2019-06-04 16:20:20 7934 2

原创 python3 asyncio库学习(三)—— 协程的超时处理和取消

import asyncioimport osimport timefrom asyncio.subprocess import PIPE, STDOUTfrom threading import Threadfrom log_helper import *@asyncio.coroutinedef do_task(domain, loop): print(11111111...

2019-06-04 16:14:47 3203

原创 python3 asyncio库学习(二)—— corcurrent和asyncio的效率对比

(1) corcurrent线程池(python3)#!/usr/bin/python3import socketimport sysimport ssl#from multiprocessing import Poolimport concurrent.futuresfrom contextlib import closingimport timeimport certifi...

2019-06-04 16:13:23 360

原创 python3 asyncio库学习(一)—— coroutine, task , future的区别

18.5.3.1. Coroutines¶Coroutines used with asyncio may be implemented using the async def statement, or by using generators. The async def type of coroutine was added in Python 3.5, and is recommended...

2019-06-04 16:05:15 1224

原创 golang判断一个对象是否被拷贝

package mainimport ( "sync/atomic" "unsafe")type noCopy struct{}// Lock is a no-op used by -copylocks checker from `go vet`.func (*noCopy) Lock() {}type TEST struct { name string noCopy no...

2019-06-04 15:52:49 651

原创 golang etcd clientv3.New()不报超时错误的问题解决

详见这条issue https://github.com/etcd-io/etcd/issues/9877正常来说,clietntv3的初始化代码如下:config := clientv3.Config{ Endpoints: []string{"localhost:2379"}, DialTimeout: dialTimeout,}client, err := clien...

2019-04-16 23:02:40 2831

原创 golang unsafe.Pointer和uintptr

uinptr一个足够大的无符号整型, 用来表示任意地址。可以进行数值计算。unsafe.Pointer代表一个可以指向任意类型的指针。不可以进行数值计算。有四种区别于其他类型的特殊操作:任意类型的指针值均可转换为 Pointer。Pointer 均可转换为任意类型的指针值。uintptr 均可转换为 Pointer。Pointer 均可转换为 uintptr。以...

2019-01-31 16:10:17 4514

LINUX设备驱动程序(第3版)--魏永明译

这一版翻译是比较好的,是理解驱动开发原理的必备参考书

2014-03-24

unix网络编程

LINUX网络编程入门必读,必读必读必读

2014-03-12

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除