Skip to content

Instantly share code, notes, and snippets.

mongolab-org

Block or report user

Report or block mongolab-org

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mongolab-org
mongolab-org / mongoose-connection-settings-example.js
Created Dec 10, 2017
mLab-recommended Mongoose driver options for production applications. Note: this example is for the Mongoose 4.3.x driver. For the most up-to-date information on driver settings, please visit the Node.js driver documentation: https://mongodb.github.io/node-mongodb-native/
View mongoose-connection-settings-example.js
// Recommended driver settings for the Mongoose 4.3.x driver.
var mongoose = require('mongoose');
var uri = 'mongodb://<dbuser>:<dbpassword>@<host1>:<port1>,<host2>:<port2>/<dbname>?replicaSet=<replicaSetName>';
var options = {
"server" : {
"socketOptions" : {
"keepAlive" : 300000,
@mongolab-org
mongolab-org / polygon-example.js
Last active Aug 29, 2015
MongoDB invalid/valid polygon example
View polygon-example.js
//Invalid - Each point/vertex of the polygon is provided.
{ "type": "Polygon",
"coordinates": [
[ [ 100.0 , 0.0 ] , [ 101.0 , 0.0 ] , [ 101.0 , 1.0 ] , [ 100.0 , 1.0 ] ]
]
}
//Valid - First vertex of the polygon is provided at both the beginning and end of a LinearRing.
{ "type": "Polygon",
"coordinates": [
@mongolab-org
mongolab-org / geojson-within.js
Last active Aug 29, 2015
Find Points within a specified Square using MongoDB GeoJSON support.
View geojson-within.js
db.places.find( { loc :
{ $geoWithin :
{ $geometry :
{ type : "Polygon",
coordinates : [ [ [ 0 , 0 ] , [ 0 , 1 ] , [ 1 , 1 ] , [ 1 , 0 ] , [ 0 , 0 ] ] ]
} } } } )
View geojson.js
// Point representation of Timmy's Taco Truck
{
name : "Timmy's Taco Truck",
loc : {
type : "Point",
coordinates : [ 37.7577 , -122.4376 ]
}
}
// Polygon representation (Square) of a Food Truck Park
@mongolab-org
mongolab-org / coordinate-pair-within.js
Created Aug 18, 2014
Find Points within a specified Square using MongoDB $polygon operator.
View coordinate-pair-within.js
db.places.find( { loc :
{ $geoWithin :
{ $polygon :
[ [ 0 , 0 ] , [ 0 , 1 ] , [ 1 , 1 ] , [ 1 , 0 ] ]
} } } )
@mongolab-org
mongolab-org / legacy-proximity.js
Last active Aug 29, 2015
MongoDB proximity query using legacy coordinate pairs
View legacy-proximity.js
db.places.find( { loc :
{ $near : [ 100 , 100 ],
$maxDistance: 10 }
} )
@mongolab-org
mongolab-org / coordinate-pair.js
Last active Aug 29, 2015
MongoDB legacy coordinate pairs
View coordinate-pair.js
{
name : "Timmy's Taco Truck",
loc : [ 37.7577 , -122.4376 ]
}
@mongolab-org
mongolab-org / watch-flip-flop.py
Last active Aug 5, 2016
check out http://mongolab.org/flip-flop/ for a more detailed explanation
View watch-flip-flop.py
#!/usr/bin/env python
# Written with pymongo-3.3
author__ = 'mongolab' \
import pymongo
import sys, datetime, time
import random
You can’t perform that action at this time.