This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var list = [{ | |
time:1000, | |
proc:function(){ | |
console.log("after 1 second"); | |
} | |
},{ | |
time:5000, | |
proc:function(){ | |
console.log("after 5 seconds"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#from https://github.com/genintho/Git-Pre-Commit | |
#!/bin/sh | |
GOOGLE_CLOSURE_PATH='/svn/staging/jsCompiler.jar' | |
echo "$(tput bold)SUMMARY$(tput sgr0)" | |
git diff --cached --name-status | |
echo '' | |
echo "$(tput bold)STAT$(tput sgr0)" | |
git diff --cached --stat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$url = "http://ditu.google.cn/staticmap?hl=zh-cn¢er=31.226659999958,121.48024000013&zoom=16&size=238x240&markers=31.226659999958,121.48024000013,red&client=free-dianping&signature=fN8tyLxLQ33hLYtFASuB2Wery7Q="; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HEADER, true); | |
$data = curl_exec($ch); | |
$contentLength = 'unknown'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Queue(tasks,alldone){ | |
var currentTask = tasks[0]; | |
Queue.result = Queue.result || []; | |
function done(result){ | |
Queue.result.push(result); | |
tasks.shift(); | |
Queue(tasks,alldone); | |
} | |
if(tasks.length){ | |
currentTask(done); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function cheatKeyMap(str,cb){ | |
var cheat_train = str.split(""); | |
var match_offset; | |
var keymap = { | |
38:"上", | |
40:"下", | |
37:"左", | |
39:"右" | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseQuery(){ | |
return location.search ? (function(query){ | |
var ret = {}; | |
query.split("&").forEach(function(kv){ | |
var pair = kv.split("="); | |
ret[pair[0]] = pair[1] | |
}); | |
return ret; | |
})(location.search.slice(1)) : {}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 非常偷懒的假设中文字符集为两个字符长度,别的都是一个 | |
function clipString(str,length){ | |
var strArr = str.split(""); | |
var result = []; | |
for(var i=0;chr=strArr[i];i++){ | |
if(/[\u0391-\uFFE5]/.test(chr)){ | |
length -= 2; | |
}else{ | |
length -= 1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(win,DP){ | |
// 适配mootools与neuron框架创建元素方法 | |
function create(tag){ | |
if(DP.DOM){ | |
return DP.DOM.create(tag).el(0) | |
}else{ | |
return new Element(tag); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function (req, res, next) { | |
var url,reqdata; | |
if(!req.xhr){next();} | |
url = urlmod.parse(req.url).pathname; | |
reqdata = { | |
get : req.query, | |
post : req.body, | |
header: req.headers | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function(resschema,body,type){ | |
var result,schema; | |
if(!resschema){ | |
return {ok:false,msg:"no response schema"}; | |
} | |
if(!body){ | |
return {ok:false,msg:"no body"}; | |
} |
OlderNewer