(C-x means ctrl+x, M-x means alt+x)
The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf
:
"""A simple addition to Python's optparse module supporting subcommands | |
like those found in the svn or hg CLIs. | |
To use it, instantiate the Subcommand class for every subcommand you | |
want to support. Each subcommand has a name, aliases, a help message, | |
and a separate OptionParser instance. Then pass a list of Subcommands | |
to the constructor of SubcommandsOptionParser to make a subcommand- | |
aware parser. Calling parse_args on that parser gives you the | |
subcommand invoked, the subcommand's arguments and options, and the | |
global options all in one fell swoop. See the smoke test at the bottom |
#!/usr/bin/python | |
# Equivalent of "tail -f" as a webpage using websocket | |
# Usage: webtail.py PORT FILENAME | |
# Tested with tornado 2.1 | |
# Thanks to Thomas Pelletier for it's great introduction to tornado+websocket | |
# http://thomas.pelletier.im/2010/08/websocket-tornado-redis/ | |
import tornado.httpserver |
// scalac -unchecked -optimise ConsistentHash.scala && scala CHApp | |
import scala.collection.immutable.LinearSeq | |
import java.util.{TreeMap => JTreeMap} | |
import java.util.{SortedMap => JSortedMap} | |
/** | |
* Inspired by http://www.lexemetech.com/2007/11/consistent-hashing.html | |
*/ |
#!/usr/bin/env python | |
""" | |
Very simple HTTP server in python (Updated for Python 3.7) | |
Usage: | |
./dummy-web-server.py -h | |
./dummy-web-server.py -l localhost -p 8000 | |
Send a GET request: |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title></title> | |
<!-- Android | |
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" /> | |
<meta charset="utf-8">--> | |
<!-- iPad/iPhone specific css below, add after your main css > |
# 中西文切換鍵的默認設置寫在 default.yaml 裏面 | |
# 以下的 default.custom.yaml 在全局範圍重定義該組快速鍵 | |
# | |
# 可用的按鍵有 Caps_Lock, Shift_L, Shift_R, Control_L, control_R | |
# Mac 系統上的鼠鬚管不能區分左、右,因此只有對 Shift_L, Control_L 的設定起作用 | |
# | |
# 已輸入編碼時按切換鍵,可以進一步設定輸入法中西文切換的形式。 | |
# 可選的臨時切換策略有三: | |
# inline_ascii 在輸入法的臨時西文編輯區內輸入字母、數字、符號、空格等,回車上屏後自動復位到中文 | |
# commit_text 已輸入的候選文字上屏並切換至西文輸入模式 |
# default.custom.yaml | |
# 全局範圍識別輸入串爲 rime + 任意數字序列,以及形如 rimeime-1.2.3 的常用西文短語 | |
# 也可將本組 patch 寫入 <輸入方案ID>.custom.yaml 使這組規則僅在一款輸入方案中有效 | |
# | |
# 第一例,輸入 rime 之後,再輸入任意一個數字,則立即識別爲西文輸入 | |
# 再加上 default.yaml 原有的 email 規則,識別包含 @ 字符的郵箱,於是可以一氣呵成 [email protected] | |
# 第二例,輸入到 rimeime 時,立即識別爲西文輸入,並可跟隨任意位數字及指定的符號 | |
patch: | |
recognizer/patterns/rime123: "^rime[0-9]+$" |
/** | |
* Takes a camel cased identifier name and returns an underscore separated | |
* name | |
* | |
* Example: | |
* camelToUnderscores("thisIsA1Test") == "this_is_a_1_test" | |
*/ | |
def camelToUnderscores(name: String) = "[A-Z\\d]".r.replaceAllIn(name, {m => | |
"_" + m.group(0).toLowerCase() | |
}) |
-- gets all fields from a hash as a dictionary | |
local hgetall = function (key) | |
local bulk = redis.call('HGETALL', key) | |
local result = {} | |
local nextkey | |
for i, v in ipairs(bulk) do | |
if i % 2 == 1 then | |
nextkey = v | |
else | |
result[nextkey] = v |