很多公司都大量使用了python,其中有一些开发规范,code guidline, 通用组件,基础框架是可以共用的。
每个公司都自己搞一套, 太浪费人力,我想开一帖和大家讨论一下这些python基础设施的搭建。
原则是我们尽量不重新发明轮子,但开源组件这么多,也要有个挑选的过程和组合使用的过程,在这里讨论一下。
另一方面,有些开源组件虽然强大,但我们不能完全的驾驭它,或只使用其中很少的一部分,我们就可以考虑用python实现一个简单的轮子,可控性更强,最好不要超过300行代码。
local cjson = require('cjson') | |
local util = require('login_util') | |
if ngx.var.request_method ~= 'POST' then | |
ngx.log(ngx.WARN, 'request method is not post') | |
ngx.exit(400) | |
end | |
ngx.req.read_body() | |
local args = ngx.req.get_post_args() |
# to generate your dhparam.pem file, run in the terminal | |
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
/** | |
* GenPAC 0.2.1 http://jeeker.net/projects/genpac/ | |
* Generated: Fri, 17 May 2013 14:15:55 GMT | |
* GFWList Last-Modified: Fri, 17 May 2013 12:41:31 GMT | |
*/ | |
// proxy | |
var P = "PROXY 192.168.1.1:8118; DIRECT"; | |
// user rules |
# use with: logging.config.dictConfig(yaml.load(open('logging.yaml', 'r'))) | |
# Formatters detailed here: http://docs.python.org/2/library/logging.html#logrecord-attributes | |
version: 1 | |
formatters: | |
simple: | |
format: '%(asctime)s - %(name)s - %(levelname)s - %(message)s' | |
detail: | |
format: '%(asctime)s - %(levelname)s - File: %(filename)s - %(funcName)s() - Line: %(lineno)d - %(message)s' |
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# CUI Downloader of "Command Line Tools for Xcode" | |
# by Akihiro Uchida, CC0 dedicated to the public domain | |
# see http://creativecommons.org/publicdomain/zero/1.0/ | |
import sys, os | |
import urllib, urllib2, cookielib | |
from getpass import getpass | |
from HTMLParser import HTMLParser |
global | |
log 127.0.0.1 local0 info | |
maxconn 5000 | |
ulimit-n 10000 | |
defaults | |
log global | |
mode http | |
frontend pub-srv 0.0.0.0:8080 |
import urllib2 | |
def xiami_decode(s): | |
s = s.strip() | |
if not s: | |
return False | |
result = [] | |
line = int(s[0]) | |
rows = len(s[1:]) / line | |
extra = len(s[1:]) % line |
# Rime alternative settings | |
# encoding: utf-8 | |
# | |
# difference from default settings: | |
# 1. ascii-style punctuation in half-shape mode | |
# 2. [ ] as paging keys | |
# | |
# save this file as: | |
# (Linux) ~/.config/ibus/rime/alternative.yaml | |
# (Mac OS) ~/Library/Rime/alternative.yaml |