Skip to content

Instantly share code, notes, and snippets.

@yuanmai
yuanmai / gist:4335012
Created December 19, 2012 07:12
iOS home screen fade in
_coverImage = [UIImage imageNamed:@"Default.png"];
}
[self.view addSubview:_coverImage];
[UIView beginAnimations:@"FadeOutCover" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(removeAndDeleteCover)];
lvextend -L +5G /dev/ubuntu/data
减少5G
lvresize -L -5G /dev/ubuntu/data
三、增加swap空间。
一般swap是内存的2倍,但是如果一不小心在安装时少分了点,那就有点郁闷了。没关系,lvm可以增加swap空间。
1、free查看swap的卷标
#free
@yuanmai
yuanmai / gist:4337084
Created December 19, 2012 14:36
lein nrepl :headless #remote nrepl connect
:repl-options {:port 10101 :host "0.0.0.0" }
@yuanmai
yuanmai / gist:4411286
Created December 30, 2012 06:40
remove all elc files in your emacs folders
find . -name "*.elc" -type f | xargs rm -f
@yuanmai
yuanmai / gist:4426362
Created January 1, 2013 10:19
Use Java 6 on OS X
sudo ln -fhsv 1.6.0 /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents
sudo ln -fhsv 1.6.0 Current
sudo ln -fhsv 1.6.0 CurrentJDK
@yuanmai
yuanmai / gist:4426568
Created January 1, 2013 10:59
Open files in Emacs in OS X shell
open [file-name] -a emacs
@yuanmai
yuanmai / gist:4458736
Created January 5, 2013 00:17
inside-out programming
user> (zero? 1)
false
user> (zero? 0)
true
user> [0 1 2 0 3]
[0 1 2 0 3]
user> (filter zero? [0 1 2 0 3])
(0 0)
user> (count (filter zero? [0 1 2 0 3]))
2
@yuanmai
yuanmai / gist:4465770
Created January 6, 2013 07:08
enlive fragment
{[:input] [:label]}
(h/clone-for [[k v] (:choices q)]
[:input]
(h/set-attr :name (-> q :question-id name)
:id (name k)
:value (name k))
[:label]
(h/do->
(h/set-attr :for (name k))
@yuanmai
yuanmai / gist:4467322
Created January 6, 2013 14:00
clone-for does not work well with single letter tag
user> (use 'net.cgrand.enlive-html)
nil
user> (sniptest "<tr><bb><div></div></bb></tr>"
[:tr] (clone-for [option-value-map [1]]
[:div] (content "a")))
"<tr><bb><div>a</div></bb></tr>"
user> (sniptest "<tr><b><div></div></b></tr>"
[:tr] (clone-for [option-value-map [1]]
[:div] (content "a")))
"<tr></tr><b></b><div><b></b></div><b></b>"
@yuanmai
yuanmai / gist:4586501
Created January 21, 2013 14:36
deliver / promise, look ma no callbacks
(defn check-item [p id]
(if-let [item (find-item id)]
(do (deliver p item)
nil)
(status 404 "Item not found")))
(defn check-access [item]
(when-not (can-user-access? item)
(status 403 "Go away")))