Skip to content

Instantly share code, notes, and snippets.

View wankdanker's full-sized avatar

Dan VerWeire wankdanker

View GitHub Profile
@wankdanker
wankdanker / gist:2400514
Created April 16, 2012 18:25
node-mysql-bindings-benchmarks + node-odbc
./bin/node-mysql-bindings-benchmark.js
Benchmarking CPP-MySQL:
**** Benchmark initialization time is 0.00s
**** 1000000 escapes in 0.17s (5882352/s)
**** 1000 sync reconnects in 0.09s (11111/s)
**** 10000 sync insertions in 0.16s (62500/s)
Benchmarking PHP-MySQL:
**** Benchmark initialization time is 0s
**** 1000000 escapes in 0.66s (1508394/s)
**** 1000 sync reconnects in 0.23s (4307/s)
@wankdanker
wankdanker / client.js
Created April 11, 2012 22:11
quick-test node udp latency: start server.js, then start the client.js
var udp = require('dgram');
var s = udp.createSocket('udp4');
s.bind(27016, '127.0.0.1');
var t;
s.on('message', function(data, remote) {
var req = data.toString();
if (req == 'go-ahead') {
@wankdanker
wankdanker / bench-callback.js
Created March 2, 2012 16:15
Benchmark javascript callback functions - anonymous vs named
//Benchmark calling a function passing it an anonymous function vs passing it a named function
//
var iterations = 100000;
function testAnon(fn) {
console.time('test-anonymous-function');
for (var x = 0; x < iterations; x++) {
fn(function () {});
}
@wankdanker
wankdanker / test-dgram-multicast-multi-process.js
Created January 27, 2012 22:57
test fix for dgram multicast test
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
@wankdanker
wankdanker / SimpleCluster.js
Created December 22, 2011 15:25
A simple cluster module that re-spawns child processes that have died. Also reloads child processes when `require()`d script files have changed.
/*jslint node: true, maxerr: 50, indent: 4 */
"use strict";
var clusterInstance;
var SimpleCluster = module.exports = function () {
//there should only be one instance of this per process
if (clusterInstance) {
return clusterInstance;
@wankdanker
wankdanker / dgram-multicast.md
Created November 21, 2011 22:25
Links regarding dgram multicast

This page has Windows tools that can send and receive test multicast messages. With this tool, I have been able to run multiple instances of mcreceive.exe on the same machine. The both instances receive all messages sent by mcsend.exe.

This page has code which can be compiled on Linux (and other Unix?). Multiple instances can be run and they will not argue about listening on the same UDP port.

@wankdanker
wankdanker / gist:1377895
Created November 18, 2011 21:58
node 0.6.2 windows xp
=== debug test-c-ares ===
Path: simple/test-c-ares
C:\node\test\simple\test-c-ares.js:46
if (error) throw error;
^
Error: getaddrinfo ENOENT
at errnoException (dns.js:31:11)
at Object.onanswer [as oncomplete] (dns.js:140:16)
Command: C:\node\Debug\node.exe C:\node\test\simple\test-c-ares.js
=== debug test-child-process-double-pipe ===
@wankdanker
wankdanker / SimpleHTTPServer.js
Created November 18, 2011 16:13
A simple static file server for node
var http = require('http'),
fs = require('fs'),
cwd = process.cwd();
http.createServer()
.on('request', function (request, response) {
var url = unescape(request.url);
var path = cwd + url;
console.log(request.socket.remoteAddress, path);
@wankdanker
wankdanker / Linux-2.6.32.md
Created November 7, 2011 15:43
udp multiple process bind test results
user@inspection09:/tmp$ uname -a
Linux inspection09 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 i686 GNU/Linux


user@inspection09:/tmp$ netstat -plun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 0.0.0.0:12345           0.0.0.0:*                           7853/udp-bind-twice
udp        0      0 0.0.0.0:12345           0.0.0.0:*                           7776/udp-bind-twice
@wankdanker
wankdanker / Linux-2.6.32-22-generic.md
Created November 4, 2011 17:37
nodejs tests for 0.6 release

####Linux inspection09 2.6.32-22-generic #36-Ubuntu SMP Thu Jun 3 22:02:19 UTC 2010 i686 GNU/Linux

[23:28|% 100|+ 623|-   9]: Done

Notes: Head @ 5213c390, bare metal


DEST_OS: linux