http://www.csie.ntu.edu.tw/~r91065/_cur/Studio/naming.html
推薦!!
星期三, 4月 07, 2010
星期四, 4月 01, 2010
[Python] String to JSON轉換必殺技
http://eishn.blog.163.com/blog/static/65231820070181041204/
如果你不想裝JSON module,請服用~~~~^^
json = lambda s, encoding = sys.getdefaultencoding(): repr(unicode(s, encoding))[1:]
PS. 據說最後那行代碼很容易令人摸不著頭腦, 你不妨把json() 換成(string) escape() 來理解。
如果你用escape 來定義這行代碼, 你只能得到escape;
如果你用 json 來命名, 你得到了 JSON。
如果你不想裝JSON module,請服用~~~~^^
json = lambda s, encoding = sys.getdefaultencoding(): repr(unicode(s, encoding))[1:]
PS. 據說最後那行代碼很容易令人摸不著頭腦, 你不妨把json() 換成(string) escape() 來理解。
如果你用escape 來定義這行代碼, 你只能得到escape;
如果你用 json 來命名, 你得到了 JSON。
星期三, 3月 17, 2010
[Linux] time 怎麼用 GNU verison
個人常常使用time來看program跑多久,man time的說明中,有--verbose,還有format,但
# time -v ps aux
這樣都會有顯示
-bash: -v: command not found
real 0m0.001s
user 0m0.000s
sys 0m0.001s
後來才知道原來是bash這個shell中,time的指令沒有GNU版本的功能
所以怎麼跑GNU版本的time呢?
就是..
# /usr/bin/time -v ps aux
水啦~~~~^^
# time -v ps aux
這樣都會有顯示
-bash: -v: command not found
real 0m0.001s
user 0m0.000s
sys 0m0.001s
後來才知道原來是bash這個shell中,time的指令沒有GNU版本的功能
所以怎麼跑GNU版本的time呢?
就是..
# /usr/bin/time -v ps aux
水啦~~~~^^
星期五, 1月 15, 2010
[Linux] vim 怎麼用?!
http://blog.vgod.tw/2009/12/08/vim-cheat-sheet-for-programmers/
這位部落客,把Vim常用的部份給圖形化了,這真是太屌了~~~^^
vim的指令(command)不會,上鳥哥太慢~~~^^
有PDF可以下載嚕~~~^^
這位部落客,把Vim常用的部份給圖形化了,這真是太屌了~~~^^
vim的指令(command)不會,上鳥哥太慢~~~^^
有PDF可以下載嚕~~~^^
星期三, 1月 13, 2010
[Linux] About "kernel: TCP: time wait bucket table overflow"
tcp_max_tw_buckets
Maximal number of timewait sockets held by system simultaneously. If this number is exceeded TIME_WAIT socket is immediately destroyed and warning is printed. This limit exists only to prevent simple DoS attacks, you must not lower the limit artificially, but rather increase it (probably, after increasing installed memory), if network conditions require more than default value (180000).
所以當你設小的時候呢,/var/log/messages就會出現一堆"kernel: TCP: time wait bucket table overflow",所以default值千萬別亂改,如果你的程式會有狠大的traffic
怎麼改回來呢?
在/etc/sysctl.conf加這行
net.ipv4.tcp_max_tw_buckets = 180000
還要
echo 180000 > /proc/sys/net/ipv4/tcp_max_tw_buckets
Maximal number of timewait sockets held by system simultaneously. If this number is exceeded TIME_WAIT socket is immediately destroyed and warning is printed. This limit exists only to prevent simple DoS attacks, you must not lower the limit artificially, but rather increase it (probably, after increasing installed memory), if network conditions require more than default value (180000).
所以當你設小的時候呢,/var/log/messages就會出現一堆"kernel: TCP: time wait bucket table overflow",所以default值千萬別亂改,如果你的程式會有狠大的traffic
怎麼改回來呢?
在/etc/sysctl.conf加這行
net.ipv4.tcp_max_tw_buckets = 180000
還要
echo 180000 > /proc/sys/net/ipv4/tcp_max_tw_buckets
訂閱:
文章 (Atom)