Tech Junkie Blog: August 2018

Monday, August 27, 2018

Love it or hate it the Eclipse IDE is a comprehensive development tool that rivals or surpasses Microsoft's Visual Studio.  If you are working outside of the .NET stack Eclipse will probably have plug-in for your development platform. I myself find the UI a little bit overwhelming.  But for the price it's a pretty good value, which is free!

Here are the steps to install the Eclipse IDE on your Fedora instance:

1.  Log into your Fedora instance, and open a terminal session
2.  Type sudo su to switch to super user priviledges
3.  Now type sudo dnf install eclipse to install Eclipse














Monday, August 20, 2018

If you come from C# or Java, JavaScript inheritance is a little different than what you are used to.  In JavaScript you don't inherit from a class, but you inherit the classes' prototype object.  In our previous post we created an Account class.  In this post we are going to inherit from the account class.  First let's recreate the Account class with the code below.


    <script>
    <script>
        function Account(balance, type) {
            this.balance = balance;
            this.type = type;
        }

        Account.prototype.deposit = function (d) {

            this.balance = this.balance + d;
            return this.balance;
        }

        Account.prototype.withdrawal = function (w) {
            this.balance = this.balance - w;
            return this.balance;
        }

    </script>


Friday, August 17, 2018

If you've installed an operating system in VirtualBox before you've probably noticed the screen is really small even when you switch to Fullscreen mode.  It's so small that you can't even see the fonts for the icons if you have a desktop GUI installed.  To fix this problem VirtualBox provides us with the Guest Additions tool.  Which enables the virtual machine to be viewed at fullscreen.

To enable full screen on a Linux operating system.  Perform the following actions, this should work on all Linux distribution that VirtualBox supports.

1.  Start the virtual machine that you want to make full screen


2.  Log into your GUI desktop

Thursday, August 16, 2018

A JavaScript class is different than classes in other languages like C# or Java.  A class in JavaScript means that the objects inherit properties from the same prototype object.  It is defined by using the function to initialize and return a new object.

First thing we have to do define the prototype object by creating a function constructor that initializes and creates a new object.  Let's say we have a bank account first we will create a constructor that will create a new account object.  We then define the class methods by defining the prototype methods.  After we do that all the new objects that created will inherit those prototype methods. Like the code below.


    <script>
    <script>
        function Account(balance, type) {
            this.balance = balance;
            this.type = type;
        }

        Account.prototype.deposit = function (d) {

            this.balance = this.balance + d;
            return this.balance;
        }

        Account.prototype.withdrawal = function (w) {
            this.balance = this.balance - w;
            return this.balance;
        }

        var a = new Account(100, "Checking");
        var bonus = 10;
        var fine = 20;

        console.log("Deposit " + bonus + " " + a.deposit(bonus));
        console.log("Withdrawal " + fine + " " +  a.withdrawal(fine))
        console.log("Account type " + a.type);
    </script>












The code above defines an account class using a function, and then we define the methods or behavior of the class with prototype methods.  After we opened the account we got a bonus of ten      dollars.  So we call the deposit the ten dollars to the account by calling the method deposit that belongs to the prototype of the class, which we inherit when we create the account object.

Our new balance is 110 dollars.  As you can see we set the objects property to the new balance.  When we pay the fine we subtract twenty dollars from the new balance.  All of this happens within the account object because we defined and initialized the account object with a constructor and use prototype methods.  We can create other objects with the same properties and behaviors by using the account class.  JavaScript does not have a class, but it can simulate classes with prototypes and functions.

Wednesday, August 15, 2018

One of the most common task you have to do as a Linux administrator is to add a new user.  Especially developers who always wants root access.  To accomplish this task you can use the useradd command in the Terminal session.  Follow the steps below to add a new user to CentOS.

1.  Switch into the root user using su - command





 2. Type the following command useradd -s  /bin/bash -d /home/john -m john then press "Enter"





Tuesday, August 14, 2018

Monday, August 13, 2018

JavaScript does not have a built-in feature to define a namespace.  A namespace is basically a container of your code that it does not pollute the other codes that's on page.  Namespace allows you to play nice with people's code and other JavaScript libraries.

Fortunately, JavaScript functions have their own contexts and scope.  Therefore, we can use functions as a namespace so that it does not pollute the global scope.

The easiest way to create a namespace on a page is to encapsulate everything in an anonymous function like the code below.


    <script>
        (function () {
            // put your code here
        }());

    </script>

Another way of using namespace is to assign the anonymous function to a variable


    <script>
       var myNameSpace = (function () {
            // put your code here
        }());

    </script>

Friday, August 10, 2018

Linux installation comes with OpenJDK, but you want to use the official JDK from Oracle instead to run most of the software.  This post will show you the steps to install the Oracle JDK

First let's check to see what version of JDK we have installed by running the command

java -version










As you can see Fedora installs the OpenJDK library by default.  What we want to do is replace it with the Oracle version instead.

Type the address http://www.oracle.com/technetwork/java/javase/downloads/index.html
into Firefox in the Fedora VM and click on the "JDK" download button


































Thursday, August 9, 2018

One of the most useful feature in Azure is the ability to reset your virtual machine's password.  There will be times when you create a virtual machine that you put aside for a long time and you forgot the password for the machine.

To reset your password do the following:

1.  Log into Azure by typing the URL https://portal.azure.com
2. Click on the "Virtual Machines" link






3. Select the virtual machine you want to reset your password on










4. Click "Start" to start the machine, your machine must be running before you can reset your password











5. Under "SUPPORT + TROUBLESHOOTING" select "Reset Password"












6.  Select the "Reset Password" radio button, enter the username and password you want to reset to.  Then click "Update" when you are finish




















Surprisingly the reset password function takes a long time to apply. So you have to wait for a while before you can use your virtual machine again.




Wednesday, August 8, 2018

An ASP.NET MVC can get big, and it could be overwhelming.  Areas are a way to break up the application into smaller segments,  A perfect candidate for an Area is the Administrative features of the site because it has multiple pages, and functionalities.  So it is a good idea to segment off the Administration area to its own area (no pun intended).

To add an Area to your MVC application right-click on the project and click "Add", then select "Area..."


















Type in the word "Admin" in the "Add Area" dialog










Tuesday, August 7, 2018

Monday, August 6, 2018

Since JavaScript functions are objects they can have properties that belongs to the function itself.  For example this simple example counts the number of times the function is being called by incrementing the counter property that belongs to the function.


    <script>
        functionCount.counter = 0;

        function functionCount() {
            return functionCount.counter++;
        }

        for (var i = 0; i < 10; i++)
            functionCount();

        console.log(functionCount.counter);

    </script>

The code above basically intialize the counter functionCount property and calls the function ten times and then output the counter property directly through the functionCount object, which is ten.


Friday, August 3, 2018

In our previous series we've gone over how to install Ubuntu Server on Oracle VirtualBox to use it as a server.  In this series we will go over how we can use the Fedora desktop as your developer's machine/virtual machine.  Having a Linux developer machine is great because a lot of the more expensive Windows developer's program are expensive.  There's usually a Linux equivalent application that is comparable to their Windows big brother that are usually free or a lot less expensive.  Also most Java technologies work better on Linux than Windows.  So let's begin on journey into the Linux desktop experience.















Thursday, August 2, 2018

In this tutorial we will add icons to your navbar.  In the previous tutorial we added a responsive layout with bootstrap.  In this post we will add some icons to your navigation.  Font-Awesome gives you professional looking vector graphics, which are implemented using CSS.  Bootstrap 4 uses Font-Awesome as it's icons. Glyphaicons will goes away. So we might as start using it.

Just to review this is how our layout looks like in our previous post.























Wednesday, August 1, 2018

With Azure, any developer can easily add a membership service immediately when you are ready to use it.  In my other tutorials we started to create the "Northwind Cafe" sample application.  Traditionally, we would store our user information in an SQL Server database.  While that would be the easiest place to store user information.  There are many downsides to doing that, for instance you have to lock down the SQL Server so that hackers are not able to hack into the database.  You also have to worry about network security and so forth.  The beauty of Azure |AD is that you let Azure take care of all of that.  It also comes with many services already built-in like OAuth, and two-factor authentication.

Before we go on, we need to make the distinction that Azure AD is not the same thing as your on-premise AD.  Your on-premise machines will still be managed by your on-premise Active Directory.  Azure AD is designed to scale your internet-based applications and APIs.

So let's get on with it!

To create a new Azure AD in Azure log into the Azure portal at https://portal.azure.com

1. Now click on the "Create a resource" link in the Azure Portal