See example: http://jsfiddle.net/SyQYp/4/
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
/** | |
* 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
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
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
# 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 has been truncated, but you can view the full file.
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
[{"name":"Abe Sapien","type":"hero","id":1339970957,"intelligence":0.88,"strength":0.14,"speed":0.35,"durability":0.42,"power":0.35,"combat":0.85,"Alternate_Identities":"Abe Sapien","Aliases":"Langdon Everett Caul, Abraham Sapien, Langdon Caul","Nicknames":"Fish Man, Fish Stick, Blue, Brother Blue","Place_of_birth":"","First_appearance":"Hellboy: Seed of Destruction (1993)","Alignment":"good","Gender":"male","Race":"Icthyo Sapien","Height_cm":"NA","Height_ft":"NA","Weight_lb":"NA","Weight_km":"NA","Skin_color":"Blue","Eye_color":"","Hair_color":"None","Occupation":"Paranormal Investigator","Base":"","Relatives":"","Group_Affiliation":"Bureau for Paranormal Research and Defense","Friends":"Hellboy, Liz Sherman","Enemies":"","superpower_Ability_Shift":0,"superpower_Absorption":0,"superpower_Accuracy":1,"superpower_Adaptation":0,"superpower_Aerokinesis":0,"superpower_Agility":1,"superpower_Animal_Attributes":0,"superpower_Animal_Oriented_Powers":0,"superpower_Animation":0,"superpower_Anti-Gravity":0,"superpower_ |
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
# Making R read data faster by precomputing the column | |
# data types | |
sample <- read.table("data.txt", nrows = 100) | |
types <- sapply(sample, classes) | |
allData <- read.table("data.txt", colClasses = classes) |
View this code at http://livecoding.io/3860275