My Shitty Code

Embracing the Messiness in Search of Epic Solutions

Home

Welcome to my encyclopedia of shitty code!

  • Spring Web: Encode ‘+’ Value Using UriComponentsBuilder

    PROBLEM Given the following code… When using Spring Web 4.3.18.RELEASE, the URL is properly encoded:- However, when using version between 5.0.0.RELEASE and 5.0.7.RELEASE, the URL containing “+” value does not get encoded:- SOLUTION There is a ticket opened regarding this breaking change. To properly encode “+” value, use 5.0.8.RELEASE or later. Then, ensure encode() is […] Read More…

  • macOS + Eclipse: The ‘X’ Executable Launcher was Unable to Locate its Companion Shared Library

    PROBLEM When attempting to launch Eclipse-based app (ex: MyApp.app) on Mac, the following error is thrown:- SOLUTION This problem seems to occur on macOS Sierra and later. When unzipping the app, the lingering extended attributes prevent the app from launching. To fix this, run the following command to remove these extended attributes:- Then, double click […] Read More…

  • React + Recompose: Calling Multiple HOC Wrappers

    PROBLEM Sometimes, wrapping a React component with multiple High Order Components (HOC) can get rather unwieldy and unreadable. For example:- SOLUTION To fix this, we can leverage recompose library. Now, we can rewrite the above example like this:- Keep in mind, the HOC order defined in compose(..) is important. Read More…

  • Webpack + ESLint: Automatically Fix ESLint Errors

    PROBLEM Given the following webpack.config.js… When running any Webpack command, ESLint may find violations and halt the entire process with the following error message:- SOLUTION Certain errors (ex: trailing commas, wrong indentation, extra semicolon) are easily fixable. There’s no need to halt the process and wait for developers to fix these obvious errors. To configure […] Read More…

  • PHP + Composer: The Process “php -S 0.0.0.0:8080 -t public index.php” Exceeded the Timeout of 300 Seconds

    PROBLEM Given the following composer.json… When running composer start… The PHP built-in web server stops with the following error message… SOLUTION There are several ways to extend the timeout value, but here is one way to do it through composer.json. To extend the timeout value from 300 seconds to 2000 seconds, add the following config […] Read More…

  • Slim: Class ‘X’ Not Found

    PROBLEM Let’s assume we have the following project structure with src/model/Person.php created… … and the class may look something like this… … and it is being used in other file… When hitting the given route from the browser, we get the following error:- SOLUTION #1: Using import/require One way to solve this is to use […] Read More…

  • Spring Security: Propagating Security Context to Spawned Threads

    PROBLEM Let’s assume we have the following Parent class… … and Child class… Let’s also assume the user has successfully logged in and Spring Security has set up the user authentication info. The Parent will spawn a new thread (through @Async) to run Child. When invoking the Parent, this is what we see:- The Child, […] Read More…

  • JEE Security: Preventing Clickjacking Attacks

    PROBLEM Clickjacking is an attack that tricks the users to perform unintended actions… see OWASP’s Testing for Clickjacking (OTG-CLIENT-009) SOLUTION To prevent clickjacking attacks, the app must set X-FRAME-OPTIONS header with an appropriate value:- If set correctly, the HTTPS response should show X-FRAME-OPTIONS header:- There are several ways to set this header. Solution 1: Using […] Read More…

  • JEE Security: Disabling HTTP OPTIONS method

    PROBLEM HTTP OPTIONS method is used to provide a list of methods that are supported by the web server. For example, the following shows both GET and HEAD are allowed on the given link:- Enabling OPTIONS may increase the risk of cross-site tracing (XST)… see OWASP’s Test HTTP Methods (OTG-CONFIG-006). SOLUTION There are several ways […] 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.