Skip to content

Instantly share code, notes, and snippets.

View keitheis's full-sized avatar

Keith Yang keitheis

View GitHub Profile
@keitheis
keitheis / gist:2382657
Created April 14, 2012 07:36
npm install ethercalc
% npm install ethercalc
npm http GET https://registry.npmjs.org/ethercalc
npm http 200 https://registry.npmjs.org/ethercalc
npm http GET https://registry.npmjs.org/ethercalc/-/ethercalc-0.20120408.192847.tgz
npm http 200 https://registry.npmjs.org/ethercalc/-/ethercalc-0.20120408.192847.tgz
npm http GET https://registry.npmjs.org/zappa
npm http GET https://registry.npmjs.org/redis
npm http GET https://registry.npmjs.org/uuid-pure
npm http GET https://registry.npmjs.org/node-uuid
npm http GET https://registry.npmjs.org/express
@keitheis
keitheis / color_picker.py
Created June 25, 2012 02:59
A Sample Color Picker by Python
#!/usr/bin/python
import gtk, sys
def tohex(c):
#Convert to hex string
#little hack to fix bug
s = ['#',hex(int(c[0]*256))[2:].zfill(2),hex(int(c[1]*256))[2:].zfill(2),hex(int(c[2]*256))[2:].zfill(2)]
for item in enumerate(s):
if item[1]=='100':
s[item[0]]='ff'
print s
@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
@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 / 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
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 / 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__':
@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 / 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 / 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