Skip to content

Instantly share code, notes, and snippets.

View s-espinosa's full-sized avatar

Sal Espinosa s-espinosa

View GitHub Profile
* When and why would you rebase?
If you had multiple small commits that awere all related and had not yet pulled from a portion of the repository that was shared (i.e. master after the original branch).
* What are the steps to do a basic rebase via the command line?
git rebase -i HEAD~somenumber
* Our cart in Little Shop is not stored in the database. How does its state persist across requests?
Cart is stored in a session, which then gets updated as items are added, etc.
* Name two objects used in Rails that can be used to track state of the user across requests.
### What does it mean to concatenate files? Find an image of an example concatenated file. Why would we want to concatenate files?
Concatenated files are separate files that have been joined into a single file. Allows fewer calls to the server to get necessary information.
### What does it mean to precompile files? What does this have to do with coffeescript and sass files?
In this context, to turn files into something that your browser understands. Sass uses variables, etc. that can't be read by a browser looking for CSS. It then gets compiled into CSS so the browser can use it.
Similarly, Coffeescript is a more developer friendly language that compiles to javascript that the browser can then use.
### What does it mean to minify files? Find an image of an example minified file. Why would we want to minify files?
Minified files have had whitespace removed, and variable naes simplified. Minifying helps shorten load time.
# Within the Source Code #
* t: activate file finder
# Within a Repository #
* g + c: go to the repository
* g + i: go to issues
* g + p: go to pull requests
# Anywhere #
* s: focus on the search bar
  • git stash: records the current state of the working directory and index, but returns you to a clean working directory.
  • git stash apply: applies the changes of a previously stashed state to the current working version. Leaves the stashed version in the stashed list. Can fail with conflicts.
  • git shortlog: summarizes git log output grouped by author and title.
  • git commit --amend: amend the last locally created commit that has not been pushed. In order to amend commits that have already been pushed, use --amend and then push with force. In order to modify older commits, use rebase.
  • git reset --hard: resets the staging area to match the most recent commit and obliterates changes made since then. If a previous commit is specified, reverts to that commit and obliterates all commits after.
  • git reset --soft: like reset --hard, but leaves the changes in place and uncommited.
  • git reset --hard HEAD~2: specifies the number of commits back that you want to remove.

Find three different ways to display the git

Models, Databases, Relationships in Rails

What is the difference between a primary key and a foreign key?

Primary key is an identifier that is used to identify an item/object/thing/row in that table. A foreign key is the primary key of another table.

A primary key is unique in its table. A foreign key does not need to be unique.

@s-espinosa
s-espinosa / cfu_crud_in_sinatra.markdown
Last active March 23, 2016 04:19 — forked from rwarbelow/cfu_crud_in_sinatra.markdown
CRUD in Sinatra -- Check for Understanding
  • Define CRUD.

Create Read Update Delete.

  • There are seven verb + path combinations that are necessary in a basic Sinatra app in order to provide full CRUD functionality. List each of the seven combinations, and explain what each is for.

/some_object GET - to provide an :index view that includes all the objects /some_object/:id GET - to provide a :show view that includes a single object /some_object/new GET - to provide a :new view that includes a form to create a new object /some_object POST - to actually create the new object and redirect to another route

Introduction to Sinatra

1. What is the purpose of the server file (routing)?

Take input from a client and figure out what to do with it (e.g. what to return, what to change on a server, what to delete, etc.)

2. How do you pass variables into the views?

ERB can reference an instance variable from the server file. Can also send variables as locals. In the code below the :number symbol in the :locals hash is what will be used in the erb template to reference the variable, number (not a symbol) references the number variable in the server file.