My Shitty Code

Embracing the Messiness in Search of Epic Solutions

Home

Welcome to my encyclopedia of shitty code!

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

  • Homebrew: “Invalid Multibyte Escape” Error

    PROBLEM When running brew on OS X Maverick, you get this error:- SOLUTION After upgrading to OS X Mavericks, the default version of Ruby is v2.0, causing Homebrew to break because it relies on v1.8. See issue #23655 for more information. To fix this, run the following command:- If you are getting the “Permission Denied” […] 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…

  • Deleting Cached Web Page by URI in CodeIgniter

    PROBLEM CodeIgniter contains a wonderful feature that allows me to cache web pages to speed up the page loading. The problem is there’s no easy mechanism for me to delete specific cached web pages, especially after I have updated the page contents. I have sucky two choices:- I always do the latter even though I […] Read More…

  • Rotating Log Files on Apache HTTP Server

    PROBLEM Consider the following log configuration:- At some point of time, both error.log and access.log are going to get insanely large. SOLUTION To fix this, the logs can be piped (by using |) to Apache HTTP Server’s built-in program called rotatelogs to rotate the log files. For example, the following configuration will create a daily […] Read More…

  • Suppressing FindBugs Warnings

    PROBLEM FindBugs is one of the many great static code analysis tools that I use everyday. However, the generated report may usually contain a few false positives that forces me to weave through them whenever I rerun my build on Jenkins. For example, I’m using Google Guava to construct my equals(…) and hashCode():- FindBugs will […] Read More…

  • How to Unit Test Spring MVC Controller

    SCENARIO Let’s assume we have the following controller that needs to be tested:- SOLUTION 1: “Works but It Won’t Get You the Promotion” This working solution relies on:- While this solution works, but it has a few problems. This test case strictly tests the actual controller API, but it completely disregards the URI and request […] Read More…

  • Hibernate: Migrating from XML-Based Configuration to Annotation-Based Configuration

    Overview At some point of time, as your project scope grows, the Hibernate mapping XML files are going to get to a point where it becomes very difficult to maintain. This is where the annotation-based configuration comes in. It took me a few years to convince myself that annotation-based configuration is the way to go. […] 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 with no mercy. He codes Java while drinking Espresso and writes Spock specifications while listening to Groovy beats. He masters Google Cloud Platform just like 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 scare him, for he does not know what to be afraid of in the first place. GCP, GCS, GCR, GKE, GWT, JWT… they all sound the same to him. 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, and if he doesn’t, that’s okay because he has the attention span of a squirrel.

By now, you should know this author is full of shit, and he apologizes in advance if you are trying to solve your company’s real problems with his shitty solutions.