A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| #/usr/bin/env python | |
| # coding=utf-8 | |
| import random | |
| import re | |
| def color(messages): | |
| color = '\x1B[%d;%dm' % (1,random.randint(30,37)) | |
| return '%s %s\x1B[0m' % (color,messages) |
| """ User-Agents """ | |
| mobile_agents = [ | |
| "Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", | |
| "Avant Browser/1.2.789rel1 (http://www.avantbrowser.com)", | |
| "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.0 Safari/532.5", | |
| "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US) AppleWebKit/532.9 (KHTML, like Gecko) Chrome/5.0.310.0 Safari/532.9", | |
| "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.514.0 Safari/534.7", | |
| "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/534.14 (KHTML, like Gecko) Chrome/9.0.601.0 Safari/534.14", | |
| "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.14 (KHTML, like Gecko) Chrome/10.0.601.0 Safari/534.14", | |
| "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.20 (KHTML, like Gecko) Chrome/11.0.672.2 Safari/534.20", |
| # -*- coding: utf-8 -*- | |
| # fabfile.py这个名字固定不能改变 | |
| from datetime import datetime | |
| from fabric.api import env, local, cd, run, put, settings, lcd | |
| from fabric.context_managers import prefix | |
| def production(): | |
| env.hosts = ["[email protected]:22"] | |
| env.key_filename = "/path/to/key_file" |
| #!/bin/bash | |
| # supervisord This scripts turns supervisord on | |
| # chkconfig: 345 83 04 | |
| # description: supervisor is a process control utility. It has a web based | |
| # xmlrpc interface as well as a few other nifty features. | |
| # | |
| # source function library | |
| . /etc/rc.d/init.d/functions |
| :: run it with administrator rights | |
| netsh interface ipv6 isatap set router 202.115.39.98 | |
| netsh interface ipv6 isatap set state enabled | |
| :: then assign your dns to the value of "2001:4860:4860::8888" or "2001:470:20::2" |
| # according to the blog:http://blog.csdn.net/Bone_ACE/article/details/55000101 | |
| import socket | |
| # from gevent import socket | |
| _dnscache = {} | |
| def _setDNSCache(): | |
| """ DNS缓存 """ |
| def get_zero_timestamp(self): | |
| cur_timestamp = time.time() | |
| cur_time = time.localtime(cur_timestamp) | |
| zero_time_stamp = cur_timestamp - ( | |
| cur_time.tm_sec + 60 * cur_time.tm_min + 3600 * cur_time.tm_hour) | |
| return zero_time_stamp |
| [unix_http_server] | |
| file=/tmp/supervisor.sock ; (the path to the socket file) | |
| [supervisord] | |
| logfile=/home/aaa/project/log/supervisord.log ; (main log file;default $CWD/supervisord.log) | |
| logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB) | |
| logfile_backups=10 ; (num of main logfile rotation backups;default 10) | |
| loglevel=info ; (log level;default info; others: debug,warn,trace) | |
| pidfile=/tmp/supervisord.pid ; (supervisord pidfile;default supervisord.pid) | |
| nodaemon=false ; (start in foreground if true;default false) |