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

Tuesday, September 22, 2020

 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, September 21, 2020

 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"

Wednesday, September 16, 2020

 A Blockchain is a distributed network of containers with data, a hash, and a pointer to the previous hash.  A hash is a text that consists of an input of all the parts of the block, and it will generate the same hash every time the input is the same.  So if the block has been tampered with the hash will be different. On top of this there's a global record of the transaction that's distributed to everyone in the ecosystem.  Making it almost impossible to to tamper with because if a hash has been tampered with there needs to be a consensus of the change before it is deemed valid.  A consensus consists of 50% of the users.



If the hash, data, or anything of block 1 changes, the block 2 becomes invalid because block 1 will have a new hash and block 2 will be pointing to the wrong previous hash, making everything after it invalid, therefore it is in everybody's interest that changes are made very difficult because it would greatly impact the integrity of the blockchain.  There are many checks and balances that must be met before a new block is accepted in the blockchain. Obviously there needs to be something that will correct a bad new block chain, else if a new block chain is bad then nobody can add a new chain to the blockchain anymore.

 

Tuesday, September 15, 2020

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 DatingApp.API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class ValuesController : ControllerBase
    {
        // GET api/values
        [HttpGet]
        public ActionResult> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/values/5
        [HttpGet("{id}")]
        public ActionResult Get(int id)
        {
            return "value";
        }

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

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

        // DELETE api/values/5
        [HttpDelete("{id}")]
        public void Delete(int id)
        {
        }
    }
}

Monday, September 14, 2020

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"

Wednesday, September 9, 2020

 The first thing you want to do in Python is to install the latest version of Python.  Even though most Linux and MAC distribution has Python installed by default, you still want to install the latest version of Python.  The latest stable version of Python at the time of this writing is version 3.8.5 in this post we are going to install version 3.6.5 on our Linux instance.  

1. Open up the terminal and type the following commands

sudo su

mkdir /opt/python

cd /opt/python/

wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tgz

tar xzf Python-3.8.5.tgz

What we did was basically was create a new folder called python to hold our files and then download the python version 3.8.5 and then unpack the file with the tar xzf command



Tuesday, September 8, 2020

 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.

Monday, September 7, 2020

 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, September 1, 2020

 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, August 31, 2020

 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, August 25, 2020

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 https://dev.mysql.com/get/mysql80-community-release-fc32-1.noarch


Monday, August 24, 2020

 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, August 18, 2020

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: https://dotnet.microsoft.com/download

Node.JS: https://nodejs.org/en/

Visual Studio Code: https://code.visualstudio.com/#alt-downloads

Postman: https://www.postman.com/downloads/

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



















Monday, August 17, 2020

 In the previous post we created an EC2 instance in AWS in this post we are going to connect to that instance on a Linux workstation or server with SSH.

Here are the steps to connect to the EC2 instance using SSH on Linux, this will also work on a Mac as well:

1. Navigate to the folder that contains the key pair file that you've downloaded in the previous post, I store it in the folder /aws/EC2/KeyPair/ folder , so I would type cd /aws/EC2/KeyPair then type ls to see the file in the folder

Thursday, August 13, 2020

The first thing we want to do is set up the Google Chrome browser on a Linux instance, I've decided to use a virtualized Fedora workstation as my development machine.  You can use Windows if you want, it would be a lot easier.  It doesn't really matter because Asp.Net Core works on Linux as well.  Google Chrome has the best development tools and it also has an extension call Postman.  Although you want to install the standalone version of Postman.  Here are the steps to install Google Chrome on Linux

I wrote a post on how to set Fedora as your development machine here

1. Navigate to the URL https://www.google.com/chrome/

2. Click on "Download Chrome"


 In the next month or so I will start a series of blog posts that will take you from scratch on how to deploy an Angular application that makes API calls from an Asp.Net Core web api backend using Entity Framework Core as it's ORM and MySQL as the database.  Most tutorials would end there, but I will take it further and deploy the application on AWS so that it lives on the world wide web.  Since I don't want to start from scratch I will be modernizing the ACME bank application that I've started with AngularJS.  If you are working with AngularJS you know that it's time to update and upgrade because it's at its' last legs and Angular is the future.  Some say the journey is more rewarding than the destination.  I hope, you will join me on this journey.  Thank you, here is a diagram of what's to come

Next: Set Up Chrome Browser On Linux

Monday, August 10, 2020

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"

Monday, January 20, 2020

Now that we have our virtual network and subnet setup in Azure, the next thing we want to do is create a Windows Server virtual machine.  A virtual machine is a great way to learn Azure because it's a fixed cost.  You can try different things without paying anything extra, also most of the promotional deals that Microsoft gives you should be more than enough to cover your costs for the virtual machine.

The following steps is how you would create a Windows 2016 Server in the Azure Portal:

1. Log into Azure Portal, and mouse over "Virtual Machines", click on "Create"

















Monday, January 13, 2020

In the previous blog post we created a "Resource Group", in this post we are going to create a "Virtual Network" in that resource group so that we have more control over four Azure network settings.  Azure actually creates a virtual network for us automatically, but we want to have more control over our Azure infrastructure.

The following is how you would create a "Virtual Network" in Azure.

1. Search for "Virtual Network" and click on "Virtual Network", mouse over and click on "Create"

































Monday, January 6, 2020


The first thing you want to create after you have an Azure account is to create a "Resource Group"  as "Resource Group" as the name implies is an Azure Resource Group, groups all of your resources in a single group so that it's easily managed.

The following steps is how you would create a "Resource Group" in the Azure Portal.

1. Log into Azure portal, and click on "Resource Group" or "More Services" depending on your UI

























Search This Blog