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
You can use | |
git add -u | |
To add the deleted files to the staging area, then commit them | |
git commit -m "Deleted files manually" | |
Delete a branch on Github |
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 format_time_difference(start_time, end_time) | |
difference = end_time.to_i - start_time.to_i | |
hours = difference/3600.to_i | |
minutes = (difference/60 - hours * 60).to_i | |
seconds = (difference - (minutes * 60 + hours * 3600)) | |
sprintf("%02d:%02d:%02d\n", hours, minutes, seconds) | |
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
#!/usr/bin/env ruby | |
# From my blog post at http://www.postal-code.com/binarycode/2009/06/06/better-range-intersection-in-ruby/ | |
class Range | |
def intersection(other) | |
raise ArgumentError, 'value must be a Range' unless other.kind_of?(Range) | |
my_min, my_max = first, exclude_end? ? max : last | |
other_min, other_max = other.first, other.exclude_end? ? other.max : other.last |
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
Time.now.in_time_zone("Eastern Time (US & Canada)") |
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
for i in 1..5 | |
begin | |
do_something_that_might_raise_exceptions(i) | |
rescue | |
next # do_something_* again, with the next i | |
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
# created by Nathan Broadbent (http://madebynathan.com/2011/03/31/thanks-first-council-of-nicaea/) | |
def easter(year) | |
c=year/100 | |
n=year-19*(year/19) | |
k=(c-17)/25 | |
i=c-c/4-(c-k)/3+19*n+15 | |
i-=30*(i/30) | |
i-=(i/28)*(1 -(i/28)*(29/(i+1))*((21-n)/11)) | |
j=year+year/4+i+2-c+c/4 |
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
Add | |
include Rails.application.routes.url_helpers | |
to model |
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
Set up databases to run AS YOUR USER ACCOUNT with: | |
unset TMPDIR | |
mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp | |
To set up base tables in another folder, or use a differnet user to run | |
mysqld, view the help for mysqld_install_db: | |
mysql_install_db --help | |
and view the MySQL documentation: | |
* http://dev.mysql.com/doc/refman/5.5/en/mysql-install-db.html |
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
vi ~/.bash_profile | |
export EDITOR="mate" | |
source ~/.bash_profile |
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
sudo /usr/sbin/apachectl restart |