Uncategorized

Java 8 streams, functions and reductions

There is a relatively simple challenge to extend the vowels in a string. Here is a way to do it in Java 8: In the above I’ve tried to make the code as short as possible while still ensuring it’s readable and conforming to the clean code rules. All of that could be written without… read more »

Reducing Streams in Java

Java 8 introduced streams, among other things, and one of my favourite features is the reduce() method. It combines a stream into a single method. Before Java 8 and streams, such a reduction had to be done with a loop like this: Now with Streams and reduce() it can be done as follows with a… read more »

Delete Files with Java 8

A friend asked me to help him with the following in Bash – delete all files but a whitelisted and use mix / max depth for directory traversal. It’s probably possible in Bash with some crazy find, grep, etc one-liner. But here’s how good it looks in Java 8 with streams, predicates, etc… With Java… read more »

How to Secure an Outdated Web Application in 5 Minutes

I’ve had the following challenge yesterday. A friend of mine had an old Joomla 2.5 with a bunch of customization – additional components installed, custom theme, etc. It was hosted somewhere and had to be transferred away for some reasons. But before being transferred to a hosting which I am responsible for, it had to… read more »

How to Create a Simple Honeypot with Spring Boot

I am sure that there are plenty of honeypots for logging remote intruders but none yet has been done on Spring Boot. So I decided to write a simple one while exploring Spring Boot: https://github.com/terry81/blocker It does the following – listens on a preconfigured port. Define it in the application properties (src/main/resources/application.properties) as blocker.honeypot_port. By… read more »

How to Run Sites Securely with Apache and Php-fpm on Ubuntu 16.04 LTS

A great security feature of Php FastCGI Process Manager (Php-fpm) is its ability to run Php scripts with different users. This in addition to its other merits such as performance and many fine grained options for tuning makes it the best choice for running Php sites. Before anything else, I must admit that Nginx with… read more »

How To Create SSH Tunnel With Putty

SSH tunneling is very useful when the network access to a remote network is restricted. Thus, to gain remote network access you can use a tunnel to a remote host which would act as an intermediary. Here’s an example. Imagine, there’s a remote host which runs a Tomcat app servlet on TCP port 8080. The… read more »

Sidebar