Mastering ExecutorService Shutdown: Tracking ThreadPool Termination
Let’s say you want to execute some tasks. Since executing it through a single thread might take you quite some time to get the result, you decide to use the ever dependable ExecutorService to process it through multiple threads. ...
Devi for Millennials, by Bibek Debroy - A Review
I went into reading this book with high expectations, and I was… disappointed? But that’s probably on me. I wanted something which inspires me to explore the rich Indian culture that I know only sparsely about, at the same time holding my hand over the things I don’t know. It does do the former very well, but the latter, not so much. A lot of questions are answered, but it raises even more questions the more you read. ...
SSH Tunnelling with Java
You heave a sigh of relief, as the QA has approved a long-awaited feature for deployment on Prod. However, as a part of the process, it is first deployed on the UAT env, where there are test accounts that can be used to certify the feature works outside of the local developer and QA testing systems. ...
Handling limited sudo access through Ansible
Running specific commands with sudo using Ansible It seems a trivial use case, but it’s not. Consider a situation when you’re not the user allowed a full sudo access on the remote machine. However, you are only allowed the sudo access on certain commands, which, of course, requires a password. For example, starting or stopping a service. ...
Stupid Patterns
We know about companies using Dark Patterns (more on this post by TechCrunch: WTF is dark pattern design?), and how they affect users. But can there be something like a “Stupid Pattern”? A thing that most companies do, and they don’t even realize it’s stupid? This blog post is a part real-life case study, and a major rant about one such pattern that is almost definitely, very stupid. ...
Dynamic Enums
But can one even make Enums dynamic? Enums, by definition, are static. They are used to “predefine” constants. I’ll let the official Oracle Java Tutorial on Enums to help explain the definition. ...
The Java Constants Interface Anti-Pattern
How do you define and use constants in Java? Most advice on Internet has the following opinions: Declare public static final for constants in a class Do not use Interfaces for constants The most common way to define a constant is in a class and using public static final. One can then use the constant in another class using ClassName.CONSTANT_NAME. Constants are usually defined in upper cases as a rule, atleast in Java. ...
How to change Java Version/JAVA_HOME for Ant?
I wrote this earlier on a Github gist, but putting it here for a consolidated reference. Want to change Java Version/JAVA_HOME for Ant builds? Open ~/.antrc file by running vim ~/.antrc Add JAVACMD=<NEW_JAVA_HOME>/bin/java and save The Ant wrapper script for Unix will source (read and evaluate) the file ~/.antrc before it does anything. On Windows, the Ant wrapper batch-file invokes %HOME%\antrc_pre.bat at the start and %HOME%\antrc_post.bat at the end. You can use these files, for example, to set/unset environment variables that should only be visible during the execution of Ant. ...
How To Implement Two Way SSL With Nginx
A couple of weeks ago, I was tasked with figuring out a way to enable two way SSL. I am a programmer, and have had only a limited experience with networking concepts like SSL/TLS in my short career. So I turned up blank on how I could make it possible. Moreover, the terminology you’d find online is not uniform. From a programming point of view, the term “Two way SSL” led me to limited results, and I soon realized that other communities have different terminology. For example the “Two way SSL” is also known as “Mutual TLS” or “mTLS” or “Client Certificate Authentication” in Cloud/DevOps communitites. This makes finding the right resources online more difficult. ...
How to achieve a 50% reduction in Redis memory usage
Yes, you read that right. To give you some context, some time ago, our (my org’s) Redis usage was un-tracked – meaning we didn’t know why our Redis memory was being occupied as much as it was. Our 2.5GB of Redis ElastiCache was almost close to being full, and if it somehow reached its limit, our system would start to fail. Though there were fallbacks in place, Redis could turn out to be a bottle-neck. ...