This file contains hidden or 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
| <!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> |
This file contains hidden or 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
| var Person = Backbone.Model.extend({ | |
| initialize: function() { | |
| console.log('Person is initialized.'); | |
| }, | |
| defaults: { | |
| name: 'undefined', | |
| age: 'undefined' | |
| } | |
| }); |
This file contains hidden or 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
| var People = Backbone.Collection.extend({ | |
| initialize: function() { | |
| console.log("People Collection is initialized"); | |
| }, | |
| model: Person | |
| }); |
This file contains hidden or 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
| var person = new Person({name:"Joe"}); | |
| var people = new People(person); |
This file contains hidden or 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
| var People = Backbone.Collection.extend({ | |
| model: Person, | |
| comparator: function(person, person2) { | |
| return person.get('name') < person2.get('name'); | |
| } | |
| }); |
This file contains hidden or 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
| var friends = new Backbone.Collection([ | |
| {name: "Athos", job: "Musketeer"}, | |
| {name: "Porthos", job: "Musketeer"}, | |
| {name: "Aramis", job: "Musketeer"}, | |
| {name: "d'Artagnan", job: "Guard"}, | |
| ]); |
This file contains hidden or 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
| var People = Backbone.Collection.extend({ | |
| model: Person, | |
| url: '/friends' | |
| }); | |
| var guys = new People; | |
| guys.fetch(); |
This file contains hidden or 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
| 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) |
This file contains hidden or 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
| <Alloy> | |
| <Window class="container"> | |
| <Label id="label" onClick="doClick">Hello, World</Label> | |
| </Window> | |
| </Alloy> |
This file contains hidden or 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
| function doClick(e) { | |
| alert($.label.text); | |
| } | |
| $.index.open(); | |