Skip to content

Instantly share code, notes, and snippets.

// The grand poobah of code loading.
(function($){
_.extend(propublica.app, {
VERSION : '0.3.3', // update on commit
live : [],
held : [],
initialize : function(){
if(window.pp_initialized) return false;
function render(ctor, name){
// The inspiration for this class is grounded in Jeremy Ashkenas's work with
// DocumentCloud. The concept of **bindings** is especially brilliant and is a
// large portion of what makes **Glass.js** tick.
//
propublica.View = Base.extend({
// jquery object for our target
el : null,
// list of bindings to listen in on
bindings : {},
// The primary function of a **Model** is to manipulate and query data. For example filtering
// an array-type object should happen in a subclass of Model. Another great candidate
// for a **Model** is any object that requires an external resource such as an ajax call.
//
// Basically, any long running or long blocking operation should happen in a model.
//
// **Models** are bindable as well, so you can subscribe to notifications by calling
// `bind` with a callback and an event to subscribe to recieve events from another object.
//
// **Models** are usually encapsulated in **Views** and rarely, if ever, stand alone.
# server
require 'rubygems'
require 'sinatra'
get '/temp' do
content_type :json
temp = `./temper`
bits = temp.split(' ')
"{ \"time\" : #{bits[0]}, \"fahrenheit\" : #{bits[2].gsub(/F/,'')}, \"celcius\" : #{bits[3].gsub(/C/,'')} }"
@daksis
daksis / Raw Links
Created June 17, 2011 15:04
Bayesian Network Resources
# These are my notes from the PragProg book on CoffeeScript of things that either
# aren't in the main CS language reference or I didn't pick them up there. I wrote
# them down before I forgot, and put it here for others but mainly as a reference for
# myself.
# assign arguments in constructor to properties of the same name:
class Thingie
constructor: (@name, @url) ->
# is the same as:
@julesfern
julesfern / gist:970584
Created May 13, 2011 13:59
spah-readme.mdown

Spah: Single-Page Application Helper

Contents

@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 + "\"" }
@julesfern
julesfern / compact-logger.js
Created December 16, 2010 17:26
A tiny javascript logger
// Create the logger singleton
window.logger = {
"messages": [],
"debug": function(msg, object) { window.logger.log("debug", msg, object); },
"warn": function(msg, object) { window.logger.log("warn", msg, object); },
"error": function(msg, object) { window.logger.log("error", msg, object); },
"log": function(level, msg, object) {
window.logger.render(level, msg, object)
window.logger.messages.push([level, msg, object]);
},