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
module EventPublisher | |
attr_reader :events | |
attr_reader :subscribers | |
def register_events(events) | |
@subscribers = {} | |
@events = events | |
end | |
def publish_event(event) |
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
server.on("response", function(response) { | |
fs.readFile('untrusted.js', function(err,data){ | |
var loaded_module = vm.createScript(data, 'untrusted.js'); | |
loaded_module.runInNewContext({response: response}); | |
}) | |
}); | |
// untrusted.js | |
(function () { |
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
server.on("response", function(response) { | |
fs.readFile('untrusted.js', function(err,data){ | |
var loaded_module = vm.createScript(data, 'untrusted.js'); | |
loaded_module.runInNewContext({response: response}); | |
}) | |
}); | |
// untrusted.js | |
(function () { |
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'); | |
function MyServer(config_file) { | |
var server = Object.create(new events.EventEmitter); | |
server.config = {}; | |
server.StartServer = function() { | |
http.createServer((function (req, res) { | |
this.SendResponse(res); |
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 object(o) { | |
function F() {} | |
F.prototype = o; | |
return new F(); | |
} |
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'); | |
function MyServer(config_file) { | |
return { | |
config: {}, | |
StartServer: function() { | |
http.createServer((function (req, res) { | |
this.SendResponse(res); | |
}).bind(this)).listen(this.config.port, this.config.host, function() { |
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'); | |
function MyServer(config_file) { | |
this.config = {}; | |
this.StartServer = function() { | |
http.createServer((function (req, res) { | |
this.SendResponse(res); |
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'); | |
function MyServer(config_file) { | |
this.config = {}; | |
var obj = this; | |
this.StartServer = function() { | |
http.createServer(function (req, res) { |
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
/** | |
* @author onteria | |
* @description | |
* @name | |
*/ | |
var ll = require('./LinkedList'); | |
var assert = require('assert'); | |
exports.testEmptyHead = function() { |
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
/** | |
* @author onteria | |
* @description A library of functions to handle linked lists | |
* @name LinkedList | |
*/ | |
// Expose our objects to APIs that use require() | |
exports.LinkedList = LinkedList; | |
exports.ListNode = ListNode; |