Skip to content

Instantly share code, notes, and snippets.

View ylg's full-sized avatar

Yuri Gadow ylg

View GitHub Profile
@ylg
ylg / pc-heroku.sh
Created July 27, 2011 17:48
Setting up a PC for and deploying to Heroku
#!/usr/bin/env bash
if [[ ! -e "./Procfile" ]]; then
echo "Oops, there's no Procfile in this directory--your developer should have included one--check you're in the application's root directory."
echo "...aborting script."
exit
fi
echo "Updating Ruby's own package manager"
gem update --system --no-ri --no-rdoc
@ylg
ylg / mac-heroku.sh
Created July 26, 2011 17:52
Setup a Mac for and deploy to Heroku
#!/usr/bin/env bash
if [[ ! -e "./Procfile" ]]; then
echo "Warning, there's no Procfile in this directory--your developer should have included one--check you're in the application's root directory."
exit
fi
echo "Downloading and installing Brew, info at http://mxcl.github.com/homebrew"
ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
@ylg
ylg / bit_interleaving.rb
Created February 27, 2011 19:30
Bit interleaving and de-interleaving in Ruby (also known as Morton Numbers.)
class Integer
def interleave(y)
x_bit_size = self > 0 ? Math.log2(self) : 1
y_bit_size = y > 0 ? Math.log2(y) : 1
z = 0
((((x_bit_size <=> y_bit_size) == -1) ? y_bit_size : x_bit_size).floor + 1).times do | i |
z |= (self & 1 << i) << i | (y & 1 << i) << (i + 1)
end