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 / cpojer.zsh-theme
Created November 24, 2011 22:59 — forked from cpojer/cpojer.zsh-theme
My zsh theme
# ZSH Theme by @cpojer
PROMPT='[%{$fg[red]%}%n%{$fg[black]%}: %{$fg[blue]%}%~%{$reset_color%}\
$(git_prompt_info)\
%{$fg[black]%}%(!.#.]$)%{$reset_color%} '
PROMPT2=''
RPS1=''
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%} %{$fg[yellow]%}("
ZSH_THEME_GIT_PROMPT_SUFFIX=")%{$reset_color%}"
@fanweixiao
fanweixiao / urlmonitor
Created March 5, 2012 09:00 — forked from peterc/urlmonitor
urlmonitor - print out the URLs requested system wide on the main network interface
# urlmonitor - print out the URLs requested system wide on the main network interface
# Accept a network interface name as an optional argument
iface = ARGV.first
# No interface specified? Try to guess which one is king..
unless iface
`ifconfig -l`.split.each do |iface|
next if iface =~ /^lo/
break if `ifconfig #{iface}` =~ /inet (0|1|2)/
require 'net/http'
require 'uri'
RIAK = ['localhost', 8098]
run lambda { |env|
req = Rack::Request.new(env)
if req.post? && req.path == '/'
res = Net::HTTP.new(*RIAK).start do |http|
http.post('/riak/shrt', req.params['url'], { 'Content-Type' => 'text/plain' })
git remote add --track master upstream git://github.com/upstreamname/projectname.git
@fanweixiao
fanweixiao / dart.txt
Created April 10, 2012 02:58 — forked from paulmillr/dart.md
Leaked internal google dart email
---------- Forwarded message ----------
From: Mark S. Miller <erights@google.com>
Date: Tue, Nov 16, 2010 at 3:44 PM
Subject: "Future of Javascript" doc from our internal "JavaScript Summit"
last week
To: javascript-standard@google.com
On November 10th and 11th, a number of Google teams representing a variety
of viewpoints on client-side languages met to agree on a common vision for
the future of Javascript.
@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
@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();
background: #f06;
background: linear-gradient(60deg, #f06, yellow);
min-height: 100%;
@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')
@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)