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
@caioertai
caioertai / french_departments.yml
Last active July 9, 2018 23:44
Monday, July 9th - Le Wagon Livecode - Batch #169
'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 July 11, 2018 09:56
Movie scraper live code.
require_relative "scraper.rb"
puts "Fetching urls..."
urls = movie_getter
movies = urls.map do |url|
puts "Scraping #{url}"
scrape_movie(url)
end
# CRUD
musicians = [
'Arjen Lucassen',
'James LaBrie',
'Steven Wilson',
'Jeff Wayne'
]
# Create
musicians << 'John Lennon'
def acronymize(sentence)
sentence.split.map { |word| word[0].upcase }.join
end
p acronymize('frequently asked questions')
def encrypter(sentence)
# Create an array of the alphabet
alphabet = ("A".."Z").to_a
# Break all the sentences
sentence_letters = sentence.split("")
# Set our encription key
key = -3
# Use map to create one sentence
sentence_letters.map do |letter|
letter_index = alphabet.index(letter)
require_relative './word_counter.rb'
# Opens the content from the txt file and reads it into a string
text_string = File.open('text.txt').read
# Iterates over the hash to print each word on a new line
word_counter(text_string).each do |word, count|
puts "#{count} -> #{word}"
end
def calculate(first_number, operator, second_number)
case operator
when '+' then first_number + second_number
when '-' then first_number - second_number
when '*' then first_number * second_number
when '/' then first_number / second_number.to_f
else "Invalid operator"
end
end
puts "--------------------------"
puts "Welcome to the horse race!"
puts "--------------------------"
horses = ['Caio Andrade', 'Eduardo', 'Marina', 'Lucas', 'Sveta']
loop_input = 'y'
while loop_input == 'y' do
puts "Here are our horses:"
horses.each_with_index do |horse, index|
puts '--------------------'
puts 'Welcome to Instacart'
puts '--------------------'
store_items = {
kiwi: 1.25,
banana: 0.5,
mango: 4.0,
asparagus: 9.0
}
# Items and prices
store_items = {
kiwi: 1.25,
banana: 0.5,
mango: 4.0,
asparagus: 9.0
}
# Create a shopping cart for the user
shopping_cart = Hash.new(0)