Skip to content

Instantly share code, notes, and snippets.

@kheppenstall
Forked from mbburch/prework.md
Last active September 28, 2016 20:25
Show Gist options
  • Save kheppenstall/785f386469e18cdb787af10f4559b695 to your computer and use it in GitHub Desktop.
Save kheppenstall/785f386469e18cdb787af10f4559b695 to your computer and use it in GitHub Desktop.
An example template for your Turing pre-work Gist

Turing School Prework Kyle Heppenstall

Task A- Practice Typing:

  • screenshots of scores will be posted in comments

Task B- Algorithmic Thinking & Logic:

  • screenshots of completed sections will be posted in comments

Task C- Create your Gist:

Task D- Set up your Environment:

  • Did you run into any issues? I spent some time trying to figure out how to change my command prompt since it seemed inconveniently long. That took me the most time (besides downloading xcode).

  • How do you open Atom from your Terminal? open -a "Visual Studio Code"

  • What is the file extension for a Ruby file? .rb

  • What is the Atom shortcut for hiding/ showing your file tree view?

  • What is the Atom shortcut for quickly finding a file (fuzzy finder)?

Task E- The Command Line:

  • screenshots of your terminal after each exercise will be posted in comments

Day One Questions:

  • What does pwd stand for, and how is this command helpful?
  • pwd stands for print working directory. It is helpful to know the directory you are in so that you know how to navigate to other directories from there and where created files will be added.
  • What does hostname tell you, and what shows up in YOUR terminal when you type hostname?
  • The hostname tells you identity/name of the device. william-heppenstalls-macbook-pro.local

Task F- Learn Ruby:

Option 1 Questions:

IRB

  • How do you start and stop irb? Type irb to start and exit to end.

  • What might you use irb for? To run and experiment with Ruby in the terminal.

Variables

  • How do you create a variable? Use an equals sign like x = 5 or words = "words".

  • What did you learn about the rules for naming variables? No dashes or leading numbers seems important. It seems like there are different conventions for naming variables from different classes.

  • How do you change the value of a variable? Assign it again. So if x currently equals 5 then just write x = 6 and now x equals 6.

Datatypes

  • How can you find out the class of a variable? Type variable.class and Ruby will return the class.

  • What are two string methods? .length and .to_i

  • How can you change an integer to a string? integer.to_s

Strings

  • Why might you use double quotes instead of single quotes in Ruby? Double quotes allows for string interpolation (put a string into another string)

  • What is this used for in Ruby: #{}? This is used for string interpolation, putting one string in another without using + and creating different strings.

  • How would you remove all the vowels from a string? Use the method .delete('aeiou')

Input & Output

  • What do 'print' and 'puts' do in Ruby? Puts prints a string you gave it on a new line and returns nil. Print prints a string you gave it on the same line and returns nil.

  • What does 'gets' do in Ruby? Gets solicits an input from the user.

  • 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? Floats are used for decimals and integers are used for integers (truncate 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?
    • == Is equal to?
    • = Is greater than or equal to?

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

Conditionals

  • What is flow control? Flow control is selectively executing code based on certain conditions.

  • What will the following code return? Not many apples...

apple_count = 4

if apple_count > 5
  puts "Lots of apples!"
else
  puts 'Not many apples...'
end
  • What is an infinite loop, and how can you get out of one? A loop that runs forever since there is no way to get out of it. Exit it with 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? nil means nothing. A variable assigned to nil means the variable has nothing assigned to it (empty).

  • 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? Symbols make memory use more efficient since it stores objects in the same place instead of making copies each time.

  • Does naming symbols use the same rules for naming variables? Symbols start with a colon and can have spaces inbetween quotes.

  • 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? Call .length on the array.

  • What is the index of pizza in this array: ["pizza", "ice cream", "cauliflower"]? 0

  • What do 'push' and 'pop' do? Push adds a new element to the end of an array. Pop removes and returns the last element of an array.

Hashes

  • Describe some differences between arrays and hashes. Arrays have an index and an element where hashes have a key and an element. Hashes use curly braces and arrays use brackets.

  • What is a case when you might prefer an array? What is a case when you might prefer a hash? Arrays are useful for things that have one property or are just coming in a list where a numerical index makes sense. Hashes seem preferable when you are storing the value of something that has two properties.

    • 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? I was able to get through the assigned work here.

  • What are you most looking forward to learning more about? Right now the way the terminal, text editor, ruby, and the computer interact seems like a black box to me. I'm excited to learn more about computers in general so I can start to understand how all of these interact.

  • What topics would you most like to see reinforced by instructors? I would like to do some review on terminal / command line. I feel confident navigating around directories and creating files but do not feel like I have a strong enough foundation to problem solve independently with the command line.

  • What is most confusing to you about what you've learned? I am most confused about Git and Github. I didn't find the codeacademy course to helpful and am uncertain about how I would use git and github.

  • What questions do you have for your student mentor or for your instructors? I would like to spend some more time learning to the command line and just how to be more efficient navigating around my computer in general. I feel like there are likely tons of shortcuts for what I am doing that I am not realizing. I'm also excited

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. Voting age

  • Functions: How do you call a function and store the result in a variable? Calling a function by typings its name and then send the values the function requires. To save it as a variable then just type the variable = function value.

  • Describe the purpose of the following in Ruby classes: initialize method, new method, instance variables.

The initialize method sets up the class and takes input from the user on any necessary information for the object (like the radius of the circle). The new method creates a new instance of your class. Instance variables are variables visible only inside one instance of the class. For example, each circle object has its own radius so it gets an instance variable to hold that radius.

  • 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.

Launch School Ruby Book

  • screenshots will be posted in comments
  • What are your three biggest takeaways from working through this book?

CodeSchool

  • screenshots will be posted in comments
  • What are your two biggest takeaways from working through this tutorial?
  • Git is a way to keep versions of code, track changes, and try out new branches. GitHub is a site used to collaborate with others with a git.
  • What is one question you have about Git & GitHub?
  • When collaborating how often are people actually pushing branches on GitHub?

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?

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? echo -n hello

  • 1.4: What do Ctrl-A, Ctrl-E, and Ctrl-U do? Ctrl-A selects all. Ctrl-E goes to the end of the line. Ctrl-U clears the line before the cuursor.

  • 1.5: What are the shortcuts for clearing your screen, and exiting your terminal? Clear clears your screen. Exit ends a session (but does not close the terminal). Ctrl + shift + q ends the session and closes terminal (force quit?).

  • 2.1: What is the "cat" command used for? What is the "diff" command used for?

The "cat" command is used to display whole files or concatenate files together.

  • 2.2: What command would you use to list all txt files? What command would you use to show all hidden files? ls lists all txt files and ls -la shows all hidden files.

  • 3.1: How can you download a file from the internet, using the command line? wget directory "url"

  • 3.3: Describe two commands you can use in conjunction with "less". Space bar will take you to the next page and b will take you to the previous page.

  • 3.4: What are two things you can do with "grep"? Grep can be used to search files and find files.

@kheppenstall
Copy link
Author

symbols
screen shot 2016-09-27 at 1 28 00 pm

@kheppenstall
Copy link
Author

Loops
screen shot 2016-09-27 at 2 24 10 pm
screen shot 2016-09-27 at 2 27 26 pm

@kheppenstall
Copy link
Author

Voting age "Summary: Basics"
screen shot 2016-09-27 at 2 31 43 pm

@kheppenstall
Copy link
Author

How to write a program
screen shot 2016-09-27 at 2 53 28 pm

@kheppenstall
Copy link
Author

Launchschool Documentation
screen shot 2016-09-27 at 3 09 27 pm

@kheppenstall
Copy link
Author

Launchschool Basics
screen shot 2016-09-27 at 3 22 43 pm
screen shot 2016-09-27 at 3 31 15 pm
screen shot 2016-09-27 at 3 36 15 pm
screen shot 2016-09-27 at 3 40 56 pm

The error message tells you that you used a parentheses instead of a curly brace.

@kheppenstall
Copy link
Author

Variables

screen shot 2016-09-27 at 3 47 49 pm

screen shot 2016-09-27 at 3 50 02 pm

screen shot 2016-09-27 at 3 51 39 pm

In the first case x puts 3 with no error. In the second case there is an error since x is not defined outside the block.

The error message tells you that the variable shoes it not defined where it is called.

@kheppenstall
Copy link
Author

Methods
screen shot 2016-09-27 at 4 18 48 pm
screen shot 2016-09-27 at 4 20 09 pm
screen shot 2016-09-27 at 4 23 26 pm

  1. It doesn't return anything.
    screen shot 2016-09-27 at 4 25 28 pm
  2. It returns Yippee!!!
  3. The error message states that the user entered 1 argument instead of 2 for a method with 2 parameters.

@kheppenstall
Copy link
Author

Flow Control

  1. False, False, False, True, True

screen shot 2016-09-27 at 5 10 20 pm

screen shot 2016-09-27 at 5 07 16 pm

1. FALSE, Did you get it right?, Alright now!

screen shot 2016-09-27 at 5 19 34 pm

1. You got the error message because you are missing one end. Add another end to end the method and it should work.

@kheppenstall
Copy link
Author

Loops

  1. [1,2,3,4,5]

screen shot 2016-09-28 at 10 09 19 am

screen shot 2016-09-28 at 10 13 59 am

screen shot 2016-09-28 at 10 17 15 am

@kheppenstall
Copy link
Author

  1. screen shot 2016-09-28 at 10 40 29 am
  2. arr = [["b"], ["b",2], ["b",3], ["a",1], ["a",2], ["a",3]] returns 1
    [["b",]["a", [1, 2, 3]]] returns [1,2,3]
  3. print arr[1][0]
  4. 3, error, 8
  5. e, A, nil
  6. Brackets imply an index so ruby is expecting an integer not the array element string. Change the brackets to parentheses.
  7. screen shot 2016-09-28 at 11 07 24 am

@kheppenstall
Copy link
Author

  1. immediate_family = family.select {|k,v| k==:sisters || k==:brothers}
    fam_array = immediate_family.values.flatten
  2. Merge does not mutate the first hash but Merge! does.
    screen shot 2016-09-28 at 11 33 32 am
  3. screen shot 2016-09-28 at 11 43 26 am
  4. person[:name]
  5. has_value?
    screen shot 2016-09-28 at 11 47 29 am
  6. Had to look up the solution on this one.
    screen shot 2016-09-28 at 12 26 42 pm
  7. In my_hash x is a symbol and in my_hash2 x is a string variable.
  8. B

@kheppenstall
Copy link
Author

More stuff

  1. screen shot 2016-09-28 at 12 40 52 pm
  2. Event not found. Need to do block.call
  3. Exception handling helps us deal with errors and unpredictable events in a predictable way.
  4. Change to block.call
  5. No & before the block when the method was created.

@kheppenstall
Copy link
Author

kheppenstall commented Sep 28, 2016

Jumpstartlab ROT Encryption / Decryption Class

It does pretty well but doesn't handle new lines when encrypting files. The encrypted file puts everything on the same line.

screen shot 2016-09-28 at 2 22 22 pm

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