Skip to content

Instantly share code, notes, and snippets.

View dreampuf's full-sized avatar

Dreampuf dreampuf

View GitHub Profile
@dreampuf
dreampuf / logic_func.js
Created May 21, 2011 13:44
函数化Javascript
var sgs = sgs || {};
(function(sgs){
var srd = Math.random,
slice = Array.prototype.slice,
copy = function(ary){ return slice.apply(ary); };
sgs.func = sgs.func || {};
sgs.func.rint = function(max) {
max = max || 100;
@dreampuf
dreampuf / bf.js
Created September 3, 2011 17:07
BF runtime
(function(g) {
var cur = 0,
p = 0,
mem = [0],
ret = [],
slen = -1,
pos = [],
unlimit_loop = 5000,
tmp = "",
ptype = Object.prototype.toString,
@dreampuf
dreampuf / gist:3302527
Created August 9, 2012 09:07
Pkg-config error Log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by pkg-config configure 0.27, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ ./configure --disable-debug --prefix=/Users/dreampuf/opt/homebrew/Cellar/pkg-config/0.27 --with-pc-path=/Users/dreampuf/opt/homebrew/lib/pkgconfig:/Users/dreampuf/opt/homebrew/share/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig --with-internal-glib
## --------- ##
## Platform. ##
@dreampuf
dreampuf / gist:3600472
Created September 2, 2012 15:26
HOMEBREW_MAKE_JOBS=1 VERBOSE=1 brew install uwsgi
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by pkg-config configure 0.27, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ ./configure --disable-debug --prefix=/Users/dreampuf/opt/homebrew/Cellar/pkg-config/0.27 --with-pc-path=/Users/dreampuf/opt/homebrew/lib/pkgconfig:/Users/dreampuf/opt/homebrew/share/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/pkgconfig --with-internal-glib
## --------- ##
## Platform. ##
@dreampuf
dreampuf / profiler.py
Created September 25, 2012 17:14
Python Profile script
#!/usr/bin/env python
# vim: fileencoding=utf-8
__author__ = "dreampuf<soddyque@gmail.com>"
import os
import sys
from functools import wraps
try:
from line_profiler import LineProfiler
@dreampuf
dreampuf / gist:3859636
Created October 9, 2012 15:44
双拼域名采集
#!/usr/bin/env python
#vim: encoding=utf-8
__author__ = "Dreampuf<soddyque@gmail.com>"
import subprocess
import itertools
dc = "a,ai,an,ang,ao,ba,bai,ban,bang,bao,bei,ben,beng,bi,bian,biao,bie,bin,bing,bo,bu,ca,cai,can,cang,cao,ce,cei,cen,ceng,cha,chai,chan,chang,chao,che,chen,cheng,chi,chong,chou,chu,chua,chuai,chuan,chuang,chui,chun,chuo,ci,cong,cou,cu,cuan,cui,cun,cuo,da,dai,dan,dang,dao,de,dei,den,deng,di,dia,dian,diao,die,din,ding,diu,dong,dou,du,duan,dui,dun,duo,e,ei,en,eng,er,fa,fan,fang,fei,fen,feng,fiao,fo,fou,fu,ga,gai,gan,gang,gao,ge,gei,gen,geng,gong,gou,gu,gua,guai,guan,guang,gui,gun,guo,ha,hai,han,hang,hao,he,hei,hen,heng,hm,hng,hong,hou,hu,hua,huai,huan,huang,hui,hun,huo,ji,jia,jian,jiang,jiao,jie,jin,jing,jiong,jiu,ju,juan,jue,jun,ka,kai,kan,kang,kao,ke,kei,ken,keng,kong,kou,ku,kua,kuai,kuan,kuang,kui,kun,kuo,la,lai,lan,lang,lao,le,lei,leng,li,lia,lian,liang,liao,lie,lin,ling,liu,lo,long,lou,lu,luan,lun,luo,lüe,lǘ,lǚ,lǜ,ma,mai,man,mang,mao,me,mei,men,meng,mi,mian,miao,mie,min,ming,miu,mo,mo
@dreampuf
dreampuf / gist:3946886
Created October 24, 2012 15:51
Pinyin Split
#!/usr/bin/env python
#vim: encoding=utf-8
"""
拼音分词
"""
__author__ = "dreampuf<soddyque@gmail.com>"
import unittest
@dreampuf
dreampuf / gist:4142565
Created November 25, 2012 06:08
Python True Value Testing
#!/usr/bin/env python
#vi: encoding=utf-8
__author__ = "dreampuf <soddyque@gmail.com>"
"""
Reference : http://docs.python.org/2/library/stdtypes.html#truth-value-testing
"""
class S(object):
@dreampuf
dreampuf / gist:4187641
Created December 2, 2012 07:48
get ips from ping command
$ for i in {1..20}; do echo `echo s$i.vpnst.com;ping -c1 s$i.vpnst.com|grep -o '(.\+)'`; done
s1.vpnst.com (106.187.39.125)
s2.vpnst.com (96.44.186.158)
s3.vpnst.com (106.187.39.125)
s4.vpnst.com (109.169.68.137)
s5.vpnst.com (173.231.12.99)
s6.vpnst.com (76.164.225.211)
s7.vpnst.com (74.82.183.119)
s8.vpnst.com (106.187.39.125)
s9.vpnst.com (76.74.172.234)
@dreampuf
dreampuf / gist:4223370
Created December 6, 2012 09:57
ab Benchmark plot
# output as png image
set terminal png
# save file to "benchmark.png"
set output "benchmark.png"
# graph title
set title "Benchmark for gunicorn(default) vs. gunicorn(gevent) vs. gunicorn(eventlet) vs. Flask default"
# aspect ratio for image size