Skip to content

Instantly share code, notes, and snippets.

View luckydrq's full-sized avatar

Deng Ruoqi luckydrq

View GitHub Profile
@luckydrq
luckydrq / connect.js
Last active December 21, 2015 05:09
Connect源码解析
var EventEmitter = require('events').EventEmitter
, proto = require('./proto')
, utils = require('./utils')
, path = require('path')
, basename = path.basename
, fs = require('fs');
//应用补丁,封装了一些方法
require('./patch');
@luckydrq
luckydrq / mo_publish.js
Created August 25, 2013 14:07
mo publish操作的并发任务优化
var Q = require('q')
var _ = require('underscore')
var exec = require('child_process').exec
var path = require('path')
var fs = require('fs')
//模拟Express App: `get`、`set`
var app = {
_data:{},
get: function(key){
@luckydrq
luckydrq / struts2_action.js
Last active August 29, 2015 13:56
post for `structs2 action`
/* Structs2的对象序列化
*
* Example:
* {a:'a', b:[{c:'c'}, {d:'d'}]}
*
* => {'a':'a', 'b[0].c': 'c', 'b[1].d': 'd'}
*
*/
function flattern(o) {
var result = {};
/**
* 把key不带引号的JSON字符串转换为JSON对象
*
* Example:
* '{a:1,b:"b",c:{arr:[{name:"n1",title:"t1"},{name:"n2",title:"t2"}]}}'
*/
function parse(s) {
s = addQuota(s);
function addQuota(s) {
@luckydrq
luckydrq / gist:1ead0f2635cb0568ec51
Created June 7, 2014 06:48
OSX下安装node-canvas的注意事项
# 如果cairo是通过homebrew安装的,那么在~/.bashrc或者~/.zshrc里加入以下配置
# https://github.com/LearnBoost/node-canvas/wiki/Installation---OSX#installing-cairo
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/X11/lib/pkgconfig
@luckydrq
luckydrq / update-git-server-hosts
Last active August 29, 2015 14:03
update git server know-hosts when host ip change
ssh-keygen -f ~/.ssh/known_hosts -R gitlab.xxx.com
@luckydrq
luckydrq / gist:60a17bc4ffe8d35728ef
Last active August 29, 2015 14:07
node-mysql-pool-benchmark
var benchmarks = require('beautify-benchmark');
var Benchmark = require('benchmark');
var mysql = require('mysql');
var pool = mysql.createPool({
host: 'x.x.x.x',
port: 8888,
user: 'test',
database: 'test_db',
password: '123456',
@luckydrq
luckydrq / .vimrc
Last active August 29, 2015 14:09
vimrc
"folding settings
set foldmethod=indent "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
set foldlevel=1 "this is just what i use
"NERDTree show hidden files
let NERDTreeShowHidden=1
"convert tab to spaces"