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
use_devise = ENV['devise'] || false | |
create_homepage = ENV['home'] || false | |
git :init | |
append_file ".gitignore", "config/database.yml" | |
run "cp config/database.yml config/example_database.yml" | |
git add: '.' | |
git commit: "-m 'Initial commit'" |
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
Math.roundTo = (number, precision) -> | |
Math.round(number * 10**precision) / 10**precision |
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
Math.roundTo = (number, precision) -> | |
+(Math.round(number + "e+#{precision}") + "e-#{precision}") |
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 Enumerable | |
# Return a Hash whose keys are the unique elements and whose values are the number of appearences of that element. | |
# [2,1,2,3,4,1,2,4,9,1,3,16,8].histogram => {2=>3, 1=>3, 3=>2, 4=>2, 9=>1, 16=>1, 8=>1} | |
def histogram | |
inject(Hash.new(0)) { |hash, x| hash[x] += 1; hash } | |
end | |
# Return an enumerable with the same elements sorted from the most frequent to least frequent. | |
# See: http://codeidol.com/other/rubyckbk/Arrays/Sorting-an-Array-by-Frequency-of-Appearance/ | |
# [2,1,2,3,4,1,2,4,9,1,3,16,8].sort_by_frequency => [2, 2, 2, 1, 1, 1, 3, 3, 4, 4, 9, 16, 8] |