虚拟机 ubuntu 12.04
$ sudo aptitude install stunnel
$ sudo aptitude install squid3
squid3的默认http端口是3128
/etc/stunnel/stunnel.conf中的foreground = yes, 是用来调试用的 如果用superviord来管理stunnel 这个选项也会用得到
/etc/stunnel/stunnel.pem, 这个pair是这样得到的
| #!/usr/bin/env python | |
| import os, sys | |
| sys.path.append(os.getcwd()) | |
| import logging | |
| import rq | |
| MAX_FAILURES = 3 |
虚拟机 ubuntu 12.04
$ sudo aptitude install stunnel
$ sudo aptitude install squid3
squid3的默认http端口是3128
/etc/stunnel/stunnel.conf中的foreground = yes, 是用来调试用的 如果用superviord来管理stunnel 这个选项也会用得到
/etc/stunnel/stunnel.pem, 这个pair是这样得到的
| var CONSUMER_KEY = "<< YOUR KEY HERE >>"; | |
| var CONSUMER_SECRET = "<< YOUR SECRET HERE >>"; | |
| function getConsumerKey() { | |
| return CONSUMER_KEY; | |
| } | |
| function getConsumerSecret() { | |
| return CONSUMER_SECRET; | |
| } |
| # 中西文切換鍵的默認設置寫在 default.yaml 裏面 | |
| # 以下的 default.custom.yaml 在全局範圍重定義該組快速鍵 | |
| # | |
| # 可用的按鍵有 Caps_Lock, Shift_L, Shift_R, Control_L, control_R | |
| # Mac 系統上的鼠鬚管不能區分左、右,因此只有對 Shift_L, Control_L 的設定起作用 | |
| # | |
| # 已輸入編碼時按切換鍵,可以進一步設定輸入法中西文切換的形式。 | |
| # 可選的臨時切換策略有三: | |
| # inline_ascii 在輸入法的臨時西文編輯區內輸入字母、數字、符號、空格等,回車上屏後自動復位到中文 | |
| # commit_text 已輸入的候選文字上屏並切換至西文輸入模式 |
| def detached(f): | |
| """Generator for creating a forked process | |
| from a function""" | |
| def wrapper(*args, **kwargs): | |
| """Wrapper function to be returned from generator. | |
| Executes the function bound to the generator and then | |
| exits the process""" | |
| import os |
| import redis | |
| import threading | |
| class Listener(threading.Thread): | |
| def __init__(self, r, channels): | |
| threading.Thread.__init__(self) | |
| self.redis = r | |
| self.pubsub = self.redis.pubsub() | |
| self.pubsub.subscribe(channels) | |
| #!/bin/bash | |
| find . \( -iname '*.rb' -o -iname '*.css' -o -iname '*.js' -o -iname '*.erb' -o -iname '*.html' -o -iname '*.haml' -o -iname '*.scss' -o -iname '*.coffee' \) -exec wc -l {} + | sort -n |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)That's it!
| #!/usr/bin/env/python | |
| # | |
| # More of a reference of using jinaj2 without actual template files. | |
| # This is great for a simple output transformation to standard out. | |
| # | |
| # Of course you will need to "sudo pip install jinja2" first! | |
| # | |
| # I like to refer to the following to remember how to use jinja2 :) | |
| # http://jinja.pocoo.org/docs/templates/ | |
| # |