Skip to content

Instantly share code, notes, and snippets.

jamiesun jamiesun

Block or report user

Report or block jamiesun

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View futures_test.py
from concurrent.futures import ThreadPoolExecutor
from functools import partial, wraps
import time
import tornado.ioloop
import tornado.web
EXECUTOR = ThreadPoolExecutor(max_workers=4)
View echoserver.py
#!/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]')
View builddb.py
import os,sqlite3
def create_sql(infile,outfile):
print infile,outfile
outfs = open(outfile,'wb')
with open(infile,'rb') as infs:
View python_comprehension.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View fetch_epg.py
#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 Jun 4, 2014
nagios coretemp check
View check_temp
#!/usr/local/bin/python
#coding:utf-8
import re
import os
import sys
import syslog
from optparse import OptionParser
syslog.openlog("nagios_plugin")
View gist:017ebd67fd1528b531fd
# 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()
View AESCipher
from Crypto.Cipher import AES
from Crypto import Random
import base64
import hashlib
_key = 't_o_u_g_h_radius'
class AESCipher:
@jamiesun
jamiesun / sh
Created Feb 24, 2015
python color shell
View sh
#!/usr/bin/env python
#coding:utf-8
import sys
import os
import subprocess
import time
class ToughError(Exception):
def __init__(self, message):
self.message = message
View twisted_sleep.py
def sleep(secs):
d = Deferred()
reactor.callLater(secs, d.callback, None)
return d
You can’t perform that action at this time.