This file contains 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
#!/usr/bin/env python | |
''' | |
image_convert.py | |
~~~~~~~~~~~~~~~~~ | |
A small tool to resize/compress/rotate image. | |
:copyright: Copyright (C) 2012 Yue Du <[email protected]> | |
:license: BSD 2-Clause License | |
''' |
This file contains 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
#!/usr/bin/env python | |
''' | |
gist.py | |
~~~~~~~~~ | |
A small tool to upload a gist. | |
:copyright: Copyright (C) 2012 Yue Du <[email protected]> | |
:license: BSD 2-Clause License | |
''' |
This file contains 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
"""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) |
This file contains 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
#!/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'] |
This file contains 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
#!/bin/env python | |
#-*- coding: utf-8 -*- | |
import sys | |
import os | |
from urlfetch import get | |
user = sys.argv[1] | |
r = get('https://api.github.com/users/%s/repos' % user) |
This file contains 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
def txt_wrap_by(begin, end, html): | |
if not html: | |
return '' | |
start = html.find(begin) | |
if start >= 0: | |
start += len(begin) | |
end = html.find(end, start) | |
if end >= 0: | |
return html[start:end].strip() |
This file contains 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 timeit | |
def f1(list): | |
string = "" | |
for item in list: | |
string = string + chr(item) | |
return string | |
def f2(list): | |
return reduce(lambda string, item: string + chr(item), list, "") |
This file contains 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
#coding: utf8 | |
from __future__ import with_statement, absolute_import | |
import os | |
import re | |
import sys | |
import signal | |
import string | |
import random |
This file contains 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
$ cat ~/bin/shurl | |
#!/bin/bash | |
curl -i http://shurl.im/ -F "url=$1" -s | grep Location | awk '{print $2}' | |
$ shurl http://lyxint.com/ | |
http://shurl.im/1 | |