Skip to content

Instantly share code, notes, and snippets.

View wankdanker's full-sized avatar

Dan VerWeire wankdanker

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / odbc-bench.c
Created April 16, 2012 20:57
benchmark minimal query using raw odbc
/*
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
@wankdanker
wankdanker / binding.gyp
Created October 4, 2012 18:13
uv_queue_work question
{
'targets' : [
{
'target_name' : 'modulename',
'sources' : [
'modulename.cpp'
]
}
]
}
@wankdanker
wankdanker / readstuff.js
Created November 16, 2012 23:56
for xp_prg
var prompt = require('prompt');
var result2 = [];
//not sure what this does so don't know when it should be called.
prompt.start();
function getData() {
prompt.get(['username', 'email'], function (err, result) {
if (err) { return onErr(err); }
console.log('Command-line input received:');

/etc/ld.so.conf.d/psql.conf

#pervasive sql libraries
/usr/local/psql/lib/

Then issue sudo ldconfig

make: Entering directory `/home/dverweire/projects/node/node-odbc/build'
CXX(target) Release/obj.target/odbc_bindings/src/odbc.o
../src/odbc.cpp: In static member function ‘static void ODBC::Init(v8::Handle<v8::Object>)’:
../src/odbc.cpp:65:16: warning: unused variable ‘isolate’ [-Wunused-variable]
v8::Isolate* isolate = v8::Isolate::GetCurrent();
../node_modules/nan/nan_new.h: In instantiation of ‘typename NanIntern::Factory<T>::return_t NanNew(A0) [with T = v8::Integer; A0 = long int; typename NanIntern::Factory<T>::return_t = v8::Local<v8::Integer>]’:
../src/odbc.cpp:386:18: required from here
../node_modules/nan/nan_new.h:209:41: error: call of overloaded ‘New(long int&)’ is ambiguous
return NanIntern::Factory<T>::New(arg0);
^