Skip to content

Instantly share code, notes, and snippets.

// JavaScript has prototypical inheritance
// so there is no real difference in extending
// something or creating a new instance
// (although the new keyword may have tricked you
// into thinking so)
var debug = true;
// A minimal polyfill for Object.assign
// A minimal polyfill for Object.assign
// (an ES6 feature)
Object.assign = Object.assign || function(){
for(var i = 1; i < arguments.length; i++){
for(var j in arguments[i]){
arguments[0][j] = arguments[i][j];
}
}
};
function getFileNames(path,callback){
// Read a folder recursively looking for js files
var fs = require('fs'), base = {__count:0, arr: []};
recursiveReadDir(path);
// Recursor
function recursiveReadDir(path){
base.__count++;
fs.readdir(path,function(err,x){
base.__count--;
// -------------------------------------------------------
// LESS-reg-js 1.0
// (c) Nodebite 2014, Thomas Frank
// MIT license, free to use everywhere.
//
// Register a JavaScript as a LESS function.
// (Yes! This is valid LESS!)
//
// -------------------------------------------------------
//
@ironboy
ironboy / gist:9032408
Last active August 29, 2015 13:56
aFrame - dropin replacement for setTimeout and setInterval using requestAnimationFrame
/*
aFrame -
a small library using requestAnimationFrame
for smoother setIntervals and setTimeouts...
© Thomas Frank, Nodebite 2014
Works as a dropin replacement for
setInterval, setTimeout, clearInterval and clearTimeout
@ironboy
ironboy / ajaxDummyResponse.js
Created September 14, 2012 11:54
Jquery ajax dummy responses, to remove need to wait for backend implementation...
(function($){
/*
ajaxDummyResponse.js
TF 2012
Let frontenders using jquery play around with dummy ajax responses
instead of waiting for backenders in an easy way...