Skip to content

Instantly share code, notes, and snippets.

@yuanmai
yuanmai / pom.xml
Created June 19, 2012 10:35
Maven Repo without Nexus
mvn -DaltDeploymentRepository=release-repo::default::file:local-path/releases clean deploy
mvn -DaltDeploymentRepository=snapshot-repo::default::file:local-path/snapshots clean deploy
@yuanmai
yuanmai / gist:2934395
Created June 15, 2012 02:32
Git svn clone
git svn clone -s -r 40000:HEAD https://svn.parrot.org/parrot
@yuanmai
yuanmai / gist:2908319
Created June 11, 2012 03:04
Macro expand as a refactoring tool
(defn f->
([s] (f-> s ()))
([s fs] (if (and (list? s)
(= 2 (count s)))
(let [[f x] s]
(recur x (conj fs f)))
(conj (conj fs s) '->))))
(defmacro r-> [sexp]
(f-> sexp))
sudo killall coreaudiod
@yuanmai
yuanmai / gist:2843435
Created May 31, 2012 13:30
Clojure 代码优化
;; f需要被调用很多次,假设g的运算非常耗时,而在循环中a的值是不变的,b每次不一样,是否有自动的方法把f转化成curry形式,从而提高性能?
(defn f [a b]
(let [gb (g b)
ga (g a)
gga (g ga)]
(+ gga gb)))
=>
(defn f [a]
@yuanmai
yuanmai / gist:2823116
Created May 29, 2012 07:26
Locate indexpath from UISwitch events
CGPoint hitPoint = [sender convertPoint:CGPointZero toView:self.tableView];
NSIndexPath *hitIndex = [self.tableView indexPathForRowAtPoint:hitPoint];
@yuanmai
yuanmai / gist:2718536
Created May 17, 2012 12:17
reload all
;; http://blog.jayfields.com/2012/05/agile-development-with-clojure.html?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+jayfields%2FmjKQ+%28Jay+Fields%27+Thoughts%29
(defonce ignored-namespaces (atom #{}))
(defn reload-all []
(doseq [n (remove (comp @ignored-namespaces ns-name) (all-ns))]
(require (ns-name n) :reload )))
@yuanmai
yuanmai / .gitconfig
Created May 17, 2012 07:32
Handle local debug changes with git
[alias]
db = !git cherry-pick -n debug-only && git status
udb = !git revert -n debug-only && git status
@yuanmai
yuanmai / .Xmodmap
Created May 16, 2012 10:06
XQuartz settings
clear Mod1
clear Mod2
keycode 66 = Meta_L
keycode 69 = Meta_R
keycode 63 = Alt_L
keycode 71 = Alt_R
add Mod1 = Alt_L Alt_R
add Mod2 = Meta_L Meta_R
@yuanmai
yuanmai / simplifier.clj
Created May 9, 2012 14:00 — forked from ck/simplifier.clj
A Simplifier for all Expressions
;; A Simplifier for all Expressions
;; Example:
;; (simplify '(* 1 (+ x (- y y)))) ;=> x
;; (simplify '(and a (and (and) b))) ;=> (and a b)
;; See section 4.4, "Syntactic Abstraction" of Norvig and Pitman's
;; "Tutorial on Good Lisp Programming Style":
;; http://norvig.com/luv-slides.ps