Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>Learning About Backbone.js Collection</title>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://documentcloud.github.com/underscore/underscore-min.js"></script>
var Person = Backbone.Model.extend({
initialize: function() {
console.log('Person is initialized.');
},
defaults: {
name: 'undefined',
age: 'undefined'
}
});
var People = Backbone.Collection.extend({
initialize: function() {
console.log("People Collection is initialized");
},
model: Person
});
var person = new Person({name:"Joe"});
var people = new People(person);
var People = Backbone.Collection.extend({
model: Person,
comparator: function(person, person2) {
return person.get('name') < person2.get('name');
}
});
var friends = new Backbone.Collection([
{name: "Athos", job: "Musketeer"},
{name: "Porthos", job: "Musketeer"},
{name: "Aramis", job: "Musketeer"},
{name: "d'Artagnan", job: "Guard"},
]);
var People = Backbone.Collection.extend({
model: Person,
url: '/friends'
});
var guys = new People;
guys.fetch();
@rightson
rightson / get_lat_lng_exif_pil.py
Created September 5, 2012 03:14 — forked from erans/get_lat_lon_exif_pil.py
Get Latitude and Longitude from EXIF using PIL
from PIL import Image
from PIL.ExifTags import TAGS, GPSTAGS
def get_exif_data(image):
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags"""
exif_data = {}
info = image._getexif()
if info:
for tag, value in info.items():
decoded = TAGS.get(tag, tag)
@rightson
rightson / apps-views-index.xml
Last active December 11, 2015 01:19
Two-tabbed Alloy Application example (apps/views/index.xml)
<Alloy>
<Window class="container">
<Label id="label" onClick="doClick">Hello, World</Label>
</Window>
</Alloy>
@rightson
rightson / app-controller-index.js
Created January 13, 2013 12:58
Alloy Controller Example (app-controller-index.js)
function doClick(e) {
alert($.label.text);
}
$.index.open();