{{ message }}

Instantly share code, notes, and snippets.

# Jared DavisJared-Prime

Created Feb 28, 2012 — forked from zeroeth/roman_numerals.rb
Roman Numerals Kata
View roman_numerals.rb
 # Feb, 27th, 2012 # Kevin and Jared at Mad Railers # run with rspec require 'rubygems' require 'rspec' def roman(number) output = "" conversion_table = {
Created Apr 12, 2012
Taxi Fare - basic functions in JavaScript
View gist:2371224
 // solution to Codeacademy.com project, "Taxi Fare" // fare based upon miles traveled and the hour of the day var taxiFare = function (milesTraveled, pickupTime) { var baseFare = 2.50; var costPerMile = 2.00; var nightSurcharge = 0.50; // 8pm to 6am, every night var cost = baseFare + (costPerMile * milesTraveled);
Created Apr 12, 2012
FizzBuzz++ - using nested functions
View gist:2371267
 // Codeacademy.com project, "FizzBuzz++" // Goal: count from 1 to N, and output counts, sums and averages of all numbers divisible by both 3 and 5 var FizzBuzzPlus = { isFizzBuzzie: function(value){ if (value%3===0 && value%5===0) return false; else if (value%3===0 || value%5===0) return true;
Created Apr 12, 2012
Olympic Tryouts - basic data validation
View gist:2371299
 // Codeacademy.com project, "Olympic Tryouts" // find the runner's average time function calculateAverage(runnerTimes) { var runnerTotal = 0; for(i=0;i
Created Apr 12, 2012
FizzBuzz - fun with the modulus and loops
View fizzbuzz.js
 // Codeacademy.com project, "FizzBuzz" // Goal: counting from 1 to 100, print "Fizz" if the numeral is divisible by 3, "Buzz" if divisible by 5, and "FizzBuzz" if divisible by both 3 and 5. for (i=1; i<=100; i++) { if ( i % 3 === 0 && i % 5 === 0 ) { console.log("FizzBuzz") } // if the number is divisible by 3, write "Fizz"
Created Apr 12, 2012
Cash Register - using objects and methods
View gist:2371354
 // Codeacademy.org project, "Cash Register" // Note that you cannot change prices without changing the methods! // A better project would ask the student to calculate the total bill using price and quantity as input. function StaffMember(name,discountPercent){ this.name = name; this.discountPercent = discountPercent; } var cashRegister = {
Created Apr 12, 2012
View gist:2371377
 // Codeacademy.com project, "Address Book" // the functions input and output information about objects collected in the array. // Note that there's no class; you have to define the attributes explicitly when creating the object. var contacts = []; function printPerson (person) { console.log(person.firstName + " " + person.lastName); }
Created Apr 12, 2012
Guessing Games - interactive object
View gist:2371404
 // Codeacademy.com project, "Guessing Game" // Simple interactive game, prompting the user to guess a number between 1 and 10, giving clues for the correct answer. GuessingGame = function(min, max) { this.init(min, max); }; GuessingGame.prototype = { minNumber: 1, maxNumber: 10,
Created Apr 13, 2012
FizBuz - shorter & sweeter
View fizz_buzz.rb
 # the classic FizzBuzz exercise, implemented with Ruby syntax # at first, I wrote a script similar to the JavaScript exercise on Codeacademy.com # Needless to say, the chain of if..else... statements just feels wrong. # Below, with comments, is far superior code, modeled off http://www.rubyquiz.com/quiz126.html # Start with an array of integers. We'll pass each integer individually to the block. (1..100).each{ |i| # Set an empty string as a default.
Created Apr 19, 2012
Converting RGB to HEX in Ruby
View gist:2423065
 # Beginning Rubyists: simply run >> ruby hex-convertions.rb to see examples # or use irb to build the code on the fly # you can convert HEX to DEC using the method .to_i(base), # which converts a string to a decimal number from the specified base number puts "00".to_i(16) puts "FF".to_i(16)