Skip to content

Instantly share code, notes, and snippets.

@iterative = (arr, key) ->
low = 0
high = arr.length - 1
while high >= low
mid = Math.floor (low + high) / 2
return mid if arr[mid] == key
if arr[mid] < key
low = mid + 1
bash-3.2$ rvm install ree
Installing Ruby Enterprise Edition from source to: /Users/Rein/.rvm/rubies/ree-1.8.7-2012.02
ree-1.8.7-2012.02 - #fetching (ruby-enterprise-1.8.7-2012.02)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 7732k 100 7732k 0 0 711k 0 0:00:10 0:00:10 --:--:-- 774k
ree-1.8.7-2012.02 - #extracting ruby-enterprise-1.8.7-2012.02 to /Users/Rein/.rvm/src/ree-1.8.7-2012.02
Applying patch 'tcmalloc' (located at /Users/Rein/.rvm/patches/ree/1.8.7/tcmalloc.patch)
Applying patch 'stdout-rouge-fix' (located at /Users/Rein/.rvm/patches/ree/1.8.7/stdout-rouge-fix.patch)
Applying patch 'no_sslv2' (located at /Users/Rein/.rvm/patches/ree/1.8.7/no_sslv2.diff)
@reinh
reinh / i-am-sorry.txt
Created March 20, 2012 19:59 — forked from robbyrussell/i-am-sorry.txt
apology ideas for @sqoot
Dear friends, we are truly sorry. You're right. We live in a bubble
and have a lot to learn. We need to do some soul searching and
practice mindfulness going forward. We hope that, in time, you'll
forgive us. Ladies.
# after running rdiscount once and opening the README.html (with `open -a Safari README.html`)
watch('README.md') do
`rdiscount README.md > README.html &&
osascript -e 'tell app "Safari"' \
-e 'do JavaScript "window.location.reload();" in first document' \
-e 'end tell'`
end
class CountHash < Hash
def initialize
super(0)
end
def count(key)
self[key] += 1
self
end
end
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction.
-- Albert Einstein

Source: http://pastebin.com/raw.php?i=FD3xe6Jt

Don't use MongoDB

I've kept quiet for awhile for various political reasons, but I now feel a kind of social responsibility to deter people from banking their business on MongoDB.

Our team did serious load on MongoDB on a large (10s of millions

def update_main_artist
artist = rovi_artist ? Artist.find_or_create_by_name rovi_artist.name : artists.first
update_attribute :main_artist_id, artist.id
end
sep = "'''" # some string delimiter that won't be found in the text
string.gsub('"', "#{sep}").gsub("\\#{sep}", '\"').scan(/#{sep}(.+?)#{sep}/m)
class FakeUDPSocket
def initialize
@buffer = []
end
def send(*args)
@buffer << args
end
def self.recv