Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
"""
How to use it:
1. Just `kill -2 PROCESS_ID` or `kill -15 PROCESS_ID` , The Tornado Web Server Will shutdown after process all the request.
2. When you run it behind Nginx, it can graceful reboot your production server.
3. Nice Print in http://weibo.com/1682780325/zgkb7g8k7
"""
@snower
snower / rproxy.py
Last active August 29, 2015 14:13
auto static refresh time proxy
# -*- coding: utf-8 -*-
# 14/12/16
# create by: snower
import sys
import time
import re
import logging
import traceback
from tornado.ioloop import IOLoop
@snower
snower / vtraceback.py
Created January 14, 2015 06:52
view local variable traceback
# -*- coding: utf-8 -*-
# 14-9-20
# create by: snower
import linecache
import sys
import types
__all__ = ['extract_stack', 'extract_tb', 'format_exception',
'format_exception_only', 'format_list', 'format_stack',
@snower
snower / gist:27d8fc414f073141376e
Last active January 22, 2016 06:33
greenlet性能测试
# -*- coding: utf-8 -*-
# 15/1/16
# create by: snower
import time
import greenlet
import threading
m = greenlet.getcurrent()
# -*- coding: utf-8 -*-
# 14-8-20
# create by: snower
import os
import time
import multiprocessing
from logging.handlers import RotatingFileHandler, TimedRotatingFileHandler
class RotatingFileHandler(RotatingFileHandler):
@snower
snower / simple_http_proxy_server.py
Last active April 20, 2020 06:59
simple_http_proxy_server
# -*- coding: utf-8 -*-
# 15/8/21
# create by: snower
import sys
import time
import sevent
import logging
import traceback
// main
package main
import (
"fmt"
"gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
"sync"
"time"
)
@snower
snower / tcpdumpwireshark.bat
Created March 11, 2017 07:32
tcpdumpwireshark
nc64.exe 192.168.199.109 5000 | "C:\Program Files\Wireshark\Wireshark.exe" -k -S -i -
@snower
snower / tcp_proxy.py
Last active April 19, 2020 07:44
simple_tcp_proxy
# -*- coding: utf-8 -*-
# 15/5/21
# create by: snower
import sys
import logging
from sevent import tcp
from sevent import current
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)1.1s %(message)s', datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
@snower
snower / build_python_to_bin.py
Created September 13, 2017 03:33
build python to bin
# -*- coding: utf-8 -*-
# 15/10/29
# create by: snower
import sys
import os
import shlex
import subprocess
def run_command(command):