Skip to content

Instantly share code, notes, and snippets.

View wuqian's full-sized avatar

wuqian

  • 快手
  • beijing, china
View GitHub Profile
@wuqian
wuqian / asyncTest.js
Created September 5, 2012 16:45
js批量异步调用,并发数量控制
var RES_MAX = 10;
var count = 0;
function foo () {
if (count > RES_MAX) {
//出让cpu,等待并发任务完成
return process.nextTick(foo);
}
//do the real work here
count ++;
@wuqian
wuqian / iconv.js
Created September 7, 2012 17:41
Nodejs抓取非utf8字符编码的页面
var http = require('http');
var options = {
host: 'www.baidu.com',
port: 80,
path: '/s?wd=gfw'
};
var Iconv = require('iconv').Iconv;
@wuqian
wuqian / async_test.js
Created September 11, 2012 07:58
node async模块 waterfall+queue使用
var async = require('async');
var http = require('http');
function getPage(callback) {
http.get('http://www.baidu.com', function(res) {
var buffers = [];
var size = 0;
res.on('data', function(buffer) {
buffers.push(buffer);
size += buffer.length;
@wuqian
wuqian / gist:3735136
Created September 17, 2012 01:44
dbshell mongo reference
http://www.mongodb.org/display/DOCS/dbshell+%28mongo%29+Reference
@wuqian
wuqian / 卸载 Xcode 3.2版本
Created September 21, 2012 06:18
卸载 Xcode 3.2版本
sudo /Developer/Library/uninstall-devtools --mode=all
@wuqian
wuqian / gist:3937510
Created October 23, 2012 07:48
object-c selector
//定义
SEL class_func;
//赋值
@interface foo
-(int)add:int val;
@end
class_func = @selector(add:int);
//执行
hdiutil convert -format UDRW -o <output-file> <input-iso-file>
diskutil list /dev/disk
diskutil unmountDisk /dev/diskN
dd if=<dmg-file> of=/dev/rdisk1
@wuqian
wuqian / gist:6796851
Last active December 24, 2015 12:19
ubuntu 12.04 安装过程
1. 系统安装
2. 网络链接
3. 显卡驱动安装
4. git安装
5. vim安装
6. 中文/输入法安装
@wuqian
wuqian / reverse.clj
Last active January 1, 2016 19:59
clojure reverse
(reduce conj '() [1 2 3 4])
@wuqian
wuqian / clamp.java
Created March 31, 2014 06:13
clamp
private final static int clamp(int x, int low, int high) {
return (x < low) ? low : ((x > high) ? high : x);
}