Grimoire

Explore the code spells and technologies in my grimoire. Contains snippets I need repeatedly across projects.

Browse CategoriesBrowse Technologies

Recent Spells →

Shell Command To Resize Images

The quick and efficient way to ad-hoc resize an image file right from bash or zsh terminals using image magick.

allow all robots.txt file

Minimal template for a robots.txt file that allows all crawlers to crawl everything. Also include a direct link to the sitemap.xml for better discoverability of the page.

Twitter Cards Markup

How to get your sites looking good on X timelines and ensure that images actually show up as intended. Sharing is caring!

Transform All Image Files to webp

Bash script that replaces all image files within a folder into webp files of the same size.

Import SQLite records from another database

See how to copy SQLite rows from an already existing (old) database into another database, table by table, using the ATTACH DATABASE built-in feature from within a bash script.

Bootstrap 5 Media Component

Responsive bootstrap card with a strictly left-aligned image, title, description and optional aside flavor text. With Rust maud example code.

Rust Chrono Relative Time Ago

A quick and dirty solution to get that "X days ago" String out of a chrono NaiveDateTime without any dependencies. Very easy to customize on-demand in your project!

Actix-Web embed and serve static asset files

Example of how to embed a folder os static assets into the final binary and serve them on configured routes from actix-web.

Rust Actix-Web HTTP Basic Auth

Protect simple admin website areas with basic auth in actix-web, including safety against timing attacks. Pragmatic choice for single-admin web sites or quickly securing a resource.

Rust actix-web with maud

How to use maud in actix web as a lightweight template engine.

Rust Maud Templates

How to build parent templates/partials with Rust in maud, using a simple functional component.

SQLite On Delete Callbacks

Leverage the built-in callback handlers of sqlite to ensure that no dangling foreign keys or orphan records exist in your database. Pure SQL solution.

Deploy a Rust or Go binary to a VPS daemonized

Example deploying to a Digital Ocean linux droplet via email/password authentication and use the screen command to keep the service running as a daemon.

Unique function for arrays/slices in Go

How to write a functional Unique function in golang using generics, including a unit test. Quite handy when processing data!

UniqueBy function for arrays/slices in Go

How to write a functional UniqueBy function in golang using generics, including a unit test. Stop writing this by hand every single time!

Reduce function for arrays/slices in Go

How to write a functional Reduce function in Go using generics, including a unit test. The foundation for many functional programming libraries!

ParallelMap function for arrays/slices in Go

How to write a concurrent functional Map function in golang using generics and goroutines. Leverage all your CPU cores!

Map function for arrays/slices in Go

How to write a functional Map function in Go using generics. The classical foundation of data pipeline code!

IndexOf function for arrays/slices in Go

How to write a functional IndexOf function in Go using generics. Surprisingly helpful during mundane tasks!

GroupBy function for arrays/slices in Go

How to write a functional GroupBy function in Go using generics, including a unit test. Returns a map with slices.