strncpy and strncat for copying strings in C

Recently, I've read an interesting article1, explaining why the strncpy function in C is not safer than strcpy. The post was very interesting, but what's more, it suggested an alternative idiom for copying strings in C, that might probably be the way to go.

Later, in another article2 that compared some functionality in C, Python and Go, one of the comments pointed out that very same idiom. That grabbed my attention, so I decided to try it in an example.

Read more...

Setting user permissions in KVM

In a previous article I mentioned how to install a library in Fedora, in order to make KVM virtualization easier, managing the NAT network configuration between the guest virtual machine and the host, by means of libvirt.

Besides that, while using KVM locally for development, I use virt-manager, a helpful application that manages the different virtual machines. This application, as well as the rest of the commands that interact with libvirt (virsh for example), require super user privileges, so it will prompt for the sudo password every time.

Read more...

Notas sobre la ArqConf 2015

Este es mi resumen sobre la ArqConf 2015, la conferencia sobre arquitectura de software que tuvo lugar en la UCA el 30 de Abril de 2015. La idea es sintetizar las principales ideas que me llevé y resaltar lo más importante.

Se presentan a continuación un listado de las ideas principales por charla con un breve listado de lo que más destaco por cada uno. Nótese que la lista no es de ninguna manera exhaustiva, y cada sección es en realidad un breve párrafo ilustrativo a modo de resumen muy a alto nivel.

Read more...

Running RabbitMQ server on Docker

If you use RabbitMQ for development frequently, sometimes you might have found it uses too much resources (it's normal while programming to have a lot of queues or tasks being queued and that makes the CPU usage to spike).

Having RabbitMQ installed on the OS seems the perfect approach for production, but on development I'd rather do something different, in order to isolate the process. I know I could bound it (for example order it not to start automatically as a dæmon), by means of systemd but a few weeks ago I decided to try docker and see how it results.

Read more...

Find Options

Among the core-utils, find is one of the most useful commands. Though I use the basic functions most of the time, find has a wide range of parameters, and it comes in handy not only for finding files, but also for operating a bunch of them at once. Here is a very simple example.

Imagine you have to move many files to a directory, but they all call different so a glob is no use, and manually moving all of them is not an option. A possible approach would be to locate the first of the batch (for example by running ls -lrth). Suppose the first one of the batch is called /tmp/checkpoint (for this example let's assume the files reside at /tmp).

Read more...

Checking Python files with Vim

Vim is an excellent editor, and mastering it leads to more productivity. Even though is very extensible and allows to be configured by many plug-ins I rather keep it as simple as possible, trying not to use many plug-ins (neither packagers like Vundle, etc.).

However, I do make use of an extension that checks Python files for errors, PEP8, among other things: flake8. Because I do not use plug-in platforms for Vim, I install just this one manually, by making the command flake8 available system-wide1.

Read more...

Alpine email client

Alpine is a software I definitely recommend for those who like minimalistic applications that go straight to the point in order to get the things done. It's an email client, with no GUI, which allows me to read emails better than by means of the web page1 without any distractions, focusing on what is just important. It is also great that shows only the text (the relevant part of the email) and it can follow the links by launching the default browser.

Read more...

Libvirt networking libraries

Fedora 21 workstation seems to come with a lot of virtualization features and most of the libvirt libraries installed. I only had to add the KVM virtual-manager which is the KVM application I am more familiar with. However, the new version of the libvirt* libraries have networking features that are great for the data centre environment, but maybe not the best option for a particular workstation, so I added the following packages in order to set up an easier network configuration for my local virtual machines.

Read more...

Do not import *

It is well-known among Python developers (or at least, it should be), that is a bad idea to import everything from a module, for example by doing from <module> import *.

The idea on this post, is to highlight and gather the reasons why this is a bad practice, in order to collectively identify many undesired effects. However, without losing pragmatism, in case there are some odd reasons why this might be acceptable, I will also mention them, if any. Let's see where we get.

Read more...

Writing forward-compatible software in Python

Python 3 is the future of Python. However there might be a problem in the community if both Python 3 and 2 coexist. The former one was great and brilliant, but it is time to start writing software in the new version in order to move towards new features and improvements.

Let's start by the beginning. One of the reasons I always preferred Python over the rest of the programming languages is because it is more advanced, meaning that included many concepts that other languages did not. For example, think of how early Python adopted ideas like lambda functions, dynamic typing, duck typing, context managers, metaclasses and so on, while other technologies (namely Java, C++ for example1) were still using data structures and calling them "objects". Python has always been many steps ahead.

Read more...