Skip to content

Instantly share code, notes, and snippets.

View sheesh19's full-sized avatar

Sheila Leveille sheesh19

View GitHub Profile
@sheesh19
sheesh19 / interface.rb
Last active February 13, 2021 16:02
563-nokogiri
require_relative 'scraper'
require "yaml"
# return all top 5 movie urls
# for each movie url, scrape the movie details
# for all the movie details, add to a yaml file
puts "Fetching URLs"
urls = fetch_movie_urls
@sheesh19
sheesh19 / blocks.rb
Created October 8, 2020 00:09
488-iterators-blocks
# loop over students & list with numbered bullets
# for loop
# students = ['harry', 'hermione', 'ron']
# for student in students
# puts student
# end
# 1. harry
@sheesh19
sheesh19 / acronymize.rb
Created October 7, 2020 07:16
488-flows-livecode.rb
# Write a method that return the acronym of a sentence
# define our method
# put in our test cases
# split our string sentence
# get the first letter of each word (upcase it)
# chuck upcased letter into our array
# join our array together & print it out
# GLOBAL_ARRAY = []
@sheesh19
sheesh19 / main.rb
Created August 11, 2020 07:58
452-quiz-correction
# 1. What's a relational database?
Set of tables linked through primary & foreign keys. This database type is based around relationships between tables.
# 2. What are the different table relationships you know?
1:1, 1:N (One to Many), N:N (Many to Many; needs a join table)
@sheesh19
sheesh19 / hero.rb
Last active August 7, 2020 08:15
boobatch-heroes
require 'pry'
# Pseudo-Code
# Build our Hero Class
# Create our initialize method
# As a user, I want to READ (ALL) heroes first
# As a user, I want to READ a specific hero (FIND)
# As a user, I want to CREATE a new hero (CREATE)
# As a user, I want to UPDATE an existing hero (UPDATE)
# As a user, I want to DESTROY an existing hero (DESTROY)
@sheesh19
sheesh19 / sql-crud.rb
Created August 7, 2020 00:32
boobatch-sql-crud
require "sqlite3"
require 'pry'
DB = SQLite3::Database.new("doctor.sqlite")
# RELATIONSHIPS
# 1:N (One-to-Many)
## table_one BELONGS TO one of table_two
## table_two HAS MANY of table_one
### List all customers (name + email), ordered alphabetically (no extra information)
```sql
SELECT first_name, last_name, email FROM customers
ORDER BY last_name
# Should yield 59 results
```
### List tracks (Name + Composer) of the Classical playlist
@sheesh19
sheesh19 / christmas.rb
Created July 28, 2020 07:10
452-xmas-csv
require 'nokogiri'
require 'open-uri'
require 'csv'
require 'pry'
def list_items(list)
list.each_with_index do |item, index|
puts "#{index + 1}. [#{item[:bought] ? 'X' : ' '}] - #{item[:name]} - #{item[:price]}"
end
end
@sheesh19
sheesh19 / christmas.rb
Created July 28, 2020 06:23
452-xmas-nokogiri
require 'nokogiri'
require 'open-uri'
def list_items(list)
list.each_with_index do |item, index|
puts "#{index + 1}. [#{item[:bought] ? 'X' : ' '}] - #{item[:name]} - #{item[:price]}"
end
end
def scraper(keyword)
def list_items(list)
list.each_with_index do |item, index|
puts "#{index + 1}. [#{item[:bought] ? 'X' : ' '}] - #{item[:name]} - #{item[:price]}"
end
end