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
Git/GitHub
Git is a version control system, a tool to manage all the different versions of your code. GitHub is an online hosting service for your git repositories.
When you start a project, you want to 1. create a file locally (in C9), 2. create a new repository in GitHub** 3. connect the two
That’s (mostly) it.
**Check out this 1-minute tutorial on how to create a new repo on GitHub: https://www.youtube.com/watch?v=LR5BYZjuXMU
Would you rather use RubyMine, vim, or Sublime Text? Why?
Of the three, I would rather use Sublime text because I am most familiar with it. However, I have used both Sublime and Atom, and of the two, I prefer Atom. However, I'm interested in trying RubyMine because of various features including Cucumber and Shoulda tests.
What is the difference between an INNER JOIN and a LEFT JOIN? INNER JOIN gets all records from one table that have some related entry in a second table
Which of these behaviors in a Rails app would require JavaScript? (you can pick more than one)
Scrolling down to a different part of the page (smoothly) when you click on a link in a menu.
Making the color of a background change over time.
def all_permutations(array)
a = []
if array.length == 0
return [[]]
elsif array.length == 1
a << (array)
end
end
How to do Files on the web 10:25
We are working in the "public" folder
if we want to use something in the public folder, go to views/where you want it/html page you want it
<%= image_tag "name/png%>
all the files are accesible immediately on the root.
anything that's in public is available to anyone all the time
if there are images that should be seen only when logged in, you put them in the asset pipelime
public is where developers (not users) put images
files that users can upload:
require 'minitest/autorun'
require 'minitest/pride'
# Write a method which accepts an array as the first paramater and a number
# as the second parameter. Return true if two of the numbers in the array sum
# to the second parameter.
def complements(array, num)
if array.length < 2 || array.length == nil
false
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
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:
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
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