Skip to content

Instantly share code, notes, and snippets.

@brandonhall
brandonhall / localStorage.js
Last active May 1, 2016 06:10
An example of overriding Backbone.sync and Backbone.parse to load data from localStorage in Backbone
// Overriding Backbone.sync to either load locally or from the server
sync: function(method, model, options) {
// Pull the key and stored object localStorage
var storageKey = localStorage.getItem('storage');
var storageData = localStorage.getItem('storage-' + storageKey);
// Apply the callback with our local data
if(storageData) {
options.success(JSON.parse(storageData));
@brandonhall
brandonhall / hack.sh
Created March 31, 2012 14:33 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#