Skip to content

Instantly share code, notes, and snippets.

View jeffdonthemic's full-sized avatar
💭
Currently being awesome

Jeff Douglas jeffdonthemic

💭
Currently being awesome
View GitHub Profile
@jeffdonthemic
jeffdonthemic / mongo-examples.js
Last active August 29, 2015 14:03
Mongo Query Examples
// find one record with the hightest value
User.find({}).sort({goldenTicket: 'descending'}).limit(1).exec(function(err, items) {
if (!items[0].goldenTicket) {
deferred.resolve(1000);
} else {
deferred.resolve(items[0].goldenTicket + 1);
}
});
// choose a random problem and return it
@jeffdonthemic
jeffdonthemic / connect-to-mongo.js
Created July 4, 2014 12:37
Mongo scripts used for Chowfinder app
if(process.env.VCAP_SERVICES){
var env = JSON.parse(process.env.VCAP_SERVICES);
var mongo = env['mongodb-1.8'][0]['credentials'];
}
else{
var mongo = {
"hostname":"localhost",
"port":27017,
"username":"",
"password":"",
@jeffdonthemic
jeffdonthemic / mongo-snippets
Last active August 29, 2015 14:03
Mongodb Notes
## Tutorials
[Node.js Development with the MongoDB Service](http://start.cloudfoundry.com/services/mongodb/nodejs-mongodb.html)
[MongoDB in 5 minutes](http://mongodbtutorial.com/mongodb-in-5-minutes.html)
[Best Doc on Commands](http://www.mongodb.org/display/DOCS/Tutorial)
## Mongo CLI
to start local mongodb from the terminal:
> mongod
@jeffdonthemic
jeffdonthemic / app.js
Created July 7, 2014 09:18
Simple socket.io example
var http = require('http'),
fs = require('fs'),
// NEVER use a Sync function except at start-up!
index = fs.readFileSync(__dirname + '/index.html');
// Send index.html to all requests
var app = http.createServer(function(req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(index);
});
@jeffdonthemic
jeffdonthemic / Problem.js
Created July 10, 2014 12:23
Mongoose embedded documents
var mongoose = require('mongoose');
var problemSchema = new mongoose.Schema({
event: String,
problemName: String,
roundName: String,
roundId: Number,
roomId: Number,
componentId: Number
});
@jeffdonthemic
jeffdonthemic / ajax.js
Created July 18, 2014 15:21
jQuery ajax
<script>
// <![CDATA[
$(document).ready(function(e) {
// get the leaderboard
$.ajax({
type: 'GET',
url: "http://tc-leaderboard.herokuapp.com/cisco",
success: function(data) {
console.log('CISCO LEADERBOARD!!');
console.log(data);
@jeffdonthemic
jeffdonthemic / q-all.js
Created July 19, 2014 11:50
Q snippets
Q.all([
salesforce.getContactByMobile(res.locals.org, '(941) 111-1111'),
twilio.getMessage("MMd3dbafbbde409a109e4c71c7684cec77")
]).then(function(results) {
console.log(results[0]);
console.log(results[1]);
});
@jeffdonthemic
jeffdonthemic / .godir
Created July 24, 2014 16:01
Building Go Web Apps Tutorial
github.com/topcoderinc/cribs
@jeffdonthemic
jeffdonthemic / httparty.rb
Last active March 8, 2024 21:37
HTTParty Examples
options = { :body =>
{ :username => 'my',
:password => 'password'
}
}
results = HTTParty.post("http://api.topcoder.com/v2/auth", options)
##
## example for post with papertrail and basic auth
##
@jeffdonthemic
jeffdonthemic / commands.md
Created August 4, 2014 15:10
Docker snippet

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