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
,\s*\n+(\s*\/\/.*\n)*\s*[\}\)\]] |
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 forEach(array, fn, cb){ | |
var i = -1 | |
function next(err){ | |
if (err) return cb&&cb(err) | |
i += 1 | |
if (i<array.length){ | |
fn(array[i], next, i) | |
} else { | |
cb&&cb(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
function flow(target, items, cb){ | |
forEach(items, function(item, next){ | |
if (Array.isArray(item)){ | |
item[0].apply(this, [target].concat(item.slice(1), cb)) | |
} else { | |
item(target, next) | |
} | |
}, function(err){ | |
if (err) return cb&&cb(err) | |
cb(null, target) |
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 mergeClone(){ | |
var result = {} | |
for (var i=0;i<arguments.length;i++){ | |
var obj = arguments[i] | |
if (obj){ | |
Object.keys(obj).forEach(function(key){ | |
result[key] = obj[key] | |
}) | |
} | |
} |
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 padNumber(number, pad) { | |
var N = Math.pow(10, pad); | |
return number < N ? ("" + (N + number)).slice(1) : "" + number | |
} |
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 walkDom(rootNode, iterator){ | |
var currentNode = rootNode.firstChild | |
while (currentNode){ | |
iterator(currentNode) | |
if (currentNode.firstChild){ | |
currentNode = currentNode.firstChild | |
} else { | |
while (currentNode && !currentNode.nextSibling){ | |
if (currentNode !== rootNode) { | |
currentNode = currentNode.parentNode |
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 rgb(hex){ | |
if (hex.charAt(0) == '#'){ | |
var color = hex.slice(1) | |
var splitter = color.length/3 | |
var value = [] | |
for (var i=0;i<3;i++){ | |
var part = parseInt(color.slice(i*splitter, (i+1)*splitter), 16) | |
if (splitter == 1){ | |
value[i] = ((part+1)*16)-1 | |
} else { |
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
ssh -R *:1234:localhost:9966 [email protected] | |
# http://server.com:1234 |
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
module.exports = animate | |
var requestAnimationFrame = | |
global.requestAnimationFrame || | |
global.webkitRequestAnimationFrame || | |
global.mozRequestAnimationFrame || | |
global.msRequestAnimationFrame || | |
global.oRequestAnimationFrame || | |
function(fn, el) { | |
setTimeout(fn, 1000/60) |
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 mutators = [ | |
'fill', 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift' | |
] | |
function ObservableArray(onChange){ | |
var array = [] | |
array.set = set | |
array.onchange = onChange |
OlderNewer