ads' corner

Extract GPS coordinates in KDE with just a right click

Oftentimes I need the GPS coordinates from where a picture was taken. In the past I was using exiftool, but that still includes too many steps. KDE has a feature where one can create custom context menus, called service menus, which let me define a right click menu for images, and a script is populating the clipboard with the coordinates.

DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC)

One of my older Python scripts is throwing a deprecation warning in the 'datetime' module after the recent switch from Ubuntu to Manjaro. The Python version is '3.12.4' now, previously it was '3.11.4'.

Watch for changed files in SyncThing

For syncing files between my devices I'm using SyncThing. This tool is reliable, available on Linux, Android, Mac and iOS. And it encrypts the communication. But sometimes I want to know when files in certain directories have changed - as example in my Obsidian vault. This allows me to post-process the files.

Hanging script at the end of Python multiprocessing

While writing and stress-testing a Python script which uses the multiprocessing library, I ran into the problem that occasionally the script hangs at the end. Literally runs past the last line of code and then hangs.

Django: Remove default entries from admin menu

The Django administration site comes with a couple of default entries, depending on which apps and middleware is installed.


Django: disable inline option to add new referenced objects

The Django Web Framework makes it quite easy to add new referenced objects in the admin menu.


Use namespace as global variable in Ansible Jinja templates

A simple task, or so I thought: in a Jinja template keep track of the number of items in a loop. And then use that count afterwards.

Disclaimer: the number of items is not equal the number of times the loop runs, so I can’t use the loop variables.

Turns out that Jinja has other opinions, and variables inside a loop are all local. When a variable is changed inside the loop, the scope of the variable stays local, and once the loop ends the original value of the variable is restored. That’s even true for variables which are created outside the loop.


Certificate expiration date in Ansible

In one of my Ansible Playbooks I’m updating Let’s Encrypt certificates. Because the Playbook is rather long, I want to make sure that Ansible is not spending cycles on a certificate which is not about to expire. Hence I wrote a small filter plugin, which receives the certificate path and the number of days the certificate must be still valid.

This plugin is used to filter out any “good” certificate which does not need to be updated.