Talkincode.org @codeid:44def9aa87254bd7836abdfff3c06825
"@tags:vim
set nocompatible
set backspace=2
source $VIMRUNTIME/vimrc_example.vim
if has('win32')
source $VIMRUNTIME/mswin.vim
behave mswin
endif
set encoding=utf-8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: UTF-8 | |
"""DoubanServiceBench""" | |
__author__ = "Qiangning Hong <[email protected]>" | |
__version__ = "$Revision: 51434 $" | |
__date__ = "$Date: 2010-11-17 17:44:38 +0800 (Wed, 17 Nov 2010) $" | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python2.7 | |
#encoding:utf-8 | |
#@description:一个python守护进程的例子 | |
#@tags:python,daemon | |
import sys | |
import os | |
import time | |
import atexit | |
from signal import SIGTERM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
#codeing:utf-8 | |
import os | |
from optparse import OptionParser | |
if __name__ == "__main__": | |
usage = "usage: %prog [options] arg" | |
parser = OptionParser(usage) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GEventServer(): | |
""" gevent wsgi服务器定义,可利用多进程 | |
""" | |
def __init__(self,handler,host,port): | |
self.handler = handler | |
self.host = host | |
self.port = port | |
def start(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import signal | |
import urlparse | |
import gevent | |
from gevent.server import StreamServer | |
from gevent.socket import create_connection, gethostbyname | |
class ProxyServer(StreamServer): | |
def __init__(self, listener, **kwargs): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################################################################### | |
# COPY FROM http://www.gnome.org/~jdub/bzr/planet/2.0/planet/htmltmpl.py | |
# and inspired from http://www.python.org/pypi/zc.lockfile | |
# LICENSE: BSD | |
# Modified by: Limodou([email protected]) | |
##################################################################### | |
__all__ = ['LOCK_EX', 'LOCK_SH', 'LOCK_UN', 'lock_file', 'unlock_file', | |
'LockFile', 'LockError'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os, sys | |
print "I'm going to fork now - the child will write something to a pipe, and the parent will read it back" | |
r, w = os.pipe() # r,w是文件描述符, 不是文件对象 | |
pid = os.fork() | |
if pid: | |
# 父进程 | |
os.close(w) # 关闭一个文件描述符 | |
r = os.fdopen(r) # 将r转化为文件对象 | |
print "parent: reading" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SocksiPy - Python SOCKS module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- Encoding: utf-8 -*- | |
import base64 | |
import binascii | |
import cgi | |
import hashlib | |
import hmac | |
import logging | |
import time | |
import urllib | |
import urlparse |
OlderNewer