Skip to content

Instantly share code, notes, and snippets.

View dewd's full-sized avatar

Donald Dew dewd

  • Cloudarial
  • Toronto
View GitHub Profile
@dewd
dewd / bad
Created December 7, 2012 15:07
excerpts from a working, but ugly, common logger
module: ./lib/logger
---------------------------
// load config file (would like this to be passed in to the constructor)
nconf.file({ file: fileConfig});
var logSetting = nconf.get('log');
// instantiate the logger
var log = new Bunyan({
name: logSetting.name,
@dewd
dewd / gist:3837794
Created October 5, 2012 02:50
example of synchronizing through a recursion & async call in node-sync
// remote API call
function asyncFunction2(x,callback ) {
var request = require('request');
var url = 'http://www.google.com';
request(url, function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log('completing transformation of '+x+'^2 = '+x*x);
callback(null, x);
}