Skip to content

Instantly share code, notes, and snippets.

View jamiesun's full-sized avatar
🍇
On vacation

Jett Wang jamiesun

🍇
On vacation
View GitHub Profile
from concurrent.futures import ThreadPoolExecutor
from functools import partial, wraps
import time
import tornado.ioloop
import tornado.web
EXECUTOR = ThreadPoolExecutor(max_workers=4)
#!/usr/bin/env python2
#coding:utf-8
import logging
from tornado.ioloop import IOLoop
from tornado.iostream import IOStream
from tornado.tcpserver import TCPServer
logging.basicConfig(level=logging.INFO, format='%(levelname)s - - %(asctime)s %(message)s', datefmt='[%d/%b/%Y %H:%M:%S]')
import os,sqlite3
def create_sql(infile,outfile):
print infile,outfile
outfs = open(outfile,'wb')
with open(infile,'rb') as infs:
@jamiesun
jamiesun / python_comprehension.ipynb
Created May 4, 2014 12:42
python_comprehension
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#coding:utf-8
import re
import urllib
import pprint
import logging
from lxml.html import fromstring,tostring
from gevent.pool import Pool
pool = Pool(3)
@jamiesun
jamiesun / check_temp
Created June 4, 2014 08:28
nagios coretemp check
#!/usr/local/bin/python
#coding:utf-8
import re
import os
import sys
import syslog
from optparse import OptionParser
syslog.openlog("nagios_plugin")
# Demonstration of inspecting all the routes, including those on sub-apps,
# from the default app instance.
#
# This should be run directly to print a list of route prefixes and the rules.
# Tested with Python 2.7 and Bottle-dev. Patch here
# https://github.com/davidwtbuxton/bottle/commit/ddd712ef252b06ecd0e957f8ac4e37b65ee79cae
import bottle
subapp = bottle.Bottle()
@jamiesun
jamiesun / AESCipher
Created January 6, 2015 02:39
AESCipher
from Crypto.Cipher import AES
from Crypto import Random
import base64
import hashlib
_key = 't_o_u_g_h_radius'
class AESCipher:
def sleep(secs):
d = Deferred()
reactor.callLater(secs, d.callback, None)
return d
@jamiesun
jamiesun / gist:2558042
Created April 30, 2012 12:49 — forked from hongqn/gist:1758954
A benchmark tool in eventlet
#!/usr/bin/env python
# encoding: UTF-8
"""DoubanServiceBench"""
__author__ = "Qiangning Hong <hongqn@gmail.com>"
__version__ = "$Revision: 51434 $"
__date__ = "$Date: 2010-11-17 17:44:38 +0800 (Wed, 17 Nov 2010) $"
import sys