- sort list object with tuple item
In [1]: import functools
In [2]: s = [('a', 10), ('c', 9), ('b', 10), ('c', 10), ('a', 7), ('a', 11), ('b', 11), ('c', 11)]
In [3]: def mysort(a, b):
In [1]: import functools
In [2]: s = [('a', 10), ('c', 9), ('b', 10), ('c', 10), ('a', 7), ('a', 11), ('b', 11), ('c', 11)]
In [3]: def mysort(a, b):
// https://stackoverflow.com/questions/9238119/find-clickable-elements | |
$.each($('.container').find("*").andSelf().data("events"), function(i, event) { | |
$.each(event, function(j, h) { | |
if(j === 'click') | |
{ | |
//Do stuff to $(this) | |
alert(j); | |
alert(h.handler); //Gets the actual handler for each event ( inject code >=] ) | |
} | |
}); |
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 ...' |
''' | |
将秒数转换为可读性更强的表述方式 | |
eg: | |
``` | |
In [4]: print seconds_to_human_readable(33) | |
33 秒 | |
In [5]: print seconds_to_human_readable(60 * 3 + 2) | |
3 分钟, 2 秒 |
''' | |
例子: | |
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, |
# 使用了 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") { |
ssh-keygen -t rsa -b 2048 -C 'your-email-address' -N '<leave blank for NO passphrase>' -f 'out-put-file' |
-- ~/root |--module1 |--sub_dir1 |--source.0.ext |--source.1.ext |--m1.py |--module2 |--source.2.ext |--m2.py
mkdir ngx-with-lua | |
cd ngx-with-lua | |
current_dir=`pwd` | |
# download luajit | |
wget http://luajit.org/download/LuaJIT-2.0.4.tar.gz | |
tar -xf LuaJIT-2.0.4.tar.gz | |
cd LuaJIT-2.0.4 | |
make && make install |