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, [], 2]这样的奇怪情况(嵌套的是空链)会跪,回头修回头修 | |
var ListNode = function(value, next){ | |
// 虽然是简单结构,但是为了Hidden Type优化做成个class | |
this.value = value; | |
this.next = next; | |
}; | |
var LinkedList = function(){ | |
this.head = this.tail = new ListNode(null, null); |
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
// app.js | |
for (var controller in routes){ | |
var mod = routes[controller]; | |
app.all('/' + controller + ':action', function(req, res){ | |
var action = req.params.action; | |
if (action in mod){ | |
mod[action](req, res); | |
}else{ | |
res.statusCode = 404; | |
res.send('404 not found'); |
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 format(fmt){ | |
var args = Array.prototype.slice.call(arguments, 1); | |
for (var i=0; i<args.length; ++i){ | |
var reg = new RegExp('([^\\\\]|^)(?:\\{' + i + '\\})', 'g'); | |
fmt = fmt.replace(reg, '$1' + args[i]); | |
} | |
return fmt; | |
} | |
console.log(format('Hello, {0}!', 'world', 'jim')); |
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 MidIterator = function(root) { | |
this.stack = [root]; | |
this.__pushLeft(root); | |
}; | |
MidIterator.prototype.__pushLeft = function(node) { | |
if (!node) return; | |
var left = node.left; | |
while (left) { | |
this.stack.push(left); | |
left = left.left; |
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
[id^="postads"], | |
[id^="bbs_ds"], | |
.adsc, | |
.adsh, | |
#gwd_browser_download | |
{ | |
display: none !important; | |
} |
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
// v2.0,避免一个for (in),速度大幅度提高,但graph的构造不如之前优雅,优化了hash,总代码量几乎没有增加,加了点注释。 | |
var ops = ['+7', '/2', '*3', '-5']; | |
var graph = [ | |
[{e:0,n:1}, {e:1,n:1}], | |
[{e:0,n:0}, {e:1,n:0}, {e:2,n:2}, {e:3,n:2}], | |
[{e:2,n:1}, {e:3,n:1}] | |
]; // 第一维是顶点,第二维是出边,e是边的id,n是指向的顶点。 | |
graph.forEach(function(vex, i){ | |
vex.forEach(function(edge, j){ | |
edge.f = new Function('val', 'return val' + ops[edge.e]); // 把边构造成一个function |
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
ex () { | |
if [ -f $1 ] ; then | |
case $1 in | |
*.tar.bz2) tar xjf $1 ;; | |
*.tar.gz) tar xzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) rar x $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xf $1 ;; | |
*.tbz2) tar xjf $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
var hrtime = (function(){ | |
if (typeof window !== 'undefined'){ | |
// browser | |
if (typeof window.performance !== 'undefined' && typeof performance.now !== 'undefined'){ | |
// support hrt | |
return function(){ | |
return performance.now(); | |
}; | |
}else{ | |
// oh no.. |
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 getCurrentScript = (function () { | |
var supportsScriptReadyState = ('readyState' in document.createElement('script')) | |
var isNotOpera = !window.opera || window.opera.toString() !== "[object Opera]" | |
function getCurrentScript() { | |
if (document.currentScript) { | |
// Chrome, OSX Safari, Firefox, Edge | |
return document.currentScript.src | |
} |
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
#pl_leftnav_app, | |
#trustPagelet_checkin_lotteryv5, | |
#trustPagelet_recom_interestv5, | |
.gn_title[node-type=app], | |
.gn_title[node-type=weiba], | |
.gn_title[node-type=game], | |
.gn_title[node-type=hot], | |
.gn_setting[node-type=member], | |
#pl_rightmod_ads35, | |
/*#trustPagelet_zt_hottopicv5,*/ /*右侧导航[热门话题]予以保留,不想看这个的可以把这行注释取消掉*/ |
OlderNewer