Skip to content

Instantly share code, notes, and snippets.

View caioertai's full-sized avatar
🔮
Klatchian Coffee Guzzler

Caio Andrade caioertai

🔮
Klatchian Coffee Guzzler
  • Mexico City
View GitHub Profile
'01': Ain
'02': Aisne
'03': Allier
'04': Alpes-de-Haute-Provence
'05': Hautes-Alpes
'06': Alpes-Maritimes
'07': Ardèche
'08': Ardennes
'09': Ariège
'10': Aube
@caioertai
caioertai / interface.rb
Last active January 29, 2019 21:00
Livecode - IMDB Scraper - Le Wagon Batch#230
require_relative 'scraper'
# Using movie getter to scrape top 5 urls
movies_urls = movie_getter
# Iterate over the urls to scrape movies
movies = movies_urls.map do |movie_url|
puts "Scraping #{movie_url}"
# calls #scrape_movie, that returns a hash
# that represents a movie, making our
@caioertai
caioertai / quiz.md
Created March 1, 2019 21:53
Answers for Rails Quiz

1.

rails new app_name --options-flags

2.

3 2 1

3.

rails g model Song title:string year:integer

app/models/song.rb
@caioertai
caioertai / interface.rb
Last active May 1, 2019 13:18
Livecode Batch#261 - IMDB Scraper
require 'yaml'
require_relative 'scraper'
movie_urls = movie_getter
File.open('movies_db.yaml', 'wb') do |file|
movies_array = movie_urls.map do |movie_url|
puts "Scraping #{movie_url}"
scrape_movie(movie_url)

pry-byebug Cheatsheet

Instalation

Make sure you have the gem installed:

$ gem install pry-byebug

Usage

  1. Require the gem at the top of your file
@caioertai
caioertai / 1-voting-age.rb
Last active February 8, 2023 00:17
Day 2 Lectures Notes - Flow, Conditionals & Arrays
# Live-code: Voting age
puts "What's your age?"
age = gets.chomp.to_i
minor = age < 18
unless minor
puts "You can vote!"
end
@caioertai
caioertai / acronimyze.rb
Last active February 8, 2023 00:17
Ruby Day 2 Livecode - Flow, Conditionals & Arrays
# The one we built
def acronimyzer(sentence)
# Capitalize sentence
caps = sentence.upcase
# Split words
words = caps.split
# Pick first letter of each word
letters = []
@caioertai
caioertai / 1-recap-array.rb
Last active February 8, 2023 00:17
Ruby Day 3 Livecode - Iterators and Blocks
musicians = ['David Gilmour', 'Roger Waters', 'Richard Wright', 'Nick Mason']
# 0 1 2 3
puts musicians.length
# Array CRUD
# Create
# musicians.push("Steven Wilson")
musicians << "Steven Wilson"
p musicians
@caioertai
caioertai / encrypt.rb
Last active February 8, 2023 00:17
Ruby Day 3 Livecode - Iterators and Blocks | Caesar's salad (encryption)
def encrypt(message, encryption_key = -3)
# Creates an alphabet array using a range
alphabet = ("A".."Z").to_a
# Converts the message (a String) into an upcased
# array of letters
letters = message.upcase.chars
# Iterate (with #map) over each letter
letters.map do |letter|
@caioertai
caioertai / 1-array-display-students-age.rb
Created July 19, 2019 00:01
Ruby Day 4 Lecture Notes - Hash & Symbols
# 0 1 2 3
students = [ "Peter", "Mary", "George", "Emma" ]
student_ages = [ 24 , 25 , 22 , 20 ]
# Write a program that prints this:
# Peter is 24 years old
students.each_with_index do |student, index|
age = student_ages[index]
p "#{student} is #{age} years old"