w1d4 Flashcards

1
Q

How do you start a fresh project with bundle? What does this do?

A

bundle init

it creates an empty Gemfile with instructions on how to add gems

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What’s the command to create an empty Gemfile with instructions on how to add gems?

A

bundle init

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do we install the gems for our project?

A

bundle install

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does bundle install do?

A

installs the gems for our project that we’ve specified in our Gemfile

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Can we pass a has to a method without curly braces?

A

Yes, only if it’s the final argument passed in.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can we set up an attr_reader that can only be accessed internally?

A

private

attr_reader :whatever

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What’s a recursive solution for creating a range(start,finish) exclusive method?

ex: range(1,5) => [1,2,3,4]

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What’s a recursive solution for generating the first n fib numbers?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the two main reasons to use git?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you see the state of your staging area with git?

A

git status

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does git status do?

A

Displays the state of your staging area.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you see the differences you’ve made in your staging area?

A

git diff –staged

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you make a snapshot of your current staging area with git?

A

git commit -m “this is the commit message”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you see all the branches your team is working on?

A

git branch

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does git branch do?

A

Shows all the branches your team is working on

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you add all the files in a directory to git?

A

git add -A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What does this do:

git add -A

A

Adds all the files in the current directory into git

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

How do you see a history of commits/merges/etc made in git?

A

git log

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What does git log do?

A

Shows a history of commits/merges/etc made in git

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How do you switch to a particular branch in git?

A

git co [branchname]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What does this do:

git co [branchname]

A

Switches to a different branch

22
Q

How do we merge changes from one branch into another?

A

make changes on a new branch
git co [branch to merge into]
git merge [branch to merge from]

23
Q

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?

A

git remote add origin something@github.com:[username]/[reponame].git

git push -u origin master

24
Q

How do you revert to a previous version?

A

first do: git log

second: take the hash from the commit you want to revert to.
third: git co [hash]

25
Q

How do you revert all changes to all files since the last commit?

A

git reset –hard

dangerous!

26
Q

What 5 actions in git do we need to memorize?

A
adding
committing
merging
pushing
branching
27
Q

What are the three states a file can exist as within git?

A

modified
staged
committed

28
Q

How do you set up a new repo and connect it to github?

A

git init

git remote add your_alias https://github.com/username/reponame

29
Q

What’s a good name for a git remote alias?

A

origin

30
Q

How do you add a file to git?

A

git add [file(s)]

31
Q

What does this do:

git add [file(s)]

A

Adds some files to the staging area.

32
Q

How do you send changes to a remote repo (on a regular basis)?

A

git push

33
Q

Why would you stay away from a gem with fewer than 100-500 followers?

A

Less people actively working to fix bugs.

34
Q

What is an atomic operation?

A

An operation whose changes are rolled back if they are somehow interrupted before completion. This helps prevent corruption.

35
Q

What type of operation does this describe:

It’s changes are rolled back if they are somehow interrupted before completion.

A

atomic operation

36
Q

What does semantic versioning refer to?

A

x. y.z versioning

i. e. OSX 10.11.1

37
Q

What is the foremost principle in Agile?

A

rapid, iterative design

38
Q

What are 3 alternative development paradigms to Agile?

A

waterfall
prototype
spiral

39
Q

HTML

What are the two main Form methods?

A

GET

POST

40
Q

HTML

What are some Input type values?

7+: 5 stars
5-6: 4 stars
4: 3 stars
3: 2 stars
2: 1 star
A
button
checkbox
color
date
email
hidden
number
password
radio
search
url
41
Q

How do you set up multiple radio inputs to create a multiple-choice?

A

Give each radio input element the same attribute value

42
Q

How do you set your username/email for git?

A

git config [–global] user.email

( –global is optional. when not used, only the config for the current repo will be set ).

43
Q

What’s the syntax for a shell alias?

A

alias [shorthand]=’[command]’

44
Q

How do you add files to the staging area?

A

git add [files]

45
Q

How do you roll back to a particular commit?

A

git reset commit_SHA

commit_SHA only needs the first 7 chars of a SHA

46
Q

What are 3 ways to backtrack in git?

A

git checkout HEAD filename

git reset HEAD filename

git reset commit_SHA

47
Q

How do you insert an element into an existing array?

A

Array#insert(index, object)

48
Q

What will this do:

Array#insert(index, object)

A

Insert an element into an existing array

49
Q

High-level: how do you recursively generate subsets?

A

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

50
Q

How do you remove a single file from the staging area?

A

git reset HEAD – filename