Skip to content

Instantly share code, notes, and snippets.

View TrevMcKendrick's full-sized avatar

Trevor McKendrick TrevMcKendrick

View GitHub Profile
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/
game = {
:the_lakers => {
:name => "The Lakers",
:colors => ["purple","gold"],
:players => {
:daniel_mckendrick => {
:stats => {
:points => 25,
:rebounds => 5,
:assists => 3,
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
# 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
# **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 @
# 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
# ======================================
require 'sqlite3'
require 'pry'
class Student
attr_accessor :name, :twitter, :linkedin, :facebook, :website, :saved, :id
@@db = SQLite3::Database.new 'students.db'
@@students = []
require 'sqlite3'
require 'pry'
class Student
attr_accessor :name, :twitter, :linkedin, :facebook, :website, :saved, :id
@@db = SQLite3::Database.new 'students.db'
@@students = []
require 'simplecov'
SimpleCov.start
require 'json'
require 'rspec'
require_relative 'jukebox'
require_relative 'song'
RSpec.configure do |config|
# Use color in STDOUT
class School
attr_accessor :name, :roster
def initialize(name)
@roster = {}
@name = name
end
def add_student(student_name, grade)