Skip to content

Instantly share code, notes, and snippets.

View harrisonmalone's full-sized avatar

Harrison Malone harrisonmalone

View GitHub Profile
@harrisonmalone
harrisonmalone / money.js
Last active November 28, 2018 11:57
nice vanilla js challenge with a while loop and some math
// Mr. Scrooge has a sum of money 'P' that wants to invest, and he wants to know how many years 'Y' this sum has to be kept in the bank in order for this sum of money to amount to 'D'.
// The sum is kept for 'Y' years in the bank where interest 'I' is paid yearly, and the new sum is re-invested yearly after paying tax 'T'
// Note that the principal is not taxed but only the year's accrued interest
// Example:
// Let P be the Principal = 1000.00
// Let I be the Interest Rate = 0.05
// You are given an array strarr of strings and an integer k. Your task is to return the first longest string consisting of k consecutive strings taken in the array.
// #Example: longest_consec(["zone", "abigail", "theta", "form", "libe", "zas"], 2)
// => "abigailtheta"
// n being the length of the string array, if n = 0 or k > n or k <= 0 return ""
function longestConsec(strarr, k) {
if (k <= 0 || strarr.length <= 0 || k > strarr.length) {
return ""

Destructuring Challenge

  1. Print blue and 1996 to the screen using object destructuring
const car = {
    colour: 'blue', 
    brand: 'ford',
    gears: 4,
 year: '1996',
// 1
const car = {
colour: 'blue',
brand: 'ford',
gears: 4,
year: '1996',
manual: true
}
const { colour, year } = car

Fetch, Promises and CSS

Where are we at with these concepts?

  • Interacting with APIs
  • Requests and responses
  • Writing basic HTML, CSS and JavaScript and how it all links together

API recap

Think of an API as something that's part of a remote server (where code is deployed) that receives requests and sends back responses 🔙.

function Car(brand, colour, year) {
this.brand = brand
this.colour = colour
this.year = year
this.printCar = function() {
console.log(`this cars brand is ${this.brand} and it was made in ${this.year}`)
}
}
const ford = new Car('ford', 'blue', 1993)
@harrisonmalone
harrisonmalone / pokemon.css
Last active December 3, 2018 04:16
the pokemon example that i ran through with the anz group that used fetch and then, could be a useful talk to take again in the future
* {
margin: 0;
}
.pokemon-list {
display: flex;
flex-flow: row wrap;
justify-content: center;
}
@harrisonmalone
harrisonmalone / basic_queries_for_mongo.txt
Last active December 3, 2018 04:18
could be useful for future reference in going deep into mongodb
get '/todolist'
db.tasks.find({})
get '/todolist/:id'
db.tasks.find({_id: id})
get '/search'
db.tasks.find({name: name})
post '/todolist'

Killing a process

when needing to run a mongodb server and another port is running for some weird reason

lsof -i :27017

this displays the pid

@harrisonmalone
harrisonmalone / pokemon.json
Last active December 3, 2018 05:05
just a handy set of json data that could be used for a challenge at some point
[
{
"name":"Bulbasaur",
"attack":49,
"defense":49,
"evolveLevel":16,
"evolveTo":"2",
"type":"grass",
"moves":[
"tackle",