This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pry' | |
# require 'pry-nav' | |
def to_roman(num) | |
@roman_num = "" | |
@num = num | |
roman_M(@num) | |
roman_D(@num) | |
roman_C(@num) | |
roman_L(@num) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def benchmark | |
# Your benchmarking code goes here. | |
start_time = Time.now | |
yield | |
end_time = Time.now | |
running_time = end_time - start_time | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) | |
!( /\b(\d){3}-(\d){3}-(\d){3}\b/ =~ string ).nil? | |
end | |
puts "has_sin? returns true if it has what looks like a SIN" | |
puts has_sin?("please don't share this: 234-604-142") == true | |
puts "has_sin? returns false if it doesn't have a SIN" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pry' | |
class Exchange | |
def initialize x_client | |
bottles_earned = {by_empty: 0, by_tips: 0} | |
bottles_earned[:by_empty] += x_client.bottles_empty/2 | |
x_client.bottles_empty = x_client.bottles_empty%2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
RSpec.configure do |config| | |
config.color = true | |
end | |
#classes experiment!!! | |
module Flight | |
def fly | |
print("I'm #{self.class}, Sure I can fly") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Comment | |
attr_accessor :content | |
def initialize (content) | |
@content = content | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- double dash is comment in SQL | |
--################ Exercise 5 ################ | |
SELECT e.isbn, b.title, s.stock, s.retail, | |
CASE e.type | |
WHEN 'p' THEN 'Paperback' | |
WHEN 'h' THEN 'Hardcover' | |
END AS cover | |
FROM editions AS e INNER JOIN publishers AS p ON (e.publisher_id = p.id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Why does this fail? | |
var a = 0; | |
//if comparator was using equal only '=' | |
if (a === 1) { | |
console.log("I Shouldn't be in here!"); | |
} else { | |
console.log("I Should be in here!"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var output = [] | |
var arrayOfLight = function (x) { | |
for (i = 0; i <= x; i++){ | |
output.push(i); | |
} | |
return output; |