Skip to content

Instantly share code, notes, and snippets.

View fanweixiao's full-sized avatar
🦖
hacking on @yomorun

C.C. fanweixiao

🦖
hacking on @yomorun
View GitHub Profile
@fanweixiao
fanweixiao / gist:3414543
Created August 21, 2012 11:01 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@fanweixiao
fanweixiao / gist:3376529
Created August 17, 2012 06:40 — forked from dervn/gist:3375687
龍應台:我們的「中國夢」(8月1日北京大學演講講辭)

龍應台:我們的「中國夢」(8月1日北京大學演講講辭)

【明報專訊】第一次接到電話,希望我談談「中國夢」的時候,我的第一個反應是:「一千枚飛彈對準我家,我哪裏還有中國夢啊?」

可是沉靜下來思索,1952年生在台灣的我,還有我前後幾代人,還真的是在「中國夢」裏長大的,我的第一個中國夢是什麼呢?

我們上幼稚園時,就已經穿著軍人的制服、帶著木製的步槍去殺「共匪」了,口裏唱著歌。當年所有的孩子都會唱的那首歌,叫做《反攻大陸去》:

反攻 反攻 反攻大陸去
@fanweixiao
fanweixiao / gist:3306907
Created August 9, 2012 18:36
flick hosts
106.10.137.23 farm9.staticflickr.com
106.10.137.23 farm8.staticflickr.com
106.10.137.23 farm7.staticflickr.com
106.10.137.23 farm6.staticflickr.com
106.10.137.23 farm5.staticflickr.com
106.10.137.23 farm4.staticflickr.com
@fanweixiao
fanweixiao / gist:2693277
Created May 14, 2012 10:53
coffeescript variable just var once
a = (_)->
a=_
(__,_)->
(__+_)*a
alert (a 10) a,3
@fanweixiao
fanweixiao / gist:2693126
Created May 14, 2012 10:23
Parentheses usage in coffeescript
alert ((_)->((_)->_+_)(((_)->_*_)(_))) 10
@fanweixiao
fanweixiao / tail_recursion_fibonacci.coffee
Created May 14, 2012 10:15
tail recursion fibonacci in coffee
fib = (n)->
return ((n,a,b) ->
if n>0 then arguments.callee n-1, b, a+b else a
)(n,0,1)
@fanweixiao
fanweixiao / Memoization_fibonacci.coffee
Created May 14, 2012 10:07
Memoization fibonacci in coffeescript
fib = (n)->
arr = {}
$ = (_) ->
return _ if _ < 2
return arr[_] if arr[_]
arr[_] = $(_-1) + $(_-2)
arr[_]
$(n)
console.time('a')
background: #f06;
background: linear-gradient(60deg, #f06, yellow);
min-height: 100%;
@fanweixiao
fanweixiao / gist:2400642
Created April 16, 2012 18:46 — forked from remy/gist:350433
Storage polyfill
if (typeof window.localStorage == 'undefined' || typeof window.sessionStorage == 'undefined') (function () {
var Storage = function (type) {
function createCookie(name, value, days) {
var date, expires;
if (days) {
date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
expires = "; expires="+date.toGMTString();
@fanweixiao
fanweixiao / create_new_kvm_os
Created April 16, 2012 11:48
Create new kvm virtual machine
qemu-img create -f raw NAME.img 8G
virt-install --name='VNAME' --ram=512 --vcpus=1 --description='' --cdrom=/share/downloads/centos-6.2-x86_64-minimal.iso --disk=/share/vos/VNAME.img --vnc --noautoconsole --force