Skip to content

Instantly share code, notes, and snippets.

View iarobinson's full-sized avatar

Ian Robinson iarobinson

View GitHub Profile
@ar5had
ar5had / mongoose-connection-options.js
Created January 20, 2017 07:17
mLab recommended mongoose connection options. More supported connections for the underlying Node Native driver can be found here: http://mongodb.github.io/node-mongodb-native/
// mongoose 4.3.x
var mongoose = require('mongoose');
/*
* Mongoose by default sets the auto_reconnect option to true.
* We recommend setting socket options at both the server and replica set level.
* We recommend a 30 second connection timeout because it allows for
* plenty of time in most operating environments.
*/
var options = { server: { socketOptions: { keepAlive: 300000, connectTimeoutMS: 30000 } },
@madzak
madzak / closure_and_scoping.js
Last active May 2, 2022 08:57
Javascript Interview Questions
/* Closures and Scoping */
!function(window) {
var body = window.getElementsByTagName('body')[0];
console.log(body);
}(document);
/*
Q: What would you expect the value of body to be?