Tech Junkie Blog - Real World Tutorials, Happy Coding!: 2021

Tuesday, August 3, 2021

 In the last post we created our ACME Bank database in MySQL, the next step is to get the values from the Values table in the Asp.Net Core WebApi controller.  

Let's create some test data so that we could retrieve the values from the database.  The Values table could contain anything.  So I am going to store famous philosophers throughout history.  These philosophers are so famous that they only have one name: 

You can run the SQL insert statement below to seed the data in MySQL:


INSERT INTO acmebank.Values (

So your Values table should look like this when you executed the insert query

Monday, August 2, 2021

 In Linux there's a service often called the Central Logger which generates logs for itself or if permited collects logs for other servers.  The service name is rsyslog and the configuration file is located in /etc/rsyslog.conf

One of the more common usage scenario is that once you scaled out your infrastructure and have hundreds of servers you don't want to log into every servers that are having problems if you need to troubleshoot an issue.  That would take forever, so it is useful to have a centralize logging location.

The command to install the package is dnf install rsyslog -y

To start and enable the service you can type the command 

  • systemctl start rsyslog
  • systemctl enable rsyslog

In the conf file /etc/rsyslog.conf there's a line that specifies the remote server to send you logging information to, if the server is going to be the client and not the central logger.  Look for the line#

#'.' @@remote-host:514

If you want to send you logs to another server replace the remote-host with the host's IP address or fully qualified hostname and as you can see it will be sending traffic through port 514

Now you can run the service with the command systemctl start rsyslog

Friday, July 30, 2021

Combinators in CSS is term used to define a style that combines more than one selectors together.

For example let's say you have the following markup

        <div id="combinator-div"><h1>I'll be back.</h1></div>
        <h1>Combinator me</h1>

Let's say you only want to apply the styles for the <h1> tag that's inside the combinator-div, you can use a combinator style which is a combination of the div id and the h1 tag as combination to style a very specific element on the page.  The style would look like the following

#combinator-div h1 {font-family: sans-serif; font-weight: bold; color: green;}

If you run the page with the code then you would get the following output

As you can see only the I'll be back <h1> is styled, the other <h1> is just not cool enough to get styled.

Thursday, July 29, 2021

 In this post we are going to create our first Entity Framework migration and creating an actual database in MySQL. 

In order to do that we need to add a few NuGet packages to our Asp.Net Core project including the Entity Framework Core package.  But, before we do that we want to find out what what version of .NET Core we are running.  Obviously I have it memorized, but for the rest of you, you can type the command dotnet --version to figure out what the version is :)  It's always a good idea to try and match the package version with the .NET Core runtime you have.  It's one of the more annoying thing with Angular and Asp.Net Core, it's changing constantly. So as you can see my version so I should try to install packages that are made for 3.1.x.

The first package we are going to install is the Microsoft.EntityFrameworkCore.  So open the ACMEBank.API project with Visual Studio Code.  Press Ctrl+Shift+P and type NuGet and select

Wednesday, July 28, 2021

 User Data in an instance allows you run commands while your instance boots up.  In the previous posts we just plain vanilla instances so far.  But in this post we are going to install the Apache Httpd service when we create our instance using User Data.

Here are the steps to create an instance with User Data:

In this blog we are going to start our journey into AWS infrastructure with the creation of an EC2 instance which is probably the most common task you'll ever do. 

 Here are the steps to create an EC2 instance on AWS:

1. Log into AWS and on the "Find Services" search box type EC2 and press enter 

2. You will be taken to EC2 screen, then click on "Instances"

2. Click on "Launch Instance"

Tuesday, July 27, 2021

Equality searches are great and efficient when you want exact matches or range of values. However, there will be times when you need to search a text field for not so perfect matches, perhaps a partial match is needed. Certain scenarios requires to search for patterns, such as an email address. That's when the LIKE operator is useful in SQL. The only caveat is that LIKE operators can only work with text fields. Examples: 1. A word/text with a % at the end, searches for all the records that begins with the letters before the percent sign

SELECT ProductName,UnitPrice
FROM Products
WHERE ProductName LIKE 'Chef%'

The query above returns all the records in the Products table that begins with the word "Chef"


Monday, July 26, 2021

 In this post we are going to install the Apache Web Server, which is the most common web server in the world.  With a web server you can serve up web sites or business products on the web.  Therefore it's kind of like giving your Linux system a purpose to exist.

The service you have to install is called httpd and the configuration files are located in the following directories

  • /etc/httpd/conf/httpd.conf
  • /var/www/html/index.html
And the log files are in /var/log/httpd

Here are the steps to install the Apache Web Server:

1. So first let's install the service, you can do this by typing the command dnf install httpd -y

2.  In the /etc/httpd/conf/httpd.conf file you will see that the ServerRoot points to the folder /etc/httpd and it's listening to port 80 because of the line that says Listen 80, you can change the directory for the ServerRoot and Listen properties in the configuration file to change the directory and the port respectively.  Another important setting is the DocumentRoot setting, this property defines your website's homepage or the starting point.  Since the DocumentRoot points to the directory /var/www/html let's navigate to the directory and see if there's an index.html page in the directory

3. If you don't have an index.html page in the directory, t's easy enough to create one.  Just type vi index.html in the directory and paste the following code in the file to get a simple html page.  But for the most part you will have the default Apache index.html page and that's perfectly fine we just want to see that it works at the end of this lesson.

<!DOCTYPE html>
<p>Hello Apache!</p>

4. Now that we have everything in place we want to start the service and enable it so that it starts on boot up with the following commands in order
  1. systemctl start httpd
  2. systemctl enable httpd
5.  To view the web page you typing ifconfig to see the server's IP address

6. To view the web page you can just type in the IP address in the browser's address bar. If you can't view the page, type stopping the firewall with the command systemctl stop firewalld

Friday, July 23, 2021

In this post we are going to use Google Fonts in our HTML markup, using Google Fonts is really easy to do.  All you have to do is go to then select the fonts that you would like to use.  Let's we want to use the Manjari, then All we have to do is click on the + sign next to the font.

Thursday, July 22, 2021

The SUM() function is used to sum up all the values in the specified column.

SELECT SUM(UnitsInStock) AS TotalInventory
FROM Products

The above query gets the total number of units in stock for all products

Wednesday, July 21, 2021

An instance metadata is data about your instance that you can use to configure your instances.  They are divided into categories.  Anyone who have access to the instance can view the metadata, therefore you should not store anything sensitive that could be accessed such as "User Data"

You can get more information here at Amazon's website:

You can access your metadata with this URL

Here are the steps to retrieve your instance data:

 1.  Connect to your AWS Linux instance and type curl

Tuesday, July 20, 2021

 In this post we are going to install MySQL Workbench on Fedora.  MySQL Workbench is a great GUI database management tool for MySQL.  Even though we can do everything we need with MySQL on the terminal it's nice sometime to see the tables and data visually.

Here are the steps to install MySQL Workbench:

1, Go to the yum repository for MySQL at select the Fedora repository, and click "Download"

Monday, July 19, 2021

 Sendmail is the most common Linux mail service, it is lightweight and is used in administrative tasks as well as sending mail.  In this post we are going to install and configure Sendmail and go over how to use it. Sendmail is the mechanism to send mail, it's not the mail server itself.

First let's install the Sendmail service, type dnf install sendmail -y after sendmail is installed you can install another package which will configure sendmail for you, type dnf install sendmail-cf -y to install that package

One it is installed you need to define your smtp relay server in the file /etc/mail/ file in the line that says dnl define(`SMART_HOST', `smtp.your.provider')dnl this is the one service that you need to have some infrastructure in place before you can use it.  Remember to remove the dnl when you specify the smtp server because dnl means comment in the file.

Once you have your smtp relay server defined, you can start the sendmail service with the systemctl restart sendmail command

To send an email you type
mail -s "subject goes here" then press ENTER

message goes after ENTER then press CTRL+D to exit and sendmail


Friday, July 16, 2021

With text-transform you can transform your text into Autobots or Deceptacon? Not exactly, but what  you can do is transform your text to uppercase, lowercase, capitalize it. It's pretty self explanatory.

Here are the examples of a text-transform:

p.upper {text-transform:uppercase}
p.lower {text-transform:lowercase}
p.cap {text-transform: capitalize}

Here are the HTML markup:

            <p class="upper">uppercase me</p>
            <p class="lower">LOWERCASE ME</p>
            <p class="cap">captain america me</p>

Here is the output:

Previous: CSS: The em Unit

Thursday, July 15, 2021

The INNER JOIN functions like the WHERE clause by relating two or more tables using matching data. The difference is that the INNER JOIN is used in the FROM clause. So to the the employee's territory like the one we wrote in this blog. We would change the query into the query below to use the INNER JOIN instead of the WHERE clause.

SELECT e.FirstName + ' ' + e.LastName AS Name, t.TerritoryDescription,t.TerritoryID
FROM Employees e
INNER JOIN EmployeeTerritories et ON et.EmployeeID = e.EmployeeID
INNER JOIN Territories t ON t.TerritoryID = et.TerritoryID

With the result:

Wednesday, July 14, 2021

 In this post we are going to connect to a Windows instance using RDP.  In order for us to connect to the Windows instance we need to get the password for the server using the key pair that we downloaded from the last post when we created the instance, the .pem file.

Here are the steps to connect to the Windows instance using RDP:

1.  Navigate the EC2 "Instances" page, check the instance and click "Connect"

2. On the next screen click on "Get Password"

Tuesday, July 13, 2021

 In this post we are going to circle back to MySQL and continue setting up our MySQL database, so that we can use it in our application.  Since we don't want to use our root for log in and we turned off root login for remote connection.  We have to create a dedicated user for our application.  Here are the steps to create a dedicated dev use in MySQL

1. Log into MySQL with root using this command mysql -u root -p

2.  In the MySQL prompt type CREATE User 'devuser'@'localhost' IDENTIFIED BY 'P@ssw0rd'; to create the user, obviously if this is your production environment you would want to use a more secure password

3. Then type GRANT ALL PRIVILEGES ON *.* TO 'devuser'@'localhost' WITH GRANT OPTION; to grant the user all the privileges on all the objects

4. Now type FLUSH PRIVILEGES; to update and apply the privileges

Monday, July 12, 2021

 Now that we have a good understanding of how time works in a Linux ecosystem.  We want to sychronize our time with the chrony package.  There's also the ntp package but it's been deprecated so the way to do this right now is the to do it with the chrony package.

Here are the steps to synchronize time with chrony:

1. First you wan to install the package by running the command dnf install chrony -y it might already be installed

2. Once it's installed type the command systemctl enable chronyd and systemctl start chronyd to start the time sychronization

3. If you want to see more information about the time synchronization on the server you can run the chronyc tracking command

As you can see our current Stratum level is 3, which is pretty decent.

Another useful command that you can run is the chronyc sources command, this command will show you want servers you synchronized against.

You can add or remove the servers in the /etc/chrony.conf file in the top section, which should have iburst in it.

# Use public servers from the project.

# Please consider joining the pool (

pool iburst

Friday, July 9, 2021

Have you always wished to have more control with your text position, but feel like you limited with the text alignment of

Align Left text-align: left;
Align Center text-align: center;
Align Right text-align: right;
Justify text-align: justify;

Well you could always do that with CSS with the text-indent property, the only caveat is that it has to be a block based element.  Meaning it automatically puts a line break after the tag.  If you need a refresher on block vs line element, I have an excellent post on this topic here.  I know a shameless plug, oh and please click on my ads so that I can retire on a tropical island!

Anyways back to the tutorial.  So with the text indent you have total control over the indentation you need on your block element.  It could either be a length value or a percentage value.

Well first let's define a div that we want our text to be in, then the text-indent will be based on that div.

Let's say we have the following styles:

div { width: 800px}

p.tdp {text-indent: 15%}

And the following markup

    <p class="tdp">Indent this text please Indent this text please Indent this text please Indent this text please</p>
   <p>This is just normal text This is just normal text This is just normal text This is just normal text This is just normal text</p>

Thursday, July 8, 2021

Before we run our Asp.Net Core application for the first time we are going to copy a controller from Asp.Net Core 2.2 to help us create the skeleton for our application.  A skeleton are the plumbings we do at the beginning of our application to make sure all the mechanisms work.  It's called the ValuesController which has been replaced with a more complicated WeatherForecastController.  The ValuesController is just a lot easier to work with to get things set up.

Just create a new controller in the "Controllers" and call it "ValuesController.cs" Here is the code for it.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace ACMEBank.API.Controllers
    public class ValuesController : ControllerBase
        // GET api/values
        public ActionResult> Get()
            return new string[] { "value1", "value2" };

        // GET api/values/5
        public ActionResult Get(int id)
            return "value";

        // POST api/values
        public void Post([FromBody] string value)

        // PUT api/values/5
        public void Put(int id, [FromBody] string value)

        // DELETE api/values/5
        public void Delete(int id)

Wednesday, July 7, 2021

In this blog we are going to start our journey into AWS infrastructure with the creation of an EC2 instance which is probably the most common task you'll ever do. 

 Here are the steps to create an EC2 instance on AWS:

1. Log into AWS and on the "Find Services" search box type EC2 and press enter 

2. You will be taken to EC2 screen, then click on "Instances"

2. Click on "Launch Instance"

Tuesday, July 6, 2021

The easiest and simplest way to explain what a subquery is to say that it's a query within a query. For example if you want to get the employee that belongs to specific territory in the Northwind database without a join, you would have to use a subquery. Like the following subquery.

SELECT EmployeeID, (FirstName + ' ' + LastName) AS Name
FROM Employees
WHERE EmployeeID IN (SELECT EmployeeID 
       FROM EmployeeTerritories 
       WHERE TerritoryID=01581) 

Things You Should Know About Subqueries:
  • They are not the most efficient performance wise
  • You can only retrieve a single column in the subquery, retrieving multiple columns will throw an error

Monday, July 5, 2021

 NTP stands for Network Time Protocol, in a nutshell what this service does is that it synchronizes your servers so that communications is reliable between servers.  The reason NTP is needed is because there are three types of time in computer networking.  They are the following:

  1. Hardware time
  2. System time
  3. NTP
The first two types of time are not reliable by nature because it could be set by people or it could be wrong.  So there's NTP time which is synched to the internet, which we always trust because the internet never lies.  For example a system admin can use the date --set command and set the wrong time.  This is crucial if you have network peers.  You can use the date and hwclock commands to the display the system time and hardware time respectively

You can use the command hwclock --systohc to sync the hardware time to the system time or hwclock --hctosys in the reverse direction, but as you can see from the scenario the system time can be manipulated and set incorrectly.

NTP is graded by Stratums with a scale, yeah buzzwords! So if you have a stratum of 1 that means you are the champ you are at atomic clock synchronization, and if you are at 16 you are a chump!  Best explanation ever!

Anyways to check if you are using NTP you can type the timedatectl status on the terminal

As you can see I am a champ, because the timedatectl status command tells me that my system clock is synchronized and my NTP service is active, and if you say otherwise, "I will break you!".  It's my blog sorry.  Besides showing the status timedatectl is also useful in setting the time it will check to see if the time you set is reasonable for instance you can set the time to 1999 because you wanted to party like it's 1999.  Let's see what happens time using the command timedatectl set-time "1999-01-01 00:00:00" 

As you can see the NTP service will not allow you to party like it's 1999 it will give you a message that says set time command failed because NTP is active.  So it gives you a nice reminder that life is not one big party. With Linux you have total control for the most part so you can turn off ntp with the command timedatectl set-ntp false and then party like it's 1999.  But why would you want to do that?

Friday, July 2, 2021

There are certain keywords in CSS that works on a global scale and inherit is one of them.
The keyword inherit simply means that current element inherit the properties of it's parent element.
It is applied automatically be default, but it could be useful when you want to be specific about what you want.

For example if you define the following style for the parent element

#parentElem {color: red; font-weight: bold}

And have the following markup, the style will automatically be applied to the child element

        <div id="parentElem">
            <p>Child element</p>

Thursday, July 1, 2021

 For those of you who works with Visual Studio, working with C# comes out of the box, but with Visual Studio Code you need to install some extensions from the Marketplace to make it suitable for C# development.  

Here are the extensions you need to install:

  • C#: This extension by Microsoft gives us IntelliSense, references, code editing and highlighting and debugging support

  • C# Extensions: This extension let's you create C# files, like classes and interfaces also some keyboard shortcuts like creating.  This one seems to be no longer in development for a long time, but it works fine.

  • NuGet Package Manager: This extension let's us install new NuGet packages which we will need from time to time.

Wednesday, June 30, 2021

 AWS has a very generous free tier account, but there will be times when you forget to clean up your work and are stuck with the bill.  There's a setting in AWS that allows to set the limits on your account so that you won't get charged for resources or get a surprise on your bill.  

Here are the steps to set a billing alarm:

1. First thing you have to do is sign in as the root user

Tuesday, June 29, 2021

 In this post we are going to use the .NET Core CLI to create a web api application for our app.  The first thing to do is create an a folder to hold our files.  Since we are using Linux you want to sudo su into the terminal and create the following folder /opt/app/ACMEBank.  Once that's done cd into it and you are ready to type in the command to create the Web Api.

Here are the steps:

1. What you want to do first is to make sure that you have .NET Core install by typing in dotnet --info, there should be information on your .NET Core install.  If you don't have .NET install you can follow the directions in this post.

Monday, June 28, 2021

 The dig and nslookup commands are useful commands that you can use to lookup information about a network.  The dig command gives you more information about a network.  For example for my network I have a DNS server setup in it, if I wanted to display the DNS information on my server I would simply type dig and I would get the following:

As you can see it gives you a lot of information about the DNS server like the IP that the server resolves to.  However, there are times when you just want something quick and brief on what the IP resolves to. For example you might know the IP address but not the hostname or vice versa and you want to lookup the information on the part that is know that's when nslookup comes in handy.  For example let's say you know the IP address but you don't know the hostname.  You can lookup the hostname by typing nslookup and you would get the hostname that resolves to the IP address

Or you can lookup the IP address with the hostname by typing nslookup

Obviously you can get more information with the dig command but sometimes it's nice to get less information with the nslookup command.  Although it is deprecated and might not be available for your Linux distribution. So if it's not available use the dig command instead.

Friday, June 25, 2021

There are often times when you see the measurement in CSS that looks something like this font-size: 2em; what does that actually mean? Well an em simply means its the multiplier of the font-size of the element. For instance 2em means that it will multiply the font-size of the element by 2x.

Let's say we have a div with a font-size of 15px, and there's a span tag with a font-size of 2em.  The span font-size of the span would be 30px, because the span is part of the div element.

Let's say have the following styles:

div {
  font-size: 15px;

span {
  font-size: 2em;

And with the following HTML markup:

<div>The font-size of the div element. <span>The span font-size</span>.</div>

The output is the following:

Thursday, June 24, 2021

SQL GROUPING allows you to segregate data into groups so that you can work on it separately from the rest of the table records. Let's say you want to get the number of products in a category in the Northwind database Products table. You would write the following query:

 SELECT COUNT(*) NumberOfProductsByCategory
FROM Products

The query above gives you the following results:

Wednesday, June 23, 2021

 So far we have connected to our EC2 instance with the terminal on Linux and Putty on Windows.  There is another option that you can perform and it only requires that you have a browser.  You must have an Amazon Linux Version 2 instance for this to work, at least that's what I think.

On the instances page on the AWS console click on the "Connect" button while the instance is selected

Select "EC2 Instance Connect (browser-based SSH connection)" radio button, and accept the defaults. User name "ec2-user" should be selected for you, then click "Connect"

Tuesday, June 22, 2021

The most important thing for most modern dynamic application these day is choosing a database to store your data.  If you are on a Windows environment then you use SQL Server database that is a fine choice. But if you are on Linux MySQL is a great choice also.  In this post we are going to go through how to install MySQL server on our Fedora development machine.

Here are the steps to install MySQL on Fedora Linux:

1. First we need to add the MySQL repository to our machine by tying in the following command in the terminal

sudo dnf -y install

Monday, June 21, 2021

 The chattr command in Linux is one of the more useful commands that you've probably used but have no idea what it's use is, it just works!  That's probably the most dangerous phrase in IT.  Well just from the command you can tell that controls the file modify attribute of the file.  Well not really I mean how is chattr related to file attributes.  I guess it's change attribute.  It's pretty easy to use + means to add an attribute, - means to remove an attribute, and = means you want to assign an attribute.  You can also add attributes with the -R option to reclusively on a directory.

One of the senario I used often is when I want to make a file immutable, I'll just type chattr +i filename.  For instance if I and setting a DNS server and I don't want the DHCP scripts to change the resolv.conf file every time I restart the NetworkManager.service I would just type chattr +i /etc/resolv.conf to make the file immutable.  If I try to modify the file I would get the following error message saying I can't modify the file.

It's just as easy to make it writable again, it would just be chattr -i /etc/resolv.conf

Friday, June 18, 2021

One descriptor of the font property in CSS is the font-stretch descriptor.  This descriptor widens and narrows a font family that has width-variant faces.

The values for widening and narrowing fonts are the following:

  • normal
  • ultra-condensed
  • extra-condensed
  • condensed
  • semi-condensed
  • semi-expanded
  • expanded
  • extra-expanded
  • ultra-expanded
The way you define a font-stretch is the following

      p.uc {font-family: Verdana; font-stretch: ultra-condensed;}

Thursday, June 17, 2021

In SQL the WHERE clause is the most common join you will see, it relates one or more tables together. For example you want to get the employeeis territory information in the Northwind database but you there are all in different tables.

Wednesday, June 16, 2021

 On the previous post we connect to our EC2 instance using SSH on Linux now I will show you how to connect to the EC2 instance using Putty on Windows

Here are the steps to connect to our EC2 instance on Windows:

1. Download and install Putty from here 

2. Open PuttyGen from the start menu, and select your .pem file and convert it to a .pkk file

Once it's open select "File", then "Load private key", then select your .pem file

Tuesday, June 15, 2021

In this post we going to get our development environment with NodeJS, VSCode and Postman

The Urls are the following, if you are developing in Linux you should install the Linux version.  All these tools are cross platform so you can develop in either Windows, Linux or MacOS:

.NET Core:


Visual Studio Code:


For .NET Core make sure you download the "recommended" version and not the preview version. Also with NodeJS, usually it has LTS status.

Installing .NET Core SDK and NodeJS On Fedora

In order to install .NET Core SDK on Fedora open the terminal and type in the following

sudo dnf install dotnet-sdk-3.1 -y

The -y tells Fedora to skip the y/N prompt and just go on with the install

Once the SDK is installed you can verify the install with the command dotnet --version

Search This Blog