Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aperezsantos/cd2d5bc5febeb982d69803a310877c34 to your computer and use it in GitHub Desktop.
Save aperezsantos/cd2d5bc5febeb982d69803a310877c34 to your computer and use it in GitHub Desktop.
Mod 0 Session 1 Practice Tasks

Session 1 Practice Tasks

The assignments listed here should take you approximately 1.5 hours.

To start this assignment, click the button in the upper right-hand corner that says Fork. This is now your copy of the document. Click the Edit button when you're ready to start adding your answers. To save your work, click the green button in the bottom right-hand corner. You can always come back and re-edit your gist.

1. Documentation and Googling (60 min)

Documentation of a langauge, framework, or tool is the information that describes its functionality. For this part of the practice tasks, you're going to practice digging into documentation and other reference material.

NOTE: The linked documentation for each question below is a good starting place, but you should also be practicing your Googling skills and sifting through the results to find relevant and helpful sites.

  • In your own words, what does the Ruby array drop method do? As you're explaining, be sure to provide an example. Your answer: The drop method enables you to remove an item from an array by specifically pointing out what slot in the array to drop. In order to understand this method, I Googled ruby array examples, and learned that an array is a list of items in order in which the first item has an index of 0. Basically the first part of an array is in slot 0, then the next in slot 1, and so on and so forth. When you use the drop method, you tell the array to drop whatever is in the slot you specify. #(i.e. groceries = ["eggs", "cheese", "carrots"] turns into groceries.drop(1) or groceries = ["eggs", "carrots"])

  • What did you Google to help you with this task, and how did you pick your results? Your answer: I included keywords such as ruby array example, I used the quotes method to look specifically for ruby array "drop method", and searched within the pages I picked by using the command+F keys. While I did this, I kept in mind the post dates, as well as the type of information I was looking at (i.e. tutorials, videos, articles, etc.). All of this led me to rubylearning.com, teamtreehouse.com, and mixandgo.com, which have information posted within the last 3 years.

  • In your own words, what does the Ruby string split method do? As you're explaining, be sure to provide an example. Your answer: The string split method allows you to take a string and divide it into different parts of an array. For example this string "yo me llamo ana" can be split into parts of an array by doing the following: #string.split = ["yo", "me", "llamo", "ana"]

  • What did you Google to help you with this task, and how did you pick your results? Your answer: I searched for ruby strings, ruby string methods, ruby "string split" method, and made use of the search box in each page I looked at. I then found a tutorial in digitalocean.com, a guide in rubyguides.com, and an article on how to use the split method written on March 29 of this year.

  • In your own words, what does the JavaScript array slice method do? As you're explaining, be sure to provide an example. Your answer: If I understand it correctly, the array slice method copies a specified part of an array and returns it without the unspecified parts. As an example, you can make an array of animals (animals = ["cat", "snake", "elephant", "fish"]), and then you decide to only use animalls with legs, which are those in slots 1 and 3. To slice you would do the following: animalswithlegs = animals.slice(1, 3) and the return is animalswithlegs = ["cat", "elephant"].

  • What did you Google to help you with this task, and how did you pick your results? Your answer: I fist wanted to know if there was a difference b/w a Ruby and JavaScript array, and I found a comparison in GitHub that helped me see the similarities and differences. I then Googled JavaScript "array slice method" and used the search box within developer.mozilla.org and scotch.io to find examples of a splice.

2. Data Types (15 min)

Imagine that you're taking your favorite board game and turning it into a computer-based game.

  • Name of board game: Clue

  • Use the space below to categorize game data into each of the following data types. You should have a minimum of two pieces of data for each category.

  1. String data:
  • suspects = ["Colonel Mustard", "Miss Scarlet", etc.]
  • weapons = ["Rope", "Lead Pipe", etc.)
  1. Integer and/or float data:
  • room_number (1, 2, 3, 4, 5, 6, 7, 8, 9)
  1. Boolean data:
  • if guess is correct = TRUE
  • if guess is wrong = FALSE
  1. Array data:
  • character_color = ["yellow", "red", etc.]
  • secret_passage = ["inlounge", "inconservatory", etc.]
  1. Hash or Object data:
  • {"Colonerl Mustard": yellow, "Miss Scarlet": red, etc.}
  • {"The Study": 1, "Kitchen": 2, etc.}

3. Modify your Bash Profile (10 min)

  • Watch this video and follow each step to modify your own bash profile. As mentioned in the video, you will need this snippet below:
# get current branch in git repo
function parse_git_branch() {
  BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
  if [ ! "${BRANCH}" == "" ]
  then
    STAT=`parse_git_dirty`
    echo "[${BRANCH}${STAT}]"
  else
    echo ""
  fi
}

# get current status of git repo
function parse_git_dirty {
  status=`git status 2>&1 | tee`
  dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
  untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`
  ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`
  newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`
  renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`
  deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`
  bits=''
  if [ "${renamed}" == "0" ]; then
    bits=">${bits}"
  fi
  if [ "${ahead}" == "0" ]; then
    bits="*${bits}"
  fi
  if [ "${newfile}" == "0" ]; then
    bits="+${bits}"
  fi
  if [ "${untracked}" == "0" ]; then
    bits="?${bits}"
  fi
  if [ "${deleted}" == "0" ]; then
    bits="x${bits}"
  fi
  if [ "${dirty}" == "0" ]; then
    bits="!${bits}"
  fi
  if [ ! "${bits}" == "" ]; then
    echo " ${bits}"
  else
    echo ""
  fi
}

export PS1="\u\w\`parse_git_branch\`$ "

4. Questions/Comments/Confusions

If you have any questions, comments, or confusions from the any of the readings that you would like an instructor to address, list them below:

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