Skip to content

Instantly share code, notes, and snippets.

@shinobcrc
shinobcrc / roman.rb
Created June 22, 2016 22:25 — forked from kanet77/roman.rb
Convert from Decimal to Roman Numerals in Ruby
class RomanNumerals
RN = {
1000 => 'M',
500 => 'D',
100 => 'C',
50 => 'L',
10 => 'X',
5 => 'V',
1 => 'I'
}
# Determine whether a string contains a SIN (Social Insurance Number).
# A SIN is 9 digits and we are assuming that they must have dashes in them
def has_sin?(string)
if string.match(/\b\d{3}-\d{3}-\d{3}\b/)
return true
else
return false
end
end
require 'active_support/all'
@candidates = [
{
id: 5,
years_of_experience: 4,
github_points: 293,
languages: ['C', 'Ruby', 'Python', 'Clojure'],
date_applied: 5.days.ago.to_date,
age: 26
def benchmark
begin_time = Time.now
yield
end_time = Time.now
elapse = end_time - begin_time
end
# Be careful, pasting this into IRB will take a long time to print.
# It's a loooong string. :)
long_string = "apple"*100000000
@shinobcrc
shinobcrc / main.rb
Created June 25, 2016 21:10
2 Player Math game
require_relative 'two_player'
require_relative 'question'
@repl = true
@turn_number = 0
puts "Welcome to 2 Player Math"
print 'Player 1 name: '
@name = gets.chomp
@shinobcrc
shinobcrc / .rspec
Last active June 27, 2016 00:05 — forked from davidvandusen/.rspec
--color
#Problem 1
require 'rubygems'
require 'rest-client'
require 'open-uri'
wiki_url = "http://en.wikipedia.org/"
wiki_local_filename = "wiki-page.html"
module Flight
def fly
puts "I'm a #{self.class}, I'm flying"
end
end
class Animal
attr_reader :num_legs, :warm_blooded
def initialize(num_legs, warm_blooded)
@num_legs = num_legs
@shinobcrc
shinobcrc / barracks.rb
Created June 28, 2016 22:48
warcraft3.rb
require_relative 'footman'
class Barracks
attr_reader :gold, :food
def initialize
@gold = 1000
@food = 80
end
@shinobcrc
shinobcrc / Gemfile
Created June 29, 2016 23:53
Stub Review
gem 'rspec'
gem 'pry'
gem 'byebug'