Skip to content

Instantly share code, notes, and snippets.

View mguterl's full-sized avatar

Mike Guterl mguterl

View GitHub Profile
@jboner
jboner / latency.txt
Last active July 27, 2026 15:19
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@justinko
justinko / Plea.markdown
Created May 30, 2012 19:40
Am I doing it wrong?

Dear Rubyists,

I just lost a contract because of my code in a Rails project.

The specific code in question is related to a "posting a comment" feature. Here are the details:

In this project, "posting a comment" does not simply entail inserting a row into the database. It involves a procedure to yes, insert a row, but also detect its language, check for spam, send emails, and "share" it to Twitter and Facebook. I believe this algorithm should be encapsulated. I do not believe it belongs in a controller or a model. I do not believe Active Record callbacks should be used.

The "senior developer", whom is the stake holder's right hand man, said this:

@wycats
wycats / 0_app.rb
Created April 19, 2012 10:22
Example of using a simple future library for parallel HTTP requests
class TicketsController < ApplicationController
def show
tickets = params[:tickets].split(",")
ticket_data = tickets.map do |ticket|
parallel { Faraday.get("http://tickets.local/#{ticket}") }
end
render json: { tickets: ticket_data.map(&:result) }
end
@jimweirich
jimweirich / abstract.md
Created April 17, 2012 23:53
Berlin Clock Kata

Berlin Clock

Original Reference

Create a representation of the Berlin Clock for a given time (hh::mm:ss).

The Berlin Uhr (Clock) is a rather strange way to show the time. On the top of the clock there is a yellow lamp that blinks on/off every two seconds. The time is calculated by adding rectangular lamps.

@ahoward
ahoward / conducer.rb
Created April 10, 2012 19:22
sketching out a high level explanation of dao's conducer: presenter X conductor
# -*- encoding : utf-8 -*-
#
# conducers combine the presenter pattern with the conductor pattern. they
# can present and conduct an arbitrary number of models. they can also unify
# models with api calls and other non-persisted data in way that supports
# restufl interfaces, validations, form helpers, etc. consider conducers and
# being 'conductive to' writing web applications: you can prepare arbirtray
# data for the view and serialize arbirtray data out of it into a data store.
#
# to your controllers and views a conducer looks *just like a model* except
@coreyhaines
coreyhaines / .rspec
Last active August 15, 2024 15:13
Active Record Spec Helper - Loading just active record
--colour
-I app
class Scanner
def initialize(display)
@display = display
end
def scan
@display.last_item = Item.new("Cornflakes")
end
end
Item = Struct.new(:name)
@ahoward
ahoward / _flash.html.erb
Created March 3, 2012 16:22
portable templates. in rails and js.
<%
unless @flash_has_already_been_rendered
flash = self.flash ### see http://groups.google.ca/group/rubyonrails-talk/browse_thread/thread/8e54e4bc3c2b4366
keys = flash_message_keys
javascript = []
unless flash[:hide]
keys.each do |key|
~/Code/ember.js ‹ruby-1.9.3› ‹master*› $ bundle && echo "fuck you giles"
Using rake (0.9.2.2)
Using confparser (0.0.2.1)
Using multi_json (1.0.4)
Using execjs (1.2.13)
Using libxml-ruby (2.2.2)
Using faster_xml_simple (0.5.0)
Using httpclient (2.2.4)
Using json (1.6.5)
Using nokogiri (1.5.0)
@ahoward
ahoward / presenter.rb
Created February 22, 2012 23:09
worlds simplest presenter pattern. drop in replacement for ActiveRecord/Mongoid models in your controller
# the worlds lightest weight presenter pattern. to use simply
#
# file app/presenters/post_presenter.rb
#
# PostPresenter =
# Presenter.for(Post) do
# validates_presence_of :custom_field_for_this_form
#
# end
#