Skip to content

Instantly share code, notes, and snippets.

View borestad's full-sized avatar

Johan Borestad borestad

View GitHub Profile
@borestad
borestad / gist:4220542
Created December 5, 2012 23:39
Express.js boilerplate - Not as pretty as Zappajs, but still more readable?
express = require 'express'
engines = require 'consolidate'
routes = require './routes'
app = express()
exports.startServer = ((config) ->
server = @listen config.server.port, ->
console.log "Express server listening on port %d in %s mode", server.address().port, app.settings.env
@borestad
borestad / backbone.$super.js
Created August 7, 2012 13:50
super call within Backbone.js
var $super = function(funcName){
funcName = funcName || 'initialize';
// _.bindAll messes upp constructor
// TODO: Add more tests with multiple inheritance
var _super = this.constructor.__super__ || this.__proto__.constructor.__super__;
return _super[funcName].apply(this, _.rest(arguments));
},
_$super = function(funcName){
funcName = funcName || 'initialize';
@borestad
borestad / jquery.switchclasses.js
Created July 16, 2012 15:37
A jQuery method for switching classes in the DOM
define([
'jquery'
], function ($) {
"use strict";
/**
* Method for switching between 2 or multiple classes
* @param {String} currentClasses The classes that currently exists
* @param {String} newClasses The classes we want to change to
* @param {Mixed} [expression] Expression/callback that will be evaluated.
@borestad
borestad / gist:2888170
Created June 7, 2012 10:50
isPlainObject()
function isPlainObject(val){
return val.toString() === "[object Object]";
}
isPlainObject({}) // => true
isPlainObject([]) // => false
isPlainObject(function(){}) // => false
@borestad
borestad / describe.tmSnippet
Created May 31, 2012 12:04
describe.tmSnippet
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>content</key>
<string>describe("${1:description}", function() {
before(function() {
$2
});
after(function() {