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 buffer = new Buffer(150000), | |
buffer.fill("0"), | |
events = require('events'), | |
util = require('util'); | |
function BufferStream(buffer) { | |
events.EventEmitter.call(this); | |
this.readable = true; | |
this.writeable = false; |
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 contextify = require('contextify'); | |
ctx = contextify({console: console, setTimeout: setTimeout}); | |
ctx.run("setTimeout(function() { now = 1; }, 1000);"); | |
ctx.on("codeFinished", function() { //The context / vm tells me the code in it has finished computing | |
//ctx is now the state of the global object at the time the code has finished computing | |
}); |
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 vm = require('vm'), | |
ctx = vm.createContext({setTimeout: setTimeout, console: console}), | |
script = vm.createScript("now = 1; setTimeout(function() { now = 2; console.log('Inside the VM: ' + now); }, 1000);"); | |
script.runInContext(ctx); | |
setInterval(function () { | |
console.log("Outside the VM: " + ctx.now); | |
}, 500); |
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.js | |
var express = require('express'), | |
app = express(), | |
routes = require('./routes')(app); | |
//routes.js | |
module.exports = function (app) { | |
app.get("/", require("./models/index")); | |
app.get("/foo", require("./models/foo")); | |
app.get("/bar", require("./models/bar")); |
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 http = require('http'), | |
curReqs = 0, | |
responsetimes = [], | |
runTime = 120, | |
processed = 0, | |
child = require('child_process'), | |
path = require('path'), | |
start = 0, | |
server = http.createServer(function (req, res) { | |
"use strict"; |
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 http = require('http'), | |
curReqs = 0, | |
responsetimes = [], | |
runTime = 120, | |
processed = 0, | |
child = require('child_process'), | |
path = require('path'), | |
start = 0, | |
server = http.createServer(function (req, res) { | |
"use strict"; |
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.use(express.cookieParser()); | |
app.use(express.bodyParser()); | |
app.use(express.session({store: new RedisStore({host: "192.168.1.106", port: 6379}), secret: 'dsa645d6:Qojkflds'})); |
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'), | |
plotter = require('plotter'), | |
vm = require('vm'), | |
app = express(), | |
share = {}, | |
memoryHeapUsage = [], | |
memoryRSS = [], | |
curReqs = 0, | |
reqs = [], | |
responsetimes = [], |
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'), | |
vm = require('vm'), | |
app = express(), | |
vhosts = { | |
"www.house-of-code.org": vm.createContext({app: app, require: require}), | |
"test.house-of-code.org": vm.createContext({app: app, require: require}) | |
}; | |
var vhostWWW = vm.createScript("var express = require('express')," + | |
" vhostApp = express();" + |
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 fs = require('fs'); | |
function existTest() { | |
fs.exists("./test/", function (exists) { | |
setTimeout(function () { | |
if (exists) { | |
fs.writeFile("./test/test.txt", "aaljdks", function (err) { | |
if (err) { | |
//Maybe permissions or disk full | |
throw err; |