Skip to content

Instantly share code, notes, and snippets.

View Pcushing's full-sized avatar

Patrick Cushing Pcushing

View GitHub Profile
@Pcushing
Pcushing / google_drive_parsing.rb
Created June 21, 2012 16:26
Log into google docs and parse the data, work in progress
require 'rubygems'
require 'google_drive'
# Go get your consumer key, client_secret, and client_id for Google Drive here https://code.google.com/apis/console/
consumer_key = 'INSERT YOUR CONSUMER_KEY HERE'
client_secret = 'INSERT YOUR CLIENT_SECRET HERE'
client_id = 'INSERT YOUR CLIENT_ID HERE'
client = OAuth2::Client.new(
client_id, client_secret,
@Pcushing
Pcushing / event_reporter.rb
Created June 20, 2012 03:36
work in progress event_reporter.rb
require 'sunlight'
require 'csv'
class EventReporter
def run
command = ""
while command != "quit"
puts ""
printf "enter command: "
input = gets.chomp
@Pcushing
Pcushing / event_manager.rb
Created June 20, 2012 00:07
Reading a messy file of names and doing something useful with it (cleaning, legislator lookup). Worked with Tom.
# Dependencies
require "csv"
require "sunlight"
# Class Definition
class EventManager
INVALID_ZIPCODE = "00000"
Sunlight::Base.api_key = "e179a6973728c4dd3fb1204283aaccb5"
@Pcushing
Pcushing / event_manager.rb
Created June 19, 2012 06:46
work in progress event_manager
# Dependencies
require "csv"
# Class Definition
class EventManager
attr_reader :file
INVALID_ZIPCODE = "00000"
def initialize
puts "EventManager Initialized."
@Pcushing
Pcushing / baseball_team.rb
Created June 18, 2012 22:12
Baseball team exercise w/ rspec
require 'rspec'
class BaseballTeam
def initialize
@starters = { 1 => { 'Aviles' => 'SS' }, 2 => { 'Pedroia' => '2B' }, 3 => { 'Youkilis' => '1B' },
4 => { 'Ortiz' => 'DH' }, 5 => { 'Middlebrooks' => '3B' }, 6 => { 'Gonzalez' => 'OF' },
7 => { 'Saltalamacchia' => 'C' }, 8 => { 'McDonald' => 'OF' }, 9 => { 'Byrd' => 'OF' },
0 => { 'Lester' => 'P' } }
end
@Pcushing
Pcushing / gist:2950678
Created June 18, 2012 21:02
Delete soon
# Create a Red Sox class that represents the starting line-up of the Red Sox in a recent game. The line-up at the start of the game, 1 through 9, is given below with the pitcher indicated at 0 as he doesn't bat (sorry, NL fans):
#
# * 1, Aviles, SS
# * 2, Pedroia, 2B
# * 3, Youkilis, 1B
# * 4, Ortiz, DH
# * 5, Middlebrooks, 3B
# * 6, Gonzalez, OF
# * 7, Saltalamacchia, C
# * 8, McDonald, OF
@Pcushing
Pcushing / TwitterFollower.rb
Created June 18, 2012 06:51
Login to Twitter, follow a single user and print all twitter client methods for future reference
require 'rubygems'
require 'oauth'
require 'twitter'
consumer_key = 'HIDDEN'
consumer_secret = 'HIDDEN'
@consumer = OAuth::Consumer.new(
consumer_key,
consumer_secret,
@Pcushing
Pcushing / redefining_count.rb
Created June 16, 2012 00:09
Redefining count, but there's got to be a better way...
class Array
def new_count
count = 0
(1..self.length).each do |i|
count += 1 if yield(self[i-1])
end
count
end
end
@Pcushing
Pcushing / RPNCalculator.rb
Created June 15, 2012 03:25
RPNCalculator with Andrew... crushing it
class RPNCalculator
def initialize
@rpn = []
end
def push(num)
@rpn << num
end
@Pcushing
Pcushing / book_class.rb
Created June 15, 2012 00:54
Andrew and Patrick crushing it on books
class Book
attr_accessor :title
def initialize
@title = ""
end
def title=(name)
arr = name.split
no_caps = ["the", "an", "a", "and", "in"]