July 31, 2021

How to Find Out Which Files Changed Most Often in a Git Repository

I found this helpful command while cleaning up my Desktop - I cannot recall where I got it from :-/ git log --since 6.months.ago --numstat | awk '/^[0-9-]+/{ print $NF}' | sort | uniq -c | sort -nr | head This will list the top 10 most often changed files in your git repository. Why would you want to know this? Well, several things come to my mind: you get a quick overview what was changed in the last couple of months this could indicate problems such as a god class, when a file shows up you did not expect What do you think?...

July 14, 2021

How to Find the Reverse Dependency of a Package

Today, there was a nice little discussion on vacdec’s GitHub project about what needs to be installed to make the barcode scanner pyzbar work on Ubuntu and MacOS. The original poster proposed to install zbar on both operating systems. zbar for Ubuntu comes with a ton of dependencies. So I had a look at my installed packages… ❯ apt list --installed | grep zbar libzbar0/bionic,now 0.10+doc-10.1build2 amd64 [installed] … which only revealed the libzbar0 library....

July 6, 2021

How to Debug Network Issues

Unlike I stated earlier today… It’s not DNS There’s no way it’s DNS It was DNS … this time it was not DNS. But let’s start from the beginning. two lonely OpenSUSE virtual machines I inherited two OpenSUSE VMs from a departing colleague. After changing passwords and cataloging what services are installed, I tried to update the VMs… and got the following errors… # zypper refresh Problem retrieving files from 'Haupt-Repository (NON-OSS)'....

July 6, 2021

How to Patch Java 7 Certificate Store to Support Let's Encrypt

Do you have to support a very old Java application? Old as in only runs on 1.7.0_21-b11? And this application needs to access websites on servers using Let’s Encrypt? Especially after September 2021, when the widespread DST Root CA X3 certificate will expire? There is help. keytool to the rescue Oracle kindly provides keytool. With keytool you can view and manipulate the contents of the Java certificate store, which usually can be found at /lib/security/cacerts within in your Java runtime....

July 6, 2021

How to Check Configuration for Bind

You probably heard of the three steps on how to debug networking issues… It’s not DNS There’s no way it’s DNS It was DNS While this is not only funny, but also true, you can do your part to prevent such issues. When you change the configuration for BIND, you should make sure it is still working. check bind configuration $ named-checkconf /path/to/named.conf The path depends on your distribution. For Ubuntu 20....

June 21, 2021

How to Generate Quick Git Stats

Ever wondered how many lines of code you have added or deleted, within a day or a week? Here we go… ❯ git diff --shortstat "@{1 day ago}" 36 files changed, 35 insertions(+), 1263 deletions(-) ❯ git diff --shortstat "@{1 week ago}" 40 files changed, 821 insertions(+), 1270 deletions(-) How do you generate stats from git? Drop me a line on Twitter or via e-mail.

June 11, 2021

How to Bring Color Back Into tox4 and pytest

When I first tried the pre-release of the upcoming tox rewrite, I noticed tox itself has funky new colors - which I like a lot… But what happened with the green dots for pytest'soutput? You may recall, running the old tox or pytest directly, the dots would be green… why has this changed Honestly, I am not 100% sure. But I know how to get the colors back. All you need to do is changing this line commands = pytest {posargs} in your tox....

June 9, 2021

What Is the True Order of Files in a Directory

This week I faced a very odd bug at work. A build process failed - on one machine, but not on the other. Identical setup - of course :-/ The build script consists of a bash script, which wraps a call to the C binary. The bash script was innocent. When I had a closer look at the C source code, it turned out there were about 30 lines of code, just dealing with traversing directories and copying files and folders....

May 28, 2021

How to Delete Anonymous Docker Volumes on Tear Down

On one of our servers, there is a demo application installed for our customers. The application, which consists of two docker images, is managed by a docker-compose.yml file. As the customers are able to change the data, the containers and the attached volume are torn down every night, and then rebuilt. Monitoring made me aware, that we are running low on disk space. Turns out the volumes do not get deleted with the current cronjob:...

May 22, 2021

Variable Scope and List Comprehensions

Python 2 In Python 2 the temporary variable was not so temporary at all… ❯ python2 Python 2.7.17 (default, Feb 27 2021, 15:10:58) [GCC 7.5.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> s = "abc" >>> [x for x in s] ['a', 'b', 'c'] >>> x 'c' As you can see, x leaks outside the scope the list comprehension. Python 3 This has been changed in Python 3....