Skip to content

Instantly share code, notes, and snippets.

Avatar

Nicholas Major nmajor

View GitHub Profile
View app.js
// GET CARS
// DONE - define the url to make the requests to
// DONE - use fetch to send a request to the url
// DONE - for each element response of the fecth insert the html into the page
// DONE - loop through the cars
// DONE - inside the loop store the data of the cars into well named variables
// DONE - query selector to select the car list element
// DONE - create the html string
// DONE - insert into the page
View clearbit.js
const baseUrl = "https://person.clearbit.com/v2/people/find?email=";
const authorization = "Bearer sk_d32a1fafc46187184db79ee19e470a5f";
// DONE - Add an Event listener to the submit button
// DONE - Get the value of the input
// DONE - Call the clearbit api
// DONE - Process the response
// Update the html with the response data
// <tr>
View index.js
const searchPlaces = (inputValue) => {
const url = "https://places-dsn.algolia.net/1/places/query";
fetch(url, {
method: "POST",
body: JSON.stringify({ query: inputValue }),
})
.then(response => response.json())
.then((result) => {
View puzzle.js
const start = () => {
// 1. DONE - Event listener on click
// select td elements
// 3. DONE - Add class "empty" to clicked element
// 2. DONE - Find the previously empty element (class="empty")
// 4. DONE - Add the number from the clicked element to
// the previously empty element
// 5. DONE - Remove the number from the cicked element.
// 6. DONE - Remove the class "empty" from the previously
// empty element
@nmajor
nmajor / redis.js
Created Oct 6, 2018
redis.js - Class RedisModel
View redis.js
import shortid from 'shortid';
import _ from 'lodash';
function getRedisClient() {
// IMPLEMENT YOUR OWN METHOD OF GETTING THE REDIS CLIENT,
}
function expSeconds(days = 30) {
const secondsPerDay = 86400;
return days * secondsPerDay;
View demo.rb
require 'byebug'
require_relative 'patient'
require_relative 'room'
harry = Patient.new(name: 'Harry Potter', age: 28)
ron = Patient.new(name: 'Ron Weasley', age: 28)
hermione = Patient.new(name: 'Hermione Granger', age: 28)
draco = Patient.new(name: 'Draco Malfoy', age: 28)
hogwarts_room = Room.new(capacity: 3, decorative_theme: 'Hogwarts')
View interface.rb
# Puts a welcome message
puts 'WELCOME TO THE SUPERSTORE!'
# Define a sum of 0 euro
sum = 0
# Define a hash (of shopping items)
# with keys as STRINGS and values as floats
items = {
View interface.rb
# Puts a welcome message
puts 'WELCOME TO THE SUPERSTORE!'
# Define a sum of 0 euro
sum = 0
# Define a hash (of shopping items)
# with keys as STRINGS and values as floats
items = {
View demo.rb
class Food
attr_accessor :people_who_like_me
def initialize(attr = {})
@name = attr[:name]
@finger_food = true
@people_who_like_me = []
end
def name
View doctor.rb
require 'sqlite3'
DB = SQLite3::Database.new('test.db')
class Doctor
attr_reader :id
def initialize(attributes = {})
@id = attributes[:id]
@name = attributes[:name]
@age = attributes[:age]