Author: admin

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

  • Sample Terraform Code to Manage Temporary Access to GCP

    TL; DR: This is a way to grant a temporary access to some GCP resources using Terraform’s time_static and google_project_iam_member resources. 🙂

  • Solved: Uninstallation of config-connector Got Stuck in ArgoCD

    The Kubernetes Config Connector is another level of IaC(Infrastructure as Code): It wraps Google Cloud resources like a Cloud Load Balancer with Kubernetes CRDs(Custom Resource Definition) so instead of writing Terraform HCL I can write YAML to manage GCP infrastructure. However when there’s a need to uninstall a config-connector, it got stuck in ArgoCD As…

  • 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: 🙂

  • Django DB Migration Job with ArgoCD

    A Job in Kubernetes is a one-off and immutable task to be carried out during deployment. But what if a job needs to run for each deployment? A new job with the same name can’t be deployed on top of the existing one, given it in completed or failed state. Since Kubernetes 1.23, A TTL(Time…

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