摘要: python有一个python模块--hash_ring,即python中的一致性hash,使用起来也挺简单。可以参考下官方例子:https://pypi.python.org/pypi/hash_ring/ 1 Basic example of usage (for managing memcached instances): 2 3 memcache_servers = ['192.168.0.246:11212', 4 '192.168.0.247:11212', 5 '192.168.0.249:1121... 阅读全文
posted @ 2013-07-28 21:22 good90 阅读(2709) 评论(0) 推荐(0) 编辑
摘要: 调试程序发现起了一个子线程后,主线程上的sleep不生效了,看到这才明白...— Function: unsigned intsleep(unsigned int seconds)Thesleepfunction waits forsecondsor until a signal is delivered, whichever happens first.Ifsleepfunction returns because the requested interval is over, it returns a value of zero. If it returns because of deli 阅读全文
posted @ 2013-07-23 23:17 good90 阅读(2732) 评论(0) 推荐(1) 编辑
摘要: 1 #baidu_hotword.py 2 #get baidu hotword in news.baidu.com 3 import urllib2 4 import os 5 import re 6 7 def getHtml(url): 8 page = urllib2.urlopen(url) 9 html = page.read()10 page.close()11 return html12 13 def getHotWord(html):14 reg = ''15 hotwords = re.compile(reg).finda... 阅读全文
posted @ 2013-07-07 18:09 good90 阅读(1222) 评论(0) 推荐(0) 编辑
摘要: 1 #!/bin/python 2 # download_pic.py 3 # download picture 4 import os 5 import sys 6 from urllib.request import urlopen 7 8 url = sys.argv[1] 9 page = urlopen(url)10 #需要指定编码格式11 html = str(page.read(),encoding='utf8')12 page.close()13 14 #create directory15 if os.path.exists("./picture&q 阅读全文
posted @ 2013-06-30 19:01 good90 阅读(299) 评论(0) 推荐(0) 编辑
摘要: int lua_next (lua_State *L, int index);Pops a key from the stack, and pushes a key-value pair from the table at the given index (the "next" pair after the given key). If there are no more elements in the table, thenlua_nextreturns 0 (and pushes nothing).A typical traversal looks like this: 阅读全文
posted @ 2013-03-20 19:29 good90 阅读(676) 评论(0) 推荐(0) 编辑
摘要: / *ObjectPool.h */#include <iostream>#include <queue>#include <vector>template <typename T>class ObjectPool{public: ObjectPool(size_t chunk_size = kdefault_size); ~ObjectPool(); T& acquire_object(); void release_object(T& obj);protected: void allocate_chunk(); static 阅读全文
posted @ 2013-03-16 14:58 good90 阅读(2925) 评论(0) 推荐(1) 编辑
摘要: 编译的时候出现warning:Linker Tools Warning LNK4098defaultlib "library" conflicts with use of other libs; use /NODEFAULTLIB:library说明存在库冲突,在link选项中加参数:/VERBOSE:LIB 再编译则显示进度消息,仅指示所搜索的库。所显示的信息包括库搜索进程,同时还列出每个库和对象名(包括完整路径),正从库中解析的符号,以及引用该符号的对象的列表。可以看到确实依赖了debug版本的库。在link选项中加参数/NODEFAULTLIB:msvcrtd.lib 阅读全文
posted @ 2013-03-01 09:41 good90 阅读(2352) 评论(1) 推荐(1) 编辑
摘要: 原因:ICEidempotent operation 存在超时重试机制导致。解决方法:设置参数,Ice.Retry.Intervals=-1Ice.RetryIntervalsSynopsisIce.RetryIntervals=num[num...]DescriptionThis property defines the number of times an operation isautomatically retriedand the delay between each retry. For example, if the property is set to0100500, the 阅读全文
posted @ 2013-01-28 14:55 good90 阅读(4215) 评论(0) 推荐(0) 编辑
摘要: dll 源文件 add.cppView Code 1 typedef int (*pfunc)(int, int); 2 pfunc myadd; 3 4 void __stdcall add(pfunc add) 5 { 6 myadd = add; 7 } 8 9 int __stdcall true_add(int x, int y)10 {11 return myadd(x, y);12 }def文件 add.defView Code 1 EXPORTS2 3 add @14 true_add @2 生成库ad... 阅读全文
posted @ 2012-10-29 22:40 good90 阅读(2499) 评论(0) 推荐(0) 编辑
摘要: 定时执行:@echo off@set interval=0.5:againecho execute test.batCALL test.batecho sleep %interval%sping -n %interval% 127.1>nul echo restartgoto againpause同时启动多个exestart "" "a.exe" -argsstart "" "a.exe" -args... 阅读全文
posted @ 2012-10-29 22:10 good90 阅读(221) 评论(0) 推荐(0) 编辑