Skip to content

Instantly share code, notes, and snippets.

View Raynos's full-sized avatar

Jake Verbaten Raynos

View GitHub Profile
var Bar = { bar: ... }
var Foo = { foo: ... }
var Delegate = {
foo: function() {
Foo.foo.apply(this, arguments);
},
bar: function() {
Bar.bar.apply(this, arguments);
}
mediator.on("receive:thingsFromDB", function(things) {
// how I get res here?
res.send(things);
});
app.get("/things", function(req, res) {
mediator.emit("request:thingsFromDB");
});
module.exports = function _routerCallback(req, res) {
};
@Raynos
Raynos / dump
Created September 21, 2011 12:21
dexter_e> Is there a way to limit Static file match attempts to a certain directory like /static/ ?
[6:33 PM] ⇐ fatjonny ([email protected]) quit: Ping timeout: 252 seconds
[6:34 PM] <tjholowaychuk> dexter_e use('/static', express.static('static'))
[6:34 PM] <tjholowaychuk> that /static can be whatever you want though
[6:34 PM] <tjholowaychuk> /public etc
[6:34 PM] <dexter_e> and then all other static file load attempts will be ignored ?
[6:34 PM] <dexter_e> ( if they don't match any other routes )
[6:35 PM] <tjholowaychuk> yeah
[6:35 PM] <dexter_e> Sweet! Thanks!
[6:35 PM] <dexter_e> I had one more question about Caching.. Is the cashe reset upon restart ?
var tasker = Object.create(EventEmitter.prototype, pd({
"options": options,
"descruct": require("./descruct").bind(this, tasker),
"addTask": require('./tasks/addTask').bind(this, tasker),
"removeTask": require('./tasks/removeTask').bind(this, tasker),
"getTasksRunning": require('./tasks/getTasksRunning').bind(this, tasker),
"getTasksQueued": require('./tasks/getTasksQueued').bind(this, tasker)
});
var new = function _new(Constructor) {
var thisObj = Object.create(Constructor.prototype);
var args = Array.prototype.slice.call(arguments, 1);
var retObj = Constructor.apply(thisObj, args);
if (typeof retObj === "object") {
return retObj;
} else {
return thisObj
}
};
@Raynos
Raynos / foo.js
Created September 23, 2011 13:22
var Tasker = exports.Tasker = function _Tasker(options) {
this.options = options;
this.state = {};
};
Tasker.prototype = new EventEmitter2();
Tasker.prototype.destruct = destructTasker;
Tasker.prototype.addTask = tasks.addTask;
Tasker.prototype.removeTask = tasks.removeTask;
var Constructor = function _constructor(prop, arg) {
this.property = prop;
this.public = arg + "dynamic";
}
Constructor.prototype.method = function () {
...
}
var obj = new Constructor(42, "value of public");
var pd = function _pd(props) {
var obj = {};
Object.keys(props).forEach(function (key) {
obj[key] = Object.getOwnPropertyDescriptor(props, key);
});
return obj;
};
pd.merge = function _merge() {
var o = {}
var add = function(a,b) {
if (this) dance();
else return a + b;
}
var addOne = add.bind(null, 1);
addOne.call("can I dance please :(");