Skip to content

Instantly share code, notes, and snippets.

View s-espinosa's full-sized avatar

Sal Espinosa s-espinosa

View GitHub Profile

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.

@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

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.

  • 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

# 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
### 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.
* 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.
# Warmup (5 mins)
* Clone repo
* index.txt
* One minute - what are the pieces?
* One minute - discuss with neighbor.
* List on board.
# HTML (10 mins)
* index.html (in atom)
* Way to organize/describe content.
@s-espinosa
s-espinosa / sal_exercisms.md
Last active June 24, 2016 21:58
Review and Comparison of JS Exercisms

Leap

My code: here

Alternative solutions seemed to follow one of three approaches:

Approach #1 (here, here, here, and here) - This approach, the most popular based on my small sample, strings the test conditions together into a single line of code that inherently returns true or false when called. It's an elegant solution, but maybe not the easiest to maintain? I understood it quickly having just gone through the problem, but I'm not positive I'd find it as easy to parse if I were to come back to it a year from now. The logic doesn't necessarily seem to map clearly to the problem at hand.

Approach #2 ([here](http://exercism.io/submissions/518629a2b007432b9dc88669

Testing Homework - Rails/JS

  • Choose one of the following tracks:
  • Skim/Read through the associated links
  • Attempt to hook up and implement unit or feature js tests in your IdeaBox or this sample idea-bin project
  • Fork this gist
  • Respond with:
  • Your experience implementing