Skip to content

Instantly share code, notes, and snippets.

View pzaich's full-sized avatar

Paul Zaich pzaich

View GitHub Profile
@pzaich
pzaich / gist:2951576
Created June 19, 2012 00:08
Another Mark_twain recursive example
class String
def mark_twain
self.mark_twain_helper([])
end
def mark_twain_helper(drafts)
words = self.split(' ')
if words.length > 1
drafts << "Draft: #{words[0..words.length].join(" ")}."
words[0..words.length-2].join(" ").mark_twain_helper(drafts)
@pzaich
pzaich / gist:2951768
Created June 19, 2012 01:16
BaseballTeam Class
class BaseballTeam
def initialize
@lineup = { 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
def get_lineup
@lineup
require 'jumpstart_auth'
require 'bitly'
class JSTwitter
attr_reader :client
def initialize
puts "Initializing..."
@client = JumpstartAuth.twitter
@screen_names = @client.followers.collect{|follower| follower.screen_name}
@pzaich
pzaich / gist:2962659
Created June 20, 2012 22:38
event_manager.rb
# Dependencies
require "csv"
require 'sunlight'
require 'date'
# Class Definition
class EventManager
Sunlight::Base.api_key = "e179a6973728c4dd3fb1204283aaccb5"
INVALID_PHONE_NUMBER = "0" * 10
@pzaich
pzaich / gist:2963031
Created June 20, 2012 23:58
follower.rb
#gems
require 'twitter'
require 'csv'
class Follower_Data
def initialize(filename)
puts "Twitter_Follower Initialized."
@list_file = CSV.open(filename, {:headers => true, :header_converters => :symbol})
end
<html>
<head>
<title>CodeClassChat</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="http://codeclasschat.herokuapp.com/bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="http://codeclasschat.herokuapp.com/style.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://codeclasschat.herokuapp.com/helpers.js"></script>
@pzaich
pzaich / todo_2.rb
Created June 22, 2012 08:39
To Do Terminal App
require 'time'
require 'csv'
class TaskItem
attr_accessor :task, :created_at, :completed, :completed_at
###Intialize with optional hash values for existing todos
def initialize(task_string, optional_values = {})
values = {created_at: Time.now, completed: false, completed_at: ""}.merge(optional_values)
@task = task_string
@created_at = values[:created_at]
@pzaich
pzaich / sudoku-rev1.rb
Created June 26, 2012 02:06
Sudoku solver rev 1
# module SudokuSolver
class Gameboard
attr_reader :board, :rows, :columns, :quadrants
def initialize(initial_values)
@board = []
@rows = []
@columns = []
@quadrants = []
generate_cells(initial_values)
@pzaich
pzaich / gist:3006810
Created June 27, 2012 20:58
Passing optional hash arguments
# Using an optional hash
#
# **branch based off of the optional hash
def initialize(task_string, created_at = Time.now, completed_at = nil)
end
def initialize(task_string, optional_values = {})
values = {created_at: Time.now, completed_at: nil}.merge(optional_values)
@task = task_string
require 'rspec'
require 'simplecov'
SimpleCov.start
require './list.rb'
require './task.rb'
#require './todo.rb'
describe Todo::Task do
before :all do
@new_task = Todo::Task.new("This is a task string")