Skip to content

Instantly share code, notes, and snippets.

View roman's full-sized avatar

Roman Gonzalez roman

View GitHub Profile
@roman
roman / latency.markdown
Created June 7, 2012 17:54 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

(ns blah
(:use [zetta.parser.seq :only (whitespace number char)]
[zetta.combinators :only (choice around)]
[zetta.core :only (*>, <*)])
(:require [zetta.core :as z]))
(def whitespaces (many whitespace))
; For that you should use parser combinators and the monadic interface!
; if you have conditionals in your parser, this is the way to go
(ns blah
(:use [zetta.parser.seq :only (whitespace number char)]
[zetta.combinators :only (choice around)]
[zetta.core :only (*>, <*)])
(:require [zetta.core :as z]))
(def whitespaces (many whitespace))
(def identifier
(around
(def identifier
(around
whitespaces
(choice
[(<$> (partial apply vector)
(*> (string "#")
(<* number (string "#"))))
; ^ I think you should be using just number here right?
; you are trying to parse (many1 digit)
(<$> (partial apply vector)
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
let lineStartsWithPipe = getline('.') =~# '^\s*|'
let pipedContentOnPrevLine = getline(line('.')-1) =~# p
let pipedContentOnNextLine = getline(line('.')+1) =~# p
if exists(':Tabularize') && lineStartsWithPipe && (pipedContentOnPrevLine || pipedContentOnNextLine)
" Getting the number of pipes that are on the line
#!/usr/bin/ruby
#
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/mxcl/homebrew/tarball/master anywhere you like.
#
#
# 30th March 2010:
# Added a check to make sure user is in the staff group. This was a problem
# for me, and I think it was due to me migrating my account over several
# versions of OS X. I cannot verify that for sure, and it was tested on
The Traveling Hacker --------------------
Today you will be building a tool for a travel agency that determines the
total distance traveled on a tour with many stops. As luck would have it, some
of the core functionality you need has already been implemented, and you won't
need to worry about coding a mileage and routing system from scratch.
But there's a catch: The mileage and routing system you'll be using lies on
the other side of a service boundary, and only minimal work has been done on
the client side. Essentially, all that has been written so far is a bit of
@roman
roman / gist:231304
Created November 10, 2009 21:47 — forked from hassox/gist:231290
module Foo
def test
self.class::Baz
end
end
=> nil
class Bar
include Foo
class Baz
@roman
roman / env.rb
Created September 2, 2009 21:55 — forked from tpope/env.rb
# Enable Webrat's Selenium mode if one or more scenarios is tagged @selenium
Webrat.configure do |config|
config.mode = :rails
ObjectSpace.each_object(Cucumber::Ast::Features) do |features|
config.mode = :selenium if features.tag_count('selenium').nonzero?
end
end
@roman
roman / edgar
Created November 13, 2008 15:59
~ Started request handling: Thu Nov 13 14:35:57 +0000 2008
~ Routed to: {"user"=>{"password_confirmation"=>"******", "openid_url"=>"edgar.gonzalez.net.ve", "username"=>"", "password"=>"******", "email"=>""}, "format"=>nil, "x"=>"74", "y"=>"12", "age_confirmation"=>"1", "action"=>"create", "controller"=>"users"}
~ Params: {"user"=>{"password_confirmation"=>"******", "openid_url"=>"edgar.gonzalez.net.ve", "username"=>"", "password"=>"******", "email"=>""}, "format"=>nil, "x"=>"74", "y"=>"12", "age_confirmation"=>"1", "action"=>"create", "controller"=>"users"}
~ Redirecting to: http://www.myopenid.com/server?openid.assoc_handle=%7BHMAC-SHA1%7D%7B491c37a5%7D%7BI5qdAQ%3D%3D%7D&openid.identity=http%3A%2F%2Fedgargonzalez.myopenid.com%2F&openid.mode=checkid_setup&openid.return_to=http%3A%2F%2Fgreenwala.integralstaging.com%2Fusers%2Fopenid_completion%3Fopenid1_claimed_id%3Dhttp%253A%252F%252Fedgar.gonzalez.net.ve%252F%26openid_complete%3D1%26rp_nonce%3D2008-11-13T14%253A35%253A58ZNOws6X&openid.sreg.optional=ful