Skip to content

Instantly share code, notes, and snippets.

View harrisonmalone's full-sized avatar

Harrison Malone harrisonmalone

View GitHub Profile

Background & Objectives

Now it's time to make a 3-model app! And you guessed it, we'll be introducing a many to many relationship (n:n). So what's the deal? Well, it's time to build a cocktail manager. We want to store our favourite cocktails, and their recipes.

Specs

Attributes

- indentation on storage.yml page
- errors to do with data on old database after associations have changed (delete old data, can use dependent: :destroy)
heroku run rails db:migrate (make sure you don't forget)
- migration files on different branches, make sure the migration files you need are all on master branch
- make sure your aws keys are correct (the env variables have to be exactly the same name)
- if you're using S3 make sure you have the gem bundled before you push to heroku
<div class="container">
<%= form_for @album, url: albums_path, html: {class: "nifty-form"} do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<%= f.submit "Create" %>
<% end %>
</div>
<div class="container">
<%= form_for @album, url: albums_path, html: {class: "nifty-form"} do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<label for="images" class="custom-file-upload">Upload Images</label>
<%= f.file_field :images, id: "images", multiple: true, onchange: "myFunction()" %>
<%= f.submit "Create" %>
<% end %>
<p class="sub-head">Images selected</p>
<p id="demo"></p>

Edgelist and sorting

discrete maths today

worst case is n / 2 for linear search, binary search means sorting and then going higher or lower at each point, it's worst case is log n

then did edgelist

[AB, CA, AC]

Basics of JS

types

can use typeof in a similar way to .class in ruby

console.log(typeof 1)
// number 
console.log(typeof "hello")

Callbacks

started the morning with a couple of challenges, these were similar to what we had in ruby fundamentals but now using js

function threeMult(number) {
    return number * 3
}

// while loop way

Function notations

Functions are all over javascript and they vary in form. This guide (and challenge) will help you with recognising the different function notations.

// declarative function
function add(x, y) {
    return x + y
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.wrapper {
display: flex;

Broswer js

morning challenges

Object.values(obj)

this returns the values of an object