Ansible and cowsay

Cowsay is one of those packages you just end up installing randomly on just about any client over time.

And if your using ansible you may be in for a little surprise:

[Read More]

Django: CSRF exempt view

Django’s CSRF protection is usually a great thing, but when building (API) endpoints meant to be accessed by scripts/third parties it gets in the way of that.

This is how to disable it:

For a class based view

from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt

@method_decorator(csrf_exempt, name='dispatch')
class MyView(View):
    pass

For a function based view

from django.views.decorators.csrf import csrf_exempt

@csrf_exempt
def my_view(request):
    pass

Handling signals with Python

When building a Python script that is long running or has to manage some state on termination it is helpful to handle a couple of signals: SIGINT: The signal sent when pressing Ctrl+C SIGTERM and SIGQUIT: Meant to terminate the process, sent by kill and process managers like systemd or supervisord Handling them is possible with Pythons signals library: import signals class SignalHandler: stop = False def __init__(self): # Ctrl+C signal. [Read More]
python 

My home office setup: 2023 edition

Since I spend more than 8 hours here most days I created a nice setup for myself. Thankfully I have a whole room just for my home office, so I take full advantage of that. Besides my main desk I have a secondary desk, a couch, a couple of sideboards, a wall mounted whiteboard and a couple of shelves to display all the techy and nerdy things. Main desk My main desk is a custom build based on a FlexiSpot height adjustable electric frame. [Read More]

Enable system extensions on Apple silicon Mac

Think before you enable this, it could be a security risk

  • Shutdown Mac
  • Press and hold the power button until the Recovery Mode menu appears
  • Select Options, then click Continue
  • From the Utilities menu select Startup Security Utility
  • Select your startup disk and click Security Policy
    • Choose Reduced Security
    • Check the option Allow user management of kernel extensions from identified developers

My hiking kit: 2023 edition

These days I enjoy hiking quite a lot. To make it easier to just “pick up the pack and go” I created two basic packs that are optimized for my needs and the environment I’m usually hiking in, the Swabian Alps. Basics I have some basics I duplicated and carry in both my packs, these are: Pen & paper Multitool Mini first aid kit in a ziploc bag Paracetamol Band aids Gel sanitizer Foam pad Waterproof poncho A bit of cash, usually around 20-30€ these days A piece of paper with my and my emergency contacts information Fisherman’s Friend for a fresh feeling and honestly because my parents had them when we were hiking Prepared packs Small pack I’m currently using a Terra Peak Flex 20l in red for my smaller backpack. [Read More]

yamllint error: "invalid config: ignore should contain file patterns"

Setting up a new repository for YAML linting today I was running in a bit of an issue with yamllint. I was using a YAML list to specify ingores, as mentioned in the documentation: ignore: - "*.dont-lint-me.yaml" - "/bin/" - "!/bin/*.lint-me-anyway.yaml" This however did not work with the above mentioned error message. After a lot of debugging I found that they released a new version recently which introduced this feature. [Read More]