Skip to content

Instantly share code, notes, and snippets.

@marclar
marclar / config.js
Last active December 18, 2015 11:38
A useful function for handling node-style callbacks.
//Add "ifok" function
global.ifok = function(args, msg, cb){
var me = this;
args = Array.prototype.slice.call(args);
var err = args.shift();
var log = (me.log || console.log);
//You can comment out a log message by adding a space at the beginning
if(msg.length && msg.charAt(0) === ' '){
msg = null;
@marclar
marclar / app.js
Created May 29, 2013 16:59
mongoose ObjectId != mongo ObjectId ??
var mongodb = require('mongodb');
var mongoose = require('mongoose');
var id = '51a11f2d4da20b020000000a';
var mongooseId = new mongoose.Types.ObjectId(id);
var mongoId = new mongodb.ObjectID(id);
var logs = [];
if(mongoId == mongooseId){
logs.push('mongoId == mongooseId');
}
else{