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
@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")
#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 / udpserver.py
Created May 25, 2014 10:34
tornado UDP server
#!/usr/bin/env python
#coding=utf-8
import socket
import os
import errno
from tornado.ioloop import IOLoop
from tornado.platform.auto import set_close_exec
class UDPServer(object):
def __init__(self, io_loop=None):
@jamiesun
jamiesun / nextid.py
Created May 18, 2014 06:43
生成有时间规则的id
import datetime
def __next_id():
_inum = [10000]
def _next():
if _inum[0] >= 99999:
_inum[0] = 10000
_inum[0] += 1
_prefix = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
return int("%s%s"%(_prefix,_inum[0]))
@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.
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
#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]')
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
#coding:utf-8
import sys, os, re
import logging
from tornado.ioloop import IOLoop
from tornado.iostream import IOStream
from tornado.netutil import TCPServer
@jamiesun
jamiesun / redis
Created January 12, 2014 05:52
redis service script
#!/bin/sh
#
# 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.