grokking hard

code smarter, not harder

Recent posts

2023-Jun-11
I finally found a good use case of Java Local ClassA Basic Problem Today I needed to come up with a method to mask some certain string (as Apache’s Common Lang’s StringUtils did not support it yet). The masking logic is simple though: If the length is smaller than 2, mask everything. If the length is up to 5, show first and last characters. If the length is up to 12, show the first two and last two characters. Otherwise, show the first four and last four characters.…
2023-Jan-16
Trying out NetworkPolicy on Kubernetes running on Docker for macOSA problem I was tempting to try out NetworkPolicy on Kubernetes as a secure way to protect traffic in and out the namespaces but never managed to actuall do it. Today a friend of mine who was pursuing “Certified Kubernetes Application Developer” asked me a problem related to it. He was using a small set of exercises to practice Kubernetes. The problem statement was: Create an nginx deployment of 2 replicas, expose it via a ClusterIP service on port 80.…
2022-Dec-02
Convert checksum between Hex and Base64 using CLIChecksums produced by SHA1, SHA2 are usually in hex format. However, there also come in base64. I just discovered a way to convert between the two.…
2022-Jan-07
Download File and Verify Checksum in BashI had a need to download a gzip tarball file (.tgz), verify its checksum and extract one particular file in it. All in one go using Bash. By using Bash’s process substitution and tee, such a task could be achieved in a one-liner. I had this need when I built a Docker image for Retype, a static site generator from Markdown files. Retype was not a pure Node.JS package. The NPM package was just a CLI wrapper for the actual binary built using .…
2021-Sep-27
MongoDB failed to lock file on OpenShift using NFS file systemThis page documented the investigation of an issue: MongoDB Pod failed to lock mongod.lock on OpenShift/OKDv4. The problem was because NFSv3 was used to mount between OKDv4 Worker Nodes to the NFS server. MongoDB used internally flock/fcntl to lock the mongod.lock file descriptor. In a network file system like NFSv3, locking support was required from both server and client, otherwise, a “No locks available” would be the outcome. NFSv4, on the other hand, came with built-in support for locking as specified in the protocol. Changing to mount using only NFSv4 solved the problem, but there were more than just that.…
2021-Jun-16
The Collector's Fallacy  - Zettelkasten MethodOn researching taking notes, speciffically the Zekkelkasten method, I learned The Collector’s Fallacy. In its essenses: Saving links, copying or just reading a material does not mean that you have consumed the knowledge. You may have increased the knowlege for a short time, but it will fade away very soon after that. By taking notes, or making a Zettel, to summarize again what you understood, you then actually can reaffirm the newly acquired knowledge.…
2021-Mar-08
Goes back quicker in TerminalI made a shell alias to easily cd back to multiple levels of parent directories…
2020-Oct-13
Less well-known uses of curlWhen it comes to make HTTP calls, I always use curl as it is a ubiquitous tool for the job. Today, I discover that I can use curl for some other tasks.…
2020-Sep-16
Convert Git to Git LFSThere are some Git repositories in the company contain mostly binary files (Words, Excel, PDFs, etc). As Git is not designed to track binary files effectively, eventually the repository ends up pretty large (over 2GB) and will become a PITA on git clone. In order to effectively solves this, switching a regular Git to Git LFS. This post aims to show you how to do it. Prerequisites Remote Git Server MUST support Git LFS (GitHub, GitLab and BitBucket all supports LFS) git (>=2.…
2020-Apr-01
TIF - Powerful SSH #1Recently, I discovered that SSH have some wonderful features and usages that I didn’t know before. Faster copying directories with rsync via SSH When it comes to copying files back and forth to a remote server, I usually go for scp. 1 $> scp hello.txt remote_user@server.example.com:/tmp/ scp even supports to copy a whole directory: 1 $> scp -r files/ remote_user@server.example.com:/tmp Not until recently, a colleague of mine, Alex, taught me that using rsync happens to be faster than scp when it comes to syncing directories between local and remote server.…