w1d4 Flashcards
How do you start a fresh project with bundle? What does this do?
bundle init
it creates an empty Gemfile with instructions on how to add gems
What’s the command to create an empty Gemfile with instructions on how to add gems?
bundle init
How do we install the gems for our project?
bundle install
What does bundle install do?
installs the gems for our project that we’ve specified in our Gemfile
Can we pass a has to a method without curly braces?
Yes, only if it’s the final argument passed in.
How can we set up an attr_reader that can only be accessed internally?
private
attr_reader :whatever
What’s a recursive solution for creating a range(start,finish) exclusive method?
ex: range(1,5) => [1,2,3,4]
base case: if start == finish, return [ ]
A: chop off the leftmost number and add to an empty array
B: call range like so: range(start+1,finish)
return A + B
What’s a recursive solution for generating the first n fib numbers?
base cases:
return [ ] if n == 0
return [0] if n == 1
return [0,1] if n == 2
general case:
fibs(n-1).push fibs(n-1)[-2] + fibs(n-1)[-1]
optimize: make one call to fibs
What are the two main reasons to use git?
We can keep track of changes and know who changed what.
Easy to work on a team. Multiple people can work on a project at once.
How do you see the state of your staging area with git?
git status
What does git status do?
Displays the state of your staging area.
How do you see the differences you’ve made in your staging area?
git diff –staged
How do you make a snapshot of your current staging area with git?
git commit -m “this is the commit message”
How do you see all the branches your team is working on?
git branch
What does git branch do?
Shows all the branches your team is working on
How do you add all the files in a directory to git?
git add -A
What does this do:
git add -A
Adds all the files in the current directory into git
How do you see a history of commits/merges/etc made in git?
git log
What does git log do?
Shows a history of commits/merges/etc made in git
How do you switch to a particular branch in git?
git co [branchname]
What does this do:
git co [branchname]
Switches to a different branch
How do we merge changes from one branch into another?
make changes on a new branch
git co [branch to merge into]
git merge [branch to merge from]
Let’s say we have a public repo on github.
How do we push the master branch of our repo up to that github repo for the first time?
git remote add origin something@github.com:[username]/[reponame].git
git push -u origin master
How do you revert to a previous version?
first do: git log
second: take the hash from the commit you want to revert to.
third: git co [hash]
How do you revert all changes to all files since the last commit?
git reset –hard
dangerous!
What 5 actions in git do we need to memorize?
adding committing merging pushing branching
What are the three states a file can exist as within git?
modified
staged
committed
How do you set up a new repo and connect it to github?
git init
git remote add your_alias https://github.com/username/reponame
What’s a good name for a git remote alias?
origin
How do you add a file to git?
git add [file(s)]
What does this do:
git add [file(s)]
Adds some files to the staging area.
How do you send changes to a remote repo (on a regular basis)?
git push
Why would you stay away from a gem with fewer than 100-500 followers?
Less people actively working to fix bugs.
What is an atomic operation?
An operation whose changes are rolled back if they are somehow interrupted before completion. This helps prevent corruption.
What type of operation does this describe:
It’s changes are rolled back if they are somehow interrupted before completion.
atomic operation
What does semantic versioning refer to?
x. y.z versioning
i. e. OSX 10.11.1
What is the foremost principle in Agile?
rapid, iterative design
What are 3 alternative development paradigms to Agile?
waterfall
prototype
spiral
HTML
What are the two main Form methods?
GET
POST
HTML
What are some Input type values?
7+: 5 stars 5-6: 4 stars 4: 3 stars 3: 2 stars 2: 1 star
button checkbox color date email hidden number password radio search url
How do you set up multiple radio inputs to create a multiple-choice?
Give each radio input element the same attribute value
How do you set your username/email for git?
git config [–global] user.email
( –global is optional. when not used, only the config for the current repo will be set ).
What’s the syntax for a shell alias?
alias [shorthand]=’[command]’
How do you add files to the staging area?
git add [files]
How do you roll back to a particular commit?
git reset commit_SHA
commit_SHA only needs the first 7 chars of a SHA
What are 3 ways to backtrack in git?
git checkout HEAD filename
git reset HEAD filename
git reset commit_SHA
How do you insert an element into an existing array?
Array#insert(index, object)
What will this do:
Array#insert(index, object)
Insert an element into an existing array
High-level: how do you recursively generate subsets?
base case:
empty array => [ [ ] ]
pull the element off the end
recursively generate subsets for the remaining elements and store to smaller_subset
create a new bigger_subset array and fill it by adding the element we pulled off the end to the end of each subset in smaller_subset
return smaller_subset + bigger_subset
How do you remove a single file from the staging area?
git reset HEAD – filename