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
class Time | |
# because i often times have trouble keeping these straight | |
# >> 1.day.ago.before? Time.now | |
# => true | |
# >> 1.day.from_now.before? Time.now | |
# => false | |
# >> 1.day.from_now.after? Time.now | |
# => true | |
# >> 1.day.ago.after? Time.now |
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
100000th post |
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
# Calculate the number of months between two dates | |
def months_between (start_date=Time.now, end_date=Time.now) | |
(end_date.month - start_date.month) + 12 * (end_date.year - start_date.year) | |
end | |
# Calculate a person's age | |
def age_at(date, dob) | |
day_diff = date.day - dob.day | |
month_diff = date.month - dob.month - (day_diff < 0 ? 1 : 0) | |
date.year - dob.year - (month_diff < 0 ? 1 : 0) |
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
# Setup git repository | |
git :init | |
# Setup .gitignore files | |
run "touch tmp/.gitignore log/.gitignore vendor/.gitignore" | |
run %{find . -type d -empty | grep -v "vendor" | grep -v ".git" | grep -v "tmp" | xargs -I xxx touch xxx/.gitignore} | |
file '.gitignore', <<-END | |
.DS_Store | |
log/*.log |
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 path_to_attachment_image(attachment) | |
image_path("attachments/#{attachment.filename}") | |
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
def is_prime(n) | |
("1" * n) !~ /^1?$|^(11+?)\1+$/ | |
end |
I hereby claim:
- I am epid on github.
- I am epid (https://keybase.io/epid) on keybase.
- I have a public key whose fingerprint is 8B67 47F9 BBFB C82F 01C4 08EC A96B EE40 D044 0E9A
To claim this, I am signing this object: