Skip to content

Instantly share code, notes, and snippets.

@indexzero
Forked from jfhbrook/app.js
Created February 25, 2012 06:29
Show Gist options
  • Save indexzero/1906920 to your computer and use it in GitHub Desktop.
Save indexzero/1906920 to your computer and use it in GitHub Desktop.
THE FRAMEWORK YOUR FRAMEWORK COULD CODE LIKE
var flatiron = require('flatiron'),
app = flatiron.app;
console.log('What\'s that in your hand? Look down,');
app.use(require('./tickets'));
console.log('look up. I HAVE IT. It\'s ' + app.qty + ' TICKETS to ' + app.description + '!');
console.log('Look again.');
app.use(require('./diamonds'));
console.log('THE TICKETS ARE NOW DIAMONDS');
app.sparkle();
setTimeout(function () {
app.stopSparkling();
console.log('Anything is possible when you use flatiron and stop using express.');
console.log('I\'m on a horse.');
}, 6000);
exports.attach = function () {
var sparkling = false;
this.sparkle = function sparkle () {
sparkling = true;
setTimeout(function () {
console.log('* bling *');
if (sparkling) {
sparkle();
}
}, 2000 * Math.random());
};
this.stopSparkling = function () {
sparkling = false;
};
}
22:18 josh@onix /tmp/old-spice
% node app.js
What's that in your hand? Look down,
look up. I HAVE IT. It's 2 TICKETS to that thing you love!
Look again.
THE TICKETS ARE NOW DIAMONDS
* bling *
* bling *
* bling *
* bling *
* bling *
* bling *
Anything is possible when you use flatiron and stop using express.
I'm on a horse.
* bling *
22:21 josh@onix /tmp/old-spice
%
exports.attach = function (opts) {
opts = opts || {};
var that = this;
this.qty = opts.qty || 2;
this.description = opts.description || 'that thing you love';
this.redeem = function () {
console.log('You go to see ' + that.description + ' and it\'s SPECTACULAR.');
that.qty--;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment