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

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