$ npm install jshint -g
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 number_cn(num, def) { | |
def = def || 0; | |
var output = []; | |
var UNIT_STR = ['', '十', '百', '千', '万']; | |
var NUMBER_STR = '零一二三四五六七八九十'; | |
num = Math.max(parseInt(num, 10) || def, def).toString().split(''); | |
while (num.length) { | |
var val = parseInt(num.shift(), 10); |
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
echo "======" && git log --since=2016-01-01 --until=2016-06-30 --pretty=tformat: --numstat | awk '{ add += $1 ; subs += $2 } END { printf "added lines: %s\nremoved lines: %s\n",add,subs }' && git log --since=2016-01-01 --until=2016-06-30 --oneline|wc -l|awk '{print "commit counts: "$1}' && git ls-files | wc -l|awk '{print "file counts: "$1}' && find . -type f | perl -ne 'chomp;print "$_\n" if -T $_'|xargs wc -l 2>&1|tail -n1|awk '{print "line counts: "$1}' && echo "======" |
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
1:解决中文不同的问题 | |
function md5(str) { | |
str = (new Buffer(str)).toString("binary"); | |
var ret = crypto.createHash("md5").update(str).digest("hex"); | |
return ret; | |
} | |
2:正常字符串加密 |
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
$.ajax({ | |
type: 'HEAD', | |
success: function(data, state, xhr){ | |
console.log(new Date(xhr.getResponseHeader('Date'))); | |
} | |
}); |
#http cache
在调试问题时经常因为cache而导致一些问题被忽略,所以了解cache还是很有必要的
HTTP 1.0/1.1推出了Expires/Cache-Control两种策略,目前 HTTP1.0 已经很少见了,所有我们重点关注HTTP1.1的Cache-Control。
拿腾讯网为例,在浏览器输入 www.qq.com
,用fiddler抓包返回:
Cache-Control: max-age=60
Date: Mon, 20 Jan 2014 13:12:36 GMT
NewerOlder