Skip to content

Instantly share code, notes, and snippets.

@johannish
johannish / node-pool-oracle.js
Last active March 5, 2016 04:34
Example pool with node-oracle that calls pool.destroy() on connection errors.
var genericPool = require('generic-pool');
// This is the 'nearinfinity' driver: `npm install oracle`
var oracle = require('oracle');
conf = {
"hostName": "localhost",
"port": 1521,
"user": "oracle",
"password": "oracle",
"database": "xe",
}
/* A simple module to query an OID (Oracle Internet Directory) server in order to
* look up the full connection string for a given database name.
*/
var ldap = require('ldapjs');
module.exports.byAlias = function(dbAlias, callback) {
var client = ldap.createClient({
url: 'ldap://oid:123/',
timeout: "2000", // LDAP operations timeout (milliseconds)
@johannish
johannish / test-console-sync-2.js
Last active August 29, 2015 14:25
Node.js console.log synchronous
console.log('stdout._type:', process.stdout._type);
process.nextTick(function() {
process.exit(123);
});
process.on('exit', function(code) {
process.nextTick(function() {
console.log('This does not run, as the docs say.');
});
@johannish
johannish / client.tcl
Last active November 11, 2019 17:36
Simple socket example in Tcl
set chan [socket 127.0.0.1 9900]
while {1} {
puts -nonewline "Message? "
flush stdout
set msg [gets stdin]
puts $chan $msg
flush $chan
puts "server response: [gets $chan]"
}