Intro to Mill Build: Pleasant Complex Builds

May 22, 2024
Note
Update March 2025. This post was originally written for Mill 0.11. I’ve updated the examples to work with Mill 0.12.9, but didn’t incorporate all improvements since then.

I’ve experienced a few build tools over time: Apache Ant, Apache Maven, Gradle, SBT, MSBuild, make and probably some more I’ve forgotten about. Recently I’ve experimented with the Mill build tool and it is one of the best ones I’ve worked so far.

Continue reading →

JQuery: Always use dataType for $.ajax

February 4, 2024

I recently investigated a XSS vulnerability reported via Bugcrowd. I could reproduce the issue, I just didn’t understand it. The vulnerability looked like this:

  1. Attacker uploads a JavaScript file onto Confluence as attachment

  2. Manipulate a Confluence macro via REST API to have invalid parameters.

  3. Now, when the macro is edited/used, the code in the uploaded JavaScript is executed.

  4. The code snipped looked something like this:

// AJS is the Atlassian JavaScript library entry point. AJS.$ refers to the included JQuery library
AJS.$.ajax({
    url: 'url-manipulated-by-attacker-to-downloads-the-attachment-file',
    type: 'GET',
    success: function (response) {
        // some basic processing
    }
})
Continue reading →

One Billion Row Challenge: Learned So Far

January 12, 2024

Last Update 2024-02-04, see below

I participate in the One Billion Row Challenge by Gunnar Morling: Parse one billion rows of CSV, in plain Java, and be fast at it. It is a friendly completion and learning experience.

I had three goals:

Run Duke
Figure 1. Run Duke, Run!
Continue reading →

Copy, Paste and Edit Java to C# after 20 years

December 2, 2023

This post is part of C# Advent Calendar 2023. Visit it for all the awesome upcoming posts!

C# and .NET have an awesome ecosystem, with tons of libraries and code snippets out there.

But sometimes you get that rare snippet of code in another language. In this blog post, we copy, paste, and edit some example snippets from Java languages to C#. When C# started back in 2001, Java and C# were similar languages. But in the last 20 years, C# has quickly evolved in its unique way. So, let’s if that similarity still helps you:

Old Pals
Figure 1. Old Pals
Continue reading →

Java: Native Memory Handling is Getting Easier

May 15, 2023

JDK 19, 20, 21 has a new preview API called 'Foreign Function & Memory API' that makes interacting with native memory and native libraries way easier. Before you had to use JNI, JNA or JNR to interact with native libraries.

Further, interacting with 'native' memory was clunky. You either used ByteBuffers, which have a clunky/dated API, max addressable size 2GByte plus 'freeing' relying on the GC, unless you do ugly reflection hacks. Or you went down the Unsafe route.

Anyway, if your projects allows, I would heavily recommend to the new APIs. If it is a project you deploy in your backend, you can control the JDK. If it is a new library, I would still think about starting/consider the new APIs, so that the library can be kick ass by the time it is mature.

Waiting for Response
Figure 1. Memory Hunger
Continue reading →