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
import re
import urllib
import pprint
import logging
from lxml.html import fromstring,tostring
from gevent.pool import Pool
pool = Pool(3)
jamiesun /
Created May 25, 2014
tornado UDP server
#!/usr/bin/env python
import socket
import os
import errno
from tornado.ioloop import IOLoop
from import set_close_exec
class UDPServer(object):
def __init__(self, io_loop=None):
jamiesun /
Created May 18, 2014
import datetime
def __next_id():
_inum = [10000]
def _next():
if _inum[0] >= 99999:
_inum[0] = 10000
_inum[0] += 1
_prefix ='%Y%m%d%H%M%S')
return int("%s%s"%(_prefix,_inum[0]))
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.
import os,sqlite3
def create_sql(infile,outfile):
print infile,outfile
outfs = open(outfile,'wb')
with open(infile,'rb') as infs:
#!/usr/bin/env python2
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]')
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 python
import sys, os, re
import logging
from tornado.ioloop import IOLoop
from tornado.iostream import IOStream
from tornado.netutil import TCPServer
jamiesun / redis
Created Jan 12, 2014
redis service script
View redis
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
# redis This is the init script for starting up the Redis server
# chkconfig: 2345 85 15
# description: Starts and stops the redis daemon that handles \
# all redis session requests.
def resize_img(img_path, out_path, new_width):
import Image
im =
width,height = im.size
ratio = 1.0 * height / width
new_height = int(new_width * ratio)
You can’t perform that action at this time.