This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env ?=upy | |
PYTHON_VENV := $(env) | |
version ?=2.7.10 | |
PYTHON_VERSION := $(version) | |
PYTHON_DIR := Python-$(PYTHON_VERSION) | |
all: task-install-venv-wrapper | |
@ echo 'All done ...' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
例子: | |
1. '*********** - 1 year, 4 months ago - someone do something1' => 1*365*24*60*60 + 4*30*24*60*60 | |
2. '*********** - 3 months, 7days ago - someone do something2' => 3*30*24*60*60 + 7*24*60*60 | |
3. '*********** - 5 hours ago - someone do something3' => 5*60*60 | |
''' | |
unit_map = { | |
'years': 365 * 24 * 60 * 60, | |
'year': 365 * 24 * 60 * 60, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 使用了 lua 模块的 nginx 配置文件 | |
# 推荐使用 openresty 或者自行编译 nginx with lua | |
lua_shared_dict proxy_ports 5m; | |
server { | |
listen 80; | |
server_name *.hproxy.yourdomain.com; | |
set $real_host $http_host; | |
if ($http_host ~* "(.*).hproxy.yourdomain.com") { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python ascii codec can't decode and unicode mess | |
# | |
# check this out https://pythonhosted.org/kitchen/unicode-frustrations.html | |
# and this http://www.joelonsoftware.com/articles/Unicode.html | |
# | |
# The short of it is this | |
# 1. If you can, always set PYTHONIOENCODING=utf8 before you start your python programs. | |
# 2. If you can't or you can't ensure this, always use the following lambda _u to get unicode text | |
# whereever you convert to strings (str.format, str % etc.) | |
# |
To remove a submodule you need to:
- Delete the relevant section from the .gitmodules file.
- Stage the .gitmodules changes git add .gitmodules
- Delete the relevant section from .git/config.
- Run git rm --cached path_to_submodule (no trailing slash).
- Run rm -rf .git/modules/path_to_submodule (no trailing slash).
- Commit git commit -m "Removed submodule "
- Delete the now untracked submodule files rm -rf path_to_submodule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import redis | |
import time | |
import sys | |
def producer(): | |
r = redis.Redis() | |
i = 0 | |
while True: | |
r.rpush('queue', 'Message %d' % i) |