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
| // Express with Underscore templating | |
| app.register('.html', { | |
| compile : function(str, options) { | |
| return function(locals) { | |
| return _.template(str, locals); | |
| }; | |
| } | |
| }); |
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
| /* | |
| Counter used for async calls | |
| Example: | |
| var files = ['a', 'b']; | |
| finished = after(files.length); | |
| finished() // false | |
| finished() // true | |
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
| /* | |
| Step - tiny, but flexible step library | |
| Usage: | |
| var first = function(next) { | |
| ... | |
| return next(null, name, date); | |
| } | |
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 node | |
| var nom = require('nom'), | |
| join = require('path').join, | |
| args = process.argv.slice(2); | |
| if(!args[0]) { | |
| console.log('Usage: read <url>'); | |
| process.exit(0); | |
| } |
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
| app.engine('mu', function(path, options, fn) { | |
| var views = app.get('views'), | |
| view = path; | |
| if(options.layout) { | |
| view = join(views, '..', options.layout); | |
| options.body = fs.readFileSync(path, 'utf8'); | |
| } | |
| cons.hogan(view, options, function(err, str) { |
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
| app.engine('mu', function(path, options, fn) { | |
| var views = app.get('views'), | |
| view = path; | |
| if(options.layout) { | |
| // Assumes layouts and views are at same level | |
| view = join(views, '..', options.layout); | |
| options.body = fs.readFileSync(path, 'utf8'); | |
| } |
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 express = require('express'), | |
| cons = require('consolidate'), | |
| port = process.argv[2] || 8080, | |
| app = express(); | |
| app.engine('html', cons.hogan); | |
| app.set('view engine', 'html'); | |
| app.set('views', __dirname); | |
| app.configure(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
| /** | |
| * toggle between n functions | |
| * | |
| * Example: | |
| * | |
| * var a = function(p) { console.log("a:", p); }; | |
| * var b = function(p) { console.log("b:", p); }; | |
| * | |
| * var func = toggle(a, b); | |
| * func('hi') // => "a: hi" |
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
| /** | |
| * Written by Jonathan Bolster | |
| * Blog Post: http://bolsterweb.com/2011/10/how-clean-is-your-window-object/ | |
| */ | |
| (function(window){ | |
| var keys = {}, | |
| cleanWindow, | |
| iframe = document.createElement("iframe"); | |
| iframe.style.display ="none"; |
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
| function __bind(fn, context) { | |
| return function() { | |
| return fn.apply(context, arguments); | |
| }; | |
| } |
OlderNewer