Skip to content

Instantly share code, notes, and snippets.

View keitheis's full-sized avatar

Keith Yang keitheis

View GitHub Profile
# encoding: utf8
# Kanban of Python Taiwan in Early November
# Python Quest #2
dates = ['1 year, 10 months, 15 days',
'2 years, 1 month, 15 days',
'1 month, 15 days',
'1 year',
'2 months',
@keitheis
keitheis / fabfile.py
Created December 8, 2012 08:48
install_server_utils_packages.py
import cuisine
from fabric.api import roles, sudo
apt_updated = None
def apt_update(force=False):
global apt_updated
if force or not apt_updated:
state = sudo('apt-get update -q')
apt_updated = True
@keitheis
keitheis / fabfile.py
Created November 21, 2012 09:51 — forked from justinvoss/fabfile.py
Example Fabric and Cuisine Scrips
from deployment.cuisine import *
from fabric.api import *
from fabric.context_managers import *
from fabric.utils import puts
from fabric.colors import red, green
import simplejson
import os
@keitheis
keitheis / redate_in_words.py
Created November 11, 2012 04:18
Python Quest #2 of Python Taiwan 2012 November
# encoding: utf8
# Kanban of Python Taiwan in Early November
# Python Quest #2
dates = ['1 year, 10 months, 15 days',
'2 years, 1 month, 15 days',
'1 month, 15 days',
'1 yesr',
'2 months',
'15 days',
@keitheis
keitheis / print_inner_class.py
Created November 1, 2012 04:17
print_inner_class.py
class Out(object):
o = 2
class In(object):
i = 1
def main():
o = Out()
print o.In.i
# 1
@keitheis
keitheis / tempfile_path.py
Created October 17, 2012 07:57
Make temporary file path
from tempfile import NamedTemporaryFile
def tempfile_path():
with NamedTemporaryFile(delete=False) as f:
return f.name
def main():
print tempfile_path()
if __name__ == '__main__':
Successfully installed askbot django-followit unidecode oauth2 python-openid pystache django-celery django-robots
django-keyedcache django html5lib django-kombu django-countries pytz Jinja2 akismet Lamson markdown2
django-recaptcha-works Coffin South django-threaded-multihost httplib2 django-picklefield celery
chardet mock nose python-daemon python-dateutil anyjson kombu pyparsing lockfile amqpli
@keitheis
keitheis / demo.log
Created August 29, 2012 09:43
RabbitMQ Topic for Pub/Sub
% ruby sub_update.rb
# output after ruby publisher.rb
Update form: UPDATE 89, routing key is data.update
% ruby sub_logger.rb
# output after ruby publisher.rb
Log: UPDATE 89, routing key is data.update
Log: CREATE 90, routing key is data.create
% ruby publisher.rb
@keitheis
keitheis / gist:3505958
Created August 29, 2012 01:45
curl -I wiki.python.org.tw
% curl -I wiki.python.org.tw
HTTP/1.0 200 OK
Server: nginx/1.1.19
Date: Wed, 29 Aug 2012 01:42:17 GMT
Content-Type: text/html; charset=utf-8
Vary: Cookie, User-Agent
X-Cache: MISS from cuisinart.iis.sinica.edu.tw
X-Cache-Lookup: MISS from cuisinart.iis.sinica.edu.tw:80
Via: 1.0 cuisinart.iis.sinica.edu.tw:80 (squid/2.6.STABLE21)
Connection: close
@keitheis
keitheis / gist:3505954
Created August 29, 2012 01:44
curl -I wiki.python.org.tw
% curl -I wiki.python.org.tw
HTTP/1.0 200 OK
Server: nginx/1.1.19
Date: Wed, 29 Aug 2012 01:42:17 GMT
Content-Type: text/html; charset=utf-8
Vary: Cookie, User-Agent
X-Cache: MISS from cuisinart.iis.sinica.edu.tw
X-Cache-Lookup: MISS from cuisinart.iis.sinica.edu.tw:80
Via: 1.0 cuisinart.iis.sinica.edu.tw:80 (squid/2.6.STABLE21)
Connection: close