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 addKeepAliveTimeout(agent) { | |
function fail(msg) { | |
console.warn(msg + ', node version: ' + process.version); | |
return agent; | |
} | |
// Check it's what we expect | |
var old_listeners = agent.listeners('free'); | |
if (!old_listeners || old_listeners.length !== 1) { | |
return fail('Unexpected lacking "free" listener'); | |
} |
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
/** | |
* Calculates the CRC32 checksum of a Buffer | |
* | |
* From libGlov under the MIT license, | |
* http://www.opensource.org/licenses/mit-license.php | |
**/ | |
/* Table of CRCs of all 8-bit messages. */ | |
var _crc_table = new Array(256); |
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 Net = require('net'); | |
var Assert = require('assert'); | |
var socket; | |
function randomInt(max) { | |
return Math.min(Math.floor(Math.random() * max), max - 1); | |
} | |
console.log('Initializing test data...'); |
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 nop() { } | |
// static functions, .bind them | |
function doop1(a, cb) { cb(); } | |
function doop2(a, b, cb) { cb(); } | |
function backupFile1(filename, cb) { | |
doop1(filename + '.bak', step2.bind(undefined, filename, cb)); | |
} | |
function step2(filename, cb, err) { | |
doop2(filename, filename + '.bak', cb); |
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 path = require('path'); | |
var getSetting; | |
if ("we can use exists") { | |
getSetting = function(fn, cb) { | |
(fs.exists || path.exists)(fn, function(exists) { | |
if (!exists) { | |
return cb(undefined, 'default value'); | |
} | |
fs.readFile(fn, 'utf8', cb); |
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 assert = require('assert'); | |
var http = require('http'); | |
var agent = new http.Agent({maxSockets: 1}); | |
var headers = {'connection': 'keep-alive'}; | |
var PORT = 8080; | |
var responses = 0; | |
var errors = 0; |
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 dns = require('dns'); | |
var http = require('http'); | |
var https = require('https'); | |
var blocked = ['207.171.163.193']; | |
var user_supplied_hostname = 'www.cloudpartytime.com'; | |
dns.lookup(user_supplied_hostname, function(err, address) { | |
console.log('DNS lookup returned ' + address); |
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'); | |
http.createServer(function (req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
var count=0; | |
function doit() { | |
while (res.writable && res.write('Data!\r\n\r\n')) { | |
++count; | |
if (count % 1000 === 0) { | |
console.log('wrote ' + count + ' chunks'); | |
return process.nextTick(doit); |
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 assert = require('assert'); | |
var zlib = require('zlib'); | |
var gzip = zlib.createGzip(); | |
var fs = require('fs'); | |
var FILENAME = 'log.txt.gz'; | |
var out = fs.createWriteStream(FILENAME); | |
gzip.pipe(out); | |
function debug(msg) { |
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 tick() { | |
//error('test'); | |
var z = getParam('ground_height'); | |
var pos = getPos(); | |
if (pos[2] < z) { | |
setGravity({ gravity: [0, 0, min(5, z - pos[2])] }); | |
} else { | |
setGravity({ gravity: [0, 0, -9.8] }); | |
} | |
} |
OlderNewer