Skip to content

Instantly share code, notes, and snippets.

@nhunzaker
nhunzaker / gist:1326678
Created October 31, 2011 01:10
Article 1 - A Simple Tweet Model
// Creates a "Tweet" model based upon the Backbone.Model object
var Tweet = Backbone.Model;
// Instantiates the tweet model:
var myTweet = new Tweet({
from_user : "natehunzaker",
text : "Grow you a #backbone for great good!"
});
@nhunzaker
nhunzaker / gist:1326714
Created October 31, 2011 01:42
Article 1 - A simple tweet model with default values
// Creates a "Tweet" model based upon the Backbone.Model object
var Tweet = Backbone.Model.extend({
defaults: {
from_user : "natehunzaker",
text : "Grow you a #backbone for great good!"
}
});
// Instantiates the tweet model:
var myTweet = new Tweet();
@nhunzaker
nhunzaker / gist:1327396
Created October 31, 2011 12:35
Article 1 - Collections
var Tweet = Backbone.Model;
var tweetsCollection = new Backbone.Collection({
model: Tweet
});
tweetsCollection.add({
from_user : "natehunzaker",
text : "Grow your JS a #backbone for great good!"
});
@nhunzaker
nhunzaker / index.html
Created October 31, 2011 12:46
Article 1 - Twittermap Basic Construction
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Twitter Map</title>
<link rel="stylesheet" href="css/style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
@nhunzaker
nhunzaker / gist:1327437
Created October 31, 2011 12:53
Article - 1 Twittermap Model and Collection
// Twitter Map
$(function() {
//-- Data ---------------------------------------------------------------------//
var Tweet = Backbone.Model;
var Tweets = Backbone.Collection.extend({
@nhunzaker
nhunzaker / gist:1332241
Created November 1, 2011 23:12
Article 1 - Example View
$(function() {
//... Model and Collection code ...//
//-- Views --------------------------------------------------------------------//
var Map = Backbone.View.extend({
el: $('#map_canvas'),
@nhunzaker
nhunzaker / gist:1332280
Created November 1, 2011 23:35
Article 1 - Example of Events
var Tweet = Backbone.Model;
var tweetsCollection = new Backbone.Collection({
model: Tweet,
initialize: function() {
this.bind('add', function(model) {
alert("Oh snap, we have a model!");
});
@nhunzaker
nhunzaker / compass.rb
Created November 2, 2011 20:35
Compass with Sprites on Rails 3.1
# Note:
# Place this file within the config directory of your Rails 3.1 Application
##########################################################################################
# This configuration file works with both the Compass command line tool and within Rails.
# Require any additional compass plugins here.
project_type = :rails
# Set this to the root of your project when deployed:
http_path = "/"
@nhunzaker
nhunzaker / gist:1338419
Created November 4, 2011 01:12
Article 1 - Twittermap Initialize
$(function() {
//... Mode, Collection, and View code ...//
//-- Initialize ---------------------------------------------------------------//
// Create an instance of the tweets collection
var tweets = new Tweets({
model: Tweet
@nhunzaker
nhunzaker / init.el
Created November 7, 2011 14:39
Enable line numbering on the left-hand side in Emacs
;;;;;;;;;;;;;;;;;;;;;;;;;
;; Line Numbering
;;;;;;;;;;;;;;;;;;;;;;;;;
;; Note: I'm doing this in Emacs 24 on OSX
;; Swap line numbers using C-<f5>, you can change this of course
(autoload 'linum-mode "linum" "toggle line numbers on/off" t)
(global-set-key (kbd "C-<f5>") 'linum-mode)