Skip to content

Instantly share code, notes, and snippets.

@Laner12
Forked from mbburch/prework.md
Last active March 18, 2016 00:31
Show Gist options
  • Save Laner12/f722e26e449bc40e0324 to your computer and use it in GitHub Desktop.
Save Laner12/f722e26e449bc40e0324 to your computer and use it in GitHub Desktop.
Lane's Prework

Turing School Prework: Lane Winham

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? The only issues I ran into thus far were contributed to having a slow download for xcode which put me a few days behind schedule.
  • How do you open Atom from your Terminal? While in Terminal I simply type atom . this will open Atom for me.
  • What is the file extension for a Ruby file? I believe the file extension for a Ruby file is RB.
  • What is the Atom shortcut for hiding/ showing your file tree view? The shortcut for this would be Command + .
  • What is the Atom shortcut for quickly finding a file (fuzzy finder)? The shortcut for this would be Command + T.

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 present working directory and this can be helpful in order to know that you are working within the directory that you want to be working in.
  • What does hostname tell you, and what shows up in YOUR terminal when you type hostname? When I type hostname in my Terminal the output is my computers name plus the word local and dictates what network I am working within as well as my computers name.

Task F- Learn Ruby:

Option 1 Questions:

IRB

  • How do you start and stop irb? To enter irb one would simply enter irb into the command line and to stop one would enter exit.
  • What might you use irb for? A good use for irb would be to test small pieces of code.

Variables

  • How do you create a variable? To create a variable one simply creates a name then adds it's value by adding = then the desired value.
  • What did you learn about the rules for naming variables? As for the rules for naming variables I was a bit confused but I did understand is that a variable name cannot be a constant.
  • How do you change the value of a variable? After a variable is named an assigned a value one can simply enter the name and set it equal to a new value and hit enter, at this point the new value would be saved.

Datatypes

  • How can you find out the class of a variable? To find out what class a variable is in one just types the variable then .class.
  • What are two string methods? I think the two methods are simply 'a' and "a".
  • How can you change an integer to a string? For an example to convert 5 to a string just type 5.to_s and the return value should be "5".

Strings

  • Why might you use double quotes instead of single quotes in Ruby? One might use double quotes instead of single quotes if they are utilizing interpolation, concatenation, or are using 's to symbolize ownership.
  • What is this used for in Ruby: #{}? That symbol is used for interpolation.
  • How would you remove all the vowels from a string? To do this one would type 'sample sentence'.delete('aeiou').

Input & Output

  • What do 'print' and 'puts' do in Ruby? Both print information puts prints information to the user of the program however puts will print with a new line while print doesn't.
  • What does 'gets' do in Ruby? When gets is used it allows the program to run then gather information from the user then finish running the program with the additional information.
  • Add a screenshot in the comments of the program you created that uses 'puts' and 'gets', and give it the title, "I/O".
  • I have included a screen shot of my terminal line, however I was unable to save the file titled I/O.rb and had to change it to I_O.rb.

Numbers & Arithmetic

  • What is the difference between integers and floats? Integers are whole numbers such as 1, 2, and 3. Floating numbers are numbers with decimal points such as 1.0, and 3.14.
  • 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?
    • == :equal to
    • = :greater than or equal to

    • <= :less than or equal to
    • != :the opposite of equal to
    • && :this means and
    • || :this means or
  • What are two Ruby methods that return booleans? The two methods that return booleans are || and &&.

Conditionals

  • What is flow control? Flow control is the ability to have some portions of code run while others portions aren't.
  • What will the following code return? Less than 5 the code will return "Not many apples.." while anything 5 and over will return "Lots of 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? An infinite loop is a program that will run continuously until the program is either terminated with control + c or if the user types the string that stops the loop.
  • 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 is nul, nothing, or a non existant value.
  • 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? It can be beneficial to use symbols in Ruby to save memory space and allow the program to run faster.
  • Does naming symbols use the same rules for naming variables? I believe so.
  • 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? One can call the .length method, this will list the number of elements in the array.
  • What is the index of pizza in this array: ["pizza", "ice cream", "cauliflower"]? pizza =[0]
  • What do 'push' and 'pop' do? 'push' will add an element to the end of the array while 'pop' will remove the last element of the array.

Hashes

  • Describe some differences between arrays and hashes. Arrays store elements in an index format and can call on those elements by position. Hashes can store properties of objects and objects can be called on by utilizing it's key or value.
  • What is a case when you might prefer an array? What is a case when you might prefer a hash? I would use arrays to store lists of things including storing hashes. I would use hashes to store any item that have properties that could be used as a key or value.
    • 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?
  • What are you most looking forward to learning more about?
  • What topics would you most like to see reinforced by instructors?
  • What is most confusing to you about what you've learned?
  • What questions do you have for your student mentor or for your instructors?

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?
  • Describe the purpose of the following in Ruby classes: initialize method, new method, instance variables.
  • 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?
  • What is one question you have about Git & 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?
  • 1.4: What do Ctrl-A, Ctrl-E, and Ctrl-U do?
  • 1.5: What are the shortcuts for clearing your screen, and exiting your terminal?
  • 2.1: What is the "cat" command used for? What is the "diff" command used for?
  • 2.2: What command would you use to list all txt files? What command would you use to show all hidden files?
  • 3.1: How can you download a file from the internet, using the command line?
  • 3.3: Describe two commands you can use in conjunction with "less".
  • 3.4: What are two things you can do with "grep"?
@Laner12
Copy link
Author

Laner12 commented Feb 24, 2016

Task A
screen shot 2016-02-19 at 11 30 05 am
screen shot 2016-02-22 at 4 24 17 pm
screen shot 2016-02-23 at 1 37 36 pm

@Laner12
Copy link
Author

Laner12 commented Feb 24, 2016

Task B
screen shot 2016-02-22 at 4 14 51 pm
screen shot 2016-02-22 at 4 15 05 pm

@Laner12
Copy link
Author

Laner12 commented Feb 24, 2016

Task D
screen shot 2016-02-24 at 12 10 36 pm

@7hoenix
Copy link

7hoenix commented Feb 25, 2016

The extension for a ruby file is .rb => not RB
Same deal with Atom shortcut. Command - t => not Command - T
If you get in the habit of being precise with your characters now it will help later!

pwd => print working directory

Great job so far!

@Laner12
Copy link
Author

Laner12 commented Feb 25, 2016

Task E
screen shot 2016-02-25 at 1 35 02 pm

@Laner12
Copy link
Author

Laner12 commented Mar 7, 2016

Task A
screen shot 2016-03-01 at 11 09 53 am

@Laner12
Copy link
Author

Laner12 commented Mar 7, 2016

*Task A
screen shot 2016-03-04 at 3 39 07 pm
*

@Laner12
Copy link
Author

Laner12 commented Mar 7, 2016

Task A
screen shot 2016-03-07 at 11 15 49 am

@Laner12
Copy link
Author

Laner12 commented Mar 7, 2016

*Task B
screen shot 2016-03-07 at 11 21 39 am
*

@7hoenix
Copy link

7hoenix commented Mar 8, 2016

Irb => I use irb to check out how code is working in isolation. Being able to break down code into its component pieces, experiment with them and then put them back together is an exceptionally useful skill.

variable rules (for ruby) => snake_case, can't start with a symbol (i think), no capital letters... probably more things.

2 methods for string => Do a quick google search for "ruby string"... remember you can use command - t to open a new tab in chrome.
The very first link should be ruby-doc.org. Get comfortable with this website. Its the official Ruby docs. Notice on the left hand side you should see a grey column called "Methods". Every class that comes prepackaged with Ruby is going to have a listing like this. Each of those methods can be called directly on the instance of the class.

So for a string you could do the following: "Hey Lane".count => 8 (count is the method).

Great job with the delete vowels!

@Laner12
Copy link
Author

Laner12 commented Mar 9, 2016

Task A
screen shot 2016-03-08 at 12 26 49 pm

@Laner12
Copy link
Author

Laner12 commented Mar 9, 2016

*Task A
screen shot 2016-03-08 at 12 51 33 pm
*

@Laner12
Copy link
Author

Laner12 commented Mar 9, 2016

*Inputs/Outputs Program
screen shot 2016-03-09 at 11 18 52 am
*

@Laner12
Copy link
Author

Laner12 commented Mar 9, 2016

*Task A
screen shot 2016-03-09 at 12 19 41 pm
*

@Laner12
Copy link
Author

Laner12 commented Mar 9, 2016

Numbers
screen shot 2016-03-09 at 12 53 03 pm

@Laner12
Copy link
Author

Laner12 commented Mar 9, 2016

Question
When trying to copy a file using the cp command in terminal this is what happens.

screen shot 2016-03-09 at 3 02 02 pm

@Laner12
Copy link
Author

Laner12 commented Mar 9, 2016

I was able to copy a file once but I would try from other spots within my file tree and it would either say that the file or directory does not exist. Do I need to be above the file or directory that I am attempting to copy?

Here is some examples form my terminal.

screen shot 2016-03-09 at 3 15 57 pm

@Laner12
Copy link
Author

Laner12 commented Mar 10, 2016

*Conditionals
screen shot 2016-03-09 at 5 27 36 pm
*

@Laner12
Copy link
Author

Laner12 commented Mar 10, 2016

Nil
screen shot 2016-03-09 at 6 12 20 pm

@Laner12
Copy link
Author

Laner12 commented Mar 10, 2016

Symbols
screen shot 2016-03-09 at 6 46 22 pm

@Laner12
Copy link
Author

Laner12 commented Mar 10, 2016

Hashes
screen shot 2016-03-09 at 7 34 42 pm

@7hoenix
Copy link

7hoenix commented Mar 10, 2016

The "gets" command will actually stop the program and wait for a user input... then continue after you enter input and hit return.

The "bang" (exclamation mark) means "not". So != technically means "not equal to".

@Laner12
Copy link
Author

Laner12 commented Mar 10, 2016

Command "mv"
This did move the file but also changed it from a ruby file to a plain text file. Does it normally change like that?

screen shot 2016-03-10 at 12 37 04 pm

@7hoenix
Copy link

7hoenix commented Mar 18, 2016

I wouldn't get super bent out of shape with the cp command. You really don't need to use it much. In your example though... it looks like you named a directory (directory is a folder) with a .txt extension. And then that confused you (rightfully so I might add!). In answer to your question... yes you do need to be at a level equal to or higher than the level that you want to interface with.

You don't need to navigate to the level in order to interface with it though. For instance... Lets say I want to move a file from an adjacent directory into my current one. I could do a command like

=> mv ../lib/test.rb test.rb
This is going to go up a level, then into the lib directory of that level then move the test.rb file into your current location.

Nil, in Ruby Nil is an object (AKA instance) of the class NilClass. http://ruby-doc.org/core-2.2.0/NilClass.html
Notice the .nil? method... if something is nil (nonexistent as you mentioned) then it will return true. Everything else will return false.

Symbols are good because they are not mutable (they can't be changed). This makes them excellent choices for naming things... as if you name something... you probably don't want the name to be changed on you right?

Arrays: .count also will return the number of entries.
.unshift will add an entry to the front. And .shift will remove an entry from the front (like pop and push but to the front). Note that they feel kind of backwards... like why would unshift add something? Good question... #RubyLyfe

Hashes (AKA "Dictionaries"): Prefer hashes if you can associate a title for a thing. If you don't have a title... OR if you want a thing to be in order... then prefer arrays.

Also... just as a piece of advice. The more practice you get with hashes, the better. Once you hit module two and beyond you will use them a lot more. So if you get used to using them sooner rather than later you will be happy about it!

With your mv command thing. I don't know. Perhaps your text editor (AKA IDE) is opening it as plain text by default because you are renaming "addition.rb" to just "things" (note that the .rb is lost).

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