This file contains hidden or 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 VERSION in `git diff --summary master..HEAD -- db/migrate/ | sed -e "s/.*migrate\///" -e "s/_.*//" | sort -r` ; do export VERSION && rake db:migrate:down; done |
This file contains hidden or 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 is the version I wrote in Ruby. I considered it to be pretty tight code at the time. | |
# It only handles integers from 0 to 999. When I wrote this, I understood that it ought to | |
# be more generalized, but I couldn't figure out how to do it in Ruby. | |
class Integer | |
ONES = %w(zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen) | |
TENS = %w(twenty thirty fourty fifty sixty seventy eighty ninety) | |
def to_english | |
if self < 20 |
This file contains hidden or 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
" Text object for indented code | |
onoremap <silent>ai :<C-u>cal IndTxtObj(0)<CR> | |
onoremap <silent>ii :<C-u>cal IndTxtObj(1)<CR> | |
vnoremap <silent>ai :<C-u>cal IndTxtObj(0)<CR><Esc>gv | |
vnoremap <silent>ii :<C-u>cal IndTxtObj(1)<CR><Esc>gv | |
function! IndTxtObj(inner) | |
if &filetype == 'haml' || &filetype == 'sass' || &filetype == 'python' | |
let meaningful_indentation = 1 | |
else |
This file contains hidden or 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
#!/bin/bash | |
# Print out what changed in a nice format. | |
git log @{1}.. --pretty=format:"%Cblue%an%Creset %ar: %Cred\"%s%b\"%Creset (%h)" --reverse --no-merges | |
# Print out any new migrations | |
diff <(ls -l db/migrate/ | grep "[0-9]\{14\}" | sed -e 's/.*\([0-9]\{14\}\).*/\1/g' | sort) <((test -f db/development.sqlite3 && sqlite3 db/development.sqlite3 "select version from schema_migrations" || mysql -uroot `pwd | xargs basename`_development -e "select version from schema_migrations") | grep [0-9] | sort) | grep "< [0-9]\{14\}" | cut -d' ' -f2 | tr '\n' '|' | sed -e 's/\(.*\)|$/"\\\(\1\\\)"/' -e 's/|/\\\|/g' | xargs -J % grep % <(ls -l db/migrate | tail -100) | sed -e 's/.*\([0-9]\{14\}_.*\.rb\)/[34mPending migration: [31;1m\1[0m/g' | |
# Yes, I know about rake db:about_if_pending_migrations, but it's way too slow. | |
# On the other hand, this makes all kinds of assumptions about your database configuration. |
This file contains hidden or 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 process(chicken) | |
case chicken | |
when Hen | |
chicken.collect(&:eggs) | |
when Rooster | |
chicken.chop | |
end | |
end |
NewerOlder