Simple Back-ups with PostgreSQL

I have a PostgreSQL database that I want to back-up periodically in case my server crashes suddenly. In this post I’m going to explore a simple but efficient way to create a back-up and how to apply it.

SQL Dump

When we take an SQL dump from a database, we will get a file with the SQL commands necessary to recreate the database to the current state.

To take an SQL dump for a PostgreSQL database, we can use pg_dump:

Read More

Installing Ubuntu on an old computer - Broken graphics

A family member told me her computer was very slow and asked me if I could do something about it. Her computer was pretty old and was running some version of Windows, but since she used it mostly for browsing and storing photos, I told her installing some light version of Linux might help it run a little faster.

The machine has an AMD 64x2 processor and 1 GB of RAM. Looking at the requirements for Ubuntu, I found that it recommends 2 GB of RAM so I decided to try Lubuntu, which uses a lighter desktop environment. I expected this to be a very simple task, but I ran into issues with the graphics card.

Enabling safe graphics

I downloaded the latest stable version of Lubuntu and created a bootable USB with it. After the installation was over and I booted for the first time, the graphics were so broken I couldn’t really use the computer:

Read More

Unit testing Golang code

In this article I’m going to explain how to write and run unit tests for Golang code using go test. If you are completely new to the language, I recommend you take a look at my introduction to Golang article.


Testing in the Golang world revolves around packages, so we need to understand what a package is before we can understand how to test code.

A package is nothing more than a way of grouping related code. In Golang, a folder can only contain a single package. If we try to define two files in a folder belonging to different packages, the compiler will complain.

Read More

PostgreSQL user management

In my previous post I gave a brief introduction to PostgreSQL. In this post I’m going to dig deeper into user management and permissions.


PostgreSQL uses roles for authentication. There are two different kind of roles: groups and users. Users and groups can belong to groups; The only difference is that users can be used to log-in to a database. If a user is created with the INHERIT property set, it will inherit permissions from the groups it belongs to.

To see all roles that currently exist on an installation of PostgreSQL, \du can be used:

                                   List of roles
 Role name |                         Attributes                         | Member of
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
Read More

Change video resolution using ffmpeg

I have some videos that I recorded in very high quality and ended up being too heavy. To save some space I decided to resize them and I found this can be easily done with ffmpeg.

To install ffmpeg:

sudo apt install ffmpeg

Then, we just need one command to change the resolution of a video:

ffmpeg -i input.mp4 -vf scale=-1:720 output.mp4

The scale argument means the output video will have a width of 720px and the height will be set based on the ratio of the original video.

Read More

PostgreSQL - Connection refused

While setting up a new PostgreSQL server, I noticed that I was getting a connection refused error while trying to connect to it. After checking the firewall settings and finding everything in order, I decided to check things in the host.

I used ss to inspect connections listening on port 5432 (Default port used by PostgreSQL):

$ ss -tna src :5432
State       Recv-Q        Send-Q       Local Address:Port        Peer Address:Port
LISTEN        0            128   *
Read More

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