Introduction to PostgreSQL

PostgreSQL is a relational database management system (RDBMS) similar to MySQL. I usually go for MySQL, but I’m going to be working on a project that uses PostgreSQL, so I need to get familiar with it.


Installation on an Ubuntu system is easy:

sudo apt install postgresql
Read More

Using service workers for caching

What’s a service worker?

A service worker is a script that can be used as a client-side proxy for network requests. When the browser makes a request, a service worker can intercept it and decide what to do with it. This article is going to focus on using service workers for client side caching of web apps.

Why use service workers?

Service workers can be used to improve the performance and user experience of an application. They can be used to cache assets that are commonly needed but don’t change often, or to provide offline functionality.

Read More

Debugging assembly with GDB

I wrote a couple of articles about assembly before, and in order to understand what I was doing, I thought it would be useful to take a look at the contents of memory and registers to confirm my understanding was correct. I looked around, and found that GDB can help with this.

I wrote an introductory article to GDB a few months ago that you can check to get the basics. This article is going to build on top of it.

Debug information

In my introduction to assembly, I used this command to assemble my program:

nasm -f elf64 -o example.o example.asm
Read More

Concurrent data structures

A concurrent data structure, is a data structure (e.g. list, stack) that can be used by multiple threads concurently and it will always show a consistent state to each thread.


The definition above mentions that the data structure will always show a consistent state. To understand this, let’s analyze a data structure that is not concurrent and can end in an inconsistent state.

Let’s say we are building an application that draws a single rectangle. The dimensions of this rectangle can be modified by users around the world, they just need to visit a website and enter the new dimensions.

Read More

Pointers to members in C++

A few days ago I was looking at some code and I found something I didn’t understand. It looked something like this:

void someFunction(int SomeClass::*value) {

I had never seen and * used after ::, so I had to do some research to find what that means. It turns out that is a pointer to a class member. In this post I’m going to explain how these work and when they might be useful.

Pointers to members

Pointers to members are pretty uncommon, so it will be very rarely that you will need to use them.

Read More

Operator overloading in C++

Operators are a fundamental part of programming languages. They allow us to perform operations on operands by using a symbol. If you have ever written code, you probably know what this snippet does:

int a = 3 + 1;

Variable a will be initialized to 4. It is initialized to this value, because the + operator has been used to add the values of 3 and 1. The = sign, is also an operator that assigns the value of the addition to the variable a.

We use these operators without thinking too much about them, but they are just symbols that perform a certain action, like any function we could define.

It turns out we can override the behavior of an existing operator. That’s what this article will focus on.

Read More

Configuring gnome terminal programmatically

As part of getting a new computer, I want to be able to run a script to configure gnome terminal to my preferred setup. Doing this is not very hard, but finding how to do it took me some time.

The first thing we need to do is get the default terminal profile id:

$ gsettings get org.gnome.Terminal.ProfilesList default
Read More

C++ value categories

In C++, all expressions have two properies: a type and a value category. Value categories are a little complicated to understand and have gone through a few changes with time.

lvalue and rvalue

Lvalue stands for locator value. An lvalue is something that occupies a memory location. But… doesn’t everything occupy a memory location? Not necessarily. Let’s look at a simple expression:

int number = 7;
Read More

Exception handling in C++

In this post I’m going to write about using exceptions for error handling in C++.


They are called exceptions, because they happen in exceptional scenarios. A program should in most cases run without exceptions, but sometimes unexpected things happen and we might want to do something in those scenarios.

Exceptions happen when there is either a developer error (Dereferencing a null pointer) or an environment error (Trying to write to a disk that is full). They should not happen for user triggered errors (incorrect input by user), if those errors are common.

When an error such as dereferencing a null pointer occurs, an Exception object is created. The Exception object contains information about the error, and the state of the program at the time this happened. The exception will then be thrown and left for the runtime to handle.

Read More

Configuring gnome properties programmatically

After installing a new distribution in my computer, I usually want to make some tweaks to gnome. In this post I’m going to explain how to do these tweaks from the command line, so they can be scripted.


Gsettings is a command-line tools that allows us to modify gnome settings. To modify a setting we can use the set command. The format is like the following:

gsettings set SCHEMA[:PATH] KEY VALUE
Read More