Skip to content

Instantly share code, notes, and snippets.

being a dad

Jeff Larson thejefflarson

being a dad
View GitHub Profile
View async_function_queue.js
propublica.models.AsyncFunctionQueue = propublica.Model.extend({
stopped : false,
init : function(attrs){
this.queue = [];
add : function(fn){
View deferrable.js
propublica.Deferrable = propublica.View.extend({
init : function(){
_.bindAll(this, 'render');
var oldRender = this.render;
this.render = function(){_.defer(oldRender);};
View view.js
// 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 : {},
tag : 'div',
View model.js
// 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 usually encapsulated in **Views** and rarely, if ever, stand alone.
propublica.Model = Base.extend({
// The **init** method copies the passed in attributes to the instance's built in
// **_attrs** object.
View stat.rb
class Stat < ActiveRecord::Base
validates_presence_of :url, :hits
validate_on_create :log_hits?
validate :url_format
named_scope :aggregate, :order => "hits DESC", :select => ["sum(hits) as hits, url, title"], :group => :url
def title
t = read_attribute(:title)
if t.nil?
View clocco_parse.clj
parse: (source, code) ->
lines: code.split '\n'
sections: []
language: get_language source
has_code: docs_text: code_text: ''
save: (docs, code) ->
sections.push {
docs_text: docs
View group_by.rb
class TableFu
def group_by(column)
rows = [["column", "value"]]
faceted_by(column).each {|table| rows << [table.faceted_on, table.rows.length] } rows
View proxies.rb
task :proxies => :environment do
todo = []
#todo << "killall ssh"
todo << "ssh -f jeff@server1 -L -N"
todo << "ssh -f jeff@server2 -L -N"
todo << "ssh -f jeff@server3 -L -N"
View load_balance_graticule.rb
module Graticule #:nodoc:
module Geocoder #:nodoc:
class Google
def initialize(key)
@key = key
@proxies = ["", "", ""]
@url = URI.parse @proxies[rand(@proxies.length)] + '/maps/geo'
View simple-node-logger.js
// hi there npm
var doColor
try {
var stdio = require("stdio")
doColor = stdio.isStderrATTY()
} catch (ex) {
doColor = true
function colorize (msg, color) {