This file contains 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
//main.js | |
var util = require('util'); | |
util.debug('main initializing'); | |
var someMod = require('./someModule').makeApp('SomeApp', 'Tom'); | |
someMod.displayAppName(); | |
someMod.displayUserName(); |
This file contains 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
//main.js | |
var util = require('util'); | |
util.debug('main initializing'); | |
var someMod = require('./someModule')('SomeApp', 'Tom'); | |
someMod.displayAppName(); | |
someMod.displayUserName(); |
This file contains 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
//main.js | |
var util = require('util'); | |
util.debug('main initializing'); | |
var someMod = require('./someModule')('SomeApp', 'Tom'); | |
someMod.displayAppName(); | |
someMod.displayUserName(); |
This file contains 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
Package.json: | |
{ | |
"name": "Blaggie-System", | |
"description": "Blog in pieces", | |
"version": "0.0.1", | |
"author": "Jake Verbaten", | |
"dependencies": { | |
"underscore": "1.1.6", | |
"express": "2.3.6", |
This file contains 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 someFunc = new (function() { | |
var me = this, | |
foobar = "twenty"; | |
me.something = "foo"; | |
somethingElse.on('someEvent', function() { | |
//this points to somewhere else now | |
me.something = 'hi'; | |
foobar = 42; | |
}); |
This file contains 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 fs = require('fs'); | |
var http = require('http'); | |
var events = require('events'); | |
var MyServer = new function() { | |
var server = Object.create(new events.EventEmitter); | |
server.on("response", function(response) { | |
response.writeHead(200, {'Content-Type': 'text/plain'}); | |
response.end('Hello World\n'); |
This file contains 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($, jQuery, window, document, undefined) { | |
var toString = Object.prototype.toString, | |
// uid for elements | |
uuid = 0; | |
// over-ride bind so it uses a namespace by default | |
// namespace is PLUGIN_NAME_<uid> | |
$.fn.bind = function(type, data, fn, nsKey) { | |
if (typeof type === "object") { | |
for (var key in type) { |
This file contains 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 after = function _after(count, f) { | |
var c = 0, results = []; | |
return function _callback() { | |
switch (arguments.length) { | |
case 0: results.push(null); break; | |
case 1: results.push(arguments[0]); break; | |
default: results.push(Array.prototype.slice.call(arguments)); break; | |
} | |
if (++c === count) { | |
f.apply(this, results); |
This file contains 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
# Flow-based example of serving web pages | |
noflo = require "noflo" | |
graph = noflo.graph.createGraph "blog" | |
graph.addNode "Web Server", "HTTP/Server" | |
graph.addNode "Profiler", "HTTP/Profiler" | |
graph.addNode "Authentication", "HTTP/BasicAuth" | |
graph.addNode "Read Template", "ReadFile" |
This file contains 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
r = require("request").defaults({ | |
"json": true, | |
"headers": { | |
"Authorization": "Basic " + new Buffer(process.env.COUCH_USER + ":" + process.env.COUCH_PWD).toString("base64") | |
} | |
}), | |
var base_url = "http://raynos.iriscouch.com/raynos" | |
// data is an Object |
OlderNewer