Next.js with and without CSS modules

I recently started using Next.js instead of create-react-app (CRA) for building React apps. The main reason is for server-side rendering. I found it a bit tricky to modify the webpack configuration, so I'm sharing how I managed to match some behaviour from CRA. By default, recent versions of CRA let you import foo.module.css in your … Continue reading Next.js with and without CSS modules

Dependency Injection Design Pattern in Java: Example

Dependency Injection Design Pattern Program to an 'interface', not an 'implementation'. This is the premise of dependency injection. It goes one step further to allow libraries that use the interface library to not 'depend' on the implementation library even though they depend on the interface library. That is, the implementation can be 'injected' at run … Continue reading Dependency Injection Design Pattern in Java: Example

logging stdout and stderr from within a shell script while still outputting to the console

If you want to send the output of a shell script to files, it's pretty easy: ./script.sh 1> out.txt 2> err.txt If you want to do it within a script, also easy: exec 1> out.txt exec 2> err.txt If you want to send it to the console and files, it's a bit more tricky: { … Continue reading logging stdout and stderr from within a shell script while still outputting to the console

Java PriorityQueue with efficient removal

I had a need for a PriorityQueue in Java with an efficient remove(Object) method, but the implementation in the JDK "provides O(log(n)) time for the enqueing and dequeing methods (offer, poll, remove() and add); linear time for the remove(Object) and contains(Object) methods; and constant time for the retrieval methods (peek, element, and size)." The patch … Continue reading Java PriorityQueue with efficient removal