很多公司都大量使用了python,其中有一些开发规范,code guidline, 通用组件,基础框架是可以共用的。
每个公司都自己搞一套, 太浪费人力,我想开一帖和大家讨论一下这些python基础设施的搭建。
原则是我们尽量不重新发明轮子,但开源组件这么多,也要有个挑选的过程和组合使用的过程,在这里讨论一下。
另一方面,有些开源组件虽然强大,但我们不能完全的驾驭它,或只使用其中很少的一部分,我们就可以考虑用python实现一个简单的轮子,可控性更强,最好不要超过300行代码。
# The beginnings of a declarative model syntax for CoffeeScript. | |
# SEE: http://almostobsolete.net/declarative-models-in-coffeescript.html | |
# Thomas Parslow | |
# Email: [email protected] | |
# Twitter: @almostobsolete | |
# The top part is the setup, see below that for the demo | |
# To see this run right away try copy pasting it into the 'Try | |
# CoffeeScript' box at http://jashkenas.github.com/coffee-script/ |
# default.custom.yaml | |
# save it to: | |
# ~/.config/ibus/rime (linux) | |
# ~/Library/Rime (macos) | |
# %APPDATA%\Rime (windows) | |
patch: | |
schema_list: | |
- schema: luna_pinyin # 朙月拼音 | |
- schema: luna_pinyin_simp # 朙月拼音 简化字模式 |
###改进算法,选择合适的数据结构
使用dict的查找要比list快很多
当要求list的交集时,转化成set来计算比较快。set的常见操作:
union: set(list1) | set(list2)
intersection: set(list1) & set(list2)
difference: set(list1) - set(list2)
module.exports = { | |
test : function(req, res) { | |
setTimeout(function() { | |
res.send({ testing : true }, 200); | |
}, 5000); | |
}, | |
} |
source 'https://rubygems.org' | |
gem 'fluentd' | |
gem 'fluent-plugin-td' | |
gem 'fluent-plugin-elasticsearch' |
;; Connect to ERC using a HTTP proxy : ( | |
;; ******************************************* | |
(defvar http-proxy-host | |
"www-cache.reith.bbc.co.uk") | |
(defvar http-proxy-port 80) | |
;; Proxy handler | |
;; ******************************************* |
;; -*- mode: emacs-lisp -*- | |
;; This file is loaded by Spacemacs at startup. | |
;; It must be stored in your home directory. | |
(defun dotspacemacs/layers () | |
"Configuration Layers declaration. | |
You should not put any user code in this function besides modifying the variable | |
values." | |
(setq-default | |
;; Base distribution to use. This is a layer contained in the directory |
<source> | |
type tail | |
path /var/log/haproxy.log | |
pos_file /var/log/td-agent/haproxy.log.pos | |
tag haproxy.http | |
format /^(?<syslog_time>.+) (?<source_ip>.+) (?<ps>\w+)\[(?<pid>\d+)\]: (?<c_ip>[\w\.]+):(?<c_port>\d+) \[(?<time>.+)\] (?<f_end>[\w\.-]+) (?<b_end>[\w\.-]+)\/(?<b_server>[^ ]+) (?<tq>[-]?\d+)\/(?<tw>[-]?\d+)\/(?<tc>[-]?\d+)\/(?<tr>[-]?\d+)\/(?<tt>\d+) (?<status_code>\d+) (?<bytes_read>\d+) (?<captured_request_cookie>.+) (?<captured_response_cookie>.+) (?<termination_state>.+) (?<actconn>\d+)\/(?<feconn>\d+)\/(?<beconn>\d+)\/(?<srv_conn>\d+)\/(?<retries>\d+) (?<srv_queue>\d+)\/(?<backend_queue>\d+) \"(?<http_request>.+)\"$/ | |
time_format %d/%b/%Y:%H:%M:%S.%L | |
</source> | |
<match *.**> |