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 / 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):
#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")
@jamiesun
jamiesun / paginator.py
Created June 10, 2014 05:11
paginator
#!/usr/bin/env python
#coding=utf-8
from __future__ import division
import math
class Paginator():
"""系统查询分页工具
"""
def __init__(self, url_func, page=1, total=0, page_size=20):
# 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:
@jamiesun
jamiesun / sh
Created February 24, 2015 12:37
python color shell
#!/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
def sleep(secs):
d = Deferred()
reactor.callLater(secs, d.callback, None)
return d
@jamiesun
jamiesun / tun-ping-linux.py
Created October 6, 2015 15:56 — forked from glacjay/tun-ping-linux.py
Reading/writing Linux's TUN/TAP device using Python.
import fcntl
import os
import struct
import subprocess
# Some constants used to ioctl the device file. I got them by a simple C
# program.
TUNSETIFF = 0x400454ca
TUNSETOWNER = TUNSETIFF + 2
@jamiesun
jamiesun / centos7.sh
Created September 11, 2016 04:28 — forked from yyang/centos7.sh
centos 7 pptpd firewalld
#!/bin/sh
#
# pptpd installation script on my own CentOS 7 box.
# inspired by: https://www.digitalocean.com/community/questions/how-to-install-pptp-vpn-on-centos-7
# and http://unix.stackexchange.com/questions/150837/redhat-centos-7-firewalld-best-practice-for-pptp-or-l2tp-ipsec-rules
#
# Author: 2015 Steve Yang <[email protected]>
# The script comes with ABSOLUTELY NO WARRANTY.