Windows 11: Taskbar

For some reason Microsoft, in their infinite wisdom, decided to no longer support moving the taskbar to other edges of the screen with Windows 11.

Using a utility like ExplorerPatcher the whole task bar can be reverted to something close to Windows 10, including moving it to all screen edges.

Bash: Find All Folders Containing File With Name

fileName="my-file.yaml"
find . -type d \! -exec test -e '{}/'$fileName \; -print

This could easily be extended to do different tests on the folder by changing the -exec block to something else.

Wait for Port to Close Using Ansible

Sometimes it is useful to wait for a port to be closed, for example when updating an app that can’t always properly be shut down using other Ansible modules. This can easily be achieved using the ansible.builtin.wait_for or ansible.builtin.win_wait_for module. - name: Wait for port to close hosts: localhost tasks: - name: Wait for port 8000 close on the host, fail after 100 seconds ansible.builtin.wait_for: port: 8000 state: stopped timeout: 100 - name: Display the config ansible. [Read More]

Navigate to Script Directory

Often times when writing scripts I want to reference files in the same directory, but keep the script portable in case it is part of a git repository being checked out somewhere else or just the folder getting moved.

[Read More]

CLI fuzzy search

I often whish to search through large bodies of text, like my knowledge base or source code repositories, from the command line.

I use fuz for this and I’m quite happy with it.

I also have it aliased to my knowledge base folder for even easier searching.

alias search="fuz -p /path/to/knowledge-base/"

Render Plain HTML with Hugo

Hugo is my favorite tool for publishing markdown to the internet, but sometimes I want to do something a little bit more advanced with my posts.

With this shortcode I can always just fall back to plain old HTML.

[Read More]
hugo 

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