Skip to content

Instantly share code, notes, and snippets.

@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: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:4426568
Created January 1, 2013 10:59
Open files in Emacs in OS X shell
open [file-name] -a emacs
@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: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:4337084
Created December 19, 2012 14:36
lein nrepl :headless #remote nrepl connect
:repl-options {:port 10101 :host "0.0.0.0" }
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: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)];
@yuanmai
yuanmai / gist:4327386
Created December 18, 2012 11:56
VirtualBox ssh NAT
VBoxManage modifyvm "Your VM Name" --natpf1 "guestssh,tcp,,2222,,22"
ssh root@localhost -p 2222
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (!maskLayer)
{
maskLayer = [CAGradientLayer layer];
CGColorRef outerColor = [UIColor colorWithWhite:1.0 alpha:1.0].CGColor;
CGColorRef innerColor = [UIColor colorWithWhite:1.0 alpha:0.0].CGColor;