Relentless Coding

A Developer’s Blog

  • Always on Vpn and Captive Portals

    I was attending a meetup that was taking place in a bar in Utrecht. The first thing you want to do is to make a connection to the internet and get started. The location used a captive portal, however. You know: you have the name of the wireless network (SSID) and the password, but when you try to open any web page, you are directed towards a login page where you have to accept the terms and conditions of whoever is operating the network.

    But what if you use an always-on VPN? You cannot connect to the network, because your MAC and IP address are not whitelisted yet by the operator. And you cannot get to the login page, because you do not allow any traffic outside your VPN.

    Read more…
  • Tutorial Rapid GUI Development With Qt Designer and PyQt

    Confession: I am the opposite of the lazy coder. I like doing things the hard way. Whether it’s developing Java in Vim without code completion, running JUnit tests on the command line (don’t forget to specify all 42 dependencies in the colon-separated classpath!), creating a LaTeX graph that looks “just right”, or writing sqlplus scripts instead of using SQL Developer (GUIs are for amateurs), I always assumed that doing so would make me a better programmer.

    Read more…
  • How to Use Groovy's CliBuilder

    Let’s use Groovy’s CliBuilder to create CLI programs that can take flags.

    Read more…
  • Using Groovy's AntBuilder to Zip and Unzip Files

    Need to zip or unzip files? Let’s take a look at how Groovy solves this.

    Read more…
  • I Like My Method Pointers With Curry in Groovy

    Invoking a method several times can easily be done in Java in a loop. But what if we have several methods that need to be executed several times? Since Java does not feature pointers to functions, we cannot pass functions around, and cannot create a generic method that takes a pointer to a method and executes it. This is where Groovy shines.

    Read more…
  • How to Ignore an Invalid SSL Certificate in Java

    Sometimes during development it is useful to use a certificate whose CN (Common Name) does not match the host name in the URL, for example localhost. In these cases Java will throw an SSLHandshakeException. How can we easily disable certificate checking for localhost and other domains of our choosing?

    Read more…
  • Creating Custom Intershop ISML Functions With CustomTag

    In this post, I’ll look at leveraging Intershop’s CustomTag to create custom functionality in ISML templates.

    Read more…
  • Java Stateful Sessions or How to Properly Send Cookies With Each Redirect Request

    Sometimes you need to log in to some webpage programmatically. I ran into one of those pages where, when the login succeeds, you’re being redirected to another page, and then to another (something along the lines of ‘Please login’ -> ‘You are successfully logged in’ -> ‘Admin panel’). So I needed to write something that would store the cookies that come along with each response, and send those cookies out with each subsequent request. With curl, I would have used:

    $ curl --location --cookie-jar logincookie 'https://login.securepage.com'
    

    So how can we emulate this behavior in Java?

    Read more…
  • Adding a File to the Root of Your Gradle Distribution

    A while ago, I needed to write a program that retrieved some information from the database by using SQL queries located in files. I wanted to add a file that would contain the settings of the app, like the port, SID, login and password for the database, but also the location of those queries. The problem was I couldn’t add those settings to a file in the standard src/groovy/resources folder, because when creating a distribution with Gradle ./gradlew distZip the file would be part of the jar, and thus it would be difficult to modify the contents. I was basically after a run-control file, a settings file in the root of my distribution, that I could easily change on each run (if necessary).

    Read more…