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
#netstate-anov_deadloop.py | |
# works for windows XP SP-2, python2.5 | |
from subprocess import call | |
import time | |
import sys | |
default_netstat_arglist = "-anov" | |
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
python2.6.5 | |
help("BaseHTTPServer") | |
It seems that HTTPServer become heavy after it inherits many methods from TCPServer. | |
Through BASEServer to TCPServer to HTTPServer, in my view it's better to be a pipe-lined structure. I hope HTTPServer could be something like a plugin for TCPServer or BASEServer, because I think the registration mechanism seems to be better than inheritance. | |
Statistically, the model for Parent Classes are probably much stabler than Child classes. Parent Classes are like infrastrcture. Usually, infrastructure tends to change less frequently than Child classes. The Child Classes don't need to get himself bound with the Parent classes too much, which limit their freedom. | |
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
A nice way to judge python version by import statement: | |
https://github.com/facebook/tornado/blob/master/tornado/web.py | |
try: | |
from io import BytesIO # python 3 | |
except ImportError: | |
from cStringIO import StringIO as BytesIO # python 2 |
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
The following lines could be moved to a separate function from def clear | |
line 248: | |
if (not self.request.supports_http_1_1() and | |
getattr(self.request, 'connection', None) and | |
not self.request.connection.no_keep_alive): | |
conn_header = self.request.headers.get("Connection") | |
if conn_header and (conn_header.lower() == "keep-alive"): | |
self._headers["Connection"] = "Keep-Alive" |
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 | |
# shows a simple example on how to use optparse module | |
# works under python2.6.5 | |
# usage 1: | |
# python optparse_exampe_1.py -o output.txt | |
# usage 2: | |
# python optparse_exampe_1.py --help | |
# usage 3: |
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 | |
# usage: | |
# python optparse_getoptcomparison.py -o output.txt | |
# works under python2.6.5 | |
# the source of this snippet is from Doug Hellmann's Python Module of The Week | |
# http://pymotw.com/2/optparse/index.html | |
import optparse |
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
coverage.py usage command | |
coverage help classic | |
======== | |
coverage -rm api/* (show statistics result for files under the path of api) | |
name@namevirtual:~/.jenkins/jobs/test_coverage/workspace$ coverage -rm namell/api/* | |
Name Stmts Miss Cover Missing | |
------------------------------------------------------------ |
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 | |
# Copyright 2008 Brett Slatkin | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software |
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 | |
# simplistic demo | |
# refer to the api doc of the website for more api interfaces and usage | |
import urllib | |
developer_key = "something_you_should_change_here" | |
REQUEST_URL = "http://api.crunchbase.com/v/1/company/facebook.js?api_key=%s" % developer_key | |
print "CHECK REQUEST URL:", REQUEST_URL |
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 | |
# the demo code is from https://pypi.python.org/pypi/XlsxWriter | |
import xlsxwriter | |
# Create an new Excel file and add a worksheet. | |
workbook = xlsxwriter.Workbook('demo.xlsx') | |
worksheet = workbook.add_worksheet() |
OlderNewer