Welcome to my encyclopedia of shitty code!
-
Java: Invoking Secured Web Service with JSESSIONID
PROBLEM I wrote a JSP custom tag that invokes a secured web service within the same application to perform some evaluation. This custom tag is only used in the secured views where the user has successfully authenticated against Spring Security, and they have access to these views. The secured web service is also guarded by… Read More…
-
Java: Performing 2-Key Lookup using HashBasedTable
PROBLEM HashMap is great to perform a simple lookup, for example:- However, what if we need 2 keys to lookup a value? For example, we need “key1” + “key2” in order to lookup “mike”. SOLUTION 1: Create combo key You can combine the keys to create a unique key:- Assuming if the keys are just… Read More…
-
Jadira Usertype: Under JDK 6 it may not be possible to handle DST transitions correctly
PROBLEM When saving a Hibernate entity that contains Joda Time object, Jadira UserType throws the following warning:- This warning occurs when using this version:- SOLUTION Upgrade Jadira Usertype to the latest version, and the problem goes away:- Read More…
-
Hibernate + Joda Time: Auto Registering Type
OVERVIEW Jadira Usertype is required when using Joda Time with Hibernate 4. The Joda Time objects are annotated accordingly in the Hibernate entity, and they looks something like this:- PROBLEM This solution works, but it is rather tedious because I can never remember the actual @Type to write, thus I always end up copying and… Read More…
-
IntelliJ: Configuring SVN Ignored Files
OVERVIEW Whenever we share a project in SVN or checks out a project from SVN, we have to perform a one-time configuration on the project to ignore selected files from being committed into SVN. That said, this configuration will only work if the files are not already in SVN. PROBLEM Let’s assume we have a… Read More…
-
VirtualBox: Failed to delete the storage unit of the hard disk /PATH/HARD-DISK.vdi. Cannot close medium ‘/PATH/HARD-DISK.vdi’ because it has N child media.
After upgrading to VirtualBox 4.3.2 r90405, I get this dreaded error message when running VirtualBox:- I was able to clone the offending VDI and boot from the cloned VDI without losing any data. The cloning process took about half hour. Now, when I try to remove the offending VDI under Virtual Media Manager, I get… Read More…
-
Backbone: model.destroy() Always Call “error” Callback Function
PROBLEM Let’s assume we invoke person.destroy() to delete a person:- … and let’s assume when person.destroy() is invoked, it will call /person/{personId} DELETE. Here’s how the Spring MVC controller API might look like:- When we execute person.destroy(), the error callback function will always get called even though the HTTP status is a 200 OK. Why?… Read More…
-
Groovy: java.lang.StackOverflowError When Implementing equals()
PROBLEM While migrating a portion of my Java code to Groovy code, I got bitten by the Groovy operator loading feature that I should have known better… and my pride hurts, but hey, I admit I write shitty code. Consider this simple POGO with custom equals() and hashCode(), both implemented using Google Guava libraries:- What… Read More…
About Author

This author has 20+ years of experience in software engineering and cloud engineering. In an industry where knowledge becomes obsolete in the next three months, he learns anything that crosses his path indiscriminately. He floats from one technology to another like a moth and stings the problem sets like a mosquito. This author codes Java while drinking Espresso and writes Spock specifications while listening to Groovy beats. He masters Google Cloud Platform just like how he masters the art of predicting the movement of dark clouds over his backyard, where 60% of the time, he is right every time.
This author suffers from the Dunning-Kruger effect, where he overestimates his competence and underestimates his ignorance. Technology buzzwords never faze him, for he does not know enough to be afraid of in the first place. GCP, GCS, GCR, GKE, GWT… everything sounds the same to him. He never fears acronyms, synonyms, or antonyms, for he has ChatGPT in his back pocket. This author is a jack of all trades but a master of none. He writes like he knows all the answers, yet he googles for better solutions from elsewhere. He fakes it until he makes it; if he doesn’t, that’s okay because he has the attention span of a squirrel. The blog posts are his buried walnuts, in case he needs them one day.
In conclusion, this author is full of something. He apologizes in advance if you are trying to solve your company’s real problems with his shitty solutions. There, he has successfully written paragraphs of nonsense because every professional blogging website needs a section about the author, with a too-cool-to-smile portrait staring sideways into the abyss.