Skip to content

Instantly share code, notes, and snippets.

View thejefflarson's full-sized avatar
👨‍👩‍👧‍👦
being a dad

Jeff Larson thejefflarson

👨‍👩‍👧‍👦
being a dad
View GitHub Profile
""" Idea taken from here: http://github.com/ericflo/django-tokyo-sessions/tree/master
Basically this is a thin wrapper around django's cache fremwork to allow for persistent
keys with no expiration values.
I'm using it to store unique values that get updated infrequently, ie via cron, and which
don't need to expire, just be updatable.
Requires TT_PERSISTENT_STORE to be set in settings.py using the memcached format.
"""
#diff parsing to side by side differences
class Differ
attr_reader :rows
LINE_REGEX = /^((?:---|[><\\]))/
CONTROL_REGEX = /(\d+(?:,\d+)?)([acd])(\d+(?:,\d+)?)/
def initialize(left_file, right_file)
@rows = []
;(function (){
var Graph;
window.Graph = Graph = function(el, data, template, highlight){
this.el = $(el);
this.width = this.el.width();
this.height = this.el.height();
this.borderWidth = 5;
this.data = data;
this.matrix = new Graph.Matrix();
#State,attribute
#California,sunshine
#California,beaches
#Texas,oil
#Texas,rock_festivals
s = TableFu.new(csv)
s.faceted_by("State").each do |state|
puts state.row
dispatch : function(e){
e.preventDefault();
var clickedOn = $(e.target);
clickedOn.parents(this.scope).find(this.tag).removeClass('active');
clickedOn.addClass('active');
this.el.filter('.active').each(function(){
var disp = JSON.parse($(this).attr('data-dispatch'));
var key = _.keys(disp)[0];
$('div#filterable').trigger(key, [disp, key]);
});
propublica.views.chiclets = propublica.View.extend({
cssClass : 'social-module',
init: function(attrs){
this.url = window.PP_SHARING_URL || window.location.href;
this._super(attrs);
},
render : function(){
// A Set implementation. If you create a set with a particular length it
// will be capped at that length. The array is kept in order of addition.
propublica.models.Set = propublica.Model.extend({
init : function(vals, cap){
this._super();
this._attrs.values = [];
this._attrs.values = vals;
this._commit();
// Highly experimental async google ads.
propublica.views.googleAds = propublica.Deferrable.extend({
cssClass: "ad",
init : function(){
this._super();
},
render : function(){
// Add google attributes
var accepted = "author,scope,project,type".split(",");
javascripts
|____app
| |____app.js
| |____models
| | |____article_content.js
| | |____ee_cookie.js
| | |____page_cookie.js
| | |____tracking_cookie.js
| |____views
| | |____beacons
propublica.Deferrable = propublica.View.extend({
init : function(){
this._super();
_.bindAll(this, 'render');
var oldRender = this.render;
this.render = function(){_.defer(oldRender);};
}
});