Skip to content

Instantly share code, notes, and snippets.

@ifduyue
ifduyue / 2_urlfetch.py
Last active October 2, 2015 01:48
2_urlfetch.py
#!/usr/bin/env python
#-*- coding: utf-8 -*-
# http://pypi.python.org/pypi/urlfetch
import urlfetch
r = urlfetch.get('https://api.github.com', auth=('user', 'pass'))
print r.status
print r.headers['content-type']
@ifduyue
ifduyue / httplib.py
Created July 11, 2012 02:10
sae modified httplib.py
"""HTTP/1.1 client library
<intro stuff goes here>
<other stuff, too>
HTTPConnection goes through a number of "states", which define when a client
may legally make another request or fetch the response for a particular
request. This diagram details these state transitions:
(null)
@ifduyue
ifduyue / gist.py
Last active December 10, 2015 06:28
A small tool to upload a gist.
#!/usr/bin/env python
'''
gist.py
~~~~~~~~~
A small tool to upload a gist.
:copyright: Copyright (C) 2012 Yue Du <lyxint@gmail.com>
:license: BSD 2-Clause License
'''
#!/usr/bin/env python
'''
image_convert.py
~~~~~~~~~~~~~~~~~
A small tool to resize/compress/rotate image.
:copyright: Copyright (C) 2012 Yue Du <lyxint@gmail.com>
:license: BSD 2-Clause License
'''
This file has been truncated, but you can view the full file.
H4sICAMrxVAC/2Rpc3QvZ2V2ZW50LTEuMHJjMi50YXIA7L3tehvXsS7ov8FV9KGdA5AbAAlSpGTK
Ug5FUTYTSWREyo6PrQM0gCbYIdCNdDdIws++jrmC+TPP3MH83Tc29VbV+mqAkhxn58x+Jt47YqN7
fa9a9V21JsltklWdXnenGO1uf/Gf8t8O/fd4fx9/e4/3d/y/5r8vers7B73d3f1HO3tf7PT2Hj3e
/SLa/+Kf8N+irOIiir4YJ1lafqTcp76biZi//0X+mwT7P7qOs0kyzSfdoqz+oft/8OjR+v3vHezs
93p2//f2sf8HvYO9L6Kdf+3/f/p/x2bHG8/Mf41GtxuNFkVBgDHLx4tpcngYCZw0Go13yTSJyyQS
iGl0gv8ajU70Kr1PxtGXu72dw2gUT6fDeHRTRndJkURZXkXFIouu8oKes844uYoX0yqa5vk8ag0X
kyjNqoK6HFELaSZ99Da71Oo8rkbXfWqutUlVqQaNupC3SRmVi+G8yEdJWUaLbIo/A/fq2WWxSAZR
WlLxskzGXTvIo6oq0uGiSk6KgoZEPV4vht0f4rRKClfqy96T3mE0i2+S6DodExxE6WyeF1UZ3aZl
OpwmUZVHV0WS/JJmE3rOp2U0Tan0fLmb3Cfd6ByjjIbL6F08vYouRteztKq89nd3dg+jeVKk+TjF
ii2jZZpMx9HdNfVF65WhXbeUrXKaJPPWzia9y7Ckw2k+uomq6yTiTZLlzPK7zaCPR4dRXnareb9I
@ifduyue
ifduyue / bson_decode_iter.py
Created March 7, 2013 12:41
An iterator version of bson.decode_all
#coding: utf8
'''
bson_decode_iter.py
~~~~~~~~~~~~~~~~~~~~~~
An iterator version of bson.decode_all
:copyright: (c) 2013 by Yue Du.
:license: The BSD 2-Clause License
'''
@ifduyue
ifduyue / curl.output
Last active December 16, 2015 16:40
openresty version
# curl 127.0.0.1/test
package.path: /usr/local/openresty/nginx//?.lua;/usr/local/openresty/lualib/?.lua;/usr/local/openresty/lualib/?/init.lua;./?.lua;/usr/local/openresty/luajit/share/luajit-2.0.0/?.lua;/usr/local/share/lua/5.1/?.lua;/usr/local/share/lua/5.1/?/init.lua;/usr/local/openresty/luajit/share/lua/5.1/?.lua;/usr/local/openresty/luajit/share/lua/5.1/?/init.lua;
package.cpath: /usr/local/openresty/lualib/?.so;./?.so;/usr/local/lib/lua/5.1/?.so;/usr/local/openresty/luajit/lib/lua/5.1/?.so;/usr/local/lib/lua/5.1/loadall.so
cjson._VERSION: nil
[1,2,3]
# curl 127.0.0.1/test
curl: (52) Empty reply from server

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

@ifduyue
ifduyue / ab.result.vs.httpsqs.txt
Last active December 20, 2015 19:09
bench httpsqs & levelq
httpsqs:
=========================
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100000 requests
Completed 200000 requests
Completed 300000 requests
@ifduyue
ifduyue / .bashrc
Last active December 25, 2015 03:49 — forked from atduskgreg/.bashrc
PS1="\[\033[01;35m\]\u\[\033[00m\]@\[\033[01;38m\]\h:\[\033[00m\]\[\e[1;34m\]\w\[\e[0m\] \$(parse_git_branch)\$(parse_git_dirty)\$ "
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
parse_git_dirty() {
if [[ -d .git ]]; then
[[ $(git status) =~ "nothing to commit, working directory clean" ]] || echo "*"
fi