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

My Publishing Pipeline

I write an extensive personal knowledge base using markdown, code-server and a variety of other tools. Originally, in 2021, I wanted to have something like Obsidian Publish but self-hosted, so I created it.

Over time my knowledge base evolved more into a second brain, tracking not only my technical notes and journal, but also things like recipes and hikes. With this my publishing pipeline, and the script at it’s core, extended in a multitude of ways.

[Read More]

Simple Self Organization

Simple Self Organization

This is a guide to a simple self organization/task management system I built for myself over the years.

From time to time I showed it to someone and they got some benefits from it, most adapted it to better fit their needs down the line, which is exactly what you should do with any kind of personal task management in my opinion.

[Read More]

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 

Hack things together

A little scripting never hurt anybody

Sometimes you have to do a specific task and you are fully capable of doing it manually, however those tasks are also great to flex your muscles and hack something together.

They can be an excellent tool to sharpen your skills with the tools you use regularly, and improve your quick prototyping skills.

In addition, with a couple of iterations, again sharpening an important skill, you could afterwards create a more general purpose tool from a hacky script.

[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

What to do with your own server

Tools, tips & tricks

What to do with your own server
Now that we have talked about the benefits of running your own server and how to run your own server let’s take a look at some things you could run on your own personal server and some things you should better not. Host a code-server code-server is an open-source application that allows you to run VSCode on your server and access it from any browser. It’s perfect for taking notes or journaling from anywhere, as you can access it from any device with a browser. [Read More]

How to run your own server

There are many ways to run your own server, from setting up a Raspberry Pi on your desk to renting a physical server at a provider.

In this post, we will focus on setting up a virtual server with DigitalOcean, which is one of the easiest ways to get started.

[Read More]

Benefits of running your own server

Benefits of running your own server

In the world of technology, we are moving further and further away from operating directly on servers, but there are still significant benefits to be gained from running a personal server.

I have been running some kind of personal server for many years now and I strongly believe anyone working in technology can benefit greatly from doing so. Here’s why:

[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]

WSL2 & Keychain

The problem

If you use ssh-agent with an encrypted ssh key it does not persist when you open a new terminal window.

The solution

Use keychain instead.

  1. Install
    sudo apt install keychain
    
  2. Add to your shells rc file, eg. .bashrc or .zshrc
    # Repeat this line for all keys you want to unlock and use this way
    /usr/bin/keychain -q --nogui $HOME/.ssh/id_rsa
    source $HOME/.keychain/wsl-sh
    
  3. Unlock your keys on shell startup and enjoy
wsl  linux  ssh 

Self-hosted notifications

Self-hosted notifications

Running any kind of personal infrastructure sometimes requires your attention based on certain events or failure states, no matter how much you automate tasks.

Over the years I have used E-Mail, Telegram bots and a variety of other tools for this purpose. However all of them have the drawback that they mix with other kinds of information and are not easilly usable in scripts.

[Read More]

Git: Add only changed files

Sometimes you may want to commit only the files you have changed and not any newly created files, this can easily be achieved by this command: git commit -a

[Read More]
git