Skip to content

Instantly share code, notes, and snippets.

View clvrobj's full-sized avatar

Chi Zhang clvrobj

  • Singapore, Singapore
View GitHub Profile
@clvrobj
clvrobj / tmux-cheatsheet.markdown
Created May 20, 2016 08:24 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#!/bin/sh -xe
# Sets up m2crypto on ubuntu architecture in virtualenv
# openssl 1.0 does not have sslv2, which is not disabled in m2crypto
# therefore this workaround is required
PATCH="
--- SWIG/_ssl.i 2011-01-15 20:10:06.000000000 +0100
+++ SWIG/_ssl.i 2012-06-17 17:39:05.292769292 +0200
@@ -48,8 +48,10 @@
@clvrobj
clvrobj / readme.md
Created January 7, 2013 08:18 — forked from liluo/readme.md

init

mkdir proj
cd proj
git init

config

git config user.name 'username'
@clvrobj
clvrobj / gist:4167644
Created November 29, 2012 08:46 — forked from rails/gist:58761
var DateHelper = {
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time
// Ruby strftime: %b %d, %Y %H:%M:%S GMT
time_ago_in_words_with_parsing: function(from) {
var date = new Date;
date.setTime(Date.parse(from));
return this.time_ago_in_words(date);
},
time_ago_in_words: function(from) {
#ab -r -n 10000 http://127.0.0.1:8880/hello/world
#You have to run Sentry at 127.0.0.1:8000 and replace the following DSN.
from bottle import route, run
@route('/hello/:name')
def index(name='World'):
from raven import Client
client = Client('http://5a77e2293b2e441188dcd03180e47e6d:4294d8e71d044c87b49a6d3f4abf113d@127.0.0.1:8000/2')
client.captureMessage('hello world!')
@clvrobj
clvrobj / gist:2290640
Created April 3, 2012 09:26 — forked from disinfeqt/gist:2286703
YYETS Copy
(function(){
var output = '';
for(var i = 0,array = document.querySelectorAll('.hover.filebox')[0].querySelectorAll('li'); i<array.length-1; i++){
if(array[i].querySelector('input').checked && array[i].querySelector('a').href.length > 0 && array[i].querySelector('a').href.match('-----') === null){
output += array[i].querySelector('a').href + '\n';
}
}
copy(output);
})();
@clvrobj
clvrobj / douban oauth, post miniblog.
Created March 8, 2012 01:45
post miniblog, douban oauth with ruby sinatra
require 'sinatra'
require 'oauth'
API_KEY = ''
API_SECRET = ''
token = ''
secret = ''
post '/miniblog' do
content = params[:content]
r1 = {'a': {'q': 1, 'w': 2}, 'b': {'q': 3, 'w': 4}}
r2 = {'a': {'q': 5, 'w': 7}, 'b': {'q': 8, 'w': 2}}
# ret = {'a': {'q': 6, 'w': 9}, 'b': {'q': 11, 'w': 6}}
def iter_dict(x, y):
if not isinstance(x, dict):
return map(lambda x: sum(x), zip(x, y))
if isinstance(x.values()[0], dict):
return dict(zip(x.keys(), map(lambda x:iter_dict(x[0], x[1]), zip(x.values(), y.values()))))
return dict(zip(x.keys(), iter_dict(x.values(), y.values())))