Skip to content

Instantly share code, notes, and snippets.

View Pcushing's full-sized avatar

Patrick Cushing Pcushing

View GitHub Profile
@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"]
@Pcushing
Pcushing / DictionaryClass.rb
Created June 15, 2012 00:31
Andrew & Patrick tackle the Dictionary (class)
class Dictionary
def initialize
@my_hash = {}
end
def add(word_hash)
if word_hash.is_a?Hash
@my_hash.merge!(word_hash)
else
@my_hash[word_hash] = nil
@Pcushing
Pcushing / numbers_in_words_recursion.rb
Created June 14, 2012 02:29
Numbers in Words with recursion up to 1 trillion
class Fixnum
def in_words
ten = 10
hundred = 100
thousand = 1_000
million = 1_000_000
billion = 1_000_000_000
trillion = 1_000_000_000_000
@Pcushing
Pcushing / PigLatin.rb
Created June 13, 2012 19:31
Pig Latin with Two Methods
def translate(word)
start_point = vowels_start(word)
end_point = word.length - 1
if start_point == 0
word + "ay"
else
word[start_point, end_point] + word[0, start_point] + "ay"
end
end
@Pcushing
Pcushing / JavascriptPlay.html
Created June 13, 2012 00:09
Javascript play with Matt Nguyen
<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript">
var message = {
user: "bob",
text: "aldfkja"
};
@Pcushing
Pcushing / NumbersInWords.rb
Created June 12, 2012 22:53
Jacquie & Patrick tackle Numbers in Words
module InWords
def in_words
num_digits = self.to_s.length
num_string = self.to_s
under_ten = { 0 => "zero", 1 => "one", 2 => "two", 3 => "three",
4 => "four", 5 => "five", 6 => "six",
7 => "seven", 8 => "eight", 9 => "nine" }
teens = { 10 => "ten", 11 => "eleven", 12 => "twelve", 13 => "thirteen",
14 => "fourteen", 15 => "fifteen", 16 => "sixteen",