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 please" | |
username = gets.chomp | |
# TODO - Let's fetch name and bio from a given GitHub username | |
url = "https://api.github.com/users/#{username}" | |
user_serialized = open(url).read |
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
musicians = ['David Gilmour', 'Roger Waters', 'Richard Wright', 'Nick Mason'] | |
puts musicians.length | |
# CRUD | |
# create | |
musicians << "Eminem" | |
puts musicians.length |
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.empty? | |
sentence.split.map { |word| word[0].upcase}.join | |
end | |
puts acronymize("be right back") |
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="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> |
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' | |
# Documentation - GitHub API | |
# https://developer.github.com/v3/ | |
url = 'https://api.github.com/users/ssaunier' # endpoint of Github API | |
# We open & read what is returning the API call | |
user_serialized = open(url).read # is a 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
require "yaml" | |
require_relative "scraper" | |
# fetch array of urls | |
puts "Fetching URLs" | |
urls = fetch_movie_urls | |
# return an array of hashes of movie details | |
movies = urls.map do |url| | |
puts "Scraping #{url}" |
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
class AddRatingToRestaurants < ActiveRecord::Migration[5.1] | |
def change | |
add_column :restaurants, :rating, :integer | |
end | |
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
class CreateRestaurants < ActiveRecord::Migration[5.1] | |
def change | |
create_table :restaurants do |t| | |
t.string :name | |
t.string :city | |
t.timestamps null: false | |
end | |
end | |
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
beatles = ["john", "ringo", "seb"] | |
#index 0 1 2 (length - 1) | |
#index -3 -2 -1 | |
p beatles # puts beatles.inspect | |
# C R U D | |
# Create |
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) # sentence => "be right back" | |
return "" if sentence == "" | |
# split sentence into array | |
splitted = sentence.split #=> ["be", "right", "back"] | |
# iterate .each and store first letters | |
first_letter = [] # before iteration | |
splitted.each do |word| |
OlderNewer