Created by Christopher Manning
Nodes are linked to nodes in neighboring cells. The cell's color is a function of its area.
The white lines are the Delaunay triangulation and the purple cells are the Voronoi diagram.
# http://yehudakatz.com/2010/02/21/ruby-is-not-a-callable-oriented-language/ | |
module DoAsYouPlease | |
Object.send :include, self | |
def method_missing(name, *args, &block) | |
self.class.const_get(name).call(*args, &block) | |
end | |
end | |
Foo = proc { 42 } |
# autoload concerns | |
module YourApp | |
class Application < Rails::Application | |
config.autoload_paths += %W( | |
#{config.root}/app/controllers/concerns | |
#{config.root}/app/models/concerns | |
) | |
end | |
end |
## PayRoll gem | |
# lib/pay_roll.rb | |
module PayRoll | |
class << self | |
attr_accessor :employee_directory | |
def config | |
yield self | |
end | |
end |
>> IF = -> b { b } | |
=> #<Proc:0x007fb4e4049cc8 (lambda)> | |
>> LEFT = -> p { p[-> x { -> y { x } } ] } | |
=> #<Proc:0x007fb4e403d680 (lambda)> | |
>> RIGHT = -> p { p[-> x { -> y { y } } ] } | |
=> #<Proc:0x007fb4e4028ff0 (lambda)> | |
>> IS_EMPTY = LEFT |
Created by Christopher Manning
Nodes are linked to nodes in neighboring cells. The cell's color is a function of its area.
The white lines are the Delaunay triangulation and the purple cells are the Voronoi diagram.
hide do
_ _ _
/\ /(_) __| | __| | ___ _ __
/ /_/ / |/ _` |/ _` |/ _ \ '_ \
/ __ /| | (_| | (_| | __/ | | |
\/ /_/ |_|\__,_|\__,_|\___|_| |_|
end
{ | |
"AL": "Alabama", | |
"AK": "Alaska", | |
"AS": "American Samoa", | |
"AZ": "Arizona", | |
"AR": "Arkansas", | |
"CA": "California", | |
"CO": "Colorado", | |
"CT": "Connecticut", | |
"DE": "Delaware", |
require 'net/imap' | |
# Net::IMAP raises a parse error exception when fetching attributes it doesn't | |
# recognize. Here I patch an instance of Net::IMAP's `msg_att` method to | |
# recognize the Gmail IMAP extended attributes | |
# Refer to: | |
# * https://developers.google.com/google-apps/gmail/imap_extensions#access_to_gmail_labels_x-gm-labels | |
# * http://blog.wojt.eu/post/13496746332/retrieving-gmail-thread-ids-with-ruby |
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 |