Install C++ in Ubuntu 20.04

This blog article shows you one of the ways to install C++ into Ubuntu 20.04. Although a lot of article out there showing it possible to use the command gcc to compile C++ instead of just C but I could not. I use g++ command to compile C++ program in Ubuntu. I perform the following to get g++. I got it in the build-essential bundle instead than looking for only g++ to install. In most of the web site they will show you the following 3 steps to install. Somehow, if you are as unluckily as I do then you will hit error during the second command.

$ sudo apt update

$ sudo apt install build-essential

Error —————————————————————————————————-

chanmm@chanmm-Virtual-Machine:~$ sudo apt install build-essential

Reading package lists… Done

Building dependency tree

Reading state information… Done

You might want to run ‘apt –fix-broken install’ to correct these.

The following packages have unmet dependencies:

build-essential : Depends: g++ (>= 4:9.2) but it is not going to be installed

    Depends: make

    Depends: dpkg-dev (>= 1.17.11) but it is not going to be installed

codelite : Depends: libncurses5 but it is not going to be installed

    Recommends: git

    Recommends: subversion but it is not going to be installed

    Recommends: xterm

    Recommends: g++ but it is not going to be installed

E: Unmet dependencies. Try ‘apt –fix-broken install’ with no packages (or specify a solution).

chanmm@chanmm-Virtual-Machine:~$ apt –fix-broken install

E: Could not open lock file /var/lib/dpkg/lock-frontend – open (13: Permission denied)

E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

chanmm@chanmm-Virtual-Machine:~$ sudo -i

root@chanmm-Virtual-Machine:~# apt –fix-broken install

—————————————————————————————————————

In this case you need to run n superuser mode.

$ apt –fix-broken install

The re-run

$ sudo apt install build-essential

$ sudo apt-get install manpages-dev

I use gedit to paste and save the follow code.

#include <iostream>

#include <vector>

using namespace std;

int main()

{

    vector<int> g1;

    for (int i = 1; i <= 5; i++)

        g1.push_back(i);

    cout << “Output of begin and end: “;

    for (auto i = g1.begin(); i != g1.end(); ++i)

        cout << *i << ” “;

    cout << “\nOutput of cbegin and cend: “;

    for (auto i = g1.cbegin(); i != g1.cend(); ++i)

        cout << *i << ” “;

    cout << “\nOutput of rbegin and rend: “;

    for (auto ir = g1.rbegin(); ir != g1.rend(); ++ir)

        cout << *ir << ” “;

    cout << “\nOutput of crbegin and crend : “;

    for (auto ir = g1.crbegin(); ir != g1.crend(); ++ir)

        cout << *ir << ” “;

    return
0;

}

It is running fine.

Reference: https://chanmingman.wordpress.com/2020/11/08/microsoft-c-c-and-assembler-documentation/

https://docs.microsoft.com/en-us/cpp/?view=msvc-160/?WT.mc_id=DP-MVP-36769

https://www.geeksforgeeks.org/set-in-cpp-stl/

Posted in .Net, Cloud, Community, Computers and Internet | Tagged , | Leave a comment

Hyper-V Enable the vertical and horizontal scroll bar

This blog article shows you how to make the vertical and horizontal of the Hyper-V appear. You can not really enable and disable it. The trick here is I am playing with the Zoom Level. The default Zoom Level is 100%.

When you maximize the window or Full Screen. The button part is missing and you do not get any scroll bar at all.

Set the Zoom Level to 75%, for you, you might want to set other percentage.

When you display in full screen again, you will realize you have the vertical and horizontal scroll bars.

Reference: https://www.tenforums.com/tutorials/68819-change-display-scaling-zoom-level-hyper-v-virtual-machine.html

Posted in .Net, Cloud, Community, Computers and Internet, Operating System | Tagged , | Leave a comment

Excel Export and Import the custom Tab

This blog post shows you how to export and import the Excel Ribbon.

Problem: After you have created a VBA Macro button and email to a friend or colleague. When your friend opens the Excel file, the ribbon and the buttons are all disappear. When you email your Excel with Custom tab and when your recipients receive your Excel file, the Custom Tab always gone missing. Hence, you need to Export all customizations then Import all customizations from the Customize the Ribbon window.

In the workbook you have created the Macro button. Click FILE.

Select Options.

Choose Customize Ribbon. From the Import/Export dropdown select Export all customizations.

Select the .UI extension file.

At the machine you want to have the ribbon. You do the same as above beside instead of you select Export all customizations, you choose Import customization file.

Video: https://youtu.be/Y7Gf_nnH8GY

Posted in .Net, Cloud, Community, Computers and Internet, Microsoft Office, Office 365 | Tagged , , | Leave a comment

Azure Data Studio in Linux

The short blog article shows you how to install Azure Data Studio in Linux. You can refer to this article, https://chanmingman.wordpress.com/2020/12/23/microsoft-sql-server-ubuntu-installation/, to install a SQL Server and create a TestDb.

Download the installation file, at this moment of time is azuredatastudio-linux-1.25.1.deb.

https://go.microsoft.com/fwlink/?linkid=2151506

Go to console.

Install the Azure Data Studio.

sudo dpkg -i ./Downloads/azuredatastudio-linux-1.25.1.deb

Run Azure Data Studio.

azuredatastudio

Connecting to SQL Server in Linux.

Connected to SQL Server.

Querying the TestDB that has created.

The full successful installation script is here: https://1drv.ms/t/s!AuZYHSwsevw1oQ1nKuc4rL4TsHLz?e=siXoHi


Reference: https://docs.microsoft.com/en-us/sql/azure-data-studio/download-azure-data-studio?view=sql-server-ver15/?WT.mc_id=DP-MVP-36769

Posted in .Net, Cloud, Community, Computers and Internet, Data Platform | Tagged | Leave a comment

Microsoft SQL Server Ubuntu 20.04 installation

This blog article shows you where to follow to get your SQL Server install successfully in Ubuntu Linux. The full steps is in the link of this article. In between you will see the screens like the following. I am using Ubuntu 20.04. Majority of the steps in https://docs.microsoft.com/en-us/sql/linux/quickstart-install-connect-ubuntu?view=sql-server-ver15/?WT.mc_id=DP-MVP-36769 is fine except 2 steps documented below.

In Install the SQL Server command-line tools section. You might not have curl. Run the following to get crul.

sudo apt install curl

The command below does not run for Ubuntu 20.04.

curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

If you are using Ubuntu 20.04 then change to the command below.

curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list

I have connected to the SQL Server in Ubuntu using SSMS from the host OS.

When create a database you will see the file path is not the same as the one in Windows operating system.

The full successful installation script is here: https://1drv.ms/u/s!AuZYHSwsevw1oQhgfB920PL7EcVN?e=YyUGoY

Posted in .Net, Cloud, Community, Computers and Internet, Data Platform | Tagged | 1 Comment

Postman POST to ASP.NET Web API 400 Bad Request

This blog article shows you one of the possible ways to resolve 400 Bad Request on Postman when sending a POST to ASP.NET Web Api. This article expects you to know C# and basic ASP.NET Web Api. When you have a HttpPost in Web Api with a method that tales string as the parameter.

[HttpPost]

public void Post([FromBody] string value)

{

    string str = value;

}

You will see the 400 Bad Request when you POST to the Web Api.


You need to create a class to hold the string, even is only one strong. Like the class below.

public class DataLean

{

    public string Name { get; set; }

}

In the HttpPost method, uses the class as the parameter.

[HttpPost]

public void Post([FromBody] DataLean value)

{

    string str = value.Name;

}

Send a POST again from Postman.


You can see the POST is working with 200 OK status.

Source code download: https://github.com/chanmmn/WebApi

Posted in .Net, Cloud, Community, Computers and Internet, Data Platform | Tagged | Leave a comment

CTO December 2020 articles and resources

These are the good reads found in this month.

Tapping into dark data for efficiency, innovation, and income

Dark data presents an exciting opportunity for early movers to secure a competitive advantage over slower rivals.

https://www.cio.com/article/3596600/tapping-into-dark-data-for-efficiency-innovation-and-income.html?upd=1606636286734

What is CI/CD? Continuous integration and continuous delivery explained

CI/CD is one of the best practices for devops teams to implement. It is also an agile methodology best practice, as it enables software development teams to focus on meeting business requirements, code quality, and security because deployment steps are automated.

https://www.infoworld.com/article/3271126/what-is-cicd-continuous-integration-and-continuous-delivery-explained.html

Evolution of the Solution Architect Role

Having worked in the design and creation of software based solutions over many years, I have seen firsthand the need for the solution architect to continually learn and adapt to the evolution of architecture design patterns, technologies and methods used to deliver solutions.

https://platform.deloitte.com.au/articles/the-evolution-of-the-solution-architect

How to Avoid Rushing to Solutions When Problem-Solving

Before you can solve a problem, you need to know what exactly you’re trying to solve. Unfortunately, too many of us want to rush to conclusions before clearly understanding the problem. The author describes a four-step process that helps you define the problem. First, don’t just rely on the data. Take facts, especially observable ones, into account.

https://hbr.org/2020/11/how-to-avoid-rushing-to-solutions-when-problem-solving

People Make The Digital Economy Go Round

To succeed as a society in the emerging digital economy, it isn’t just machines and software that will move us forward — we need people to be well-educated, well-trained, and well-motivated to take part in its growth.

https://www.forbes.com/sites/joemckendrick/2020/11/27/people-make-the-digital-economy-go-round/?sh=55157cc6b15a

Resources:

Power BI developer documentation, https://chanmingman.wordpress.com/2020/11/03/power-bi-developer-documentation/

Posted in .Net, Cloud, Community, Computers and Internet, CTO, Data Platform | Tagged | Leave a comment

ASP.NET Blazor Session State

This blog post shows you one of the options for ASP.NET Blazor session. The official way should be create a class. This way below is one of the earliest suggestion by Microsoft and it is still working. First you add the library from Nuget, Blazored.LocalStorage.


Add Singleton to Program.cs as below.

public static async Task Main(string[] args)

{

    var builder = WebAssemblyHostBuilder.CreateDefault(args);

    builder.Services.AddBlazoredLocalStorage();

    builder.RootComponents.Add<App>(“app”);

    builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

    builder.Services.AddSingleton<DataStorage>();

    await builder.Build().RunAsync();

}

In the Counter.razor page, the UpdateLocalStorage is to save the session and ReadLocalStorage is to read back the session.

@page “/counter”

@inject Blazored.LocalStorage.ILocalStorageService localStore

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<textarea @bind=”noteContent/>

<p>Read: @noteRead</p>

<p>Read:</p>

<button @onclick=”UpdateLocalStorage“>Save</button>

<button @onclick=”ReadLocalStorage“>Save</button>

<button class=”btn btn-primary”
@onclick=”IncrementCount“>Click me</button>

@code
{

    private int currentCount = 0;

    const string noteKey = “note”;

    string noteContent;

    string noteRead; 

    public async Task UpdateLocalStorage()

    {

        await localStore.SetItemAsync(noteKey, noteContent);

    }

    public async Task ReadLocalStorage()

    {

        noteRead = await localStore.GetItemAsync<string>(noteKey);

    }

    private void IncrementCount()

    {

        currentCount++;

    }

}

Source Code Download: BlazorApp/BlazorApplocalstorage at master · chanmmn/BlazorApp (github.com)

Reference: https://docs.microsoft.com/en-us/aspnet/core/blazor/state-management?view=aspnetcore-5.0&pivots=webassembly/?WT.mc_id=DP-MVP-36769

Posted in .Net, Cloud, Community, Computers and Internet | Tagged , | Leave a comment

Generate a list of random float number(s) C#

This blog post shows you how to generate a list float number. Many developers out there need to generate a list of float number for testing. I have found the NextFloat from the reference below. Somehow, it generates only one number. I have added the code to generate 10 using the max variable. You can change the max variable to generate as many float numbers as you like. The code snippet below will round up to 2 decimal point for you as well.

static void Main(string[] args)

{

    double result = 0.0;

    int max = 10;

    List<double> lst = new List<double>();

    for (int i = 0; i < max; i++)

    {

        result = NextFloat(0.1f, 10.0f);

        lst.Add(Math.Round(result,2));

        Console.WriteLine(result);

    }

    Console.WriteLine();

    foreach (double j in lst)

    {

        Console.WriteLine(j);

    }

}

public static float NextFloat(float min, float max)

{

    System.Random random = new System.Random();

    double val = (random.NextDouble() * (max – min) + min);

    return (float)val;

}


Reference:

https://www.codegrepper.com/code-examples/csharp/random+float+between+0+and+10+c%23

http://net-informations.com/q/faq/round.html

https://docs.microsoft.com/en-us/dotnet/api/system.math.round?view=net-5.0/?WT.mc_id=DP-MVP-36769

Posted in .Net, Cloud, Community, Computers and Internet | Tagged | Leave a comment