Skip to content

Instantly share code, notes, and snippets.

View burtlo's full-sized avatar

Lynn Frank burtlo

View GitHub Profile
@burtlo
burtlo / .bash_profile
Last active October 3, 2015 18:18
Github pull request from the command-line
function pull-request {
hub pull-request -h $(__github_remote_origin):$(__github_current_branch)
}
function __github_remote_origin {
# Finds the origin on github if it is https or git
echo "$1`git remote -v | grep -e "^origin.* (push)" | sed "s#origin[[:blank:]]https://github.com/\([^/]*\)\/.*#\1#" | sed "s#origin.*:\([^/]*\).*push.*#\1#"`"
}
function __github_current_branch {
@burtlo
burtlo / recipe.rb
Created April 30, 2012 00:58
Trivial Example of a the Recipe creation
module Measurements
def cup
self * 48
end
alias_method :cups, :cup
def tsp ; self ; end
alias_method :tsps, :tsp
@burtlo
burtlo / dsl.rb
Created May 6, 2012 03:15
Ruby DSL, the hard way
require 'rspec'
class Recipe
attr_accessor :name
def initialize(name)
@name = name
end
end
module BeginState
def add_player
# really add the player
end
def add_ship
# really do it
end
@burtlo
burtlo / etchosts
Created May 15, 2012 18:07
Subdomains
127.0.0.1 pod.local my.pod.local
@burtlo
burtlo / sunlight.rb
Created September 5, 2012 18:26
Using the Sunlight API
require 'csv'
require 'sunlight'
Sunlight::Base.api_key = 'e179a6973728c4dd3fb1204283aaccb5'
filename = ARGV.first || "event_attendees.csv"
options = {:headers => true, :header_converters => :symbol}
def clean_zipcode(zipcode)
@burtlo
burtlo / Rakefile
Created September 5, 2012 21:03
Rakefile to run Event Manager
task :default => :first
def open_file(filename)
system "ruby event_manager.rb #{filename}"
end
desc "open the first event attendees"
task :first do
open_file "event_attendees.csv"
end
@burtlo
burtlo / sunlight.rb
Created September 5, 2012 22:07
Sinatra with Sunlight
require 'csv'
require 'sunlight'
require 'sinatra'
Sunlight::Base.api_key = 'e179a6973728c4dd3fb1204283aaccb5'
representatives = Sunlight::Legislator.all_in_zipcode(90210)
filename = ARGV.first || "event_attendees.csv"
@burtlo
burtlo / data.yml
Created September 5, 2012 22:31
Working with YAML
name: 'La Crosse, WI'
code: LSE
directions: http://g.co/maps/62ufz
image: 'lacrosse-image.jpg'
website: http://www.cityoflacrosse.org/index.aspx?NID=851
rental_cars: http://www.cityoflacrosse.org/index.aspx?NID=882
description: La Crosse is the closest flight destination. It is right
on the Mississippi and about an hour away. It is a small airport so we
<strong>definitely recommend</strong> making a rental car reservation ahead of time.
@burtlo
burtlo / string.rb
Created September 6, 2012 15:10
Monkeypatching
class String
  def capitalize
    self.gsub(/^[a-z]|\s+[a-z]/) { |a| a.upcase }
  end
end