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
STATE_ABBR_TO_NAME = { | |
'AL' => 'Alabama', | |
'AK' => 'Alaska', | |
'AS' => 'America Samoa', | |
'AZ' => 'Arizona', | |
'AR' => 'Arkansas', | |
'CA' => 'California', | |
'CO' => 'Colorado', | |
'CT' => 'Connecticut', | |
'DE' => 'Delaware', |
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
# $ translate hola | |
# hello | |
# $ translate hello es | |
# hola | |
# $ translate hello fr | |
# bonjour | |
# | |
# USAGE: | |
# | |
# translate <phrase to translate> <destination language> [<source language>] |
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
-- Show the coverage of a partial index | |
SELECT COUNT(DISTNICT(SUBSTR(<column>,1,<partial index length>))) / COUNT(DISTINCT(<column>)) * 100 FROM <table>; |
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
DEFAULT="\[\033[1;00m\]" | |
BLACK="\[\033[1;30m\]" | |
YELLOW="\[\033[1;33m\]" | |
GREEN="\[\033[1;32m\]" | |
WHITE="\[\033[1;37m\]" | |
BLUE="\[\033[1;36m\]" | |
# Returns "*" if the current git branch is dirty. | |
function parse_git_dirty { | |
[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && echo "*" | |
} |
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 toggle_console_logging | |
if ActiveRecord::Base.logger == Rails.logger | |
l = Logger.new(STDOUT) | |
l.level = Rails.logger.level | |
set_logger l and return "console" | |
else | |
set_logger Rails.logger and return "log file" | |
end |
NewerOlder