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
exports.AutoLoader = function() {}; | |
AutoLoader.prototype.autoload = function(type, filePath, includeAsType) { | |
var obj = undefined; | |
if(includeAsType === undefined) includeAsType = true; | |
this.__defineGetter__(type, function(){ | |
if(!obj){ | |
obj = require(filePath); | |
if(includeAsType) obj = obj[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
tim@tim-laptop ~ $ ab -c 100 -n 1000 http://localhost:8000/fostle/static/images/fade_bg.gif | |
This is ApacheBench, Version 2.3 <$Revision: 655654 $> | |
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ | |
Licensed to The Apache Software Foundation, http://www.apache.org/ | |
Benchmarking localhost (be patient) | |
Completed 100 requests | |
Completed 200 requests | |
Completed 300 requests | |
Completed 400 requests |
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
exports.hotRequire = function(variable, path, prop = null) { | |
if ("string" === typeof prop) | |
module.parent.exports.scope[variable] = require(path)[prop]; | |
else | |
module.parent.exports.scope[variable] = require(path); | |
(function(variable, path, prop) { | |
process.watchFile(path, function() { | |
if ("string" === typeof prop) | |
module.parent.exports.scope[variable] = require(path)[prop]; |
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
// Automatic parse querystrings. If "^/home" is specified, | |
// it will also check for "^/home?somedata=test" | |
Get(["^/(home)(.*)", "^/(news)(.*)"], function(details, regexMatch) { | |
details.params["help"]; | |
... | |
} | |
Post(..., function(details, regexMatch) { | |
details.params["username"]; | |
... |
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 http = require('http'), | |
sys = require('sys'), | |
path = require('path'), | |
posix = require('posix'), | |
events = require('events'); | |
var Walker = function() { | |
this._counter = 0; | |
}; | |
Walker.prototype = { |
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 Walker = require('./walker').Walker; | |
var walker = new Walker(); | |
walker.walk('/home/test/', function(structure) { | |
// structure now contains dir tree | |
// The directory / filename | |
structure.name; |
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 sys, path, file, random; | |
require({ | |
"sys": sys, | |
"path": path, | |
"file": file, | |
"./module": random | |
}, function() { | |
//Call main function etc | |
main(); |
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
// exports defined out here. | |
exports.foo = "bar" | |
require( | |
"sys", "file", "persistence/sqlite3" | |
)(function (sys, file, sqlite) { | |
sys.p(File); | |
// Rest of program here | |
}); |
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 vars = {}; | |
exports.hot = function(path) { | |
vars = require(path); | |
process.watchFile(path + ".js", function() { | |
process.mixin(vars, require.unCache(path)); | |
}); | |
return vars; |
OlderNewer