This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
var problemSchema = new mongoose.Schema({ | |
event: String, | |
problemName: String, | |
roundName: String, | |
roundId: Number, | |
roomId: Number, | |
componentId: Number | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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":"", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csv' | |
require 'httparty' | |
CSV.foreach('/Users/jeff/Desktop/names.csv', :headers => false) do |row| | |
response = HTTParty.get("http://api.topcoder.com/v2/users/#{row.first}") | |
puts "#{response['handle']},#{response['country']}" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page standardController="Contact" tabStyle="Contact" extensions="UploadAttachmentController"> | |
<apex:sectionHeader title="{!Contact.Name}" subtitle="Attach File"/> | |
<apex:form id="form_Upload"> | |
<apex:pageBlock > | |
<apex:pageBlockButtons > | |
<apex:commandButton action="{!back}" value="Back to {!Contact.Name}"/> | |
<apex:commandButton action="{!back}" value="Cancel"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var allPromise = Q.all([ getTemplates(), getGroups() ]) | |
allPromise | |
.then(function (data) { | |
console.log(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 |