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 / 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 / gist:3376529
Created August 17, 2012 06:40 — forked from dervn/gist:3375687
龍應台:我們的「中國夢」(8月1日北京大學演講講辭)

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

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

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

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

反攻 反攻 反攻大陸去
@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 / Macros.h
Created November 19, 2012 07:51 — forked from numo16/Macros.h
Some useful iOS/Objective-C Macros
#define ApplicationDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
#define UserDefaults [NSUserDefaults standardUserDefaults]
#define NotificationCenter [NSNotificationCenter defaultCenter]
#define SharedApplication [UIApplication sharedApplication]
#define Bundle [NSBundle mainBundle]
#define MainScreen [UIScreen mainScreen]
#define ShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
#define HideNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
#define NetworkActivityIndicatorVisible(x) [UIApplication sharedApplication].networkActivityIndicatorVisible = x
#define NavBar self.navigationController.navigationBar
var fs = require('fs'),
util = require('util'),
Stream = require('stream').Stream;
/**
* Create a bandwidth limited stream
*
* This is a read+writeable stream that can limit how fast it
* is written onto by emitting pause and resume events to
* maintain a specified bandwidth limit, that limit can