Category: Opensource

  • An Admin-Only Python Decorator for Telegram Bots

    TL; DR: Here’s a Python Decorator I wrote for Telegram Bots so certain commands can only be used by group admins.

  • Solved: Blank Screen After Login in Gnome Shell 44

    Background: I have an old desktop computer running Fedora 36 + Gnome Shell desktop environment and upgraded to 38 recently. It was used as an archive so I left it in garage and only connect to it vis SSH or VNC. Now I moved it into my home office because I think it can act…

  • How to Sort Lines in YAML

    I asked myself this question and it turns out that I don’t need to write a script to do this, yq has the answer already. More on array sorting and map sorting 🙂

  • 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…