Ref. http://www.mactricksandtips.com/2011/01/auto-complete-words-on-your-mac.html
command + >
Tuesday, December 18, 2012
Thursday, December 13, 2012
Running python in 32-bit mode for wxPython
在 Mac OS X 上面寫 wxpython 時,必須打開 32bit mode 不然他不會動 ...
解法:
加入以下環境變數
export VERSIONER_PYTHON_PREFER_32_BIT=yes
參考
http://stackoverflow.com/questions/2088569/how-do-i-force-python-to-be-32-bit-on-snow-leopard-and-other-32-bit-64-bit-quest
http://stackoverflow.com/questions/4665818/running-python-in-32-bit-more-for-wxpython
emacs beginer's notes
http://www.linux.org.tw/CLDP/OLD/Emacs-Beginner-HOWTO-2.html
http://linux.chinaitlab.com/man/newsoft/Emac/book.html
上下左右
C-p previous line
C-n next line
C-f forward
C-b backward
PageUp/Dn
C-v scroll-up
M-v scroll-down
以字移動
上下左右
C-p previous line
C-n next line
C-f forward
C-b backward
PageUp/Dn
C-v scroll-up
M-v scroll-down
以字移動
M-f forward-word
M-b backward-word
行首行尾
C-a move-beginning-of-line
C-e move-end-of-line
句首句尾
M-a backward-sentence
M-e forward-sentence
檔頭檔尾
M-< beginning-of-buffer
行首行尾
C-a move-beginning-of-line
C-e move-end-of-line
句首句尾
M-a backward-sentence
M-e forward-sentence
檔頭檔尾
M-< beginning-of-buffer
M-> end-of-buffer
search
search
M-q C-s forward search
M-q C-r backward search
delete
C-d delete-char
M-d kill-word
delete
C-d delete-char
M-d kill-word
C-k kill-line
M-k kill-sentence
yank
yank
C-y yank
M-y yank-pop
buffer
C-x C-b list-buffers
C-x b switch-to-buffer
C-x k kill buffer
M-y yank-pop
buffer
C-x C-b list-buffers
C-x b switch-to-buffer
C-x k kill buffer
C-x C-c save-buffers-kill-emacs
M-x rename-buffer
files
C-x C-f open a file
C-x C-s save
C-x C-w save as
windows
M-x rename-buffer
files
C-x C-f open a file
C-x C-s save
C-x C-w save as
windows
C-x 0 delete-window
C-x 1 delete-other-windows
C-x 2 split window vertically
C-x 1 delete-other-windows
C-x 2 split window vertically
C-x 3 split window horizontally
C-x o other-window
C-x o other-window
misc
C-x u undo
C-x l count-lines-page
M-x execute-extended-command
M-x shell 開啟 shell
C-x l count-lines-page
M-x execute-extended-command
M-x shell 開啟 shell
C-g keyboard-quit
C-u M-x calendar
help
C-h k describe-key
C-h i info # 神奇說明書
C-h F Emacs FAQ
C-h b shortcut keys enabled in current buffer
Monday, December 10, 2012
geek calendar
http://technet.tw/ 是一個有趣的宅宅農民曆,於是寫出了一個 one liner 去抓他
btw, 背景是君君 >///<
date "+%F, %A" && w3m -dump "http://technet.tw" | head -n 26 | sed -e '/^$/d' -e '1,3d'| sed -e '1,4{N; s/\n/ /}'
btw, 背景是君君 >///<
Thursday, December 6, 2012
我們都活在太舒服的年代
跟 jserv 信件往來的一小段節錄... 反思我們對於電腦環境的認識與了解
我們都活在太舒適的年代
jserv:
話說回來,二十年前當我剛開始接觸電腦時,那時沒有太多科技術語,而且人們探討的議題也相當局限,不外乎 BIOS、文書編輯器、繪圖程式 (你想過AutoCAD 跑在受限於 640 KB 的 DOS 環境是怎麼樣呢?)、幕後排版 (比 TeX 陽春許多)、程序導向的程式語言 (還記得 OOP/4GL 慰為風氣的年代嗎?還要再早一點) 等等。
而現在就非常可怕,我想要是把科技術語整理起來,或許都比當年的 BIOS 原始程式碼列表 (可在圖書館找到這樣的專書,全書都是程式碼,在 301 條款生效之前,把有版權保護的程式碼印列出來的盜版行為,在台灣不追究) 還長。
me:
這些更早的年代在我深入接觸電腦早已過去,但是閱讀前輩們的書籍時還是能從中體驗到那種氛圍,那個處處受現的年代,所有資源都要透過整個系統去思考,做最佳、最有效率的利用;反觀現在太多 "外殼" 將計算機內部的行為包裝起來,一般接觸電腦的人也不容易產生興趣、去明白 how it works ,太多商業化 (或是說物質)的包裝混淆了焦點。
但是值得反思的是,就拿機械工業技術來對比吧,工業革命時代下也是許多 "hackers" 想要改進蒸氣機、齒輪和傳動軸等動力機械的發展,而商業化和大量的規模生產後的現代,想要去了解各式機械的運作原理的人們也漸漸變少了。像是我們並不會想去深入探討一輛汽車或是機車如何工作、不必了解引擎運轉的種種原理等,大眾化後的結果是大家享受某項工具的的 "商品",而技術本身可能除了技術人員外就愈來愈少人想要去理解這些。
回到電腦科學的角度不也如此?我認為電腦科學中很大的概念是 abstraction ,透過更上一層的抽象角度來思考整個系統的運作,而不去鑽底層技術的牛角尖,這種學習方式未嘗不好,只是當我們在上層進行抽象、全局的思考模式時,不能因而模糊了焦點。這個時代太多過多的包裝讓電腦系統變得漂漂亮亮的商品,而想去了解他背後工作原理的人很容易被這些外部的包裝所迷惑、混淆,相較之下當年一群 geek 跟 hacker 的時代要接觸底層工作知識的途徑就顯的容易許多。我想,這是現在學生不容易對於系統產生興趣的其中一個原因吧!
Tuesday, December 4, 2012
gnutls_anon_server_credentials is deprecated
compile qemu 遇到
error: ‘gnutls_anon_server_credentials’ is deprecated 解法
基本上就是把 type 換掉即可
ref
好奇這 bug 應該很久以前就解掉了,但是我去 fetch 目前最新的 qemu 1.3 還是在 @@"
error: ‘gnutls_anon_server_credentials’ is deprecated 解法
基本上就是把 type 換掉即可
ref
好奇這 bug 應該很久以前就解掉了,但是我去 fetch 目前最新的 qemu 1.3 還是在 @@"
Index: qemu-kvm-1.1.rc2/ui/vnc-tls.c =================================================================== --- qemu-kvm-1.1.rc2.orig/ui/vnc-tls.c +++ qemu-kvm-1.1.rc2/ui/vnc-tls.c @@ -99,9 +99,9 @@ static ssize_t vnc_tls_pull(gnutls_trans } -static gnutls_anon_server_credentials vnc_tls_initialize_anon_cred(void) +static gnutls_anon_server_credentials_t vnc_tls_initialize_anon_cred(void) { - gnutls_anon_server_credentials anon_cred; + gnutls_anon_server_credentials_t anon_cred; int ret; if ((ret = gnutls_anon_allocate_server_credentials(&anon_cred)) < 0) { @@ -382,7 +382,7 @@ int vnc_tls_client_setup(struct VncState } } else { - gnutls_anon_server_credentials anon_cred = vnc_tls_initialize_anon_cred(); + gnutls_anon_server_credentials_t anon_cred = vnc_tls_initialize_anon_cred(); if (!anon_cred) { gnutls_deinit(vs->tls.session); vs->tls.session = NULL;
Wednesday, November 28, 2012
google hangout on Arch linux
install this aur https://aur.archlinux.org/packages.php?ID=40056
sudo yaourt -S google-talkplugin
if there's no video, then add this
sudo echo "O3D_OVERRIDE_RENDER_MODE=2D" >> /opt/google/talkplugin/envvars
sudo yaourt -S google-talkplugin
if there's no video, then add this
sudo echo "O3D_OVERRIDE_RENDER_MODE=2D" >> /opt/google/talkplugin/envvars
Tuesday, November 27, 2012
heapify algorithm
Data Structure 小練習,heapify 算法
關於 heap 更多內容請參考良葛格的精美筆記
感謝強者我同學 Unclehandsome ㄉㄉ指點 <(_ _)>
heap 的性質:
用白文來講就是,
對於 heap 裏面的每一個 node ,他的 value 一定大於他子樹的任一節點的 value
並且他 left-subtree 跟 right-subtree 都要是 heap
簡記一下 make heap 的步驟:
make heap 的作法:想像一個空的 tree, 然後一次 insert 一個在 heap 的尾端
實作上要注意的地方是 tree 的 array index 從 1 開始 (算 node / 2 時比較好做)
Output:
關於 heap 更多內容請參考良葛格的精美筆記
感謝強者我同學 Unclehandsome ㄉㄉ指點 <(_ _)>
heap 的性質:
# Max heap for all nodes in array: A[ parent(i) ] >= A[i]
用白文來講就是,
對於 heap 裏面的每一個 node ,他的 value 一定大於他子樹的任一節點的 value
並且他 left-subtree 跟 right-subtree 都要是 heap
簡記一下 make heap 的步驟:
make heap 的作法:想像一個空的 tree, 然後一次 insert 一個在 heap 的尾端
for nodes in array: insert node insert: 1: append to the end of the heap (the last leaf) 2: compare with my parent 3: swap if i'm greater than my parent 4: goto 2
實作上要注意的地方是 tree 的 array index 從 1 開始 (算 node / 2 時比較好做)
#!/usr/bin/python import random import heapq def mk_heap (arr): heap = [''] for i in arr: heap.append(i) l = len(heap) - 1 while l >= 2 and heap[l] < heap[l//2]: heap[l], heap[l//2] = heap[l//2], heap[l] l = l // 2 print heap[1:] if __name__ == '__main__': arr = range (1, 20) random.shuffle(arr) brr = arr print "before heapify" print arr print "my make heap:" mk_heap(arr) h = [] for i in brr: heapq.heappush(h, i) print "using heapq:" print h
Output:
before heapfy [14, 11, 19, 2, 3, 10, 5, 13, 8, 15, 16, 1, 18, 9, 17, 4, 7, 6, 12] my make heap: [1, 3, 2, 4, 11, 5, 9, 7, 6, 15, 16, 19, 18, 10, 17, 14, 8, 13, 12] using heapq: [1, 3, 2, 4, 11, 5, 9, 7, 6, 15, 16, 19, 18, 10, 17, 14, 8, 13, 12]
Friday, November 23, 2012
bye bye, mouse!
丟掉滑鼠的方法...
awesome wm - next gerneration framework window manager for X
http://awesome.naquadah.org/
vimium - the hacker's browser
http://vimium.github.com/
w3m text-based browser # with mobile web pages
http://w3m.sourceforge.net/
turses - twitter client
http://turses.readthedocs.org/en/latest
rxvt-unicode - terminal emulator
http://software.schmorp.de/pkg/rxvt-unicode.html
ranger file manager
http://ranger.nongnu.org/
irssi - the IRC client of the future
http://www.irssi.org/
alsamixer
http://alsa.opensrc.org/Alsamixer
mplayer
http://www.mplayerhq.hu/design7/news.html
emacs - just another operating system(X
http://www.gnu.org/software/emacs/
vim - the ultimate editor
http://www.vim.org/
... lots of command line tools
Good keybord
FILCO ninja majestouch II
Wednesday, November 21, 2012
sha-bang! running scripts on Unix machines
reference: http://en.wikipedia.org/wiki/Shebang_(Unix)
sha-bang 是 Unix 系統上面的特殊慣例,由一個 # (sharp) 和一個 ! (bang) 組成
在 script 中,這個慣例用來表示要用哪個 interpreter 來解釋 / 執行這個 script
一般用絕對路徑來表示,例如 #!/bin/sh 來呼叫外部的 Bourne shell
#!/path/to/the/interpreter [arguments]
常見例子:
#!/bin/sh
#!/bin/sh -x
#!/bin/bash
#!/bin/sed -f
#!/usr/bin/awk -f
#!/usr/bin/perl
#!/usr/bin/python
#!/usr/bin/ruby
當然也可以很空虛的...
#!/bin/cat
另外,有時候為了可攜性,會用 /usr/bin/env python 這種用法來找到該機器的 interpreter 在哪邊
然後不要傻呼呼的吃到 Permission denied. 才在哭說不知道要怎麼跑 lol
chmod +x your_script
sha-bang 是 Unix 系統上面的特殊慣例,由一個 # (sharp) 和一個 ! (bang) 組成
在 script 中,這個慣例用來表示要用哪個 interpreter 來解釋 / 執行這個 script
一般用絕對路徑來表示,例如 #!/bin/sh 來呼叫外部的 Bourne shell
#!/path/to/the/interpreter [arguments]
常見例子:
#!/bin/sh
#!/bin/sh -x
#!/bin/bash
#!/bin/sed -f
#!/usr/bin/awk -f
#!/usr/bin/perl
#!/usr/bin/python
#!/usr/bin/ruby
當然也可以很空虛的...
#!/bin/cat
另外,有時候為了可攜性,會用 /usr/bin/env python 這種用法來找到該機器的 interpreter 在哪邊
然後不要傻呼呼的吃到 Permission denied. 才在哭說不知道要怎麼跑 lol
chmod +x your_script
Subscribe to:
Posts (Atom)