Skip to content

Instantly share code, notes, and snippets.

@bermannoah
Forked from mbburch/prework.md
Last active August 11, 2016 13:15
Show Gist options
  • Save bermannoah/631d4583c9369cd2eb070efb90b168eb to your computer and use it in GitHub Desktop.
Save bermannoah/631d4583c9369cd2eb070efb90b168eb to your computer and use it in GitHub Desktop.
Noah Berman's Turing School Prework Gist

Turing School Prework - Noah Berman

Task A- Practice Typing:

  • screenshots of scores are posted in comments

Task B- Algorithmic Thinking & Logic:

  • screenshots of completed sections are posted in comments

Task D- Set up your Environment:

  • Did you run into any issues?
  • -- Think it might be good to go through what I've installed -- have done a few different web based learn-to-code things and I'm worried I've installed conflicting versions of things. Plus... I can't seem to get seeing-is-believing to run.
  • How do you open Atom from your Terminal?
  • --Just by typing the word atom. Can also open files by typing, say, atom file_name.rb
  • What is the file extension for a Ruby file?
  • -- .rb
  • What is the Atom shortcut for hiding/ showing your file tree view?
  • -- Command + i
  • What is the Atom shortcut for quickly finding a file (fuzzy finder)?
  • -- Command + t

Task E- The Command Line:

  • screenshots of your terminal after each exercise are posted in comments

Day One Questions:

  • What does pwd stand for, and how is this command helpful?
  • -- pwd stands for "print working directory" and it is helpful because it shows you the full directory you're currently working in. Especially useful if you have directories with similar names in different project files.
  • What does hostname tell you, and what shows up in YOUR terminal when you type hostname? The hostname tells you the 'name' of your computer. (On the network?) In my terminal hostname returns "box.local"

Task F- Learn Ruby:

Option 1 Questions:

IRB

  • How do you start and stop irb?
  • -- Start: type irb in terminal.
  • -- Stop: type exit in irb.
  • What might you use irb for?
  • -- Running/experimenting with small pieces of code to make sure (or see if) they work.

Variables

  • How do you create a variable?
  • -- type something like my_variable = 17
  • What did you learn about the rules for naming variables?
  • -- they can't be a number, include a dash, or start with a number.
  • How do you change the value of a variable?
  • -- set it as 'equal' to something else.

Datatypes

  • How can you find out the class of a variable?
  • -- add .class to the variable (ex. hello = 4, 4.class returns 'fixnum')
  • What are two string methods?
  • -- .upcase and .delete
  • How can you change an integer to a string?
  • -- use the .to_s method

Strings

  • Why might you use double quotes instead of single quotes in Ruby?
  • -- double quotes allows you to use interpolation, single quotes does not.
  • What is this used for in Ruby: #{}?
  • -- interpolation -- embedding one ruby statement within another.
  • How would you remove all the vowels from a string?
  • -- "here is a string of some sort but wow these vowels need to go".delete('aeiou')

Input & Output

  • What do 'print' and 'puts' do in Ruby?
  • -- Both print and puts print information to the user, but print doesn't create a new line after printing.
  • What does 'gets' do in Ruby?
  • -- 'gets' pauses the program and waits for user input, which can then be run back into the program.
  • Add a screenshot in the comments of the program you created that uses 'puts' and 'gets', and give it the title, "I/O".

Numbers & Arithmetic

  • What is the difference between integers and floats?
  • -- Integers are always rounded to the nearest whole number, floats allow decimals.
  • Complete the challenge, and post a screenshot of your program in the comments with the title, "Numbers".

Booleans

  • What do each of the following symbols mean?
    • == equals
    • = greater than or equal to

    • <= less than or equal to
    • != not equal to
    • && and
    • || or
  • What are two Ruby methods that return booleans?
  • -- .include? and .empty?

Conditionals

  • What is flow control?
  • -- it's a way of selectively executing code based on user inputs and program values. usually rendered as the if...else...end construction.
  • What will the following code return?
apple_count = 4

if apple_count > 5
  puts "Lots of apples!"
else
  puts 'Not many apples...'
end

-- it will return "Not many apples..."

  • What is an infinite loop, and how can you get out of one?
  • -- an infinite loop is what happens when a program never runs into a false statement. You can end the program (in terminal, anyway) by typing ctrl + c.
  • Take a screenshot of your program and terminal showing two different outputs, and post it in the comments with the title, "Conditionals".

nil

  • What is nil?
  • -- nothing, really! (hah hah hah no sorry but yeah it's a datatype that means nothing)
  • Take a screenshot of your terminal after working through Step 4, and post it in the comments with the title, "nil".

Symbols

  • How can symbols be beneficial in Ruby?
  • -- A symbol lets you point variables to the same object without using up additional memory. (The object_id remains the same, unlike if you use a new variable for the same object each time.)
  • Does naming symbols use the same rules for naming variables?
  • -- symbols can use the same rules BUT they must begin with : -- also worth noting that variables can include symbols but symbols are just... symbols. :symbol = "Hello World" doesn't work, hello_world = :symbol does.
  • Take a screenshot of your terminal after working through Step 4, and post it in the comments with the title, "Symbols".

Arrays

  • What method can you call to find out how many elements are in an array?
  • -- .length
  • What is the index of pizza in this array: ["pizza", "ice cream", "cauliflower"]?
  • -- the index of pizza is 0
  • What do 'push' and 'pop' do?
  • -- push adds an element to an array, pop removes an element from an array

Hashes

  • Describe some differences between arrays and hashes.
  • -- arrays list elements of varying types, hashes use both values and keys. When you look up something in an array you do so via its index, when you look up something in a hash you use keys. Arrays are collections of data, hashes let you assign properties to data -- context, essentially.
  • What is a case when you might prefer an array? What is a case when you might prefer a hash?
  • -- An array might be more useful when you have a large amount of information that you want to store or make large-scale changes to -- gathering results from a survey, say, and then running various operations on the whole group of data. A hash might be more useful when you want to pick and choose within a large amount of information about a particular item -- maybe you have a rudimentary translation program that looks up particular words & the relevant translations.
    • Take a screenshot of your terminal after working through Step 2, and post it in the comments with the title, "Hashes".

Task G- Prework Reflection:

  • Were you able to get through the work? Did you rush to finish, or take your time?
    • Was definitely able to get through the work. I took my time.
  • What are you most looking forward to learning more about?
    • How to turn these little scraps of programs into functional things!
  • What topics would you most like to see reinforced by instructors?
    • Hashes! Hashes! Also hashes! For some reason they're just not clicking yet. Ways of using loops. Symbols. Instance variables.
  • What is most confusing to you about what you've learned?
    • When to use each kind of loop... how to keep a program with many methods organized... hashes! Definitely hashes.
  • What questions do you have for your student mentor or for your instructors?
    • I started learning how to use require for the encryptor jumpstartlab program but I'd really like to know more about how to connect different apps / organize classes and methods. I've started reading (on my student mentor's advice) the Practical Object Oriented Design book and I'm looking forward to going into that sort of thing in more detail.

Pre-work Tasks- One Month Schedule

(Note: You will most likely only get to the following sections if you have more than a week for your pre-work. If you are doing the one week pre-work schedule, you may delete this section of the Gist.)

Railsbridge Curriculum, cont.

  • Loops: Take a screenshot of your "Challenge" program, and post it as a comment in your Gist.
  • What challenges did you try for "Summary: Basics"? Post a screenshot of one of your programs.
  • Functions: How do you call a function and store the result in a variable?
  • -- to call a function, you type the name of the function and then the values it needs to work.
  • -- backwards 'Hello'
  • -- to store the result in a variable, use the following:
  • -- mirror = backwards 'Hello'
  • Describe the purpose of the following in Ruby classes: initialize method, new method, instance variables.
  • -- initialize method saves the data the object is created with and performs other setup tasks.
  • -- a new method is a user-created method for interacting with information
  • -- instance variables are normal variables BUT only accessable from within a specific instance of an object
  • How to Write a Program: Screenhero with your student mentor and share your program. Write a bit about what you found most challenging, and most enjoyable, in creating your program.
  • -- The Railsbridge page is pretty thorough in going through the program, so it wasn't that difficult. Still, I think until I'm actually at Turing I'm not going to feel like I have a full grasp of what exactly my programs (and the bits and pieces within them) are doing. I feel like I understand it now (which is pretty cool! that's definitely the most enjoyable bit) but I had to go through and create a new version of the file for the more nuanced (?) roller program and compare differences before I could really see it. Part of this is the way Railsbridge zips through things, part of it is just figuring out new ideas. All enjoyable, though! :)

Launch School Ruby Book

  • screenshots will be posted in comments
  • What are your three biggest takeaways from working through this book?
  • You can do a lot with not a whole lot of code.
  • Hashes can be really really useful but they're still not clicking for me.
  • The most obvious method (both literally and... not) is not always the clearest solution. It might be obvious to me what's going on, but if I want other people to use the code... sometimes better to be more explicit.

CodeSchool

  • screenshots will be posted in comments
  • What are your two biggest takeaways from working through this tutorial?
  • -- I learned that the git knowledge I thought I had previously barely scratched the surface, and that there's way more I can get out of it than just a place to store pieces of code. (Ways of collaborating, etc)
  • What is one question you have about Git & GitHub?
  • -- The CodeSchool tutorial doesn't really explain how to use github with other people -- it goes through branches and such but I guess I'd like to know how best to use it w/others? Best practices for when to file issues or pull requests and that sort of thing.

Workflow Video

  • Describe your thinking on effective workflow. What shortcuts do you think you'll find most useful? What would you like to learn or practice that will most help you improve your speed and workflow? -- The command + d shortcut is going to be incredibly useful. I wish I'd know about that a month or three ago! Being able to move quickly through files and make changes globally, but intelligently seems like the ideal way to manage a workflow. I want to be able to make the changes I need to make without accidentally screwing up something invisible (...at the time...) that ultimately causes more problems than it solves. One of the things I'd like to learn is how to include a certain level of paranoia into the things I do -- getting feedback and some kind of process documentation would be ideal. (ex: using sudo to install a gem without knowing exactly what it's going to modify.) I guess part of that is just knowing where to go to find the information ahead of time. Also would be useful to know best-practices for organizing files/directories so that they're easibly navigable for me & anyone else who might need to use them.

Michael Hartl's Command Line Book

As you complete each section, respond to the related questions below (mostly taken directly from the tutorial exercises):

  • 1.3: By reading the "man" page for echo, determine the command needed to print out “hello” without the trailing newline. How did you do it?
  • -- you can use -n to remove the trailing newline. ex: echo -n "Hello" omits that line.
  • 1.4: What do Ctrl-A, Ctrl-E, and Ctrl-U do?
  • -- Ctrl-A moves the cursor to the beginning of the line, ctrl-e to the end. Ctrl-u erases whatever was on the current line.
  • 1.5: What are the shortcuts for clearing your screen, and exiting your terminal?
  • -- clear, well, clears the screen. You can type exit or ctrl+d to exit the terminal, and of course command+q to quit.
  • 2.1: What is the "cat" command used for? What is the "diff" command used for?
  • -- cat reads and outputs files sequentially. It will concatenate files if you ask it to read more than one. Diff compares differences between two files.
  • 2.2: What command would you use to list all txt files? What command would you use to show all hidden files?
  • -- find . -name "*.txt" -print for all txt
  • -- ls -ld .?* will pull a list of all hidden files.
  • 3.1: How can you download a file from the internet, using the command line?
  • -- curl -O "url goes here" works best as default, but apparently there's something called wget that can be installed that's better. Yes? No? Maybe?
  • 3.3: Describe two commands you can use in conjunction with "less".
  • -- find and cat
  • 3.4: What are two things you can do with "grep"?
  • -- search within files for a specific piece of text via various methods. You can also pass it to other commands, apparently, so you can search within a list of running processes or suchlike. (ps aux | grep spotlight for example)
@bermannoah
Copy link
Author

screen shot 2016-07-01 at 9 56 30 pm

@bermannoah
Copy link
Author

screen shot 2016-07-02 at 6 11 30 pm
screen shot 2016-07-02 at 6 14 11 pm

@bermannoah
Copy link
Author

screen shot 2016-07-04 at 9 40 26 am

@bermannoah
Copy link
Author

screen shot 2016-07-04 at 9 51 17 am
screen shot 2016-07-04 at 9 49 39 am
screen shot 2016-07-04 at 9 44 40 am

@bermannoah
Copy link
Author

bermannoah commented Jul 4, 2016

"I/O"
screen shot 2016-07-04 at 10 01 01 am

@bermannoah
Copy link
Author

"Numbers"
screen shot 2016-07-04 at 10 08 58 am

@bermannoah
Copy link
Author

screen shot 2016-07-05 at 9 50 03 am

@bermannoah
Copy link
Author

screen shot 2016-07-05 at 9 54 57 am
screen shot 2016-07-05 at 9 57 19 am
screen shot 2016-07-05 at 9 58 41 am

@bermannoah
Copy link
Author

"Conditionals"
screen shot 2016-07-05 at 1 19 04 pm
screen shot 2016-07-05 at 1 20 24 pm

@bermannoah
Copy link
Author

bermannoah commented Jul 5, 2016

"nil"
screen shot 2016-07-05 at 1 25 43 pm

@bermannoah
Copy link
Author

Finished the Ruby lesson -- might try a couple of other things, then go through Ruby again.
screen shot 2016-07-06 at 9 31 43 am

@bermannoah
Copy link
Author

screen shot 2016-07-06 at 9 43 32 am

@bermannoah
Copy link
Author

"Hashes"
screen shot 2016-07-06 at 10 56 49 am

@bermannoah
Copy link
Author

Trying some javascript...
screen shot 2016-07-07 at 7 50 39 pm

@bermannoah
Copy link
Author

screen shot 2016-07-09 at 6 46 39 am

@bermannoah
Copy link
Author

Typing.io's Javascript section: done and done. Yikes.
screen shot 2016-07-10 at 10 05 50 pm

@bermannoah
Copy link
Author

Time for some Python, I guess! Why not?
screen shot 2016-07-10 at 10 13 26 pm

@bermannoah
Copy link
Author

bermannoah commented Jul 11, 2016

Loops 'Challenge' Programs
greeting.rb
screen shot 2016-07-11 at 8 38 20 am
numbers.rb
EDIT: it works now without using .reduce(:+) !!!!
screen shot 2016-07-12 at 5 26 57 pm

@bermannoah
Copy link
Author

Here's my five numbers challenge...
screen shot 2016-07-11 at 1 13 02 pm

@bermannoah
Copy link
Author

screen shot 2016-07-12 at 9 38 41 am

@bermannoah
Copy link
Author

screen shot 2016-07-12 at 12 24 50 pm

@bermannoah
Copy link
Author

screen shot 2016-07-17 at 10 42 18 pm

@bermannoah
Copy link
Author

"Getting set up and installing ruby"
screen shot 2016-07-18 at 10 54 35 am

@bermannoah
Copy link
Author

"Basic Building Blocks"
screen shot 2016-07-18 at 11 13 51 am
screen shot 2016-07-18 at 11 17 18 am
screen shot 2016-07-18 at 11 17 22 am

@bermannoah
Copy link
Author

"Variables"
...the name.rb program after all modifications...
screen shot 2016-07-18 at 6 56 32 pm

...the age program...
screen shot 2016-07-18 at 6 53 16 pm

...errors...
screen shot 2016-07-18 at 6 57 45 pm

In the first case x prints the number 3, in the second it is only initialized within the scope of the do ... end loop, and nowhere else in the program. When ruby tries to print it to the screen it can't find it, so it errors out. The NameError in the code sample for question six tells me the same problem is happening -- 'shoes' is defined within the wrong scope.

@bermannoah
Copy link
Author

"Methods"

  1. greeting.rb
    screen shot 2016-07-21 at 10 29 50 am

screen shot 2016-07-21 at 10 30 36 am
3.
screen shot 2016-07-21 at 10 31 32 am
4. It will print nothing to the screen.
5. "Yippeee!!!!"
screen shot 2016-07-21 at 10 33 49 am
6. The error message tells the user that the method requires two arguments but only one has been submitted.

@bermannoah
Copy link
Author

bermannoah commented Jul 21, 2016

"Flow Control"
1 --

  1. will return false

  2. will return false

  3. will return false

  4. will return true

  5. will return false
    Answers:
    screen shot 2016-07-21 at 11 24 34 am

screen shot 2016-07-21 at 11 35 48 am

screen shot 2016-07-21 at 11 46 31 am

4 --

  1. FALSE
  2. "Did you get it right?"
  3. "Alright now!"
    Answers:
    screen shot 2016-07-21 at 4 54 18 pm
  4. screen shot 2016-07-21 at 5 00 04 pm
  5. That error means that the file is missing an 'end' statement. In this case it's not seeing an 'end' to the method being defined, only to the if...else statement within. So to fix the error simply add another 'end' to the next line.

@bermannoah
Copy link
Author

"Loops"

  1. It returns the contents of the array for the loop to modify.
  2. screen shot 2016-07-25 at 10 59 45 am
  3. screen shot 2016-07-25 at 11 03 49 am
  4. screen shot 2016-07-25 at 11 06 50 am

@bermannoah
Copy link
Author

"Arrays"
1.
screen shot 2016-07-25 at 6 53 08 pm
2. The first program will return 1. arr will equal [["b"], ["b", 2], ["b", 3], ["a", 1], ["a", 2], ["a"]]
The second program will return [1, 2, 3] and arr will equal [["b"], ["a", [1, 2, 3]]
3. arr.last.first
4. arr.index(5) returns 3. arr.index[5] returns an error. arr[5] returns 8.
5. a = e, b = A, c = nil.
6. The problem is that names['margaret'] is trying to use a string as an index. You could fix it by using an integer insteadd of 'margaret'.
7.
screen shot 2016-07-25 at 7 18 29 pm

@bermannoah
Copy link
Author

bermannoah commented Jul 26, 2016

  1. screen shot 2016-07-25 at 7 46 55 pm
  2. screen shot 2016-07-25 at 7 55 39 pm
  3. screen shot 2016-07-25 at 7 59 05 pm
  4. person[:name]
  5. has_value?
    screen shot 2016-07-25 at 8 09 25 pm
  6. The first line uses x as a key, the second line uses the value of x (a string) as the key.
  7. B- there is no method keys for array objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment