Category: Opensource

  • SAUS: Such A URL Shortener

    TL; DR: It’s a simple but effective URL shortener I wrote in Python + Django, I consider it stable now. Also added QR code generator for mobile applications. Source code is in Github. 🙂

  • How to Serve QR Images from Memory with Django

    TL; DR: I used SpooledTemporaryFile with FileResponse to server generated QR images directly from memory, no disk IO involved. Please see my code sample with notes: 🙂

  • Caching in Python with Redis + @Decorator

    TL;DR: Here’s a simple Python decorator I wrote which can cache function results with Redis. Prerequisites The Python Decorator What’s a decorator in Python? Here’s a very easy-to-understand explanation just for the question. Below is my code of the decorator with notes: Done 🙂

  • How to Query in MongoDB and Group by Date

    TL;DR: Here’s a quick example to query MongoDB documents created this year(2023) and group them by date, ie. how many my_doc were created today, yesterday, the day before yesterday, etc. The following statement works in a MongoDB client such as mongosh. Then here’s an equivalent example to do it with MongoEngine in Python: Since I…

  • How to Self-Host a Mastodon Instance in Kubernetes

    TL;DR: Instead of the official installation including setting up Ruby, nginx, systemd service, etc., I found it more comfortable to install and run a Mastodon instance using some YAML files. Just in case, what is Mastodon anyway? I used kustomize to manage and generate Kubernetes manifests for a fully functional Mastodon instance. Please see my…

  • How to Use a Local Persistent Volume

    TL;DR: A local persistent volume in a Kubernetes cluster is a persistent volume allocated in a certain node. Any pod mounting the volume will be automatically scheduled in the same node. Since it’s limited to 1 node, clearly it can’t be used as a high-availability solution, but hey, it’s quite Ok to use it for…

  • How to Share Files on Linux Using Docker

    Prerequisites: A Linux computer(mine is Fedora 36) Docker(or podman) installed I know, there’s traditional ways to share files over network such as samba or the very current cloud way such as Google Drive. Or I can just use a USB key. But I managed to impress my child(who has to use Windows because of her…

  • How To Renew Certificates in Kubernetes Clusters, Revisited

    There is a lot of TLS certificates used by the core of a Kubernetes cluster and a popular one is the client-server pair used by kubectl to authenticate to the cluster control plane. In my previous notes on how to renew certificates in a Kubernetes cluster with kubeadm, I found that the steps are quite…