Skip to content

Instantly share code, notes, and snippets.

View vanderhoop's full-sized avatar
💭
🤷🏻‍♂️

Travis Vander Hoop vanderhoop

💭
🤷🏻‍♂️
View GitHub Profile
cd ~/Desktop
mkdir marp
cd marp
git init
touch darp.rb
echo "I like turtles" >> darp.rb
git add .
git commit -m "example commit"
hub create
cd ..

##The Search for Obi-Wan

C-3PO is a well-known protocol droid from the Star Wars universe, famed for having a frantic resolve and for directing snappy emotional outbursts at his droid life-mate, R2-D2. Your task is to write a program modelling a simple interaction with C-3PO as he searches for the reclusive Jedi Master, Obi-Wan Kenobi.

NOTE: This lesson not only reinforces, but also builds upon what you learned yesterday, so you will likely have to Google a certain bit of Ruby syntax.

  1. Create a new Ruby file called searching_for_obi_wan.rb in your work folder.
  2. C-3PO should:
    • introduce himself as "C-3P0, human-cyborg relations."
  • ask the user's name

While The Cradle Rocks

In today's "Classwork" directory, write a short Ruby program that tracks all the things Anastasia does while her son, Desmond, sleeps.

Directions

  1. Create a variable, desmond_is_sleeping and assign it the value of true
  2. Create a variable, anastasias_accomplishments and assign it an empty string ""
  3. Create a while loop that will run as long as Desmond is sleeping.
  4. As long as Desmond sleeps, ask Anastasia what errand she runs. Add it to the end of anastasias_accomplishments, along with a comma + space, as this should print as a string.

Everything Returns Something

Learning Objective

  • to begin thinking of every object and operation in Ruby as having a return value

Directions

The lines below all return a value. To identify that value, copy and paste each of the following lines into pry and press enter. Examine the return value.

"Miranda Hildensplat"

Practice Writing and Invoking Methods

  1. Define a method, sings_fav_lyric that takes a lyric as input and print that lyric to the console as if it's been screamed (think all caps and a bunch of exclamation points)
  2. Call your new sings_fav_lyric method, passing your favorite lyric as input.
  3. Define a method, calculate_volume that takes three inputs: length, width, and height, and returns the calculated volume.
  4. Call this method with values of your choosing and save the output to a variable called volume.
  5. Define a method, calculate_tip which takes a single input called meal_value and returns a value equal to 20% of any given meal value.
  6. Call this method with a value of your choosing and save the output to a variable called tip.
  7. Write another method calculate_custom_tip that takes two arguments: meal_value and tip_percentage. Define this method such that when calculate_custom_tip(10.00, 20) is entered into the console, it returns the string "You should tip your serv

Iterating with .each

Using the data provided, complete the steps outlined below.

students_array = ["Evan Berg", "Robert Silverblatt", "El Toro Roja", "Jared Norcott", "Jessica Franko", "Andy Fritz", "Aaron Gregory", "Dewey", "Janine Harper", "Erica Kantor", "Larkin", "Sarah McDonald", "Jenny Nguyen", "Ariel Olin", "Ryan Parks", "Grayson Reinhard", "Maria Schettino", "Will Schjang", "Neil Sidhu", "Yinan Song", "Ade Ugbogbo", "Jacqueline Williams", "Carrie Xu", "Anastasia Konecky"]
  1. Pull from upstream master.
  2. Create a each_practice.rb file in today's "Classwork" folder.
  3. Within your new file, write code that uses .each to print each of the students names to the console.

Iterating With .each, Part 2:

Unlike methods, blocks can access values outside of their bounds. To drive this point home, follow the directions below, declaring empty arrays outside of blocks and pushing values into these arrays from within blocks.

Directions

  1. If you haven't, pull from upstream master.
  2. Using the data provided in wine.rb, use .each to iterate over the wine_cellar array, pushing all Pinot Noirs into a sensibly-named array.
  3. Save and commit your work.
  4. Now push all wines that with two-word labels into a long_labeled_wines array.

WDI Guidelines for Survival

  1. PRESS ENTER.

    • To get the most from this course, you'll have to let go of your fear of being wrong. So press enter and run your program. The worst that can happen is you get an error, and in Ruby, errors tell you what to correct. So run your programs early and often. Press enter.
  2. When you feel bad about your progress or level of understanding, remember that to become good at anything, you first have to be terrible, and the only way to stop being terrible is to keep going. So keep going.

  3. Do the smallest Next Thing.

    • Don't read the whole exercise or homework (especially when it's given in parts) and try to plan out how to build the entire thing! Read the first bit of the assignment, and then proceed to get that part working. Only then should you move on. Even simple exercises will become overwhelming if you try to tackle the whole thing at once.
  4. Assume nothing.

  • You might think you know what your program is doing, but if your program
@vanderhoop
vanderhoop / ivan_pakkitz.md
Last active August 29, 2015 14:05
ivan_gist_1

Ivan Pakkitz

Pre-Requisites

  1. A partner.

The Sitch

The internet does not exist, and you & your pair partner are friends living on opposite sides of the country. Because you are dear friends, you want to be able to communicate with each other, but you can only do so by employing the services of your new hire, Ivan Pakkitz.

... but who is Ivan Pakkitz?

Ivan Pakkitz Implementation

Directions

  1. Craft actual messages on actual index cards, following the rules you and your partner devised.