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
# Read a comma-delimited file that has the following content | |
# time,observations | |
# 2011/11/01,12 | |
# 2012/01/01,320 | |
# 2011/12/01,100 | |
# 2012/06/01,7 | |
raw.data <- read.delim("timefill.csv", header=T, sep=",") | |
# Convert the time column to a date column. | |
# Accessing a column is done by using the '$' sign |
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 ds = new Miso.Dataset({ | |
// Paths can be relative or absolute. | |
path: "/some/path/here", | |
// Make sure you specify the filesystem importer. | |
importer: Miso.Importers.Filesystem | |
}); |
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 el = $('div.button'); | |
// is this bad? I'd think so: | |
el.addClass('closed').css('border', 'none').attr('x', 5); | |
// first method call in line, subsequent below indented? | |
el.addClass('closed') | |
.css('border', 'none'); | |
// context switching adds indentation? (like in d3) |
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
/** | |
* A useful little pagination collection extension. Handles two | |
* types of collections: | |
* 1. Those where the number of pages is discoered on first page | |
* 2. Those whose number of pages is known in advance. | |
* Used by startup Collection and Trends collection. | |
*/ | |
ST.Collections.PaginatedCollection = Backbone.Collection.extend({ | |
initialize : function(attributes, options) { |
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
// A collection holding many tweet objects. | |
// also responsible for performing the | |
// search that fetches them. | |
var Tweets = Backbone.Collection.extend({ | |
model: Tweet, | |
initialize: function(models, options) { | |
this.query = options.query; | |
}, | |
url: function() { | |
return "http://search.twitter.com/search.json?q=" + this.query + "&callback=?"; |
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
// Create base tweet model and tweets collection. | |
var Tweet = Backbone.Model.extend({}); | |
var Tweets = Backbone.Collection.extend({ | |
model : Tweet, | |
initialize: function(options) { | |
this.query = options.query | |
}, | |
url: function() { | |
return "http://search.twitter.com/search.json?q=" |
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"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | |
<title>Example</title> | |
<link rel="stylesheet" href="/assets/css/main.css"> | |
</head> | |
<body> |
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
// Define whatever global space vars you might need. | |
var mbta = { | |
// application configuration parameters | |
app : { | |
server : "http://backbonetraining.bocoup.com:8000" | |
}, | |
// application data | |
data : { | |
// station collection | |
lines : null |
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 chat = { | |
// Create this closure to contain the cached modules | |
module: function() { | |
// Internal module cache. | |
var modules = {}; | |
// Create a new module reference scaffold or load an | |
// existing module. | |
return function(name) { | |
// If this module has already been created, return it. |
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
// src/application.js | |
// Define the application namespace in global scope and module handler | |
var namespace = { | |
// Create this closure to contain the cached modules | |
module: function() { | |
// Internal module cache. | |
var _modules = {}; | |
// Create a new module reference scaffold or load an | |
// existing module. |