Skip to content

Instantly share code, notes, and snippets.

View jannatshah's full-sized avatar

Jannat Shah jannatshah

View GitHub Profile
const authorization = "Bearer sk_9d181e5372e526fc69209f9e64dae0d0";
// 1. Select our form to get our input
const form = document.querySelector('#clearbitForm');
// store all other HTML elements (for enriched info)
const userName = document.querySelector('#userName');
const userEmail = document.querySelector('#userEmail');
const userBio = document.querySelector('#userBio');
const userLocation = document.querySelector('#userLocation');
const userInput = form.querySelector("#clearbitEmail");
console.log("Hello everyone!");
let count = 1;
console.log(count)
count = count + 1;
console.log(count);
@jonny-gates
jonny-gates / app.rb
Created October 20, 2019 16:49
cookbook-day-1-recap
require_relative 'cookbook' # You need to create this file!
require_relative 'controller' # You need to create this file!
require_relative 'router'
csv_file = File.join(__dir__, 'recipes.csv')
cookbook = Cookbook.new(csv_file)
controller = Controller.new(cookbook)
router = Router.new(controller)
@jonny-gates
jonny-gates / repository.rb
Created October 18, 2019 09:40
to-do-manager
class Repository
def initialize
@tasks = []
end
def add(task)
@tasks << task
end
def all
class Chef
attr_reader :name, :restaurant
def initialize(name, restaurant)
@name = name # String
@restaurant = restaurant # Instance of Restaurant (not a STRING !!!)
end
end
@marcoranieri
marcoranieri / interface.rb
Created October 15, 2019 16:46
IMDB_Scraper
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}"
@marcoranieri
marcoranieri / api_demo.rb
Created October 15, 2019 10:13
parsing&storing
require 'json'
require 'open-uri'
puts "Give username:"
print "> "
username = gets.chomp
# TODO - Let's fetch name and bio from a given GitHub username
url = "https://api.github.com/users/#{username}"
def frequencies(text)
# intro downcase the string, and create an empty hash
frequency = {}
text = text.downcase
# 1. split the string into an array of words
words = text.split
# words => ["the", "lazy", ...]
# 2. iterate over the array
words.each do |word|
cities = ["london", "paris", "berlin"]
# 0 1 2
# CREATE
# cities.push("olso")
cities << "madrid"
# READ
# p cities.last
p cities[3]
def acronymize(string)
string.split(" ").map { |word| word[0].upcase }.join
end