This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module WelcomeHelper | |
def social_share_button(network) | |
content_tag :div, class: "btn btn-#{network}" do | |
link_to ENV["#{network}_share"] do | |
image_tag "#{network}.png", class: 'social-image' | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sorts an array of decimals as if the were the chapters and sections of a book | |
sections = [3.1, 3.11, 3.2, 3.3, 3.8, 3.7 , 3.8, 3.9, 3.10] | |
sections.sort do |e1, e2| | |
if e1.to_i == e2.to_i # Comparing sections within the same chapter | |
# Get the real value for the section within the chapter | |
n1 = e1 + e1.to_s.split('.')[1].to_i | |
n2 = e2 + e2.to_s.split('.')[1].to_i | |
# Compare using the real value of the section | |
n1 <=> n2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /home/$USER/.zlogin | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* | |
# /home/$USER/.zshrc | |
ZSH_THEME=avit | |
plugins=(rails3 gitfast git-extras ruby bower bundler command-not-found common-aliases npm rvm sublime) | |
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Couple of functions that transform a given integer into a mixed-base string | |
# representation and back. The string representation is formed by three 'A-Z' | |
# characters (base 26), followed by four '0-9' digits (base 10). | |
# Some examples: | |
# | Integer | Pattern | | |
# | 0 | AAA0000 | | |
# | 1 | AAA0001 | | |
# | 9999 | AAA9999 | | |
# | 10000 | AAB0000 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def peel(vegetable_with_layers) | |
if vegetable_with_layers[0] == 'core' | |
# base case: have I reached the core? | |
vegetable_with_layers[0] | |
else | |
# not the core... remove one layer | |
peel(vegetable_with_layers[0]) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This combines the examples given here http://pastebin.com/zxsur5MX | |
# and here http://pastebin.com/agjb5qBF | |
# Note: Time.now returns current time as seconds since epoch | |
module TimeConventions | |
TIME_CONVENTIONS = { | |
'second' => 1, | |
'minute' => 60, | |
'hour' => 60 * 60, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def labelize number | |
magnitudes = [ | |
[1e12.to_i, 'trillion'], [1e9.to_i, 'billion'], [1e6.to_i, 'million'], | |
[1e3.to_i, 'thousand'], [1e2.to_i, 'hundred'] | |
] | |
left = number | |
magnitudes.each do | label | | |
if left / label[0] > 0 | |
write = left / label[0] |
NewerOlder