Indent with two spaces, never tabs.
# bad
def foo
# indented with tabs
When a mobile device is detected, the .loadVideo click event attaches a div#videoOverlay element containing the Youtube embed iframe to the document. The overlay is sized to cover the whole document and the iframe is centered inside it. | |
#videoOverlay has a click event bound after it is inserted that removes it from the document. This gets around the problem of the close button being unclickable. |
me.age = 5 | |
him.age = 6 | |
[me, him].each do |we| | |
we.ride(Horse.new made_of: :sticks) | |
end | |
me.wear :black | |
him.wear :white | |
Fight.all.each do |fight| | |
fight.winner = him | |
end |
brew update | |
brew install openssl readline | |
CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline`" rbenv install 1.9.3-p362 |
PROMPT='%{$fg_bold[green]%}%n@bean:%~$(git_prompt_info)%# %{$reset_color%}' | |
ZSH_THEME_GIT_PROMPT_PREFIX=" %{$fg[magenta]%}[" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$fg_bold[green]%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[red]%}*%{$fg[magenta]%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="" |
fout = File.open "outfilename", "w+" | |
File.open "infilename" do |fin| | |
fin.each do |line| | |
fout << line.gsub(/production.log.[0-9]+.gz-...[:-] /, "") | |
end | |
end |
jQuery -> | |
mapOpts = | |
dragging: false | |
touchZoom: false | |
scrollWheelZoom: false | |
doubleClickZoom: false | |
boxZoom: false | |
map = L.map('map', mapOpts) | |
tileOpts = | |
attribution: 'Tiles by <a href="http://mapbox.com/about/maps" rel="external">MapBox</a>' |
def pset(set) | |
bins = (0...(2 ** set.length)).map { |x| ("%0#{set.length}d" % x.to_s(2)).split('').map(&:to_i) } | |
bins.map do |a| | |
a.map.with_index.map { |v, i| v > 0 ? set[i] : nil }.compact | |
end | |
end |
def qsort(list) | |
return list unless list.length > 1 | |
pivot_index = rand(0...list.length) | |
pivot = list[pivot_index] | |
less = [] | |
greater = [] | |
list.delete_at(pivot_index) | |
list.each do |el| | |
(if el > pivot then greater else less end) << el | |
end |
def reverse(ary) | |
return ary unless ary.length > 1 | |
reverse(ary[0...ary.length-1]).unshift(ary[-1]) | |
end |