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 /
Created Sep 22, 2015 proof
    "body": {
        "client": {
            "name": " node.js client",
            "version": "0.8.20"
        "key": {
            "eldest_kid": "01017e6bf6b40651b3462eac3eac9203d8708904de24287fa6c034bf6a008894276d0a",
            "fingerprint": "43d8c4e47eff66d1dc95697ed23a839f8f3cd8c8",
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>;
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 =
l.level = Rails.logger.level
set_logger l and return "console"
set_logger Rails.logger and return "log file"
# Returns "*" if the current git branch is dirty.
function parse_git_dirty {
[[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]] && echo "*"
hmcfletch /
Created May 11, 2011
Command line translate with Google APIs
# $ translate hola
# hello
# $ translate hello es
# hola
# $ translate hello fr
# bonjour
# translate <phrase to translate> <destination language> [<source language>]
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
'AL' => 'Alabama',
'AK' => 'Alaska',
'AS' => 'America Samoa',
'AZ' => 'Arizona',
'AR' => 'Arkansas',
'CA' => 'California',
'CO' => 'Colorado',
'CT' => 'Connecticut',
'DE' => 'Delaware',
hmcfletch / gist:1018085
Created Jun 10, 2011
TextMate javascript syntax highlighting for content_for :inline_js
View gist:1018085
// To edit:
// Bundles -> Bundle Editor -> Edit Languages
// Open Ruby on Rails
// Edit HTML (Rails)
// add to the patterns
// works for <% content_for :inline_js do -%>
// can prefix :inline_js like :fb_inline_js
// the end tag must look like
// <!-- end :fb_inline_js--> works as well
hmcfletch / months_between.rb
Created Jul 28, 2011
Determine the number of months between two time stamps
View months_between.rb
# A direct calculation of the number of months between two dates
class Time
class << self
def months_between(start_date, end_date)
return -months_between(end_date, start_date) if end_date < start_date
s = start_date
hmcfletch /
Created Nov 28, 2011
Get the latest Rails up and running locally
# this was for Rails 3.2.0 before the RC dropped
rvm gemset create rails-master
rvm gemset use rails-master
cd ~/src
git clone git://
cd arel
gem build arel.gemspec
gem install arel-*.gem
hmcfletch / application.rb
Created Dec 29, 2011
Rails project wide and personal configuration files
View application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
module MyApp
class Application < Rails::Application
# you app configuration code
You can’t perform that action at this time.