Sunday, October 16, 2016

[JAVA,SPRING] Intercept and modify @ResponseBody before sending it back

So I got this idea to have a single common place to modify all my ResponseBody before sending it back to the caller. Initially I thought I can use Spring's HandlerInterceptor but I found out that ResponseBody can only be read once. Once it is read by HandlerInterceptor class, the ResponseBody will be gone. After much googling, I found out there are few solution to this. First is to implement a filter class. Another way is using ControllerAdvice classes which I will share below.

Friday, October 7, 2016

[SCRIPTHACKS] How to quickly change DNS with Windows batch script.

There is probably a few reasons you might want to change DNS on your PC from time to time. For me, I use it to circumvent, region blocking on streaming services. However to change the DNS manually every time manually is tedious. SO I wrote a simple batch script to help me change the DNS in just 2 clicks away.

Thursday, October 6, 2016

[JAVA] Encrypt/Decrypt With PGP On The Fly

Recently I've been working on a project that need to do PGP encrypt/decrypt. The best solution that I found is here. However the downside is the data need to be written to a file. I've modified the file so that encrypt/decrypt can be done on buffered streams. Below is how I do it.