Skip to content

Instantly share code, notes, and snippets.

View borestad's full-sized avatar

Johan Borestad borestad

View GitHub Profile
@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() {
@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 / 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 / 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 / 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
========= server.coffee ===========
server.coffee
express = require 'express'
engines = require 'consolidate'
#sugar = require './assets/javascripts/vendor/sugar'
# Create ExpressServer
app = express()
exports.startServer = ((config) ->
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'
@borestad
borestad / bootstrap.sh
Last active September 2, 2015 06:09
Debian Jessie custom/stripped KVM host with some useful tools (on a Macbook Air)
wget --no-cache -O- https://gist.githubusercontent.com/borestad/ddab79ed5d3412248eed/raw/f7050315505df4287bd54ca514b0a94c7f1848ff/install.sh | /bin/bash