Skip to content

Instantly share code, notes, and snippets.

Les Fletcher hmcfletch

Block or report user

Report or block hmcfletch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hmcfletch
hmcfletch / state_abbr_to_name.rb
Created Jun 2, 2011
Ruby hashes for converting states to abbreviations and back
View state_abbr_to_name.rb
STATE_ABBR_TO_NAME = {
'AL' => 'Alabama',
'AK' => 'Alaska',
'AS' => 'America Samoa',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DE' => 'Delaware',
@hmcfletch
hmcfletch / translate.sh
Created May 11, 2011
Command line translate with Google APIs
View translate.sh
# $ translate hola
# hello
# $ translate hello es
# hola
# $ translate hello fr
# bonjour
#
# USAGE:
#
# translate <phrase to translate> <destination language> [<source language>]
@hmcfletch
hmcfletch / useful_queries.sql
Created May 10, 2011
A list of helpful SQL queries
View useful_queries.sql
-- Show the coverage of a partial index
SELECT COUNT(DISTNICT(SUBSTR(<column>,1,<partial index length>))) / COUNT(DISTINCT(<column>)) * 100 FROM <table>;
View git_prompt.sh
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 "*"
}
@hmcfletch
hmcfletch / .irbrc
Created May 10, 2011
Allows you to toggle logging to dump to the console and back to the log file
View .irbrc
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
You can’t perform that action at this time.