Skip to content

Instantly share code, notes, and snippets.

Currently being awesome

Jeff Douglas jeffdonthemic

Currently being awesome
View GitHub Profile
jeffdonthemic / promises-parallel.js
Last active Aug 29, 2015
Node Promises in parallel with mongo
View promises-parallel.js
var allPromise = Q.all([ getTemplates(), getGroups() ])
.then(function (data) {
function getTemplates () {
var deferred = Q.defer()
Template.find({}, function (err, data) {
if (err) deferred.reject(err) // rejects the promise with `er` as the reason
jeffdonthemic / app.js
Created Apr 13, 2014
Setting nforce org in express session
View app.js
var nforce = require('nforce');
* Salesforce configuration.
var org = nforce.createConnection({
clientId: process.env.SFDC_CLIENT_ID,
clientSecret: process.env.SFDC_CLIENT_SECRET,
redirectUri: 'http://localhost:3000/oauth/_callback',
jeffdonthemic / getuser.rb
Created Jun 12, 2014
Reads handles from a CSV and calls topcoder API for more user details
View getuser.rb
require 'csv'
require 'httparty'
CSV.foreach('/Users/jeff/Desktop/names.csv', :headers => false) do |row|
response = HTTParty.get("{row.first}")
puts "#{response['handle']},#{response['country']}"
jeffdonthemic / mongo-examples.js
Last active Aug 29, 2015
Mongo Query Examples
View mongo-examples.js
// find one record with the hightest value
User.find({}).sort({goldenTicket: 'descending'}).limit(1).exec(function(err, items) {
if (!items[0].goldenTicket) {
} else {
deferred.resolve(items[0].goldenTicket + 1);
// choose a random problem and return it
jeffdonthemic / connect-to-mongo.js
Created Jul 4, 2014
Mongo scripts used for Chowfinder app
View connect-to-mongo.js
var env = JSON.parse(process.env.VCAP_SERVICES);
var mongo = env['mongodb-1.8'][0]['credentials'];
var mongo = {
View mongo-snippets
## Tutorials
[Node.js Development with the MongoDB Service](
[MongoDB in 5 minutes](
[Best Doc on Commands](
## Mongo CLI
to start local mongodb from the terminal:
> mongod
jeffdonthemic / Problem.js
Created Jul 10, 2014
Mongoose embedded documents
View Problem.js
var mongoose = require('mongoose');
var problemSchema = new mongoose.Schema({
event: String,
problemName: String,
roundName: String,
roundId: Number,
roomId: Number,
componentId: Number
View ajax.js
// <![CDATA[
$(document).ready(function(e) {
// get the leaderboard
type: 'GET',
url: "",
success: function(data) {
console.log('CISCO LEADERBOARD!!');
View q-all.js
salesforce.getContactByMobile(, '(941) 111-1111'),
]).then(function(results) {

Great cheatsheet!! and this is a good article as well.

Start virtualbox and the vm
boot2docker start

Pull down the google go image docker pull google/golang

Find the ip attached to the container
boot2docker ip