This file contains hidden or 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
/** | |
* Generates an href to a resource depending on the environment. In development, | |
* this will be fully qualified based on the host. Otherwise it will be relative | |
* without any host information. | |
* | |
* @param {Object} app The express app object | |
* @param {Object} req The express request object | |
* @param {String} path The relative path to the resource, for example "/members/123" | |
* @return {String} An href to this resource | |
*/ |
This file contains hidden or 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
/** | |
* Generates a number between low and high | |
* | |
* @param {Number} low The lower bound for the number generator | |
* @param {Number} high The upper bound for the number generator | |
* @return {Number} A number between low and high | |
*/ | |
function generateNum(low, high) { | |
return Math.floor(Math.random() * ((+high) - (+low) + 1)) + (+low); | |
} |
This file contains hidden or 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
/* global module:true */ | |
module.exports = function(grunt) { | |
"use strict"; | |
grunt.initConfig({ | |
watch: { | |
files: "done.testing", | |
tasks: ["shell"], | |
options: { | |
event: ["added"] |
This file contains hidden or 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
# The first node application | |
upstream app-one { | |
server 127.0.0.1:3000 max_fails=0; | |
} | |
# The second node application | |
upstream app-two { | |
server 127.0.0.1:3001 max_fails=0; | |
} |
This file contains hidden or 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
/*global define:true, sessionStorage:true*/ | |
define([ | |
"underscore" | |
], function(_) { | |
"use-strict"; | |
var appState, sessionStorageNamespace; | |
sessionStorageNamespace = "app.appState"; |
This file contains hidden or 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
/* global define:true */ | |
define([ | |
"backbone" | |
], function(Backbone) { | |
"use strict"; | |
// Extend Backbone's Model to override the sync function. Doing so allows us | |
// to get a hook into how the errors are handled. Here we can check if the | |
// response code is unauthorized, and if so, navigate to the login page | |
return Backbone.Model.extend({ |
This file contains hidden or 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("express-namespace"); | |
var express = require("express"), | |
fs = require("fs"), | |
cons = require("consolidate"), | |
app = express(), | |
passport = require("passport"), | |
mongoose = require("mongoose"); | |
// 30 days for session cookie lifetime | |
var SESSION_COOKIE_LIFETIME = 1000 * 60 * 60 * 24 * 30; |
This file contains hidden or 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 express = require("express"), | |
fs = require("fs"), | |
cons = require("consolidate"), | |
app = express(); | |
// configure the app (all environments) | |
app.configure(function() { | |
// read the port from the environment, else set to 3000 | |
app.set("port", process.env.PORT || 3000); |
This file contains hidden or 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 request = require("request"), | |
csv = require("csv"); | |
module.exports = function(app) { | |
// accepts the POST form submit of the CSV file | |
app.post("/upload/data", function(req, res) { | |
// the name under "files" must correspond to the name of the | |
// file input field in the submitted form (here: "csvdata") | |
csv().from.path(req.files.csvdata.path, { | |
delimiter: ",", |
This file contains hidden or 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
To list the Java versions installed on your machine (note the big V): | |
/usr/libexec/java_home -V | |
To change the version of Java (note the small v): | |
export JAVA_HOME=`/usr/libexec/java_home -v 1.7` | |
export JAVA_HOME=`/usr/libexec/java_home -v 1.6` | |
The default JAVA_HOME is: | |
export JAVA_HOME=/Library/Java/Home |