Skip to content

Instantly share code, notes, and snippets.

@knowtheory
knowtheory / gist:2709760
Created May 16, 2012 11:45
Backbone confusion
var test = Backbone.Model.extend({
var1 : [],
initialize : function(obj) {
this.var1.push("1")
console.log(this.var1.length, this.cid)
}
});
var x = (new test);
@knowtheory
knowtheory / coursera_lecture_time.js
Created March 25, 2012 02:04
A quick script for totaling up how much time it'd take to watch through a coursera class's lectures straight through.
var lectureLinks = $('#page-content .item_list a.lecture-link')
var timecodes = $.map(lectureLinks, function(link){
return link.text.split(" ").reverse()[0].replace(/[()]/g,'')
})
var times = $.map(timecodes, function(time){
var timesplit = time.split(':')
var min = timesplit[0], sec = timesplit[1]
return min*60+sec*1
})
var total = 0; for (var time in times) { total += times[time] }
DV.model.Document = Backbone.Model.extend({
className : 'document',
url : function(){ return DV.host + '/documents/' + this.get('id') + '.json'; },
sync : function(method, model, options) {
options.dataType = "jsonp";
return Backbone.sync(method, model, options);
}
});
DV.model.DocumentSet = Backbone.Collection.extend({
DV.model.Document = Backbone.Model.extend({
className : 'document',
url : function(){ return DV.host + '/documents/' + this.get('id') + '.json'; },
sync : function(method, model, options) {
options.dataType = "jsonp";
return Backbone.sync(method, model, options);
}
});
DV.model.DocumentSet = Backbone.Collection.extend({
  • From Amy: Hi Amanda, When is it OK to put the big findings or hint to them in the readout to highlight them? Or should you leave findings for the users to find on their own?
  • From Ted Han: Which comes first, the data set, or the question being asked/answered? (or do they evolve together iteratively? or does it depend on circumstance?)
  • From Laurian: If you have data, what tools you usually use to explore it before discovering how to make a visualisation (before knowing the question, the interesting pattern)? [What do you use to get a sense of it?]
  • From Juan: can you think of any great visualizations that have been built on video? (not delivered through video, but using video as the element of visualization)
  • From Amy: How much does "shelf life" play a role in what you choose to spend time on, especially with breaking news?
  • From Ted Han: How many people participate in designing an analysis? How does that affect the "sketching" process?
  • From Regnard: What books/resources did you read & study when

"I am looking forward to accelerating Ruby's progress" - Q&A with Matz regarding joining Heroku as a chief architect.

Date: 13th July 2011

Introduction

As mentioned in my previous article, It has been announced that Yukihiro Matsumoto (Matz) is joining Heroku as Chief Architect of Ruby. I asked Matz about the story behind his future role via email.

My mission is to make Ruby core more functional and higher quality.

@knowtheory
knowtheory / player_events.js
Created June 6, 2011 12:55
JS Bridge functions for the videojuicer player
// available events that can be fed to addListener
[ 'player.ready',
'player.unready',
'player.resume',
'player.pause',
'player.seek',
'player.duration',
'player.durationResolved',
'player.durationUnresolved',
'player.fullscreen',
@knowtheory
knowtheory / mojo.markdown
Created June 1, 2011 00:34
My Mojo Ideas

My Ideas for the Mozilla-Knight Journalism Challenge

I've spent the past couple weeks participating in the Mozilla Knight Journalism Challenge, and trying my best to make others aware of the challenges :)

The submission phase of the MoJo challenges have closed, and the voting phase has begun. Below you'll find my four entries, with quick descriptions. If you are interested and like any of my entries, i encourage you to create a drumbeat account (you can login with google or twitter etc), and vote for the ones you like.

The voting phase for MoJo will display a random four entries to voters to review and vote for (if they so choose). The MoJo challenges themselves are divided into three sections: Unlocking Video, Beyond Comment Threads, Open Web's Killer Apps

Here are my submiss

@knowtheory
knowtheory / sql.citrus
Created May 20, 2011 16:24
A Parsing Expression Grammar for parsing an SQL subset. Written as a start to parsing SQL and generating Veritas relations (see: https://github.com/dkubb/veritas )
grammar SQL
rule statement
select_statement <Veritas::SQL::Select>
| set_operation_statement <Veritas::SQL::SetOperation>
| "(" [\s]* statement [\s]* ")"
end
rule set_operation_statement
"(" [\s]* left:select_statement <Veritas::SQL::Select> [\s]* ")"
[\s]* set_operator ([\s]+ distinct:`DISTINCT`)? [\s]*
@knowtheory
knowtheory / prettyprint.js
Created April 11, 2011 05:44
A pretty printer for Javascript objects that looks like Ruby's pp formatter. In use on Rhino, untested elsewhere.
function pp(object, depth, embedded) {
typeof(depth) == "number" || (depth = 0)
typeof(embedded) == "boolean" || (embedded = false)
var newline = false
var spacer = function(depth) { var spaces = ""; for (var i=0;i<depth;i++) { spaces += " "}; return spaces }
var pretty = ""
if ( typeof(object) == "undefined" ) { pretty += "undefined" }
else if ( typeof(object) == "boolean" ||
typeof(object) == "number" ) { pretty += object.toString() }
else if ( typeof(object) == "string" ) { pretty += "\"" + object + "\"" }