Tech Junkie Blog - Real World Tutorials, Happy Coding!: September 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.

Search This Blog