Skip to content

Instantly share code, notes, and snippets.

Avatar

Les Fletcher hmcfletch

View GitHub Profile
@hmcfletch
hmcfletch / config.yml
Created Sep 21, 2018
An example Circle CI workflow for a Ruby on Rails app
View config.yml
version: 2
jobs:
checkout_and_deps:
docker:
- image: circleci/ruby:2.5.1-node-browsers
steps:
- checkout
- run:
View git-branch-status
#!/bin/bash
# git-branch-status
# * originally by http://github.com/jehiah
# * "s'all good!" message by http://github.com/kd35a
# * ANSI colors by http://github.com/knovoselic
# * column formatting, filters, and usage by http://github.com/bill-auger
# this script prints out pretty git branch sync status reports
@hmcfletch
hmcfletch / keybase.md
Created Sep 22, 2015
Keybase.io proof
View keybase.md
{
    "body": {
        "client": {
            "name": "keybase.io node.js client",
            "version": "0.8.20"
        },
        "key": {
            "eldest_kid": "01017e6bf6b40651b3462eac3eac9203d8708904de24287fa6c034bf6a008894276d0a",
            "fingerprint": "43d8c4e47eff66d1dc95697ed23a839f8f3cd8c8",
View AFRailsHTTPClient.h
//
// AFRailsHTTPClient.h
// TopHatter
//
// Created by Leslie Fletcher on 1/30/12.
// Copyright (c) 2012 Blippy. All rights reserved.
//
#import "AFHTTPClient.h"
@hmcfletch
hmcfletch / ColorHelper.h
Created Jan 23, 2012
A bunch of objective-c color helpers
View ColorHelper.h
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
// generate a UIColor from rgb and alpha values
#define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define RGB(r, g, b) RGBA(r, g, b, 1.0)
// generate a UIColor
#define GRAYSCALEA(rgb, a) RGBA(rgb, rgb, rgb, a)
#define GRAYSCALE(rgb) GRAYSCALEA(rgb, 1.0)
// generate a UIColor from a hex and an alpha value
@hmcfletch
hmcfletch / application.rb
Created Jan 1, 2012
Automatic Observer Registration
View application.rb
module AppName
class Application < Rails::Application
config.encoding = "utf-8"
config.filter_parameters += [:password]
config.assets.enabled = true
config.assets.version = '1.0'
# registers any file in the app/observers directory as an observer
observers = [] # Register all observers in the observers folder.
pattern = File.join(Rails.application.config.root, 'app', 'observers', '**', '*.rb')
@hmcfletch
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
end
end
@hmcfletch
hmcfletch / install_rails_master.sh
Created Nov 28, 2011
Get the latest Rails up and running locally
View install_rails_master.sh
# 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://github.com/rails/arel.git
cd arel
gem build arel.gemspec
gem install arel-*.gem
@hmcfletch
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
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