C++ multithreading part1: std::thread

To write multithread programs, thread objects and thread execution are explained with examples. We focus on how threads are constructed, joined and detached for functions and class functions.
Read more...

What is the difference between concurrency and parallelism?

I explain the difference between serial, concurrent, and parallel code. The processor is defined. The readers are guided on what to look for to start writing concurrent and parallel codes.
Read more...

Master C++ const once and for all

A constant object doesn’t change during program runtime. Constantness also means read-only access to an object. I expain it with examples.
Read more...

Automate MPI custom type creation with C++

Here with the aid of C++20, variadic functions, and type-traits, I created a header library to automate creation of MPI custom (derived) datatype.
Read more...

C++ constexpr makes compile-time programming a breeze

The code written with constexpr is aimed to be evaluated at compile-time.Here constexpr conditions, variables and calsses are explained.
Read more...

Compile-time vs runtime programming in C++

Here I explain the difference between compile-time and runtime in C++ with examples. being a statically typed language, C++ contains meta-programming syntax and commands that let us to program the types and constant values for just compile-time.
Read more...

Use pybind11 for a detailed but simple example

A detailed C++ project, the robot, is created. Then, its classes and their components are declared in python: constructors, methods, public data members, and setter and getter (property).
Read more...

Python for file management

I show how Python functions can be used for file management: create, delete, copy, and move files. Therefore, you can automating complex tasks with Python programming.
Read more...

pybind11: call OpenMP function in Python

I want to use pybind11 to compile an OpenMP parallel code. Then, I load the created module in Python and run it. The code is in C++.
Read more...

Essential Linux commands to know

Here, I picked essential Linux commands, you need to know to use a Bash terminal: navigation, copy, delete, variables, aliases, and so on.
Read more...

Journal quality x-y chart with Matplotlib

I write a python script that, using Matplotlib, creates high-quality x-y charts from a CSV file. LaTeX is supported. The chart details such as font, line and marker styles and ticks are modifiable.
Read more...

Build GCC 11 from source on Ubuntu

Here I am building and installing the latest GCC, 11.1, on Ubuntu 21.04 from the source. The procedure is explained step by step.
Read more...

SSH port forwarding to download files

I want to download files from a destination computer connected to a public SSH server. The destination is accessible only via the server by SSH tunnel.
Read more...

Span is a new norm in C++ codes

Span is a new feature of C++20 for reading and writing a sequence of objects. Here, I mention how to use std::span and its functions including subspan.
Read more...

Essential VS Code font and extensions for C++

I briefly enumerate the primary font and extensions that I install on my Visual Studio (VS) Code to develop a C++ code: Fira Code font, CMake tools, bookmarks, snippets, and so on.
Read more...

An overview of C++ perfect forwarding

With a simple example, it is demonstrated that how perfect forwarding can keep rvalueness of function’s parameters. The universal reference is also discussed.
Read more...

Is C++ static polymorphism useful?

With examples, I explain static vs dynamic polymorphism. I show that static one limits the flexibility of the program at runtime. However, it can improve the performance of the code whose behaviour can be resolved at compile-time.
Read more...

From lvalue, prvalue, and xvalue to move semantics in C++

With examples, I explain the difference between lvalue, rvalue, prvalue, and xvalue. The rvalue references are defined. Consequently, I describe std::move and its application in creating move constructors and assignments.
Read more...

What is a C++ weak pointer and where is it used? smart pointers part III

Weak pointers (weak_ptr) are smart pointers that observe other objects but don’t take ownership of them. Here, I explain how they are implemented and why we need them with examples.
Read more...

What is a C++ shared pointer and how is it used? smart pointers part II

Shared pointers (shared_ptr) are smart pointers which ameliorate memory management. Here, I explain them with examples and discuss their usage and performance.
Read more...

What is a C++ unique pointer and how is it used? smart pointers part I

Unique pointers (unique_ptr) manage a pointer’s allocated memory. Here, I define them and explain the operations, passing to / returning from a function, and performance. A factory example is also demonstrated.
Read more...

What are C++20 concepts and constraints? How to use them?

With examples, C++ concepts are used to constrain template classes and functions. It is shown that concepts improve the readability of code and facilitate finding bugs.
Read more...

Building a C++ project with Travis continuous integration (CI)

I explain with an example that how a C++ project is automatically built by Travis CI with the push of a commit.
Read more...

How to use C++ namespace for large projects

I exaplain how namespaces can organize a large project and prevent name conflicts.
Read more...

Create a contiguous array of a generic class in C++

I want to create a contiguous array of a class and its derived ones. I make sure the polymorphism behavior is captured too.
Read more...

A note on computer round-off error in physics

The way floating-point numbers are stored in the memory of a computer can lead to unwanted errors. Here we have an overview of the basics of storing numbers and how they affect the outcome of physics programs.
Read more...

Various ways to create arrays and vectors and their differences in C++

Different methods to create arrays in C++ are overviewed: c-style array, pointer array, std::vector, std::array, and Boost multiarray. How the memory is managed by each style and also their practical usage is discussed.
Read more...

MPI Traffic Program with C++

I want to solve a traffic problem with MPI and C++. The road is divided into sections which send their boundaries and receive their ghost points.
Read more...

Debug MPI program with Visual Studio Code

Debugging MPI program can be a nightmare. I explain how easily you can debug a parallel MPI program with visual studio (VS) code.
Read more...

C++ auto keyword makes your life easier

In C++, auto keyword can speed up coding and improve the maintainability of code. Here, I show cases that auto can make a difference.
Read more...

MPI race condition

When a buffer, which is involved in an uncompleted non-blocking communication, is used in another communication, there will be a race to read and write the buffer.
Read more...

MPI ping pong program using C++

I want to write an MPI ping pong program where two processes send a piece of data back and forth to each other.
Read more...

Handy cross-platform packages to connect to a remote Linux server

Interaction with a remote Linux server like transferring files, editing code, or accessing the remote desktop can be much easier with these free cross-platform packages.
Read more...

The difference between modes of MPI send

There are different modes of MPI send: MPI_Send, MPI_Isend, MPI_Ssend, MPI_Bsend, and so on. They can be local or non-local, blocking or non-blocking, and synchronous or asynchronous. Their definition and differences are explained here in detail.
Read more...

How and where to use C++ templates

Using templates in C++, you can create functions or classes having similar behaviours for different types. Here, all the useful features of templates are explained with examples.
Read more...

How to use Bookmark in Visual Studio

Visual Studio bookmark speeds up code development in big projects. Here, I mention the keyboard shortcuts.
Read more...

Connect to Microsoft Access database with C# .Net core

I want to connect to an MS Access database with C# in .Net core. Therefore, I will be able to create, read, update, and delete (CRUD) records.
Read more...

Lockout user after multiple failed authentication via .Net core Identity

Goal I want to configure .Net core Identity in a way that when a user inserts wrong passwords several times the account gets locked for 5 minutes.
Read more...

Add Identity pages to .Net core web app

By default, the identity pages are pre-compiled in .Net core 3.1 and not available to be modified. I want to bring them back so they can be edited.
Read more...

Create a table of content from headings of a Hugo post

Goal I want to write code to get a table of content (ToC) for each blog post automatically. It is created and shown on the right-hand side of the content of a post.
Read more...

How to add a video to a Hugo post

I want to add a video to a Hugo blog post. The video is hosted on my website, so it is not a Youtube or Vimeo.
Read more...

Tutorial: Setup of Entity Framework (EF) core for CRUD and authentication with Razor pages

Goal In this post, step by step I create a web app using Entity Framework core and razor pages. The app is a library that admin can CRUD books info on a database and authenticated users can browse the records.
Read more...

C++ inheritance crash course

Inheritance is the mechanism that the attributes and methods of a base class are passed to a derived class. Here, all useful details of C++ inheritance are mentioned with examples.
Read more...

Host a .Net core web application for less than $5 a month

I talk about Google Cloud Platform (GCP), Microsoft Azure and Heroku. You can register with them and try their services for free or very low prices.
Read more...

How to have math equations in your website

If you want to write math equations in your website or blog, plain text becomes immediately illegible when writing something more complex than addition and subtraction.
Read more...

Code LU decomposition step by step in object-oriented way in C#

Introduction In this post I want to revisit PLU or LU decomposition or factorisation, which is used to find unknowns of a system of linear equations, for two reasons.
Read more...

How Dry principle leads to clean and easy to debug code?

Dry is short for “Don’t repeat yourself”. There are occasions that a piece of code is rewritten several times. It is better to define that as a specific method or class. I explain it with examples.
Read more...

What is a recursive function?

Definition A recursive function is a function that calls itself with different arguments. Therefore, it is applied to a problem that each step of it is similar to the previous one.
Read more...

Implementing YAGNI and KISS principle to have maintainable code

After reading a lot of design patterns, loose-coupling ideas, and so, you cannot wait to implement all of them in the first program you are making.
Read more...

How Inversion of Control improves flexibility of numerical codes?

Introduction When programming it’s very convenient to create class A which has a concrete member class B. However, this creates a tightly-coupled system since any change in B should be reflected in A.
Read more...

How visitor design pattern is useful for numerical programming?

Introduction The visitor design pattern separates operations from data storage. When the efficiency and memory consumption is not of concern this design pattern is not common.
Read more...

What is "object slicing" trap in C++?

Every now and then, I switch programming language from C# to C++, I fall in the trap of object slicing. It happens when a derived object is assigned by value to a base object where the extra information in the derived object is scrapped for worst.
Read more...

How to use C++ raw pointers properly?

A pointer is an 8-byte type on a 64-bit machine that holds the memory address of a target object. Here, I mention the most useful characteristics of pointers with examples.
Read more...

Create a lightweight weblog homepage with Bootstrap and Html

I want to create a lightweight homepage of a weblog with HTML, Bootstrap and a bit of custom CSS. No javascript, no database, no WordPress is used. It should be a lightweight and fast static website.
Read more...

How to create a simple component, using Blazor, HTML, and CSS: Word Block

Using .Net Blazor, I want to create a simple word-block which is a rectangle that contains a word with an X button at its right side. Clicking on X the word-block disappears.
Read more...