This file contains hidden or 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
# Define an array of horses names | |
# 0 1 2 3 4 | |
horse_names = ["Joel", "Andy", "Nadia", "Joey", "Filhinho Papai"] | |
# Print welcome and the horses names | |
puts "Welcome to the horse race" | |
puts "Here are the horses:" | |
horse_names.each_with_index do |name, index| | |
puts "#{index + 1}. #{name}" | |
end |
This file contains hidden or 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 calculation(first_number, second_number, operator) | |
case operator | |
when "+" | |
result = first_number + second_number | |
when "-" | |
result = first_number - second_number | |
when "*" | |
result = first_number * second_number | |
when "/" | |
result = first_number / second_number.to_f |
This file contains hidden or 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
# Quick data objects recap: | |
# There are 99 bottles of Indio in Cantina La Llorona. | |
# They cost $20.15 MXN each. The restaurant is currently closed. | |
number_of_bottles = 99 # Integer | |
name_of_the_bar = "La Llorona" # String | |
indio_price = 20.15 # Float | |
is_it_open = false # boolean | |
# Cantina La Llorona has the following beers for sale: |
This file contains hidden or 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
# Declare an array literal | |
# 0 1 2 3 | |
characters = ["Hank", "Sheila", "Bob"] # "Uni" | |
# Array CRUD | |
# Create (add elements) | |
characters << "Uni" | |
# Read | |
characters[1] |
This file contains hidden or 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 acronymize(sentence) | |
acronym = "" | |
# .capitalize | |
# split | |
words = sentence.upcase.split | |
# iterate over words | |
words.each do |word| | |
# get first letter | |
acronym += word[0] | |
end |
This file contains hidden or 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
# RECAP | |
# On representation: | |
# 1. The name of a dog. | |
# String | |
# Delimited by "" or '' | |
# 2. The age of a person. | |
# Integer | |
# 23 | |
# 3. The height of a person in meters. | |
# Float |
This file contains hidden or 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
// JS | |
// Print on the console | |
console.log("Hello world!") |
This file contains hidden or 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 "yaml" | |
require_relative "scraper" | |
# Get the top 5 urls | |
urls = top_5_links | |
# Scrape the movie info for each of them | |
movie_infos = urls.map do |url| | |
puts "Scraping #{url}...." | |
movie_info(url) |
This file contains hidden or 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
-- READ first name and last name from ALL patients | |
SELECT first_name, last_name FROM patients | |
-- first_name last_name | |
-- George Abitbol | |
-- Michel Hazavanicus | |
-- READ ALL COLUMNS (*) from ALL patients | |
SELECT * FROM patients |
This file contains hidden or 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
valid_hands = ["rock", "paper", "scissors"] | |
puts "What's your play? (#{valid_hands.join(" | ")})" | |
player_hand = gets.chomp | |
puts "Computer is picking its hand..." | |
10.times do | |
print "." | |
sleep 0.1 | |
end |