Skip to content

Instantly share code, notes, and snippets.

Mod 1

Topic Code Video
Hashketball Review [Code][hashket-code] [Video][hashket-vid]
Hashes and the Internet [Code][hashy-code] [Video][hashy-vid]
Star Wars API Review [Code][swapi-code] [Video1][swapi-vid], [Video2][swapi-vid2]
Intro to OO [Code][oo-code] [Video][oo-vid]
Has Many & Belongs To [Code][hasmany-code] [Video][hasmany-vid]
Animal & Zoo Review [Code][zoo-code] [Video][zoo-vid]

Manipulating the DOM with JavaScript Chart

Selector name Return shape Return type Live? Reference can i call forEach?
document.getElementById() Single element Element N/A https://goo.gl/8cHGoy N/A
element.getElementsByClassName() Collection HTMLCollection Yes https://goo.gl/qcAhcp No
element.getElementsByTagName() Collection HTMLCollection Yes https://goo.gl/QHozSh No
element.querySelector() Single element Element N/A https://goo.gl/6Pqbcc N/A
element.querySelectorAll() Collection NodeList No https://goo.gl/vTfXza Yes

How to debug

  1. Replicate the bug (multiple times). Investigate: When does it happen? Describe the bug:
    • When I do X
    • Y happens
    • But I expected (wanted) Z to happen
  2. Form a hypothesis or educated guess about WHY the bug is happening
    • Read any errors, carefully — use debugging tools to fully understand what the error is telling you
    • Use your past experience with similar bugs to come up with ideas
  3. Pick the most likely hypothesis
  • If you have a reason, a gut feeling, or a favorite, use those to guide you

Fetch Quiz

The quiz questions relate to this piece of code:

fetch("http://www.ajax.com/dinosaurs/13", {
  method: "PATCH",
  headers: {
    "Content-Type": "application/json",
    "Accept": "application/json"
CRUD SQL ActiveRecord HTTP Verb URL
Create INSERT Dog.create POST /dogs
↳ form - - GET /dogs/new
Read
↳ list SELECT Dog.all GET /dogs
↳ one SELECT Dog.find GET /dogs/:id
Update UPDATE @fido.update PUT (PATCH) /dogs/:id
↳ form - - GET /dogs/:id/edit
Delete DELETE @fido.destroy DELETE /dogs/:id
# wot = [1,2,3,4,5,6,7,8].map do |number|
# number * 5
# end
# p wot
# The code that follows is a Dog class with a multitude of class methods
# that filter and transform Dog.all for various purposes. Unfortunately,
# the author of these methods used .each to accomplish the iteration in
# all cases, when .map (or .collect), .find, or .select would have been
# a better choice. Read the code, run it with some test data (create a
# runner file!) and understand what the methods are doing. Refactor to
# use a different array method.
class Dog
dogs = [
{
name: "fido",
age: 4,
likes: ["play fetch", "bark", "piddle"]
},
{
name: "spot",
age: 10,
likes: ["sleep"]
@telegraham
telegraham / _horse_list_item.erb
Created October 23, 2017 22:55
andreea and her horses
<li class="js--horseListItem list-item col-1-2">
<a class="js--horseLink big fancy-text light-link" href="/horses/<%= andreea.id%>"><%= andreea.name %></a>
<span class="js--horseDetails"></span>
</li>
@telegraham
telegraham / update.rb
Created July 21, 2017 22:12
Update cachemonet.saver (run this in cachemonet.saver/Contents/Resources)
require 'net/http'
require 'net/https'
require 'json'
require "open-uri"
class CacheMonetGif
attr_reader :remote_path