Personal Productivity

How Best to Capture Output from Scientific Calculations?

When writing programs that do computations, my overwhelming preference is to simply write results to standard output, and to use shell redirection to capture the output in a file. In this way, I am leveraging the shell’s full functionality, in particular filename completion, in the most convenient way possible. For the file format itself, I prefer simple, column-oriented, delimiter-separated flat files. They are completely portable, and can be read and understood by most tools. (They also play well with the usual Unix toolset.)

But this simple approach breaks down, once a program has to write more than one output stream: for example in the case of a simulation run, I may want to capture periodic snapshots of the simulation itself, but also track various calculated metrics as well. These two streams will not fit comfortable into a single flat file. One option is to use a structured file format, the other option is to write to multiple files simultaneously.

QR Codes

QR Codes

QR codes are a two-dimensional equivalent of barcodes: a graphical encoding of information, which in practice means a string of about 4000 alpha-numeric characters (upper-case only) or a little less than 3000 arbitrary bytes.

So, how then are QR codes able to perform magic, such as automatically opening web pages, or sending text messages, or even dealing bitcoin? The answer is: they can’t.

Let’s try to understand what’s going on.

Command Line Arguments with Python's Argparse Module

Processing command-line arguments in ad-hoc python tools is one of those areas where I tend to just hack it together from scratch — simply because the effort of learning and understanding the relevant library packages not only seems to be more work than it is worth, but also and in particular more effort than “just doing it” by hand. I don’t want anything fancy, after all. I just want to get it done.

A Guide to Running GUI Applications in a Docker Container

Containers are not usually associated with GUI applications, but there may be times when one might still want to run such a program inside a container, for example to isolate the application’s dependencies. Installing a GUI application in a container means that not only the application, but also all its specific dependencies are encapsulated inside the container (respectively, the container image), and can therefore reliably be removed from the system in a single step.

The primary challenge is to let a container communicate with the host’s display system, so that it can create GUI windows on the host. A GUI application will likely also need to share files with the host system, which in turn requires the appropriate user permissions.

Running a GUI Application in a Docker Container

Containers are not usually associated with GUI applications, but there may be times when one might still want to run such a program inside a container, for example to isolate the application’s dependencies. Installing a GUI application in a container means that not only the application, but also all its specific dependencies are encapsulated inside the container (respectively, the container image), and can therefore reliably be removed from the system in a single step.

Using Xsession to Set an Environment Variable Without a Shell

The freedesktop project, arguably the most important Linux organization you’ve never heard of, has (among many other noble deeds) done an admirable job clearing up the mess of local cache and config files in one’s home directory. But how does one override their defaults, if this requires setting environment variables globally, for all processes, and outside an explicit shell environment?