Skip to content

Instantly share code, notes, and snippets.

Testing Homework - Rails/JS

  • Unit Testing

  • Your experience implementing

    Teaspoon was reasonably easy to implement, and seems to maintain similarities to testing frameworks that I'm already familiar with.

  • Were you successful?

  • What is ES6?

ECMAScript is the proper name for JavaScript, and ES6 is the newest version of the language.

  • What is Transpilation and how does it relate to ES6?

Transpilation is the conversion of code from one version or language to another at a similar level of abstraction, and it is relevant to ES6 because browsers do not immediately transition to new versions of code, and ES6 will have to be transpiled to ES5 in order to work in current browser versions.

  • Looking at the ES6 Features link below, discuss one update from ES5 and if it seems useful/superfluous.

###Leap

Most Frequent Word in a String

Description: Write a function that, given a string of text (possibly with punctuation and line-breaks), returns an array of the top-3 most occurring words, in descending order of the number of occurrences.

Assumptions:

  • A word is a string of letters (A to Z) optionally containing one or more apostrophes (') in ASCII. (No need to handle fancy punctuation.)
  • Matches should be case-insensitive, and the words in the result should be lowercased.
  • Ties may be broken arbitrarily.
  • If a text contains fewer than three unique words, then either the top-2 or top-1 words should be returned, or an empty array if a text contains no words.

Week 5 Diagnostic

When and why would you rebase? In preparation to merge your branch into master, in order to squash small commits and make the git log easier to interpret.

What are the steps to do a basic rebase via the command line? git rebase -i HEAD~<# of steps backward in the commit log>

Our cart in Little Shop is not stored in the database. How does its state persist across requests? As of right now, it's stored in a session that is only cleared when the user leaves/logs out.

  1. What does it mean to concatenate files? Find an image of an example concatenated file. Why would we want to concatenate files? Joining or merging files. We might want to concatenate files to reduce the size of the files and speed up our app's use of assets. Concatenated Files

  2. What does it mean to precompile files? What does this have to do with coffeescript and sass files? Pricompiled files are compiled into an intermediate form that is faster to process for the compiler.
    Coffeescript is an abbreviated language that compiles into JavaScript. Sass is faster to write than CSS, and it is reusable and read more efficiently by the computer.

  3. What does it mean to minify files? Find an image of an example minified file. Why would we want to minify files?

Setting Group Expectations

Group Member Names:

  1. When are group members available to work together? What hours can each group member work individually? Are there any personal time commitments that need to be discussed?
  • Kami: happy to stay until evening but don't want to spend forever here. Generally want to be able to take work with us if possible.
  • Chris: has some personal commitments in the afternoon
  • Ashwin: some things on M W at 630 but also doesn't want to stay in basement
  1. How will group members communicate? How often will communication happen, and how will open lines of communication be maintained?

Git Commands

  • git stash is used to temporarily store the uncommitted changes that you've made on one branch in order to go and work on another branch without being forced to commit files that aren't ready to be committed.
  • git stash apply applys the changes from the most recent stash when you return to the branch. You can view all previous stashes with git stash list, and apply changes from a specific stash with git stash apply stash@{#}, where # is the stash id.
  • git shortlog summarizes the git log output, and can be modified to provide a numbered list (-n) or summary (-s), among several other options accessible at git shortlog --help.
  • git commit --amend is used to edit local commit messages. In order to alter the version pushed to github, a force command must be used.
  • git reset --hard resets the index and the working tree. Any changes to tracked files in the working tree since the last commit are discarded.
  • git reset --soft does not reset the index or
## Models, Databases, Relationships in Rails
#### What is the difference between a primary key and a foreign key? Where would we find a primary key? What would it be called by default? Where would we find a foreign key? What is the naming convention for a foreign key?
A unique primary key exists for every element/row in a table, and would be called that object's id. A foreign key is the identifier of an object/row in a table different from the one in which it is found, and does not have to be unique in the table in which it is found. It points to a related object. The naming convention is the table/object name + _ + id.
#### Write down one example of:
* a `one-to-one `relationship: student to locker assignment
* a `one-to-many relationship`: teacher to students
* a `many-to-many relationship`: students to classes