Skip to content

Instantly share code, notes, and snippets.

View Pcushing's full-sized avatar

Patrick Cushing Pcushing

View GitHub Profile
@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 / 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 / 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_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 / 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 / todo_app.rb
Created June 21, 2012 22:32
A command line app to manage a todo list in a local file... work in progress
require "docopt"
##################################################
# Task object
##################################################
class Task
attr_accessor :description, :creation_time, :completion_time, :completed
def initialize(description)
@Pcushing
Pcushing / todo_google_spreadsheet.rb
Created June 24, 2012 07:42
Todo app that writes to a google spreadsheet... this is a work in progress
require 'rubygems'
require 'google_drive'
######################################################################
# Receive some input (not done or next) and update the task object -- this should be in /lib on its own
######################################################################
class Task
attr_accessor :description, :created_at, :created_by, :status, :completed_at
def initialize(description)
@Pcushing
Pcushing / sudoku.rb
Created June 26, 2012 04:31
solving sudoku... sorta
class Cell
attr_reader :number, :row, :column, :box
attr_accessor :value
# cell = {num: 1, value: [1,3,5], row: 2, column: 2, box: 9}
def initialize(cell_number, cell_value)
# Cells, rows, columns, and boxes all start at 0
cell_to_box_map = { 0 => 0, 1 => 0, 2 => 0, 9 => 0, 10 => 0, 11 => 0, 18 => 0, 19 => 0, 20 => 0,
3 => 1, 4 => 1, 5 => 1, 12 => 1, 13 => 1, 14 => 1, 21 => 1, 22 => 1, 23 => 1,
6 => 2, 7 => 2, 8 => 2, 15 => 2, 16 => 2, 17 => 2, 24 => 2, 25 => 2, 26 => 2,
@Pcushing
Pcushing / week3JsExercises.html
Created June 27, 2012 02:56
js week3 exercises
<!DOCTYPE html>
<head>
<title>Week 3 Exercises... sort of like yoga</title>
<script type="text/javascript" language="javascript" src="patrickCushing_allExercises.js"></script>
<!-- Just wanted to see what jquery was all about so feel free to remove this for ease of reading.
It would have been cooler if I'd gotten hide / expand working to show the code instead -->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js"></script>
@Pcushing
Pcushing / week3JsExercises.js
Created June 27, 2012 02:56
Week3 JS exercises
function hello(firstName, lastName) {
printResults(["Hello",firstName,lastName].join(' '), "http://socrates.devbootcamp.com/labs/ruby-intro/strings/greeter");
}
function favoriteNumber(guess){
myFavoriteNumber = 4;
if (guess > myFavoriteNumber) {
printResults("Too high, Vi...", "http://socrates.devbootcamp.com/labs/ruby-intro/branching/favorite-number");
} else if (guess < myFavoriteNumber) {