snipMate, better than snippetsEmu!

Mac 上的 TextMate 最有名的 feature 就是會幫你補完程式碼,vim 也有個叫 snippetsEmu 的 plugin。好久以前曾經試用過,覺得很難用,而且 coding style 很醜 XD

今天我發現 vim 現在有個叫 snipMate 的 plugin,做的比 snippetsEmu 好很多! 另外,snippetsEmu 也已經一年多沒更新了,snipMate 則比較活躍,也比較令人期待。不多說,直接看作者提供的 screencast 吧:

snipMate.vim Introductory Screencast from Michael Sanders on Vimeo.

除此之外,它的 snippet 還支援 backtick 跟 vim script:


snippet date
`system("date +%Y-%m-%d")`

snippet filename_foo
`filename()`

如果你用 Emacs,可以試試 gugod 提到yasnippet

當 Dororo 遇上 iPod shuffle

有一天走在路上看到 iPod shuffle,覺得他跟 Dororo 實在太像了 … 來合體吧!

退伍倒數計時器 手機版

前幾個禮拜發現我的舊手機也可以跑 Java,於是決定參考軒田教授的退伍日期計時器寫個手機版,這樣我在部隊裡面也可以看了(有那麼想看嗎 XD)

下載網址: http://code.google.com/p/countmento/downloads/list
Project 網頁: http://code.google.com/p/countmento/

(別人都在寫 iPhone、Android,我還在寫 Java ME…)

LISP Practice

Quick-sort


(defmacro for-all (x op xs)
`(remove-if-not #'(lambda (y) (,op y x)) xs))

(defun qsort (nums)
(if (not nums)
()

(let ((x (first nums))
(xs (rest nums)))
(if (eq x nil)
()

(append
(qsort (for-all x < xs))
(list x)
(qsort (for-all x >= xs)))))))

Permutation

(defun remove-first (n nums)
(remove n nums :count 1))

(defun join-sublists (superlist)
(reduce #'(lambda (l1 l2) (append l1 l2)) superlist))

(defun permute-sorted-list (nums perm)
(if (eq nums nil)
(list perm)

(let ((unique-nums (remove-duplicates nums))) (join-sublists
(mapcar (lambda (n)
(permute-sorted-list (remove-first n nums) (append perm (list n))))
unique-nums)))))

(defun permutation (nums)
(permute-sorted-list (sort nums #'<) '()))