Skip to content

Instantly share code, notes, and snippets.

@johannish
johannish / client.tcl
Last active Nov 11, 2019
Simple socket example in Tcl
View client.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]"
}
@johannish
johannish / node-pool-oracle.js
Last active Mar 5, 2016
Example pool with node-oracle that calls pool.destroy() on connection errors.
View node-pool-oracle.js
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",
}
@johannish
johannish / test-console-sync-2.js
Last active Aug 29, 2015
Node.js console.log synchronous
View test-console-sync-2.js
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.');
});
View oracle-ldap-search.js
/* 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)