Skip to content

Instantly share code, notes, and snippets.

@Benjaminpjacobs
Forked from mbburch/prework.md
Last active March 4, 2017 00:29
Show Gist options
  • Save Benjaminpjacobs/1b429b11520bd7f07a525ad2adefdd58 to your computer and use it in GitHub Desktop.
Save Benjaminpjacobs/1b429b11520bd7f07a525ad2adefdd58 to your computer and use it in GitHub Desktop.
BJ - Turing pre-work

Turing School Prework - Benjamin Jacobs

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?

Not really. I already had xcode installed from previous online coursework so and have been through the command line lessons on code academy so it was all very straightforward.

  • How do you open VS Code from your Terminal?

type code. hit enter.

  • What is the file extension for a Ruby file?

.rb

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

Command B

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

Command P

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?

Present working directory. It lets you know which directory you are currently working in and thus affecting. Since the command line moves one at a time it seems like it can be easy to become disoriented. This ensures you know where you are.

  • What does hostname tell you, and what shows up in YOUR terminal when you type hostname?

My computer's network name. Benjamins-MacBook-Pro.local

Task F- Learn Ruby:

Option 1 Questions:

IRB

  • How do you start and stop irb?

Type irb and hit enter to start. Type exit and hit enter to stop. On my machines I can also use CTRL + D.

  • What might you use irb for?

irb is a place to experiment with how ruby language and functions work. It is not a good place to write code...

Variables

  • How do you create a variable?

creat a variable name such as "my_variable" and set it equal(using the "=") to something(number, string, etc).

  • What did you learn about the rules for naming variables?

variables cannot start with a number, cannot have dashes and cannot have space. They should generally start with a lower case letter or an underscore.

  • How do you change the value of a variable?

set the variable name equal("=") to the new value.

Datatypes

  • How can you find out the class of a variable?

type the variable and call the method ".class"

  • What are two string methods?

.upcase, .downcase

  • How can you change an integer to a string?

call the method ".to_s" i.e. "5.to_s"

Strings

  • Why might you use double quotes instead of single quotes in Ruby?

If I want to use string interpolations(#{example}) I have to use double quotes. Otherwise double or single quotes are valid for strings.

  • What is this used for in Ruby: #{}?

That combination of symbols is used for string interpolation. So whatever is inside the curly braces will be embeded into the string when it's outputted. If it is a number or equation it will be converted to part of the string during output. If it's a variable the value of the variable will be called into the string.

  • How would you remove all the vowels from a string?

'This sentence is a string containing vowels'.delete('aeiou')

Input & Output

  • What do 'print' and 'puts' do in Ruby?

Print outputs some to ruby on a single line. Puts outputs something to ruby with a line after it.

  • What does 'gets' do in Ruby?

"Gets" prompts the use for some sort of input.

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

Inegers are whole numbers like 2, -5, and 55. Floats are numbers with decimels like 3.14 or 2.1

  • 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

    • !=

    not equal to

    • &&

    both sides must be true to return true boolean

    • ||

    one side or the other or both must be true to return true boolean

  • What are two Ruby methods that return booleans?

.nil? .empty?

Conditionals

  • What is flow control?

Flow control is the idea that the program makes decisions on which piece of code to run depending on the conditions. Either as a result of input or other circumstances it chooses which code to execute.

  • What will the following code return?
apple_count = 4

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

The code will return 'Not many apples...' because apple_count is less than 5 so the true condition is not met.

  • What is an infinite loop, and how can you get out of one?

An infinite loop is a piece of code using something like a while statement has no provision to make the statement false, thereby it will simply continue to run forever until stopped with a command like ctl + 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 is a datatype that means nothing. Not zero but specifically the abscence of data.

  • 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 can be beneficial in ruby by creating single consitant objects that can be pointed to throughout a program. This matters more in larger programs where conserving memory helps for efficiency. Unlike strings which require individual object identities, even if the conent is the same, if two symbols are the same content then they are the same object. Hence one id, less memory used.

  • Does naming symbols use the same rules for naming variables?

Generally the rules are the same except that a symbol can circumvent all naming conventions by putting the name in quotes. For example :10 Varraible-15 would return ane error but :"10 Varraible-15" is acceptable.

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

array_name.length will tell you how many elements are in an array.

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

The index of the first item in an array is 0.

  • What do 'push' and 'pop' do?

.push() will add whatever is between the brackets to the end of the array it is called on. Conversely .pop will remove the last elements of the array it is called on.

Hashes

  • Describe some differences between arrays and hashes.

Arrays store values in a specific order which can be retrieved by the index number of their position. Hashes store pairs of keys and values thus you don't need the exact location within a hash to find a value, only its corresponding key. Arrays use brackets whereas hashes use curly braces and rockets to assign keys to values.

  • What is a case when you might prefer an array? What is a case when you might prefer a hash?

You may prefer an array if keep a set of data in a particular order because the index of a given item in the array would be useful. You would prefer a hash if, for example, you are keeping a set of data about an object(i.e. a basketball) where the keys in the hash are characteristics(i.e. color, shape) and the values are the corresponding values of those characteristics for the item(i.e. orange, spherical)

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

Yes I was able to get through all the pre-work. I would not say that I rushed although I did finish this section very quickly. I would say that I dedicated a significant amount of time each day to the tasks and so was able to accomplish faster than if I had had more pressing life commitments or time constraints. With so much time still to come before the start of class I intend to not only move on to the additional prework but to also reviewing and solidifying the concepts in these earlier sections.

  • What are you most looking forward to learning more about?

I am most looking forward to learning more about the command line. I'm really enjoying interacting with my computer on that level. I'm fascinated by all the things you can accomplish just from the terminal. Additionally I'm looking forward to learning how to practically apply ruby for designing and making programs. After doing all the brilliant excercises I'm realizing there is just a staggering depth of computer science I am unaware of and I'm hoping to close that gap as much as possible.

  • What topics would you most like to see reinforced by instructors?

In terms of the Ruby specific pre-work I would love to see the use and explanation of symbols reinforced. I understand the basic differences between symbols and strings, but in a more utilitarian sense I want to understand why it is better to an immutable vs mutable data type. Again this is just getting into more solid computer science concepts that I imagine will be a future focus of certain classes.

  • What is most confusing to you about what you've learned?

In addition to what I was mentioning about symbols in the previous sections I would also like to get more clarification about flow control. That section of the pre-work gave me the most trouble in terms of the additional challenge part of the assignment. I was able to design something that fit the criteria but only by searching ahead to find the functionality I needed. I don't know if the intention of the challenge was to go in search of the answer or if there was a way to write the program using the concept we were supposed to have learned up to that point.

  • What questions do you have for your student mentor or for your instructors?

Most pressing would be the question from the previous question regarding the additional challenge program from the flow control section. Beyond that I don't have any specific questions regarding the ruby or command line prework. Having jumped ahead a bit, I'm curious about git and github and how that is used in practicle programming workflow.

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?

After defining the function you can simply call it by name. To store it as a variable would look something like:

myVar = function_name parameter

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

The initialize method is the first function of a class and saves the intial date a given object is created with in addition to any further required setup. The new method is how you create an object using a defined class. It is called on the class with the argument of whatever variable the initialize function of that class requires. Instance variables are used within a object to store data and are only used within the object. For instance the variable given as the argument when calling .new on a class to create an object will be stored as an instance variable and used when calling any other functions defined within the class of that 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.

What I found most enjoyable about creating this program was edging toward a practicle use of ruby to do something. It was good to learn about the rand method and how that can be useful. What I found both enjoyable and challenging was starting to understand what makes code clunky vs streamline and useful. It's a difficult thing to wrap my head around without more experience but I'm beginning to get how classes and objects are going to be vital in this respect.

Launch School Ruby Book

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

My first and biggest take-away was clarifying the difference between a command that mutates the caller and one that doesn't. Similary, learning about how variables are pointers to values and do not neccessarily behave how you would imagine when assigning and reassigning. Another take away regarding variables was scope. The launch school reading made the concept of when and where a variable is accessible depending on where it was initialized. My last big takeaway was about chaining methods together. In the earlier excecises I was writing method after method on new lines, but the launch school book made it clear that you should consider what the output of every method will be and if the next thing you need to do can utilize that return then just chain it to the end. It makes the code a lot more concise and even readable.

CodeSchool

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

Big takeaway number one is that it seems vital to have a full understanding of git because version control is vital and integral to any sort of collaborative code development. Big takeaway number two is that git offers a great deal of redundancy and human error protection so learning to utilize it to its full potential will offer the greatest protection again irreparable data loss.

  • What is one question you have about Git & GitHub?

I still don't really understand how pull requests work, but in all fairness that is because I have not really sought out the answer yet. My real questions are really more related to how this workflow goes on larger and smaller scales and how project are organized on github. Mainly a general practicle application curiosity.

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?

To me effective workflow is going to be based on solid communication, clear goals and technical proficiency. In terms of shortcuts, learning to be a VS Code power user as well as becoming a master of the terminal including it's interaction with git are of paramount importance to optimizing workflow. I would like to learn more about the practicle interaction of these programs and practice utilizing them in a variety of circumstances to feel most comfortable and thereby increase speed and efficiency.

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 brings the cursor to the front of the comman line. Ctrl-E brings it to the end. Ctrl-U Clears it.

  • 1.5: What are the shortcuts for clearing your screen, and exiting your terminal?

To clear the screen Ctrl-L. To exit terminal Ctrol -D

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

Cat is used both to easily display the contents a file in the terminal as well as add lines from the terminal into files. The diff command is used to display the difference between two files in the terminal.

  • 2.2: What command would you use to list all txt files? What command would you use to show all hidden files?

To list all text files "ls *.txt". To show all hidden files "ls -la".

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

utilizing the curl or cURL command

  • 3.3: Describe two commands you can use in conjunction with "less".

By typing "/" you can search for a specific string, navigating forward and backward through each occurance with "n" and "N" respectively. "G" and "1G" will take you to the end and beginning of the file respectively.

  • 3.4: What are two things you can do with "grep"?

Using grep you can search for specific strings within files, logs, proccesses etc. By piping grep into other commands or using regex as search criteria you can find/count/copy/move/delete all sorts of things with efficiency.

@Benjaminpjacobs
Copy link
Author

Day 11 Typing and Logic Problems

typinglessonsummary50

typinglessonsummary49

typinglessonsummary48

typinglessonsummary47

typinglessonsummary46

brilliantlogicproblems6

@Benjaminpjacobs
Copy link
Author

Launch School Excercises Arrays
launchschoolarrays_ex2-6
launchschoolarrays_ex7
launchschoolarrays_ex1

@selfup
Copy link

selfup commented Feb 4, 2017

Just a few things:

  1. set your Spaces: 4 to Spaces: 2 for ruby in VSCode
  2. install the ruby extension for VSCode
  3. gem install pry if you want something that is wayyy better than irb
    1. once installed: pry
    2. it will have syntax highlighting and it has other magical powers that you will learn once you start 😄

You are doing great!

While collect is a neat trick, I do recommend using a map if you are just creating a new array:

arr = [1, 3, 5, 7, 9]

new_arr = arr.map { |num| num * 2 }

p arr
p new_arr

Also try to use more spaces. It is more ruby-like.

Once again, great job so far!

@Benjaminpjacobs
Copy link
Author

Day 12 Logic Problems and Typing
typinglessonsummary55
typinglessonsummary54
typinglessonsummary53
typinglessonsummary52
typinglessonsummary51
brilliantlogicproblems7

@Benjaminpjacobs
Copy link
Author

Launch School Hashes Excercises

launchschoolhashs_ex6

launchschoolhashs_ex5

launchschoolhashs_ex3

launchschoolhashs_ex2

launchschoolhashs_ex1

launchschoolhashs_ex4

@Benjaminpjacobs
Copy link
Author

Day 13 Logic Problems and Typing

typinglessonsummary63

typinglessonsummary62

typinglessonsummary61

typinglessonsummary60

typinglessonsummary59

typinglessonsummary58

typinglessonsummary57

typinglessonsummary56

brilliantlogicproblems8

@Benjaminpjacobs
Copy link
Author

Launch School Files Exercises

launchschool_files_ex3d

launchschool_files_ex3c

launchschool_files_ex3b

launchschool_files_ex3a

launchschool_files_ex2

launchschool_files_ex1

@Benjaminpjacobs
Copy link
Author

Launch School More Stuff Exercises

launchschool_morestuff_ex4

launchschool_morestuff_ex1

@Benjaminpjacobs
Copy link
Author

Day 14 Typing Exercises

typinglessonsummary65

typinglessonsummary66

typinglessonsummary67

![Uploading TypingLessonSummary68.png…]()

typinglessonsummary69

![Uploading TypingLessonSummary70.png…]()

@Benjaminpjacobs
Copy link
Author

Launch School End Excercises
launchschool_endexercises_ex1
launchschool_endexercises_ex2
launchschool_endexercises_ex3
launchschool_endexercises_ex4
launchschool_endexercises_ex5 6
launchschool_endexercises_ex8
launchschool_endexercises_ex9
launchschool_endexercises_ex10
launchschool_endexercises_ex11
launchschool_endexercises_ex12
launchschool_endexercises_ex13
launchschool_endexercises_ex14
launchschool_endexercises_ex15
launchschool_endexercises_ex16

@Benjaminpjacobs
Copy link
Author

Code School Git Badges
codeschoolgitbadge1
codeschoolgitbadge2

@Benjaminpjacobs
Copy link
Author

Logic and Typing Day 15

brilliantlogicwordsex1

typinglessonsummary71

![Uploading TypingLessonSummary72.png…]()

@Benjaminpjacobs
Copy link
Author

@Benjaminpjacobs
Copy link
Author

@Benjaminpjacobs
Copy link
Author

Day 17 Logic and Typing Practice

brilliantlogicwordsex3

typinglessonsummary77

typinglessonsummary78

typinglessonsummary79

typinglessonsummary80

typinglessonsummary81

typinglessonsummary82

typinglessonsummary83

typinglessonsummary84

@Benjaminpjacobs
Copy link
Author

Day 18 Logic and Typing
brilliantlogicwordsex4
typinglessonsummary84
typinglessonsummary85
typinglessonsummary86

@Benjaminpjacobs
Copy link
Author

@Benjaminpjacobs
Copy link
Author

Day 19 Logic and Typing

syllogisticlogic1

![Uploading SyllogisticLogic2.png…]() ![Uploading SyllogisticLogic3.png…]() ![Uploading SyllogisticLogic4.png…]() ![Uploading TypingLessonSummary87.png…]() ![Uploading TypingLessonSummary88.png…]() ![Uploading TypingLessonSummary89.png…]() ![Uploading TypingLessonSummary90.png…]()

@Benjaminpjacobs
Copy link
Author

Project Euler Problem Solution:
projecteulerss

@Benjaminpjacobs
Copy link
Author

Day 20 Typing and Logic

typinglessonsummary93

typinglessonsummary92

typinglessonsummary91

brilliantgametheory3

![brilliantgametheory2](https://cloud.githubusercontent.com/assets/24966769/22902171/66cb3130-f1f1-11e6-8b42-2370283f5189.png)

@Benjaminpjacobs
Copy link
Author

propositionallogic2

propositionallogic1

![deterministicgames](https://cloud.githubusercontent.com/assets/24966769/23030555/6140df76-f42b-11e6-9a51-f34ce82fce5b.png)

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