Skip to content

Instantly share code, notes, and snippets.

View theotherzach's full-sized avatar

Zach Briggs theotherzach

View GitHub Profile
@theotherzach
theotherzach / hit_load.rb
Created April 12, 2013 14:05
strategy for splitting hit file efficiently
require 'set'
require 'csv'
data_path = '/Users/zach/Code/metrics_loader/data/'
$hits_path = "#{data_path}/analytic_recording_tags_20121216.csv"
$recordings_path = "#{data_path}/recordings_20121216.csv"
$raw_ids = Set.new
IO.foreach($hits_path).each do |line|
next if(ids = line.slice!(0, 13)) == 'record_ident|'
@theotherzach
theotherzach / body_view.js
Last active December 17, 2015 14:18
Thinking about how to approach numbers that are formatted as fancy strings but saved as numbers
window.app.views.BodyView = Backbone.View.extend({
el: $("body"),
events: {
"click #app-submit": "save",
},
save: function () {
var lineItem = $('#line-item').val()
this.model.saveWithFormat(lineItem)
}
});
# From Spotlight, search for terminal
# From the terminal, type irb to start the Interactive Ruby shell
# To leave irb, type exit
# If shit gets weird, control-c
############################################
# Words for Mary
# Special words
# while, if, puts, do, end
# most others are variables or numbers
@theotherzach
theotherzach / clever_code.rb
Created June 20, 2013 21:10
I have become Brian Muller
class User < ActiveRecord::Base
geocoded_by :address
def save_with_geocode
geocode if address_changed?
save
end
def address
address_compenents.map { |e| self.send e }.join(" ")
## Example 3 ###
class Charlie
def hey(drivel)
answerer(drivel).reply
end
private
parse: function(response){
return response.notifications.map(function(e) {
return e.notification;
});
},
class Today
WEDNESDAY = 3
def self.wednesday?
Date.today.wday == WEDNESDAY
end
end

Broken

Maintenance is the primary cost of software systems. What we build is brittle and ill suited for even minor changes.

Maintenance as a % of the total cost by decade.

  • 35-40% in the 70's
  • 40-60% in the 80's
  • 70-80% in the 90's

The consequence of this is an exponential increase in the cost of building systems as they grow.

Frontend Performance

It is quite possible to instrument and collect timings from our front end code. Suddenly we've got just as much insight into our frontend code as our backend and optimize accordingly.

We want to use the native browser performance api where possible and fall back to Date.now() when it's not. Luckily a polyfill library exists already - User Timing

The first step is to instrument the actual JavaScript.

toggleAllComplete: function () {
  var elapsedTime,