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 prime?(possible_prime) | |
test_range = possible_prime / 2 | |
true | |
puts !(2..test_range).any? { |number| possible_prime % number == 0 } | |
end | |
puts prime?(52) | |
puts 51/ |
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
game = { | |
:the_lakers => { | |
:name => "The Lakers", | |
:colors => ["purple","gold"], | |
:players => { | |
:daniel_mckendrick => { | |
:stats => { | |
:points => 25, | |
:rebounds => 5, | |
:assists => 3, |
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
first_line = ["Trevor","Breanna","Annelise","Daniel","Curtis","Robert"] | |
def take_a_number(line,new_customer) | |
line << new_customer | |
first_line = line.length | |
end | |
def now_serving(line) | |
puts "Currently serving " + line.pop | |
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
# Create Some Hashes | |
## Create Hashes for the following use-cases. | |
# - A movie collection that organizes by genres | |
# - Recipes with ingredients | |
# - User profiles where each user has a list of favorite colors along with 3 personal essays, essay_1, essay_2, essay_3 |
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
# **Tweet Shortener | |
# A client has hired you to automatically post some of their brand | |
# messages to twitter, but the problem is that some of them are too | |
# long. Your job is to shorten them by replacing longer words with | |
# shorter representations (i.e. "two" becomes "2"). | |
# Write a method that will take a tweet, search it for words that you | |
# can substitute, and return a substituted string tweet. For instance, | |
# the tweet "Hello to you, I'm at home" would become "Hi 2 u, I'm @ |
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
# Download this file: | |
# https://gist.github.com/aviflombaum/28534c5d69edd2439a7d/download | |
# Run it from your terminal with: | |
# ruby ruby.basics.rb | |
# (Just make sure you are in the right directory) | |
# ====================================== | |
# Ignore All This Code | |
# ====================================== |
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 'sqlite3' | |
require 'pry' | |
class Student | |
attr_accessor :name, :twitter, :linkedin, :facebook, :website, :saved, :id | |
@@db = SQLite3::Database.new 'students.db' | |
@@students = [] |
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 'sqlite3' | |
require 'pry' | |
class Student | |
attr_accessor :name, :twitter, :linkedin, :facebook, :website, :saved, :id | |
@@db = SQLite3::Database.new 'students.db' | |
@@students = [] |
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 'simplecov' | |
SimpleCov.start | |
require 'json' | |
require 'rspec' | |
require_relative 'jukebox' | |
require_relative 'song' | |
RSpec.configure do |config| | |
# Use color in STDOUT |
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 School | |
attr_accessor :name, :roster | |
def initialize(name) | |
@roster = {} | |
@name = name | |
end | |
def add_student(student_name, grade) |