Null terminated and length prefixed strings

Null terminated strings

Null terminated strings (also called C strings) store a string as a sequence of characters terminated by a null character (\0).

For example, if we have a variable with the string taco, in a character array, it would look like this:

index: 0 | 1 | 2 | 3 | 4
value: t | a | c | o | \0

Notice that even though, taco is only 4 characters, it is necesary to allocate an extra byte for the null characer (\0).

Read More

How hard drives work

As computer users, we are accustomed to storing data to retrieve it sometime in the future. Today there are many ways to do this. If you take a photo on your cell phone, it’s going to be saved into the phones internal flash memory (or an external flash card). If you have a modern computer it’s likely that you have a Solid State Drive (SSD). It’s also possible to save your data in the “cloud”. So, why focus on Hard drives?

Hard Disk Drives (HDD) have been a reliable way to store data since the 1950’s. Cloud providers (AWS, Azure, Google Cloud) have HDD offerings that are cheaper than the SSD alternatives. At the time I wrote this article, if I want to buy a 5TB HDD, I would have to pay around $100 USD; if I want to buy 5TB SSD I would have to pay around $500 USD. For this reason HDDs are still widely used.

Read More

Introduction to Apache Ant

I just started working with Java and I have realized I don’t know much about how the build system works. In this article I’m going to explore Java’s build system. Ant is analogous to Make, Gradle or Gulp. It’s main goal is to automate the process of running tasks. More specifically, it is often used to compile code, run tests, etc.


Ant is a Java application, so a Java Runtime Environment is necessary. The installation will vary depending on your environment, so you might want to check the official documentation. If you use ubuntu, you can use apt-get:

sudo apt-get install ant

To verify the installation was successful:

ant -version
Read More

Introduction to AWS CLI

I’m going to start working a lot with AWS, so I will need to get familiar with they’re tools. One of the most important tools to get familiar with, is their CLI.

Although it is possible to do most things from AWS management console, learning how to use the CLI allows for scripting and automation, which can help increase productivity.

AWS Management Console


To install AWS CLI we need Python 3.4 or later. Use --version to verify it’s installed:

Read More

Introduction to CircleCI

I have a few private Github repositories where I use Travis for running checks on each of my commits. A couple of days ago I received a message from Travis telling me that I only had 10 builds left as part of my trial. Luckily, someone told me CircleCI allows unlimited private builds for free, so I’m going to try it out.

Creating an account

The first step is to create an account. They allow to sign up with Github, so I just chose that option:

Sign up with Github

Read More

Using testify for Golang tests

A few weeks ago I wrote an article about writing unit tests for Golang. In this article I’m going to explore using testify to make writing tests easier.


I’m not going to cover how to install the testify library in this article. I wrote an article in the past explaining how to use dep for dependency management, you should follow that process to use testify.

Read More

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