Tag archive for "Python"
The folder sensor in home assistant is good if you need a random file from one directory, but how about a random file from a file hierarchy?
more
I often want to mock reading from a file when writing unit tests in Python, and I always struggle to find the right solution again. So I'm posting it on my own blog in the hope of finding it later 🤣 My solution is to return a StringIO object from …
more
I recently had to restore some data from backups, and was using Django serializers to get the job done. Objects of one class were not deleted, but the relationships were set to None when the related objects were deleted. Here's how I restored the relationship information.
more
I ran into this error several times recently while trying to run a few Python-based GTK apps. Here's how I solved the problem.
more
Procmail is an old tool, and the reason you're using it today is probably because you started using it many years ago, and changing to something else is not something you want to do. Procmail doesn't know about unicode, so unicode in headers is problematic. This post contains my solution to creating procmail rules that understand unicode subjects.
more
I use find on a network filesystem and pipe the output to rofi for a nice menu, but the list of files got longer and longer over time and getting the results took too long. I looked around and couldn't find a solution I liked a lot so I wrote …
more
I recently switched to py3status to populate my i3bar. I had several scripts I wanted to call that generate some output for the bar. Below is an example how this can be accomplished.
more
Django models are usually created with a get_absolute_url method, but Wagtail pages don't have one. On this site I mix Wagtail pages with other Django models and needed an url without a domain in some places, below is the solution I'm using right now. Most methods to get a page … more
Wagtail has the modeladmin module in contrib which allows you to edit any Django model through the Wagtail admin interface. Unfortunately it's not very flexible, the code calls the get_edit_handler method on the admin class and the panels property of the model can only be a list. In one project … more
I run Debian unstable on a few machines and wanted to know if I was always running the latest kernel. I've added the script below to my shell startup. And then I went on and added it to some servers as well, after a few hundred days of uptime there …
more