Skip to content

Instantly share code, notes, and snippets.

View totallymike's full-sized avatar

Michael Westbom totallymike

View GitHub Profile
@totallymike
totallymike / gist:2716049
Created May 17, 2012 03:36
Fun With Errors
db.query(statement, function (err, res) {
if (err) {
throw new Error(err);
} else {
// Do normal stuff.
}
});
db.query(statement, function (err, res) {
if (err) {
@totallymike
totallymike / gist:2701630
Created May 15, 2012 13:10
setInterval closure trick that's not sustainable
var assert = require('assert')
, cradle = require('cradle')
, conn = new(cradle.Connection)('https://myCouch.couch',443,{
auth: {username: "mike", password: "pass"}})
, db = conn.database('articles');
function saveDoc(doc) {
db.save(doc.data, printResult);
}