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 / deploy.json
Last active January 4, 2016 17:19
Rapid dev & deploy to server over ssh by using [mina](https://npmjs.org/package/mina)
{
"server": "cc@xxxx.com",
"server_dir": "/srv/qr.xxx.com",
"repo": "git@github.com:fanweixiao/xxxx.git",
"branch": "release",
"history_releases_count": 3,
"shared_dirs": [
"node_modules",
"public/bower_components"
],
#!/bin/bash
pacman -S nginx
export JAIL=/srv/http
# Create Necessary Devices
mkdir $JAIL/dev
mknod -m 0666 $JAIL/dev/null c 1 3
mknod -m 0666 $JAIL/dev/random c 1 8
mknod -m 0444 $JAIL/dev/urandom c 1 9
require 'oauth2'
require 'json'
OAuth2::Response.register_parser(:text, 'text/plain') do |body|
parsed_body = JSON.parse(body)
parsed_body
end
client = OAuth2::Client.new(YOU_KEY, YOU_SECRET, :site => "https://api.weibo.com", :authorize_url => "/oauth2/authorize", :token_url => "/oauth2/access_token")
puts client.auth_code.authorize_url(:redirect_uri => YOUR_CALLBACK_URL)
token = client.auth_code.get_token('authorization_code_value', :redirect_uri => YOUR_CALLBACK_URL)
@fanweixiao
fanweixiao / ruby_installer
Last active December 10, 2015 18:18
Install Ruby from source with rvm
- wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz
- ./configure --prefix=/usr/local
- Download ruby source
- ./configure --prefix=/usr/local --disable-install-doc --with-opt-dir=/usr/local/lib/
- sudo apt-get install zlib1g-dev libssl-dev
RUBY_SOURCE_DIR/ext/openssl
ruby extconf.rb
make
make install
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
@fanweixiao
fanweixiao / gist:4134260
Created November 23, 2012 06:39
uber writer
sudo add-apt-repository ppa:w-vollprecht/ppa
sudo apt-get update
sudo apt-get install uberwriter
UberWriter 非常简单易用,主要功能如下:
具备预览功能( Ctrl+P) ,全屏功能及专注书写模式
提供 斜体 、粗体、项目列表等快捷键。
支持导出到 PDF (需安装 texlive)、Html 、OTD 、LaTex 、ePub 等多种文档格式。
@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
@fanweixiao
fanweixiao / gist:3878635
Created October 12, 2012 10:40
[top] tips
【z】 to toggle color.
【x】 to toggle coloring of sort column.
【s 9 9 Enter ↵】 to set update frequency to every 99 seconds.
【Space】 to force a update.
【>】 to change the sort column to the right of current sort column.
【<】 to change the sort column to the left.
【R】to toggel reverse sort order.
【O k Enter ↵】 to order by CPU usage. (also 【P】)
【O n Enter ↵】 to order by memory usage. (also 【M】)
@fanweixiao
fanweixiao / gist:3786595
Created September 26, 2012 07:29
gem install pg on CentOS 6.3
gem install pg -- --with-pg-lib=/usr/pgsql-9.1/lib --with-pg-config=/usr/pgsql-9.1/bin/pg_config
==========
$ export PATH=/usr/pgsql-9.1/bin:$PATH
$ uname -a
$ export ARCHFLAGS=' -arch x86_64'
$ bundle install
==========