5 November 2023
Leafpad with access to system files
As I have explained earlier, I am using Leafpad instead of gedit in my Ubuntu system.
However, recent versions of Ubuntu does not have Leafpad available through APT any longer, you have to install it with Snap instead. This is quite annoying, since the Snap packaging of Leafpad is too restrictive, it cannot access hidden files in your home directory, nor anything in ~/bin/. This is not good, since I often want to use Leafpad to edit such files.
28 October 2023
From WordPress to Hugo
I have used self-hosted WordPress for this blog since its start in 2006, but I finally got fed up with having to frequently update WordPress itself and a bunch of plugins, or having to constantly worry about security issues. Since I am the only one publishing on this blog, I decided to switch to a static site generator instead, and I chose Hugo, mainly because it is easy to install and does not require any heavy runtime (most of its competitors require Python, Ruby or Node.
14 October 2023
From screen to tmux
I have written about how to configure screen in XTerm to support Ctrl-Tab and convenient scrolling back in history.
This has worked well for over a decade now, but it seems like screen is not developed very much any longer, and tmux has gained popularity as a more modern and actively developed alternative. So I decided to try it, and was able to replicate my setup with tmux instead of screen.
1 May 2023
In-memory database for testing
I have written about using an embedded database like HSQLDB or H2 for testing Java applications. This can still be useful (although JavaEE is not so popular any longer). But even though H2 claims to emulate PostgreSQL and several other popular production SQL databases, sometimes your application uses very specific features of a particular database and you need to test against the real thing to be really sure your application works correctly.
20 April 2023
Alpine rather than distroless
I have been using the distroless Docker base images to package my applications, mainly since I want slim and simple image without unnecessary cruft.
However, they are based on Debian, and Debian is unfortunately not so diligent to fix serious security issues as other distributions like Ubuntu or Alpine. If you scan a distroless image with the grype tool, you get this result:
$ grype gcr.io/distroless/java17-debian11 NAME INSTALLED FIXED-IN TYPE VULNERABILITY SEVERITY libharfbuzz0b 2.
10 February 2023
How to enable multi-platform Docker builds on Ubuntu 22.04
Docker’s official documentation on how to enable multi-platform Docker builds is a bit intimidating, suggesting you to run the Docker image tonistiigi/binfmt in privileged mode on your machine. I searched for alternatives on Ubuntu, and found this very detailed description. However, with recent versions of Ubuntu and Docker, it is now much easier than that:
Install QEMU’s static user mode emulation binaries:
sudo apt install qemu-user-static Install Docker Engine with Buildx support according instructions here (do not install docker-ce or docker.
2 November 2022
How to capture log events in tests with Log4j 2
Sometimes you want to verify that your program actually logs what it is supposed to be logging.
When using Apache Log4j 2 as logging framework, it can be done like this:
Include this dependency (for Maven, adjust appropriately for other build systems): <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <type>test-jar</type> <scope>test</scope> </dependency> Import some stuff: import org.apache.logging.log4j.core.Logger; import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.test.appender.ListAppender; Add a ListAppender to the logger you are interested in: var loggerContext = LoggerContext.
30 July 2019
How to run exec-maven-plugin only if a file is not up-to-date
In my Maven build, I use exec-maven-plugin to run an external tool for Java code generation. In this case the flatbuffers compiler (flatc).
By default, flatc always runs, so you always get a new .java file. This will always trigger Java compiler to run, which will in turn always trigger jar packaging to run, etc. I would like flatc to only run if it’s source file is updated, so I can get a properly incremental build and avoid needlessly recompiling.
14 June 2016
Support fake Android TV devices
Android TV is included in some modern Smart TVs, and there are also external set-top-boxes to get Android TV for any TV with HDMI input.
However, there are also some set-top-boxes which almost, but not quite, support Android TV.
With not so much extra effort, it is possible to make an Android app supporting those fake Android TV devices as well as the real ones.
In addition to the guidelines from Google for building Android TV apps, do this to support the fake TV Android TV devices as well:
10 February 2016
Data structures and Domain Driven Design
After listening to a presentation about Domain Driven Security, I got some additional insights about what a data structure (as opposed to OOP object) should be able to do. Data structures (I call them struct) should have a subset of OOP features which I think is useful and harmless.
A struct should allow constructors. Such constructors can have two purposes, to convert one type of data into another and to validate the input.