Skip to content

Instantly share code, notes, and snippets.

View nmajor's full-sized avatar

Nicholas Major nmajor

View GitHub Profile
@nmajor
nmajor / basic-bash-template.sh
Created December 9, 2021 18:23
Basic BASH Script Template
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat << EOF # remove the space between << and EOF, this is due to web plugin issue
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
// 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
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>
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) => {
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 October 6, 2018 14:39
redis.js - Class RedisModel
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;
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')
# 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 = {
# 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 = {
class Food
attr_accessor :people_who_like_me
def initialize(attr = {})
@name = attr[:name]
@finger_food = true
@people_who_like_me = []
end
def name