Using flex
children can easily be positioned vertically in their parent container.
Published directly from my personal knowledge base.
Debugging CSS Layouts
When debugging issues with CSS layouts it can sometimes be tricky to really understand what is going on.
[Read More]Simple Copy Button Using JavaScript
I often find myself wanting a simple copy button in my web projects.
This is the recipe I build them from using clipboard.js and a couple lines of JavaScript.
[Read More]Generate link in plain text element using JavaScript
Sometimes, when working with externally generated content you might want to make links clickable when rendering it in the client.
This is a snippet to do just that.
[Read More]Register all models with Django admin
Sometimes, mostly when throwing together a quick idea or MVP, it can be useful to just register all models with the admin and leave proper customization for later.
[Read More]Add fields to list with Kustomize
How to add things to a list using kustomize. This is useful for example when you need to patch additional environment variables into a pod.
[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 Details Shortcode
The HTML details element is a nice way to create natively expandable content with wide browser support.
[Read More]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
Helm: Join two lists
Since early 2019 the sprig
library used by helm
provides a concat
function that does exactly this.
HTMX
Go check out their website, it’s incredibly good at explaining itself.
To me, a backend heavy developer, HTMX is the frontend framework I like to use because:
- It does not feel like a JavaScript framework at all, but more like an extension of the HTTP/HTML model
- It allows me to write interfaces that feel responsive and modern to users while still doing all the heavy lifting in my backend with the tools I’m used to
- It works with my mental model, which is heavily based on the request-response cycle
Handling signals with Python
My home office setup: 2023 edition
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 clickContinue
- From the
Utilities
menu selectStartup 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
- Choose
DigitalOcean CLI Cheat Sheet
My hiking kit: 2023 edition
1Password CLI Cheatsheet
The 1Password CLI op
works either in connection with a client app, like on the Mac,
or standalone, useful on a server.
# Login
eval $(op signin)
# Get favorites
op item list --vault "Private" --favorite
# Get a specific item
op item get <ID>
# !! Important: Sign out at the end
op signout
Some helper functions
Helpers to more easily work with the op
cli.
1login() {
eval $(op signin)
}
alias 1signout="op signout"
1search() {
term=$1
if [ -n "$2" ]
then
vault="$2"
else
vault="Private"
fi
echo "Searching for '$term' in vaut '$vault'"
op item list --vault "$vault" --long | grep "$term" --ignore-case
}
1get() {
op item get $*
}
Being a good code reviewee
Things I do to be a good code reviewee.
[Read More]