Skip to content

Instantly share code, notes, and snippets.

HTML and CSS
We are building webapps
one purpose webapps are fun
in html, white spaces are ignored (well, they are condensed down to one space).
html tags need to be opened and closed. <tag></tag>. when nesting, ident two spaces.
codepen to write and see hteml/css
<title><title> what shows up in search tab
header tags, 1 - 6
html = hypertext markup language
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
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)
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
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.
What command do you run if you want to discard all changes since your last commit? git checkout . There are three areas inside a repo: working directory(atom file), staging area, repository. Git checout takes what was in the repository and wipes it out. Git stash saves what you've done but removes them from the working directory.
Git stash pop: to get it out of the stack
Only use git stash if you want to get your code back.
Git reset --hard HEAD: HEAD is the last thing in the repository. Git reset hard is take the state of the repo and copy HEAD to staging area and working directory, and override the HEAD in those parts. -hard pulls it back 2 steaps. -mix and -soft as well
What command do you use if you run git add and then want to revert it? git reset --hard HEAD (HEAD is optional)
What command do you use if you run git commit and then want to revert it? git reset --hard HEAD ~1 (takes you back one step in time. any number will work. git revert won't work because it creates a new commit, but d
SQL the langauge we use to get information out of normalized date structures
Select clause tells you which
From clause tells you which
Where clause dictates which row you get back out
Answer.where(question_id=3).map &:response
Select * = select all is equivalent to .select(:response), but with the last one use and id otherwise you get back all the items, even if there are millions
function disableButton(){
var button = document.getElementById("submit");
setTimeout(function() [button.disabled = true;}, 1);
}
SQL
IN: let's you pass in multiple things. similar to Ruby include
removing N+1 queries is the best way to speed up runtimes
.joins:
AREL:
def primes(num)
array = []
1..num do |n|
array << n
end
array.reject {|x| if x.is_prime? = false }
end
def is_prime?(n)
if n % 2 == 0 && n % 3 == 0 & n % 5 == 0