Embracing the Messiness in Search of Epic Solutions

Month: July 2015

  • Maven: Skinning Generated Site

    PROBLEM The default Maven generated site looks like web pages created in the 80s:- SOLUTION The good news is Maven allows us to change the skin. To use one of these pre-defined skins, create site.xml at this location:- In site.xml, enter the following:- In the above example, we use Maven Fluido Skin. In Maven 3,… Read More…

  • JaCoCo Web Report Not Rendering Properly in GitHub Pages

    PROBLEM When pushing JaCoCo web report to GitHub’s gh-pages branch, it does not render properly on the web. For example:- The GitHub pages are powered by Jekyll. By default, Jekyll does not allow directories or files that begin with a dot, pound sign, tilde or underscore. Since JaCoCo places all the image and CSS files… Read More…

  • Java: Builder for Immutable POJO

    PROBLEM Let’s assume we have an immutable Person object:- … and an immutable Car object:- To create the Person object, we need to write something like this:- If the POJO has a lot of properties, it becomes very difficult to keep track all the constructor argument positions. SOLUTION @mkarneim wrote a POJO Builder that creates… Read More…

  • IntelliJ IDEA 14.1: Better equals(), hashCode() and toString()

    PROBLEM Let’s assume we want to create the default equals(), hashCode() and toString() with the following bean:- Most IDEs, including older version of IntelliJ, have code generation features that would create something similar to this:- While it works, the generated code is usually crazy horrendous. SOLUTION With IntelliJ 14.x, it allows us to select templates… Read More…

  • Underscore.js: Introducing _.chain(…)

    PROBLEM Let’s assume we have the following JSON data:- What we want to do is to get all unique employees and ordered them by their names so that we get the following data:- SOLUTION 1: Less Elegant Underscore.js provides various functions that allow us to pull this off. While doable, the code is virtually not… Read More…