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 slice = Function.prototype.call.bind(Array.prototype.slice); | |
var forEach = Function.prototype.call.bind(Array.prototype.forEach); | |
var Event = function(event){ | |
this.event = event || window.event; | |
this.locals = {}; | |
}; | |
Event.prototype.target = 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
./node_modules/.bin/jade --no-debug --client --out ./public/templates ./views/partials/* | |
sed -i 's/^function anonymous/require("jade\/runtime");module.exports = function/' ./public/templates/* |
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 jsdom = require('jsdom') | |
var fs = require('fs') | |
var nodes = fs.readFileSync("../nodes.js").toString(); | |
jsdom.env({ | |
features: { | |
QuerySelector: true | |
}, | |
src: [nodes], |
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 parentify = function(prime){ | |
var parent = prime.parent | |
if (!parent) throw new Error('Cannot parentify this prime') | |
var method = prime.prototype.parent = function(name){ | |
var fn = parent[name] | |
if (typeof fn != 'function') throw new Error('This method called with parent() does not exist') | |
delete this.parent | |
var ret = fn.apply(this, array.slice(arguments, 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 mocha = require('mocha'); | |
// setup | |
var suite = new mocha.Suite('', new mocha.Context), | |
utils = mocha.utils, | |
Reporter = mocha.reporters.Spec, | |
ui = mocha.interfaces['bdd']; | |
ui(suite); | |
suite.emit('pre-require', global); |
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
def(emi.prototype, "emit", function(event){ | |
var listeners = this._listeners, events, off = [] | |
this.off = function(_event, fn){ | |
if (_event == event) off.push(fn) | |
else emi.prototype.off.call(this, _event, fn) | |
return this | |
}; | |
if (listeners && (events = listeners[event])){ | |
var args = Array.prototype.slice.call(arguments, 1) | |
for (var i = 0, l = events.length; i < l; i++) events[i].apply(null, args) |
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 fs = require('fs'); | |
var packages = JSON.parse(fs.readFileSync('/home/arian/.npm/-/all/.cache.json')); | |
var total = 0, zeros = 0, alphas = 0; | |
for (var name in packages){ | |
var package = packages[name], |
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 slice = Array.prototype.slice; | |
return function(){ | |
var queue = []; | |
this.push = function(fn){ | |
if (typeof fn != 'function'){ | |
throw new Error('the passed argument is not a 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
describe('getStyle height / width / margin with CSS', function(){ | |
var style, element; | |
it('[beforeAll]', function(){ | |
var className = String.uniqueID(); | |
style = $(document.createElement('style')); | |
style.type = 'text/css'; | |
var definition = [ | |
'.' + className + '{', |
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 re = /([\d.]+)(s|ms)?/, units = {ms: 1, s: 1e3}; | |
var parseDuration = function(value){ | |
var match = value.toString().match(re); | |
return match ? parseFloat(match[1]) * (units[match[2]] || 1) : parseFloat(value) | |
}; | |
console.log(parseDuration(200)); | |
console.log(parseDuration('200')); | |
console.log(parseDuration('200ms')); | |
console.log(parseDuration('.2s')); |