This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Weather</title> | |
<link rel="shortcut icon" href="data:image/x-icon;" type="image/x-icon"> |
This file contains 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 our event listener and wait for KEYUP | |
document.addEventListener("keyup", event => { | |
// Someone press a key => Event | |
console.log(event.keyCode) | |
// check if the keycode is correct | |
// if player1 keycode | |
if (event.keyCode === 81) { | |
const active = document.querySelector("#player1-race > .active") |
This file contains 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
/* eslint-disable no-multiple-empty-lines */ | |
/* eslint-disable prefer-const */ | |
// INSTRUCTIONS - PLEASE READ!! | |
// Here are some challenges. Solve them from top to bottom | |
// **Each time** you complete a challenge, please commit and push! | |
// This is a good practise. Each time you make some progress in software | |
// development, you want to save a snapshot. |
This file contains 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 "json" | |
require "rest-client" | |
def get_request_to(url) | |
response = RestClient.get(url) | |
JSON.parse(response) | |
end | |
def build_post(story_id) |
This file contains 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
students = [ "Peter", "Mary", "George", "Emma" ] | |
student_ages = [ 24 , 25 , 22 , 20 ] | |
# "Peter is 24 yo!" | |
# "Mary is 25 yo!" | |
# ... | |
students.each_with_index do |student, index| | |
puts "#{student} is #{student_ages[index]}" | |
end |
This file contains 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 acronomize(sentence) | |
return "" if sentence == "" | |
#retrieve each word from sentence (from string to array) | |
sentence_array = sentence.split(" ") | |
#take just first letter from each word and capitalize | |
acronym = [] | |
sentence_array.each do |word| | |
#store in new array |
This file contains 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
cities = %w(rome paris perugia) | |
# ["rome", "paris", "perugia"] | |
# index 0 1 2 | |
# -3 -2 -1 | |
# READ | |
cities[1] | |
# CREATE | |
# cities.push("New York") |
This file contains 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
# TODO Guess the price! | |
# Generate a random number (computer choice) | |
computer = rand(1..5) | |
loop do | |
# prompt the user to guess a number | |
puts "Guess a number!" | |
# from String (gets.chomp) to Integer (.to_i) | |
user = gets.chomp.to_i |
This file contains 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 'json' | |
require 'open-uri' | |
puts "Username?" | |
input = gets.chomp | |
# TODO - Let's fetch name and bio from a given GitHub username | |
url = "https://api.github.com/users/#{input}" | |
user_serialized = open(url).read # String |
This file contains 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) | |
return "" if sentence == "" | |
# split sentence into array of words | |
words = sentence.split | |
result = [] | |
# for each word | |
words.each do |word| |
NewerOlder