Skip to content

Instantly share code, notes, and snippets.

@scribblet
scribblet / taskRunner.js
Created December 27, 2013 10:08
Example task runner
//makeThumbnail.js
module.exports = {
start : function(input, db){
// makeThumbnail
// save timestamp
db.save({...});
}
};
@scribblet
scribblet / closureDi.js
Created December 27, 2013 10:01
Closure form of DI
//makeThumbnail.js
module.exports = function(db) {
db = db || require('./database.js');
return {
start : function(input){
// makeThumbnail
// save timestamp
db.save({...});
}
var Engine = require('engine');
var Car = function(name) {
this.name = name;
this.engine = new Engine(5);
}
Car.prototype.toString = function() {
return 'Car called ' + this.name + ' with engine power ' + this.engine.power + '.';
};
function myThing(){
// data hiding
var collection = [];
var api = {};
api.methodOne = function(params){
collection.push(params.argument);
//...
};
api.methodTwo = function(params){
var something = api.methodOne(stuff);
function myThing(){
if(!(this instanceOf myThing)){
return new myThing();
}
var private = 'blah';
var api = this;
api.methodOne = function(params){
if(private){
//...
}

Awesome PHP

A list of amazingly awesome PHP libraries, resources and shiny things.

Composer

@scribblet
scribblet / .inputrc
Created April 18, 2013 04:23
Bash history hack
"\e[A": history-search-backward
"\e[B": history-search-forward
set show-all-if-ambiguous on
set completion-ignore-case on