<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Denise Pen</title>
    <description>The latest articles on DEV Community by Denise Pen (@denisepen).</description>
    <link>https://dev.to/denisepen</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F127296%2F5bed9b76-a298-45e5-8e74-c78a42beebf3.jpg</url>
      <title>DEV Community: Denise Pen</title>
      <link>https://dev.to/denisepen</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/denisepen"/>
    <language>en</language>
    <item>
      <title>Learning Java</title>
      <dc:creator>Denise Pen</dc:creator>
      <pubDate>Mon, 25 Feb 2019 19:20:40 +0000</pubDate>
      <link>https://dev.to/denisepen/learning-java-1m2l</link>
      <guid>https://dev.to/denisepen/learning-java-1m2l</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IXCSW6Ws--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/tg6tPAH.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IXCSW6Ws--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/tg6tPAH.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the past few weeks I have been teaching myself Java. The languages I have worked with in the past (Ruby and Javascript) have been mainly for web development. I've decided that it's time to branch out and learn something new. I realize that Java can also be used for web development but it's also used for so much more.    &lt;/p&gt;

&lt;p&gt;Below is a list of references I have been using on my journey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Introductory Book:&lt;/strong&gt;&lt;br&gt;
&lt;a href="http://www.greenteapress.com/thinkapjava/thinkapjava.pdf"&gt;Think Java: How To Think Like A Computer Scientist&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For anyone considering learning Java, this is the first resource you should examine. It's written by a computer science professor who was unhappy with the huge and complex textbooks first year computer science students were given. This book is only 266 pages (including appendices) and uses the Java language to introduce students to basic computer science ideas.  Because it's so short it can be read rather quickly so you get a quick overview of the syntax of the language. &lt;/p&gt;

&lt;p&gt;This book was a great intro to Java, object oriented programming in Java, and basic problem solving with the language. The language is presented in a very elementary and thorough way so the basics are extremely easy to absorb.  If you're curious about the language and just want a quick peek to see if it's something you want to learn I highly encourage you to give this book a read. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Text Book:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.scribd.com/document/265519876/Starting-Out-With-Java-pdf"&gt;Starting Out With Java&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This is a text book used in universities for introductory computer science courses.  Unlike the book above, this book is very thick (over 1000 pages) and chock full of detail. However, it is very easy to read. The concepts are presented in depth with accompanying illustrations. The end of the book also covers algorithms and data structures so this book can be used to prep for interviews. &lt;/p&gt;

&lt;p&gt;I found myself using this book in tandem with the video course (listed below). Whenever a topic was presented in the video course I would look it up in this book to get more detail.&lt;/p&gt;

&lt;p&gt;I have a hard copy of the book but the link above gives you access to the pdf version.      &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Video Course:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://www.udemy.com/java-the-complete-java-developer-course/"&gt;Udemy Java course&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When possible, I like to supplement my learning with a video tutorial from Udemy. I am a visual learner and it helps me to see another person writing code, making mistakes, and discussing their approaches to a problem.&lt;/p&gt;

&lt;p&gt;This course covers everything from the basic syntax of the language to working with databases, networking, building unit tests, and more. &lt;/p&gt;

&lt;p&gt;I am only about 30% of the way through this course but from what I have seen everything is explained thoroughly and the pace is perfect for someone very new to the language. Also, the instructor and his team have responded to questions in less than 24 hours.  &lt;/p&gt;

&lt;p&gt;As I said, I am just beginning my journey to learn Java so this list is only the beginning. If you have any recommendations to add to my list, please feel free to leave them in the comments below.  &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published &lt;a href="http://deniseonaquest.com/learning_java"&gt;here&lt;/a&gt;.&lt;/em&gt;      &lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>java</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Recursion</title>
      <dc:creator>Denise Pen</dc:creator>
      <pubDate>Mon, 18 Feb 2019 20:50:39 +0000</pubDate>
      <link>https://dev.to/denisepen/recursion-1kab</link>
      <guid>https://dev.to/denisepen/recursion-1kab</guid>
      <description>&lt;p&gt;&lt;strong&gt;What Is Recursion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Recursion is a process that calls itself.  With respect to programming, recursion is a function that calls itself. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Does It Work?&lt;/strong&gt;&lt;br&gt;
A recursive function calls itself until it reaches the base case.&lt;/p&gt;

&lt;p&gt;The base case is where the recursion ends. Without the base case your function would not know when to stop calling itself. Once the base case is reached the function stops calling itself and returns its final value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's Look At An Example&lt;/strong&gt;&lt;br&gt;
Let's look at the following example of recursion:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0muurunj6d3aqyfiay59.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0muurunj6d3aqyfiay59.png" alt="Imgur" width="800" height="346"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have a function that counts down from the number given to the function as an argument, until it gets to 1.  &lt;/p&gt;

&lt;p&gt;The &lt;em&gt;base case&lt;/em&gt; instructs the function to return once the number has reached 1 &lt;br&gt;
( &amp;lt;=0 ).&lt;/p&gt;

&lt;p&gt;The remainder of the function prints out the current value of the number and then decrements it before the &lt;strong&gt;countdown&lt;/strong&gt; function is called again.&lt;/p&gt;

&lt;p&gt;This cycle repeats until the number has reached the base case, at which point it prints out &lt;em&gt;"You've reached the end"&lt;/em&gt; and the returns and exits the function.&lt;/p&gt;

&lt;p&gt;Let's execute the function with a number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;countdown(4);

=&amp;gt; 4
=&amp;gt; 3
=&amp;gt; 2
=&amp;gt; 1
=&amp;gt; You've reached the end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above function could have been solved with a simple for loop as well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function countdown(num) {
    for (let i = num; i &amp;gt; 0; i--) {
        console.log(i)
    }
    console.log("You've reached the end")
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see for this simple example the for loop is much easier to use and understand. However, it is important to become familiar with recursion because is is used extensively in programming. Also, recursion comes up frequently in technical job interviews so take the time now to learn it.&lt;/p&gt;

</description>
      <category>recursion</category>
      <category>javascript</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Looking At Linked Lists</title>
      <dc:creator>Denise Pen</dc:creator>
      <pubDate>Mon, 11 Feb 2019 15:11:22 +0000</pubDate>
      <link>https://dev.to/denisepen/looking-at-linked-lists-1277</link>
      <guid>https://dev.to/denisepen/looking-at-linked-lists-1277</guid>
      <description>&lt;p&gt;A linked list is a data structure that includes a 'linked' sequence of nodes. Each node contains data.&lt;/p&gt;

&lt;p&gt;In a singly linked list each node points to the next node in the linked list:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2F4Y6bLlM.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2F4Y6bLlM.png" alt="Imgur"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In a doubly-linked list each node points to the next node as well as the previous node:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FsCGHclk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FsCGHclk.png" alt="Imgur"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In order to access a single node you must traverse the entire linked list until you land on that node.&lt;/p&gt;

&lt;p&gt;For example, to find node 4 we must start at node 1, move to node 2, then node 3, and finally to node 4:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2F6ddcC2N.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2F6ddcC2N.png" alt="Imgur"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is very different from an array where each value can be found by using it's index, or a dictionary (hash/object) where a value can be found using it's key.&lt;/p&gt;

&lt;p&gt;One benefit of a linked list is that you can add a node to the beginning of a linked list using constant time (O(1)). This means that subsequent nodes do not need to be re-indexed as they do in an array.  The newest node simply becomes the "head" of the linked list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FpuV3Ehl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FpuV3Ehl.png" alt="Imgur"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you ever used linked lists in your applications?&lt;/p&gt;

&lt;p&gt;If so why did you choose them over other data structures?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="http://deniseonaquest.com/looking_at_linked_lists" rel="noopener noreferrer"&gt;http://deniseonaquest.com/looking_at_linked_lists&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>datastructures</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Tackling Algorithms: Counting Unique Values</title>
      <dc:creator>Denise Pen</dc:creator>
      <pubDate>Mon, 04 Feb 2019 01:15:04 +0000</pubDate>
      <link>https://dev.to/denisepen/tackling-algorithms-counting-unique-values-1a5n</link>
      <guid>https://dev.to/denisepen/tackling-algorithms-counting-unique-values-1a5n</guid>
      <description>&lt;h3&gt;
  
  
  Problem:  Given an array of integers, count the number of unique values.
&lt;/h3&gt;

&lt;p&gt;For example, if we have the following array:&lt;/p&gt;

&lt;p&gt;[1, 1, 1, 1, 1, 1, 3, 5]&lt;/p&gt;

&lt;p&gt;the count of original values is 3 =&amp;gt; 1, 3, and 5.&lt;/p&gt;

&lt;h4&gt;
  
  
  First Solution: Frequency Counter
&lt;/h4&gt;

&lt;p&gt;The first time I attempted this problem I decided to: &lt;br&gt;
&lt;strong&gt;1. Create an empty object&lt;/strong&gt;, and for every integer encountered either&lt;br&gt;
&lt;strong&gt;2.  Add that integer to the object&lt;/strong&gt; or, if that integer is already in the object &lt;br&gt;
&lt;strong&gt;3. Increment its value by 1&lt;/strong&gt;.  &lt;/p&gt;

&lt;p&gt;Here is my code (using javascript):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function countUniqueValues(arr){

  let newObj = {};                  //created new empty object to hold integer values.

  for (let i=0; i&amp;lt;arr.length; i++){ //iterate over the array


      let char = arr[i];

      if ( newObj[char] &amp;gt; 0 ) {     //if the item is already in newObj 
          newObj[char]++            //increment its value by 1
      } else {
          newObj[char] = 1          //if the integer is not already in newObj put it there with a value of 1
      }

  }
  return Object.keys(newObj).length;   //return length of array returned by Object.keys(newObj)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running &lt;strong&gt;countUniqueValues([3,3,3,4,4,4,5,5,5,5,5,6])&lt;/strong&gt; returns 4. because there are 4 unique values =&amp;gt; 3, 4, 5, and 6.&lt;/p&gt;

&lt;p&gt;If we want to see the value of newObj at the end of the function we can put *console.log(newObj) before the final return:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
}
  console.log(newObj)
  return Object.keys(newObj).length;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Running &lt;strong&gt;countUniqueValues([3,3,3,4,4,4,5,5,5,5,5,6])&lt;/strong&gt; prints a newObj value of&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
newObj = {
     3: 3, 
     4: 3, 
     5: 5,
     6: 1
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see there are 4 keys in the object: 3, 4, 5, and 6. &lt;/p&gt;

&lt;p&gt;At this point all that is left to do is count the number of keys which we accomplish with Object.keys(newObj).length.&lt;/p&gt;

&lt;h4&gt;
  
  
  Second Solution: Multiple Pointers
&lt;/h4&gt;

&lt;p&gt;(&lt;em&gt;Taken from &lt;a href="https://www.udemy.com/js-algorithms-and-data-structures-masterclass/learn/v4/overview" rel="noopener noreferrer"&gt;this course&lt;/a&gt;&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;To use this method you must start with a sorted array.&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Compare the value at the  index of i with the value at the index of j.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If they are equal move j ahead until we find something that is not equal to i.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If they are not equal move i up 1 space and put the value of j into i's new place.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Continue to do this until you have gone through the array completely.  'i' will be at the index of the final unique value. If we add 1 to this index number we will have the total number of unique values.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will  use the same array as above: &lt;strong&gt;[3,3,3,4,4,4,5,5,5,5,5,6]&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's walk through the code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function countUniqueValues(arr) {
    var i=0;

    for (var j=1; j &amp;lt; arr.length; j++) {
        if(arr[i] !== arr[j]){
            i++;
            arr[i] = arr[j]
        }
    console.log(i,j)
    }
    return i + 1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FUUJpmbB.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FUUJpmbB.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fyo7Lobw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2Fyo7Lobw.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After we have gone completely through the array one time every unique value is at the beginning of the array and 'i' is in the position of the final unique value:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FkvUCdF5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi.imgur.com%2FkvUCdF5.png" alt="img"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We see that i is at index 3 so we just add 1 to this to get 4 which is the total number of unique values:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return i + 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because we are adding 1 to i this become a problem when we are given an empty array, [].  If we were to use the above solution we would get a return value of 1.  To combat this we can add a check to the beginning of the function to check for empty arrays:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (arr.length === 0 ) return 0;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final function is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function countUniqueValues(arr) {
  if (arr.length === 0 ) return 0;
    var i=0;

    for (var j=1; j &amp;lt; arr.length; j++) {
        if(arr[i] !== arr[j]){
            i++;
            arr[i] = arr[j]
        }
    console.log(i,j)
    }
    return i + 1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the second solution to this problem only runs through the array once and there was no need to create an additional object or count the number of keys of that object so this second solution is much more efficient than the first.  Although both solutions should have time complexity of O(n), the second solution is an improvement when it comes to space complexity.&lt;/p&gt;

&lt;p&gt;How would you approach this problem?&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>javascript</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Setting Up Vagrant for a Rails Application: Part 2 </title>
      <dc:creator>Denise Pen</dc:creator>
      <pubDate>Thu, 24 Jan 2019 04:54:17 +0000</pubDate>
      <link>https://dev.to/denisepen/setting-up-vagrant-for-a-rails-application-part-2--2gkm</link>
      <guid>https://dev.to/denisepen/setting-up-vagrant-for-a-rails-application-part-2--2gkm</guid>
      <description>&lt;p&gt;In a previous &lt;a href="https://dev.to/denisepen/setting-up-vagrant-for-a-rails-application-kgc"&gt;post&lt;/a&gt; we configured the Vagrant File in preparation of using the vagrant box to host a rails application. In this post I will walk through how to configure he vagrant box and include your rails application to it.&lt;/p&gt;

&lt;p&gt;After the vagrant file has been created you can simply run &lt;em&gt;vagrant up&lt;/em&gt; to start it.  To ssh into it simply use the command &lt;em&gt;vagrant ssh&lt;/em&gt; and you will see that you are now in your vagrant box. We are now in a fully functioning yet isolated operating system.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring The Vagrant Box
&lt;/h3&gt;

&lt;p&gt;Since I plan to run a rails application in this environment I need to add everything needed to run rails: git, rvm, ruby, rails, nodejs, and Postgresql. I took my instruction for setting up git, rvm, ruby, and rails from this &lt;a href="http://tutorials.jumpstartlab.com/topics/vagrant_setup.html"&gt;article&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;Install git:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get update
sudo apt-get install git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Install curl:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install curl
\curl -sSL https://get.rvm.io | bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Load rvm:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;source /home/vagrant/.rvm/scripts/rvm
rvm requirements
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Install whatever version of Ruby you choose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rvm install 2.1
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Set  your Ruby default version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rvm use 2.1 --default
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Verify your Ruby version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ruby -v
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Install rails:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem install rails
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Check your rails version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rails -v
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Install bundler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;gem install bundler
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Bundle your gems:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bundle install
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Install node js:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install nodejs
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Install Your Database(s) - I used Postgresql&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt-get install postgresql libpq-dev
$ sudo su - postgres
$ psql

    postgres=# CREATE USER vagrant;
    postgres=# CREATE DATABASE your_database_name;
    postgres=# GRANT ALL PRIVILEGES ON DATABASE "your_database_name" to vagrant;
    postgres=# \q
$ exit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The database(s) that you created above should have the same name as the database(s) used in your rails application. Database names are set in the database.yml file.&lt;br&gt;
For example, my application's database.yml file has the following setup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;default: &amp;amp;default
    adapter: postgresql
    pool: &amp;lt;%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %&amp;gt;

development:
    adapter: postgresql
    username: vagrant
    database: main_rest_development

test:
    adapter: postgresql
    username: vagrant
    database: main_rest_test

production:
  &amp;lt;&amp;lt;: *default
  database: main_rest_production
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Please keep in mind that the &lt;strong&gt;alignment of your text&lt;/strong&gt; in this file must be perfect or it won't be read correctly! &lt;/p&gt;

&lt;p&gt;Once all of this is done your vagrant environment is configured and ready to run your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating An Application From Scratch
&lt;/h2&gt;

&lt;p&gt;If you will be creating an application from scratch you will need to do that on your local machine. &lt;/p&gt;

&lt;h3&gt;
  
  
  Performed on you local machine - Not Vagrant
&lt;/h3&gt;

&lt;p&gt;You should open a new tab in your terminal to the same directory where you created your Vagrant file. &lt;/p&gt;

&lt;p&gt;To create a new application simply run &lt;em&gt;rails new your-app-name --database=postgresql&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;This will create a new application in this directory and the database should be configured with the names and permissions you assigned above. &lt;/p&gt;

&lt;h3&gt;
  
  
  Performed in Vagrant
&lt;/h3&gt;

&lt;p&gt;To run this application you must go into the other terminal tab where  the vagrant box is running. Move (cd) into the '/vagrant_file' directory (or whichever directory you designated as the synced folder in the Vagrant file). Move (cd) into the new app's directory. Run &lt;em&gt;'bundle install'&lt;/em&gt;. Then start your rails server using &lt;em&gt;rails s&lt;/em&gt;. Your application should now be running on the port or url you designated.    &lt;/p&gt;

&lt;h2&gt;
  
  
  Using An Existing Application
&lt;/h2&gt;

&lt;p&gt;This must also be performed on the local machine.&lt;/p&gt;

&lt;h3&gt;
  
  
  Performed on you local machine - Not Vagrant
&lt;/h3&gt;

&lt;p&gt;You should open a new tab in your terminal to the same directory where you created your Vagrant file. If you have an existing application that you want to use you can simply clone the code from github to  your local machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone your_existing_app
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You will need to update the database.yml file to have the correct database, and database names.&lt;/p&gt;

&lt;h3&gt;
  
  
  Performed in Vagrant
&lt;/h3&gt;

&lt;p&gt;To run this application you must go into the other terminal tab where  the vagrant box is running. &lt;/p&gt;

&lt;p&gt;Move (cd) into the '/vagrant_file' directory (or whichever directory you designated as the synced folder in the Vagrant file). &lt;/p&gt;

&lt;p&gt;Move (cd) into the new app's directory. &lt;/p&gt;

&lt;p&gt;Run &lt;em&gt;'bundle install'&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;Then start your rails server using &lt;em&gt;rails s&lt;/em&gt;. Your application should now be running on the port or url you designated. &lt;/p&gt;

&lt;p&gt;When you you are finished running your application you can stop it. Move into the Vagrant's root file and type &lt;em&gt;exit&lt;/em&gt;. This will put you back into you local machine.&lt;/p&gt;

&lt;p&gt;On your local machine type &lt;em&gt;vagrant destroy&lt;/em&gt; and your box is now stopped.  &lt;/p&gt;

&lt;p&gt;It is quite alot of work to configure the Vagrant box to run your application. However, once configured this box can be used for any other rails application that needs the same setting in the future. It can also be copied and moved to other systems if necessary. Vagrant provides total isolation which will give your apps much needed stability.&lt;/p&gt;

</description>
      <category>vagrant</category>
      <category>devops</category>
      <category>rails</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Setting Up Vagrant for a Rails Application: Part 1</title>
      <dc:creator>Denise Pen</dc:creator>
      <pubDate>Mon, 21 Jan 2019 15:30:09 +0000</pubDate>
      <link>https://dev.to/denisepen/setting-up-vagrant-for-a-rails-application-kgc</link>
      <guid>https://dev.to/denisepen/setting-up-vagrant-for-a-rails-application-kgc</guid>
      <description>&lt;p&gt;Recently I was given a technical challenge that required me to create a rails application inside an isolated environment.  I was given the choice of either using a Docker container or a virtual machine. &lt;/p&gt;

&lt;p&gt;I didn't have any experience with either of these environments but after doing some research I decided to use a virtual machine (vm). Though they both perform the same task, Vagrant seemed to need less set up to get started. &lt;/p&gt;

&lt;p&gt;To begin I downloaded VirtualBox which is the virtualization engine that Vagrant will be built on top of. Then I downloaded Vagrant.&lt;/p&gt;

&lt;p&gt;I then created a directory that will be the root of my vagrant environment and cd'd into the directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir vagrant_demo
cd vagrant_demo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To initialize this directory to be used with Vagrant you must run 'vagrant init' followed by the name of the base operating system you want to be used in your Vagrant environment. I used 'ubuntu/trusty64' to create a Linux environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vagrant init ubuntu/trusty64
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The above command creates a VagrantFile in your directory. You receive the following message after running 'vagrant init':&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This Vagrantfile dictates how your Vagrant environment is configured and can be changed to fit each individual application. Below is a copy of the Vagrantfile we just created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# -*- mode: ruby -*-&lt;/span&gt;
&lt;span class="c1"&gt;# vi: set ft=ruby :&lt;/span&gt;

&lt;span class="c1"&gt;# All Vagrant configuration is done below. The "2" in Vagrant.configure&lt;/span&gt;
&lt;span class="c1"&gt;# configures the configuration version (we support older styles for&lt;/span&gt;
&lt;span class="c1"&gt;# backwards compatibility). Please don't change it unless you know what&lt;/span&gt;
&lt;span class="c1"&gt;# you're doing.&lt;/span&gt;
&lt;span class="no"&gt;Vagrant&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"2"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
  &lt;span class="c1"&gt;# The most common configuration options are documented and commented below.&lt;/span&gt;
  &lt;span class="c1"&gt;# For a complete reference, please see the online documentation at&lt;/span&gt;
  &lt;span class="c1"&gt;# https://docs.vagrantup.com.&lt;/span&gt;

  &lt;span class="c1"&gt;# Every Vagrant development environment requires a box. You can search for&lt;/span&gt;
  &lt;span class="c1"&gt;# boxes at https://vagrantcloud.com/search.&lt;/span&gt;
  &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;vm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;box&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ubuntu/trusty64"&lt;/span&gt;

  &lt;span class="c1"&gt;# Disable automatic box update checking. If you disable this, then&lt;/span&gt;
  &lt;span class="c1"&gt;# boxes will only be checked for updates when the user runs&lt;/span&gt;
  &lt;span class="c1"&gt;# `vagrant box outdated`. This is not recommended.&lt;/span&gt;
  &lt;span class="c1"&gt;# config.vm.box_check_update = false&lt;/span&gt;

  &lt;span class="c1"&gt;# Create a forwarded port mapping which allows access to a specific port&lt;/span&gt;
  &lt;span class="c1"&gt;# within the machine from a port on the host machine. In the example below,&lt;/span&gt;
  &lt;span class="c1"&gt;# accessing "localhost:8080" will access port 80 on the guest machine.&lt;/span&gt;
  &lt;span class="c1"&gt;# NOTE: This will enable public access to the opened port&lt;/span&gt;
  &lt;span class="c1"&gt;# config.vm.network "forwarded_port", guest: 80, host: 8080&lt;/span&gt;

  &lt;span class="c1"&gt;# Create a forwarded port mapping which allows access to a specific port&lt;/span&gt;
  &lt;span class="c1"&gt;# within the machine from a port on the host machine and only allow access&lt;/span&gt;
  &lt;span class="c1"&gt;# via 127.0.0.1 to disable public access&lt;/span&gt;
  &lt;span class="c1"&gt;# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"&lt;/span&gt;

  &lt;span class="c1"&gt;# Create a private network, which allows host-only access to the machine&lt;/span&gt;
  &lt;span class="c1"&gt;# using a specific IP.&lt;/span&gt;
  &lt;span class="c1"&gt;# config.vm.network "private_network", ip: "192.168.33.10"&lt;/span&gt;

  &lt;span class="c1"&gt;# Create a public network, which generally matched to bridged network.&lt;/span&gt;
  &lt;span class="c1"&gt;# Bridged networks make the machine appear as another physical device on&lt;/span&gt;
  &lt;span class="c1"&gt;# your network.&lt;/span&gt;
  &lt;span class="c1"&gt;# config.vm.network "public_network"&lt;/span&gt;

  &lt;span class="c1"&gt;# Share an additional folder to the guest VM. The first argument is&lt;/span&gt;
  &lt;span class="c1"&gt;# the path on the host to the actual folder. The second argument is&lt;/span&gt;
  &lt;span class="c1"&gt;# the path on the guest to mount the folder. And the optional third&lt;/span&gt;
  &lt;span class="c1"&gt;# argument is a set of non-required options.&lt;/span&gt;
  &lt;span class="c1"&gt;# config.vm.synced_folder "../data", "/vagrant_data"&lt;/span&gt;

  &lt;span class="c1"&gt;# Provider-specific configuration so you can fine-tune various&lt;/span&gt;
  &lt;span class="c1"&gt;# backing providers for Vagrant. These expose provider-specific options.&lt;/span&gt;
  &lt;span class="c1"&gt;# Example for VirtualBox:&lt;/span&gt;
  &lt;span class="c1"&gt;#&lt;/span&gt;
  &lt;span class="c1"&gt;# config.vm.provider "virtualbox" do |vb|&lt;/span&gt;
  &lt;span class="c1"&gt;#   # Display the VirtualBox GUI when booting the machine&lt;/span&gt;
  &lt;span class="c1"&gt;#   vb.gui = true&lt;/span&gt;
  &lt;span class="c1"&gt;#&lt;/span&gt;
  &lt;span class="c1"&gt;#   # Customize the amount of memory on the VM:&lt;/span&gt;
  &lt;span class="c1"&gt;#   vb.memory = "1024"&lt;/span&gt;
  &lt;span class="c1"&gt;# end&lt;/span&gt;
  &lt;span class="c1"&gt;#&lt;/span&gt;
  &lt;span class="c1"&gt;# View the documentation for the provider you are using for more&lt;/span&gt;
  &lt;span class="c1"&gt;# information on available options.&lt;/span&gt;

  &lt;span class="c1"&gt;# Enable provisioning with a shell script. Additional provisioners such as&lt;/span&gt;
  &lt;span class="c1"&gt;# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the&lt;/span&gt;
  &lt;span class="c1"&gt;# documentation for more information about their specific syntax and use.&lt;/span&gt;
  &lt;span class="c1"&gt;# config.vm.provision "shell", inline: &amp;lt;&amp;lt;-SHELL&lt;/span&gt;
  &lt;span class="c1"&gt;#   apt-get update&lt;/span&gt;
  &lt;span class="c1"&gt;#   apt-get install -y apache2&lt;/span&gt;
  &lt;span class="c1"&gt;# SHELL&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This file is written in the Ruby programming language and as you can see most of it is commented out. The only lines not commented out are the lines to configure the vagrant box (or operating system):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Vagrant.configure("2") do |config|
    config.vm.box = "ubuntu/trusty64"
end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In order to define other aspects of your virtual machine you can modify the Vagrant file as needed. If no modifications are made default settings are used. There are 5 specs in this file that can be modified:&lt;/p&gt;

&lt;p&gt;-&lt;em&gt;config.vm.box&lt;/em&gt; - This defines the operating system of your virtual machine and for our app we used ubuntu/trusty64.&lt;/p&gt;

&lt;p&gt;-&lt;em&gt;config.vm.provider&lt;/em&gt;- This defines the vm provider or base for our vagrant environment. We are using VirtualBox. We can also modify the memory and number of cpu's needed for the vm. For my rails app I increased the memory from the default value to 4G:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;config.vm.provider "virtualbox" do |vb|
    vb.memory = "4096"
end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you needed more cpu's  you could use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;config.vm.provider "virtualbox" do |vb|
    vb.cpus = 2
end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;-&lt;em&gt;config.vm.network&lt;/em&gt; - This is how your host computer sees your vagrant box and application. Here you can configure the ip address and ports for your application.&lt;br&gt;
Since rails applications default to port 3000  I updated this network setting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; config.vm.network "forwarded_port", guest: 3000, host: 3000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Where the guest is the vm and the host is our computer.&lt;/p&gt;

&lt;p&gt;-&lt;em&gt;config.vm.synced.folder&lt;/em&gt; - This is where you define how the files on your virtual  machine (your Vagrant box) will access files from the host (your computer). This allows you to create and alter your project files on your computer without having to do it in the virtual machine.  These files will then be automatically synced with the Vagrant box if desired. I used the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;config.vm.synced_folder ".", "/vagrant_files"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The first argument "." points to the current directory on &lt;em&gt;our computer&lt;/em&gt; or the 'vagrant_demo' directory. This is where we will put our rails application and tells our vagrant box to use these files. The second argument, "/vagrant" is the directory we want to be built on the vm to house our rails application. In essence our files are on both our computer and in the vm but we can alter them on our computer and they will be automatically housed and synced on the vm in the "/vagrant_files" directory. You can name this directory whatever you want. I just used "/vagrant_files" for simplicity.&lt;/p&gt;

&lt;p&gt;-&lt;em&gt;config.vm.provision&lt;/em&gt; - This is the heart and soul of the Vagrantfile. This is where we define how we want to set up the virtual environment. We can instruct the vm to retrieve and install any applications, gem, modules, or whatever we need here.  In the above automatically generated Vagrantfile we see an example of this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;config.vm.provision "shell", inline: &amp;lt;&amp;lt;-SHELL
     apt-get update
     apt-get install -y apache2
   SHELL
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Notice that because this is a linux machine we can use normal linux commands to define and set up our environment. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The final version of the Vagrant File is:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Vagrant.configure("2") do |config|

  config.vm.box = "ubuntu/trusty64"
  config.vm.network "forwarded_port", guest: 3000, host: 3000
  config.vm.synced_folder ".", "/vagrant_files"
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "4096"
  end
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Once we have defined the Vagrantfile we can use the command &lt;em&gt;vagrant up&lt;/em&gt; and this will get our vagrant box up and running.  &lt;/p&gt;

&lt;p&gt;In my next blog &lt;a href="https://dev.to/denisepen/setting-up-vagrant-for-a-rails-application-part-2--2gkm"&gt;post&lt;/a&gt; I will describe how to add the rails application to your vagrant box.  &lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>vagrant</category>
      <category>virtualbox</category>
      <category>rails</category>
    </item>
    <item>
      <title>Express HTTP Requests</title>
      <dc:creator>Denise Pen</dc:creator>
      <pubDate>Thu, 17 Jan 2019 18:41:30 +0000</pubDate>
      <link>https://dev.to/denisepen/express-http-requests-jkm</link>
      <guid>https://dev.to/denisepen/express-http-requests-jkm</guid>
      <description>&lt;p&gt;What's the best way to make an HTTP request in express? Using 'request', 'fetch', 'axios' or something else?&lt;/p&gt;

</description>
      <category>help</category>
    </item>
    <item>
      <title>Console.table()</title>
      <dc:creator>Denise Pen</dc:creator>
      <pubDate>Mon, 14 Jan 2019 16:21:25 +0000</pubDate>
      <link>https://dev.to/denisepen/consoletable-25l8</link>
      <guid>https://dev.to/denisepen/consoletable-25l8</guid>
      <description>&lt;p&gt;Like all javascript programmers I will frequently throw a &lt;em&gt;console.log&lt;/em&gt; into my code. I find it so much faster to log to the console than to deal with debugger for quick sanity checks. Recently I came across &lt;strong&gt;console.table&lt;/strong&gt; which blew my mind and won a permanent place in my heart.&lt;/p&gt;

&lt;h1&gt;
  
  
  What Is It?
&lt;/h1&gt;

&lt;p&gt;It's exactly what it sounds like - it allows you to log your data to the console as a table. Let's say we have the following array:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;let people = ["Frank", "Mary", "Bob"]&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;If we use &lt;em&gt;console.log&lt;/em&gt; we get this output in the console:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;["Frank", "Mary", "Bob"]&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;However, with &lt;em&gt;console.table&lt;/em&gt; we get:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IFHprFur--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/U1POfMK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IFHprFur--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/U1POfMK.png" alt="Imgur"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that we get a list of each item in the array as well as the item's index (or position in the array).This might seem like overkill for such a simple array but &lt;em&gt;console.table&lt;/em&gt; can also be used for objects. In fact the Mozilla Web Documents state: &lt;br&gt;
    &lt;em&gt;If data is an array, then its values will be the array indices. If data is an&lt;br&gt;
object, then its values will be the property names.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's look at an object:
&lt;/h2&gt;



&lt;p&gt;&lt;code&gt;let courses = {&lt;br&gt;
            math: "calculus",&lt;br&gt;
            science: "biology",&lt;br&gt;
            language: "french"&lt;br&gt;
  }&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;console.log&lt;/em&gt; gives us this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sp2rHkAS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/ounQpli.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sp2rHkAS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/ounQpli.png" alt="log_obj"&gt;&lt;/a&gt;&lt;br&gt;
while &lt;em&gt;console.table&lt;/em&gt; gives us this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QzTs640g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/dqZAHbJ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QzTs640g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/dqZAHbJ.png" alt="table_obj"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Now, an array of objects:
&lt;/h2&gt;

&lt;p&gt;Let's look at the following array:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;let students = [&lt;br&gt;
    {&lt;br&gt;
      name: "Beth",&lt;br&gt;
      course: "Math",&lt;br&gt;
      age: 25&lt;br&gt;
    },&lt;br&gt;
    {&lt;br&gt;
      name: "Adam",&lt;br&gt;
      course: "English",&lt;br&gt;
      age: 29&lt;br&gt;
    },&lt;br&gt;
    {&lt;br&gt;
      name: "Amy",&lt;br&gt;
      course: "Physics",&lt;br&gt;
      age: 32&lt;br&gt;
    },&lt;br&gt;
  ]&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;em&gt;console.log&lt;/em&gt; will return:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dhmWeODo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://i.imgur.com/oCSnnR3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dhmWeODo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://i.imgur.com/oCSnnR3.png" alt="log_arr_obj"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;console.table&lt;/em&gt; returns:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V4ypp-VN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/fVI9AA6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V4ypp-VN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/fVI9AA6.png" alt="table_arr_obj"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is fantastic because now our complicated array of objects is in an easy to read table. For me, it's so much easier to understand and grapple with data when it's in tabular form.  &lt;/p&gt;
&lt;h2&gt;
  
  
  One Last Thing...
&lt;/h2&gt;

&lt;p&gt;When using &lt;em&gt;console.table&lt;/em&gt; you can also restrict the columns that are shown in the table.  Continuing with the array of objects used above, if we only want the student's names and ages logged out we could use the following:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;console.table(students, ["name", "age"])&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;to return:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rF7nmTmY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/DPZXNeg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rF7nmTmY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.imgur.com/DPZXNeg.png" alt="name_age"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, &lt;em&gt;console.table&lt;/em&gt; gives you a few options to quickly review and analyze your data on the fly. &lt;/p&gt;

&lt;p&gt;What other debugging tools have you stumbled across that could be helpful?&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>debugging</category>
      <category>beginners</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
