Category: Programming Language
-
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…