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
// 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 || '/'; |
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
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" |
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
#!/usr/bin/env python | |
import os | |
import sys | |
import json | |
from cStringIO import StringIO | |
from django.core import management | |
def cmp_value(av, bv): |
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
AppState = new Backbone.Model | |
domain: null | |
class Domain extends Backbone.Model | |
class DomainCollection extends Backbone.Collection | |
model: Domain |
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
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() |
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
class Book(models.Model): | |
author = models.OneToOneField(Author) | |
... |
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
class Author(models.Model): | |
first_name = models.CharField(max_length=30) | |
last_name = models.CharField(max_length=30) | |
author = Author('John', 'Doe') | |
author.save() |
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
author.pk = None | |
author.save() | |
author.pk # 2 |
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
class Book(models.Model): | |
authors = models.ManyToManyField(Author) | |
... |
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
authors = book.authors.all() | |
book.pk = None | |
book.save() | |
book.authors = authors |
OlderNewer