Skip to content

Instantly share code, notes, and snippets.

View bruth's full-sized avatar

Byron Ruth bruth

View GitHub Profile
@bruth
bruth / catch_route.js
Created July 1, 2014 13:09
Document event handler that catches links and navigates to a Backbone route if one exists.
// Route based on the URL
$(document).on('click', 'a', function(event) {
// Path of the target link
var path = this.pathname;
// Handle IE quirk
if (path.charAt(0) !== '/') path = '/' + path;
// Trim off the root on the path if present
var root = Backbone.history.root || '/';
boot2docker down
boot2docker destroy
curl http://static.dockerfiles.io/boot2docker-v1.2.0-virtualbox-guest-additions-v4.3.14.iso > ~/.boot2docker/boot2docker.iso
boot2docker init
VBoxManage sharedfolder add boot2docker-vm -name home -hostpath /Users
boot2docker up
boot2docker ssh "sudo modprobe vboxsf && sudo mkdir -v -p /Users && sudo mount -v -t vboxsf -o uid=0,gid=0 home /Users"
@bruth
bruth / diff_metadata.py
Created May 6, 2015 14:31
Diff Avocado metadata
#!/usr/bin/env python
import os
import sys
import json
from cStringIO import StringIO
from django.core import management
def cmp_value(av, bv):
@bruth
bruth / gist:1120062
Created August 2, 2011 12:02
Backbone Controller/Delegate Example
AppState = new Backbone.Model
domain: null
class Domain extends Backbone.Model
class DomainCollection extends Backbone.Collection
model: Domain
class Book(models.Model):
title = models.CharField(max_length=50)
author = models.ForeignKey(Author)
summary = models.TextField()
pub_date = models.DateField()
book = Book('John Doe: The Autobiography', author,
'A long, long time ago..', date(2011, 9, 3))
book.save()
class Book(models.Model):
author = models.OneToOneField(Author)
...
class Author(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
author = Author('John', 'Doe')
author.save()
author.pk = None
author.save()
author.pk # 2
class Book(models.Model):
authors = models.ManyToManyField(Author)
...
authors = book.authors.all()
book.pk = None
book.save()
book.authors = authors