Skip to content

Instantly share code, notes, and snippets.

What is a partial?
pieces of code in Views that are called upon in different places. its like a method for the views.
<%= render partial: "partial file name", locals:{parameters} %>
in JS, : goes inside of the "" like in "getShow('hoops');"
why code in the <script> tags on the html page?
control flow on a webpage.
when the application.js runs, there is nothing on the page. this isn't request/response like Ruby, it is event driven. the point in time in which events happen, matters. JS loads when the page loads
onclick is an html code.
10:53
comments in JS start with //
define a variable with keyword var
there is no do and end in JS, we use open anc close brackets instead
parentheses around parameters
while(counter < array.legnth) is while(parameter)
implicit return in ruby, but not in JS. if you want a return, you have to write "return x"
how to puts: alert or console.log
CSS box model: content is on the inside. you can give it a witdth and height.
outside of content is padding.
outside of padding is border.
outside of border is margin.
right click "Inspect Element" to see and adjust border/padding/margins etc.
div id="verses" CSS #verses div { }
CSS #verses > div { } direct children, not just any ancestor
#verses > div:first-letter (pseudo selector. selecting the first letter only)
What is HTTP? Hypertext Transfer Protocol. Https is secure, but HTTP is not.
What is an IP address? an IP address is a signature on every computer that it allows it to communicate to other computers within the web. IP addresses are unique within the network that goes out to the world. But, within the network, IP addresses may be different.
What are all of the HTTP Verbs? get, put, post, patch, delete
Which HTML Verbs imply that their actions are idempotent? put, post, get
An array and a hash are both collections of data. While an array is written with brackets [], a ahsh is written with curly braces {}. In an array, each piece of data is in a particular place, or index, withn the array. The indexes begin at 0. To get an particualr item from an array, one calls the name of the array and the index on the item like this: array[index_number]. Hashes are often referred to as dictionaries because each spot in a has contains two things, one (the key) refers to the other (the value). To get a particular item from a hash, one calls the name of the hash and uses the key to retrieve the item. There are also different methods available to arrays and hashes. Array methods incluede .each, .map, .select., .join, etc.
A string can be an type of text that is encolsed within quotes. A symbol is the key element in a hash. A symbol is a more powerful tool because it can be used as an attr_accessor within a program, or as a parameter in an initiliazed method. Thus is can be passed ar
require 'minitest/autorun'
require 'minitest/pride'
require './may1.rb'
module Intelligent
NUMBER_OF_LEGS = 2
NUMBER_OF_BRAINS = 1
class Human
def say_name
puts "My name is #{@name}."
require 'minitest/autorun'
require 'minitest/pride'
require './may26.rb'
class Array
def initialize
end
def has_even?(array)
num.map{|n| n % 2 == 0}
require 'minitest/autorun'
require 'minitest/pride'
require './array.rb'
class OddArray
def initialize(array)
@array = array
end
def to_a
require 'minitest/autorun'
require 'minitest/pride'
require './may.rb'
# Write two classes which inherit from the Vehicle class below. You will also
# need to add a method to the Vehicle class during this challenge.
class Vehicle
def initialize(make, model)
@make = make
@model = model