Skip to content

Instantly share code, notes, and snippets.

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Apprentice">
<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>
@bcamarda
bcamarda / pig_latin.rb
Created June 21, 2012 00:21
Pig Latin
def translate(string)
vowel = ["a", "e", "i", "o", "u", "y"]
if ((vowel.include? string[0]) == false) && ((vowel.include? string[1]) == false) && ((vowel.include? string[2]) == false)
string = string[3..-1] + string[0..2] + "ay"
elsif ((vowel.include? string[0]) == false) && ((vowel.include? string[1]) == false)
string = string[2..-1] + string[0..1] + "ay"
elsif (vowel.include? string[0]) == true
string = string + "ay"
elsif string[0..1] == "qu"
@bcamarda
bcamarda / rps.rb
Created June 18, 2012 23:18
RPS Winner
def game(pair)
raise WrongNumberOfPlayersError unless pair.length == 2
strategy = pair[0][1].downcase + pair[1][1].downcase
if ["rs", "sp", "pr"].include?(strategy)
#return "#{pair[0]} wins since #{pair[0][1]} > #{pair[1][1]}}"
return pair[0]
elsif ["sr", "ps", "rp"].include?(strategy)
#return "#{pair[1]} wins since #{pair[1][1]} > #{pair[0][1]}}"
return pair[1]
@bcamarda
bcamarda / Scope
Created June 15, 2012 16:16
Explanation of scope
# VARIABLE SCOPE
=Begin
$example A global variable
@example An instance variable
example A local variable
Example A constant
@@example A class variable