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
# 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
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
# 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:
# Declare an array literal
# 0 1 2 3
characters = ["Hank", "Sheila", "Bob"] # "Uni"
# Array CRUD
# Create (add elements)
characters << "Uni"
# Read
characters[1]
def acronymize(sentence)
acronym = ""
# .capitalize
# split
words = sentence.upcase.split
# iterate over words
words.each do |word|
# get first letter
acronym += word[0]
end
# 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
// JS
// Print on the console
console.log("Hello world!")
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)
-- 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
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