Skip to content

Instantly share code, notes, and snippets.

Avatar

Jeff Larson thejefflarson

View GitHub Profile
View django_tokyo_persistent_store.py
""" 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.
"""
View Javascript Tokenizer
function(script){
var tokens = function(string){
var curr_pos = string,
from = 0, // character position of the start of the new token in the string
i = 0, // current position
length = string.length, // total length of the string
tks = [], // collection of tokens
line = 1, // line number we're currently on
tokenizer = function(regex, fn){
View differ.rb
#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 = []
View speechartcode.js
;(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();
View gist:415038
#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
View my_day.js
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]);
});
View socialism.js
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(){
View set.js
// 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();
View async-google-ads.js
// 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(",");
View gist:458101
javascripts
|____app
| |____app.js
| |____models
| | |____article_content.js
| | |____ee_cookie.js
| | |____page_cookie.js
| | |____tracking_cookie.js
| |____views
| | |____beacons
You can’t perform that action at this time.