Tech Junkie Blog: June 2018

Tuesday, June 26, 2018

If you want to know your way around Red Hat Enterprise Linux distribution, but the you don't have the financial ability to obtain a license.  CentOS is your best bet get to the the Red Hat Enterprise Linux official experience.  Because CentOS is a binary compatible version of Red Hat Enterprise Linux.  Meaning all the things that matters are the same, only the branding and logos are different.  CentOS is open sourced and can be downloaded for free.  Although it might be a couple of versions behind Red Hat Enterprise Linux.  But, you should be able to perform everything you can with CentOS that you can with Red Hat Enterprise.  Below is a step by step instruction on how to install CentOS in Oracle VirtualBox.

Step-By-Step Instructions:

1.  Type http://centos.org in your browser
2.  Click on the "Get CentOS Now" button

Monday, June 25, 2018

The lastIndexOf() method searches for last appearance the element in the array that matches the passed in value. In this example we will search for the value 60.50 in the array.  The lastIndexOf() method takes two arguments.  The first argument is the value to search for, the second argument is optional and specifies the index to start the search at.  If the second argument is omitted the search will start at the first element of the array.

    <script>
        var oilPrices = [70.15, 69.50, 71.23, 74.32, 69.50, 76.99];

        var searchAtBeginning = oilPrices.lastIndexOf(60.50);

        var searchAtIndex = oilPrices.lastIndexOf(60.50,2);

        console.log("searchAtBeginning: " + searchAtBeginning);
        console.log("searchAtIndex: " + searchAtIndex);
    </script>

Here is the output:









As you can see the first lastIndexOf() method call returns the index of 4 because that's where 60.50 resides.  It was able to find the element because the second argument was omitted therefore the search starts at the end of the array and returns the first index that it finds from the end.  The second lastIndexOf() method call has the value of 1 as the second argument that tells the method start the search at index 2 in the array because that's the new end of the array according to the method.


Tuesday, June 19, 2018

In this post we are going to install the Putty client for Windows.  Which is the most common way to connect to a Linux instance remotely.

Here are the steps to install Putty:

1.  Go to the URL https://www.putty.org/
2. Click on the "Download" link


3. Click select the 64-bit version
















4.  Click "Open" to install if your are using "Chrome"













5.  Click "Next" on the "Welcome" screen
6.  Accept the file path
7.  Eventually you will get to the "Product Features" install everything on the hard drive, then click "Install"
























8. Click "Finish"






Monday, June 18, 2018

The indexOf() method searches for the element in the array that matches the passed in value.
In this example we will search for the value 60.50 in the array.  The indexOf() method takes two arguments.  The first argument is the value to search for, the second argument is optional and specifies the index to start the search at.  If the second argument is omitted the search will start at the first element of the array.

    <script>
        var oilPrices = [70.15, 69.50, 71.23, 74.32, 76.99];

        var searchAtBeginning = oilPrices.indexOf(60.50);

        var searchAtIndex = oilPrices.indexOf(60.50,2);

        console.log("searchAtBeginning: " + searchAtBeginning);
        console.log("searchAtIndex: " + searchAtIndex);
    </script>

Here is the output:







As you can see the first indexOf() method call returns the index of 1 because that's where 60.50 resides.  It was able to find the element because the second argument was omitted there the search starts at the beginning array.  The second indexOf() method call has the value of 2 as the second argument that tells the method start the search at index 2 in the array.  Since the value 60.50 exists at index 1, the method returns a -1 which means it cannot find the value.


Monday, June 11, 2018

The some() array works similar to the every() method, it also returns true or false when the condition is met.  some() needs to match just one element in the array that meets the condition to return true.  So lets run the same code that we ran for the every() method.  We will test to see if the array is greater than 50 for the first condition, and then we will test to see if the array is greater than 70 for the second condition.  For the every() method the first condition returns true, while the second condition returns false.  Let's see what happens with the some() method.


    <script>
        var oilPrices = [70.15, 69.50, 71.23, 74.32, 76.99];

        var greaterThanFifty = oilPrices.some(function (value) { return value > 50; });

        var greaterThanSeventy = oilPrices.some(function (value) { return value > 70 });

        console.log("greaterThanFifty: " + greaterThanFifty);
        console.log("greaterThanSeventy: " + greaterThanSeventy);
    </script>







As you can see both conditions return true because at least one of the element in the array meets the condition.


Monday, June 4, 2018

The every() method is a method that tests a condition on every array element and makes sure that all the elements meets the criteria.  It returns true or false.

The code below test to see if the oil prices array is greater than $50 or greater than $70


    <script>
        var oilPrices = [70.15, 69.50, 71.23, 74.32, 76.99];

        var greaterThanFifty = oilPrices.every(function (value) { return value > 50; });

        var greaterThanSeventy = oilPrices.every(function (value) { return value > 70 });

        console.log("greaterThanFifty: " + greaterThanFifty);
        console.log("greaterThanSeventy: " + greaterThanSeventy);
    </script>







As you can see the first condition is true because all of the elements in the array are greater than 50.  However, the second condition returns false because 69.50 is not greater than 70 even though the rest of the elements in the array are greater than 70.