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 / 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
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)
#!/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
@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": "[email protected]",
"server_dir": "/srv/qr.xxx.com",
"repo": "[email protected]:fanweixiao/xxxx.git",
"branch": "release",
"history_releases_count": 3,
"shared_dirs": [
"node_modules",
"public/bower_components"
],
@fanweixiao
fanweixiao / gist:9533725
Last active August 29, 2015 13:57
/Interface/Search/getAllIndex json response
{ "data" : { "all" : [ { "area" : "0",
"areaName" : "全国",
"key" : "taylor swift",
"period" : "20110101|20140311",
"ratio" : { "agv_m" : "6064",
"agv_w" : "7079",
"qoq_m" : "-17",
"qoq_w" : "32",
"yoy_m" : "-44",
"yoy_w" : "-30"
@fanweixiao
fanweixiao / hosts
Created July 1, 2014 17:27
dropbox hosts file
108.160.166.62 dropbox.com
108.160.166.62 www.dropbox.com
108.160.166.140 client-lb.dropbox.com
107.20.134.222 dl.dropbox.com
107.20.134.222 dl-web.dropbox.com
23.21.206.219 forums.dropbox.com
108.160.165.211 notify0.dropbox.com
108.160.165.211 notify1.dropbox.com
108.160.165.211 notify2.dropbox.com
108.160.165.211 notify3.dropbox.com
<?xml version="1.0"?>
<root>
<item>
<name>Switch Input Source</name>
<appendix>Use the right Option key to select the next input source</appendix>
<identifier>private.switch_input_source_with_right_option</identifier>
<autogen>--KeyToKey-- KeyCode::OPTION_R, KeyCode::SPACE, ModifierFlag::OPTION_L</autogen>
</item>
<item>
@fanweixiao
fanweixiao / cayley_antigfw
Last active August 29, 2015 14:05
Anti-GFW when using `cayley http`
if [ `builtin type -p gsed` ]; then
gsed -i 's/fonts.googleapis.com/fonts.useso.com/g' templates/head.tmpl
gsed -i 's/ajax.googleapis.com/ajax.useso.com/g' templates/head.tmpl
gsed -i 's/fonts.googleapis.com/fonts.useso.com/g' static/third_party/flatly/bootstrap.min.css
else
sed -i 's/fonts.googleapis.com/fonts.useso.com/g' templates/head.tmpl
sed -i 's/ajax.googleapis.com/ajax.useso.com/g' templates/head.tmpl
sed -i 's/fonts.googleapis.com/fonts.useso.com/g' static/third_party/flatly/bootstrap.min.css
fi
@fanweixiao
fanweixiao / gulpfile.js
Last active October 30, 2015 03:50 — forked from elrrrrrrr/gulpfile.js
var gulp = require('gulp');
var gulpif = require('gulp-if');
var sprite = require('css-sprite').stream;
var base = require('gulp-base64');
// generate sprite.png and _sprite.scss
gulp.task('sprites', function () {
return gulp.src('img/*.png')
.pipe(sprite({
name: 'tx.png',