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 express = require("express"); | |
var routes = require("./lib/routes"); | |
// You're existing code to instantiate the app. | |
var app = express(); | |
// ... and configure it... | |
// Set your routes. |
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 fs = require("fs"), | |
path = require("path"); | |
var common = require("./lib/common"); | |
module.exports = function(grunt) { | |
var Ss = grunt.config("Ss"), | |
_ = grunt.util._, | |
async = grunt.util.async; |
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
# snipped all the outer require js stuff | |
class InnerViewBase extends Chaplin.View # Or whatever your base view is | |
autoRender: true | |
container: "#innerViewContainer" | |
containerMethod: "html" | |
initialize: (templateName) -> | |
@template = require templateName |
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
// Some basic javascript Date examples | |
// NOTE: Javascript dates have 0 indexed months, because they are awesome | |
// January 1, 2012 (Chicago, IL) | |
var firstOfYear = new Date(2012, 0, 1), | |
// 6 Hour offset (before DST change) | |
hoursOffset = firstOfYear.getTimezoneOffset() / 60; | |
// April 1, 2012 (Chicago, IL) |
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
arraysEqual = (nums1, nums2) -> | |
# Check the length | |
return false unless nums1.length == nums2.length | |
# Sort the arrays | |
nums1.sort() | |
nums2.sort() | |
# A helper for checking indices are same |
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
isMult = (num, mult) -> (num % mult) is 0 | |
isMult3 = (num) -> isMult num, 3 | |
isMult5 = (num) -> isMult num, 5 | |
fizzBuzz = (min = 0, max = 100) -> | |
output = (num) -> | |
is3 = isMult3 num | |
is5 = isMult5 num | |
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
_when = (proms..., cb) -> | |
def = newPromise() | |
promCount = proms.length | |
finishProm = -> | |
promCount-- | |
# May be -1 here... | |
unless promCount > 0 | |
def.resolve() |
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
DisposableView = Backbone.View.extend({ | |
modelUnbindAll: function() { | |
var modelOrCollection = this.model || this.collection; | |
if (modelOrCollection) { | |
modelOrCollection.off(null, null, this); | |
} | |
}, |
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
// pages.Page1.js | |
// I like to include the file name at the top in case we ever concatenate our scripts and need to find this file to debug. | |
// Wrap each block of code in a self executing function. | |
// At the bottom, we pass in these objects to this function and immediately execute it. | |
(function($, window, document) { | |
"use strict"; | |
// Optionally, a single string "use strict" will force strict mode and help you catch common javascript errors before they get into the wild. | |
// Pass in jQuery and the window object to protect from other people messing with their values. |
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
function highlightMenu() { | |
// Find my the current menu item and highlight it... | |
}; | |
function loadWizzyMathinger() { | |
// Load the almighty Wizzy Mathinger | |
}; | |
function handleItemClick(evt) { |