ckclark's Blog

Errors = more code2

Use another location of ssh key while using git

當需要暫時(或一直)用別的ssh key來連線時 可以用GIT_SSH這個env var來完成
使用方式如下

/path/to/your_script/my_ssh.sh裡面寫

#!/bin/bash
ssh -i /path/to/your/private/key/id_rsa $1 $2

然後再視情況設定GIT_SSH這個env var

# 一次性的
GIT_SSH=/path/to/your_script/my_ssh.sh git pull

# 同個session下
export GIT_SSH=/path/to/your_script/my_ssh.sh

# 每次開啟bash …

itertools.product will cause MemoryError

使用itertools.product的時候請小心MemoryError

雖然當其中一個或全部參數都是無窮數列的時候理論上也是能跑出結果
不過itertools.product的行為會需要重跑其中的iterable (不一定所有傳進來的iterable都是能夠重跑的 也不見得重跑會有一樣結果)
所以實作上就會試著先把傳進來的iterable都變成tuple暫存起來
那當其中一個是無窮數列的時候 就爆炸囉
順帶一提 我的情況是需要建出(0, 1, 2, 3, ...) x 'ABCD' => (0A, 0B, 0C, 0D, 1A, 1C, ...) 直到第n個item
原本想法是用

for (letter, idx), _ in zip(product(itertools.count(), 'ABCD'), xrange(n)):
    print letter, idx

結果就當掉 連滑鼠都沒反應 …

--reset-author flag in git commit

當使用git commit -c/--reedit-messagegit commit -C/--reuse-message的場合
有時候只是想拿上個 commit message 當 template 來用(like git commit -c HEAD)
不過最近發現 author date 也會沿用這個指定的commit的
查了一下在manual裡面有提到

-C <commit> --reuse-message=<commit>
Take an existing commit object, and reuse the log message and the authorship information (including the timestamp …

Find git difftool fix using git bisect

用了 git 一陣子 覺得diff.tool設成vimdiff後有點麻煩 每次都是Read-only的狀態
發現網路上有一個 設定 其實就是去改 git 實作 diff.tool=vimdiffcommand 而已
奇怪的是 照著做後 有一台電腦可以 另一台電腦卻不行
網路上大部分也都說 打開後再設:set noro就好了
不過既然都有一台電腦可行了 當然要把它找出來囉
反覆比較後 發現原來是 git 的版本不一樣(現在想想好像也理所當然)
正巧 git 學了這麼久還沒用過git bisect 來玩玩看好了

Switch to pelican

pelican
就如同蠻多blogger說的 身為一個pythonist當然就要用python做的static site generator
所以就換成pelican了

一開始的確不是很順利 quickstart 跑起來缺東缺西
config看完全部manual才搞定
有空再補一下差異

first post

開板誌慶

第一篇來個reference

Read on button is: <!-- more -->

markdown

Reference 1
Reference 2

section heading 1

section heading 2

section heading 3

section heading 4

# section heading 1
## section heading 2
### section heading 3
#### section heading 4

Paragraphs are very easy; separate them with a blank line. You can write your …