This file contains hidden or 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 spawn = require('child_process').spawn; | |
var Stream = require('stream'); | |
/** | |
* crops and resizes images to our desired size | |
* @param {Stream} streamIn in stream containing the raw image | |
* @return {Stream} | |
*/ | |
exports.cropImage = function(streamIn){ |
This file contains hidden or 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
#! /usr/bin/env bash | |
# build MooTools | |
packager build Core/Class \ | |
Core/Class.Extras \ | |
Core/Element \ | |
Core/Element.Event \ | |
Core/DOMReady \ | |
-blocks 1.2compat 1.3compat '!ES5' '!ES5-bind' \ |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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')); |