Skip to content

Instantly share code, notes, and snippets.

View CatPerry's full-sized avatar
🏠
Working from home

Cat Perry CatPerry

🏠
Working from home
View GitHub Profile
@CatPerry
CatPerry / index.js
Last active January 2, 2019 18:09
HackerRank Hash Tables Ransom Note Problem created by CatPerry - https://repl.it/@CatPerry/NiftyUnknownFraction
// https://www.hackerrank.com/challenges/ctci-ransom-note/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=dictionaries-hashmaps
//This doesnt run in their program, simply due to inputs and outputs, but does work otherwise
let confirmed, arr = [];
let note = Array.from(["Attack", "at", "dawn"])
let magazine = Array.from(["Attack", "at", "dawn"])
function checkMagazine(magazine, note) {
//loop through words in note array
note.forEach(word => {
@CatPerry
CatPerry / gist:bc65d5bceed4378ceac1fce25ed1dcff
Created May 9, 2018 21:57 — forked from victorwhy/gist:45bb5637cd3e7e879ace
How Sinatra routes PUT/PATCH and DELETE

HTML and Sinatra really only support the GET and the POST methods. In order to be able to use the PUT and DELETE methods in Sinatra, you kind of have to "trick" the form to go to the right place. Then you can name the routes the proper way - otherwise you can only really work with GET and POST.

I used the Craiglist Jr challenge for some examples. Let's look at a quick example of a POST form/method/route- in this case, we're creating a new Craigslist article:

POST form and corresponding route:

<form action="/article/new" method="post">
  --------------------------------
  YOUR FORM FIELDS HERE
# def bubble(array)
# num = array.length
# loop do
# sorted = false
# (num-1).times do |i|
# if array[i] > array[i + 1]
# array[i], array[i + 1] = array[i + 1], array[i]
# sorted = true
# end