AWS Cloud Practitioner (Level I)

Amazon Web Services (AWS) provides cloud-based computing platforms for use on-demand. AWS hosts the infrastructure and firmware, while the consumer (which can be an individual or even a Fortune 500 company) is provided access to utilize this infrastructure via the AWS dashboard.

This set-up is managed by the “shared responsibility model” in which AWS ensures the uptime of hardware and infrastructure while the consumer ensures its proper usage. The shared responsibility model is at the core of the AWS business operation.

AWS controls about a third of the current market share for cloud infrastructure services, shaming Microsoft, Google, and IBM’s market share percentages, both individually and combined. That makes an AWS certification significantly more valuable in terms of general marketability.

To get your foot in the door, you can attempt the AWS Cloud Practitioner certification, which tests general knowledge of services offered, pricing, and other basic concepts that assist in understanding the business side of AWS. This exam is available both proctored in person, or online. The exam itself costs an even $100 USD, and a significantly shorter practice test costs about $20 USD.

If you already have a decent understanding of AWS in general, or want to focus more on the technical side rather than marketing and business, you can skip the Cloud Practitioner certification and work on AWS Solutions Architect certification, which comes in two levels: Associate and Professional. You can also skip to my post on AWS Solutions Architect, Level I (coming soon!).

Here is a video that covers most of the topics which appear on a typical AWS Cloud Practitioner exam. If you can handle it, I suggest watching the video at a slightly higher speed, such as 1.25x to 1.5x, in order to make studying quicker. Just be sure you can still follow along, as the follow-along steps are crucial for truly understanding what is being discussed. Check it out:

I suggest watching this video in portions, over time, in order to properly digest the information provided. In addition, watch the video more than once, as this will allow your brain to catch info that was previously missed or not given much priority.

For the sake of clarity and completeness, the next levels of the AWS Cloud Practitioner lesson will go over these services and talk more in-depth about each one. Some levels will feature services which were not mentioned in the video, so these lessons could be useful for rounding out your knowledge.

Good luck, and keep an eye out for AWS Cloud Practitioner, Level II!

Logic Gates, Level III

Welcome back for another round with logic gates. If you haven’t already read Logic Gates, Level I or Logic Gates Level II, please do so in order to make sure you are fully caught up. Moving along…

We will start this lesson with the “buffer” gate. This gate is also known as a digital buffer or voltage buffer because of its function. The buffer provides a way to pass along an output that is the same value as the input. For instance, passing in a 1 will give you a 1, and a 0 will give you a 0. Here is the truth table just for completion:

Input A: 1 | Output Q: 1
Input A: 0 | Output Q: 0

The buffer gate is represented as such:

A “buffer” gate in “Distinctive Shape” symbolic illustration

Why use a buffer gate if there is no change in the output? Simply put, the purpose of the buffer gate is to increase the propagation delay in a circuit, which is just to say that it makes the signal take longer to reach its destination.

A buffer gate can also restore the strength of a weak output. This is because of the design of the buffer gate, which is usually two inverters back-to-back. This takes a weak input, inverts it twice, and with the inversion the input strength is restored in the strong output.

There is a version of the buffer gate known as the Tri-State Digital Buffer, which can take input as a control input alongside the data input. In this case, the control acts as gatekeeper.

When the control input is 1, then the data input is passed on as usual. However, if the control input is 0, then nothing is passed on, and this state is called the “Hi-Z” state. This is effectively the same as no output whatsoever.

Here is a truth table for the Tri-State Digital Buffer:

Data Input: 1 | Control Input: 0 | Output Q: Hi-Z
Data Input: 0 | Control Input: 0 | Output Q: Hi-Z
Data Input: 1 | Control Input: 1 | Output Q: 1
Data Input: 0 | Control Input: 1 | Output Q: 0

Notice that a 1 is only output if both the control and the data input are 1 as well.

That is about all for Level III, which gives a detailed description of the buffer gate and its purpose. More info coming in the next Level, so keep an eye out.

Good luck!

Logic Gates, Level II

Welcome back for another round with logic gates. If you haven’t already read Logic Gates, Level I, please do so in order to make sure you are fully caught up. Moving along…

The next gate we will look at is the “NOR” gate. This gate is essentially like the opposite of the “AND” gate in that both inputs must be 0 in order for the output to be 1, or true. Here is the truth table to demonstrate the “NOR” gate:

Input A: 0 | Input B: 0 | Output Q: 1
Input A: 0 | Input B: 1 | Output Q: 0
Input A: 1 | Input B: 0 | Output Q: 0
Input A: 1 | Input B: 1 | Output Q: 0


A “NOR” gate in “Distinctive Shape” symbolic illustration

Following the “NOR” gate on our list is the “NAND” gate, which outputs a 1 only if the inputs are not both 1. This can be thought of as “not and” in that a 0, or false, is output when both values are a 1, or true. Here is the truth table for “NAND”:

Input A: 0 | Input B: 0 | Output Q: 1
Input A: 0 | Input B: 1 | Output Q: 1
Input A: 1 | Input B: 0 | Output Q: 1
Input A: 1 | Input B: 1 | Output Q: 0


A “NAND” gate in “Distinctive Shape” symbolic illustration

After that, we have the “XOR” gate, which outputs 1, or true, strictly when only one input is a 1 or 0. Therefore, the other must be a 0 or 1, respectively. The “exclusive or” gate determines if both outputs are different. Here is the truth table showing the results:

Input A: 0 | Input B: 0 | Output Q: 0
Input A: 0 | Input B: 1 | Output Q: 1
Input A: 1 | Input B: 0 | Output Q: 1
Input A: 1 | Input B: 1 | Output Q: 0

Notice that when both values are the same, such as 0 & 0 and 1 & 1, the output is 0, or false.


A “XOR” gate in “Distinctive Shape” symbolic illustration

Finally, we will wrap up this section with the “XNOR” gate, which does the opposite of the “XOR” gate in that it determines if both inputs are the same. If both inputs are 0, or both inputs are 1, then the output will be 1, or true. Otherwise, it is 0, or false. Here is the truth table:

Input A: 0 | Input B: 0 | Output Q: 1
Input A: 0 | Input B: 1 | Output Q: 0
Input A: 1 | Input B: 0 | Output Q: 0
Input A: 1 | Input B: 1 | Output Q: 1


A “XNOR” gate in “Distinctive Shape” symbolic illustration

That wraps up Logic Gates, Level II. Most of the basics of the logic gates has now been covered, but there is more to learn about the symbolic representation and implementation of gates in the next levels.

Good luck!

Logic Gates, Level I

Logic gates, in an abstract sense, perform a Boolean function on one or more binary inputs. They take in binary data, decide if that data equals a 0 or 1, and then outputs that binary result.

In a physical sense, they can be transistors, diodes, or any number of physical objects with an “on” and “off” state. The “on” state is the binary 1, and an “off” state is the binary 0.

So let us start with a simple logic gate as an example. We will use the “AND” logic gate, which is a common and foundational piece of logic in general.

Assuming we have two binary bits of data coming into the “AND” gate, the gate will output a 1 if both inputs are 1 as well; otherwise, it will output a 0. Here is the truth table that represents these possible results:

Input A = 0 | Input B = 0 | Output Q = 0
Input A = 0 | Input B = 1 | Output Q = 0
Input A = 1 | Input B = 0 | Output Q = 0
Input A = 1 | Input B = 1 | Output Q = 1

Only in the final row, where both input 1 and input 2 are 1, does the “AND” gate output a 1 as well. Remember this.

An “AND” gate in “Distinctive Shape” symbolic illustration

Now, we can check if one or the other input is a 1 using the “OR” gate. Only if both inputs are 0 does the output equal 0. Here is the truth table for these results:

Input A = 0 | Input B = 0 | Output Q = 0
Input A = 0 | Input B = 1 | Output Q = 1
Input A = 1 | Input B = 0 | Output Q = 1
Input A = 1 | Input B = 1 | Output Q = 1

Notice the contrast with the “AND” table. Now, even if one of the inputs is a 0, the result can still be 1 if the other input is a 1 as well.


An “OR” gate in “Distinctive Shape” symbolic illustration

Finally, let’s talk the “NOT” gate, also known as the inverter. This is because this gate inverts a binary input. If the input is 0, then the output is 1, and vice versa. Here is a truth table to demonstrate that:

Input A = 0 | Output Q = 1
Input A = 1 | Output Q = 0

A “NOR” gate in “Distinctive Shape” symbolic illustration

That covers the basics of logic gates. There are more logic gates, such as “NOR” and “XOR” and even “NAND” which provide clever twists on the basic logic gates presented here. Check these logic gates out in Logic Gates, Level II.

Update a MySQL database from AngularJS & PHP

I found myself working with AngularJS and needing to update my MySQL database with information generated in AngularJS. Normally, I only ever updated MySQL databases using information already accessible with my PHP code, either by initializing it within the same scope as my queries or even by passing it via POST from one PHP page to the other. This time, however, the data was generated in my AngularJS script, not PHP.

The solution still requires PHP in order to send the actual query, but the data must be sent from AngularJS to the PHP script. Here is how I managed it.

In my AngularJS code, I wrote a function to send an update to the page via built-in HTTP POST functions. Essentially, the AngularJS function takes in basic info like what to replace — and with what — and sends it as individual pieces of POST data. Take a look:

/* AngularJS: Update values in MySQL with POST (handle with a PHP program) */
$scope.updatePhp = function(table, column, value, whereColumn, whereValue) {

    $http({
        method: 'POST',
        url: 'update-data.php',
        data: { 
            'table': table,
            'column': column,
            'value': value,
            'whereColumn': whereColumn,
            'whereValue': whereValue
        },
        headers: { 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8' } 
    }).then(function successCallback(response) {
        /* Fires on success; for debugging */
    }, function errorCallback(response) {
        /* Fires on error; for debugging */
    });

}

This bundles the data up nicely if you intend to make a MySQL query with it, specifically one like “UPDATE $table SET $column = $value WHERE $whereColumn = $whereValue” — though you can easily tweak the code and query together to get the desired results.

Now that you have the data, you need to make the actual query. The data is sent via POST to a file with the URL “update-data.php” which is clearly a PHP file. Inside this file, I do the following:

  1. Get the contents of the POST data.
  2. Translate the data for the program to easily access.
  3. Make the MySQL query using the data values.

Here is the code for the pseudocode above:

<?php

//CORS header stuff
header("Access-Control-Allow-Origin: *");

//PHP posted info
$data = file_get_contents('php://input');
$dataArr = explode(',',$data);

$dCount = 0;
foreach ($dataArr as $datum) {
    $newDatum = substr($datum, strpos($datum, ":") + 1);
    $newDatum = str_replace(array('}', '{', '"'), '', $newDatum);
    $dataArr[$dCount] = $newDatum;
    $dCount++;
}

//MySQL
$hostname_DB = "HOSTNAME";
$database_DB = "DATABASE";
$username_DB = "USER";
$password_DB = "PASS";
$PORT_NUM = 80; // Get the proper port number here
$mysqli = mysqli_connect($hostname_DB, $username_DB, $password_DB, $database_DB, "PORTNUM" ) or die(mysqli_error());

//Values
$table = $dataArr[0];
$column = $dataArr[1];
$value = $dataArr[2];
$whereColumn = $dataArr[3];
$whereValue = $dataArr[4];

//Update the table
$query = "UPDATE $table SET $column = $value WHERE $whereColumn = $whereValue";
$mysqli->query($query) or mysqli_error($mysqli);

?>

Again, some editing may be required to fit custom query needs.

Good luck.