About mrhaki

My name is Hubert A. Klein Ikkink also known as mrhaki. I work at the great IT company JDriven. Here I work on projects with Java, Groovy, Gradle, Asciidoctor and more. At JDriven we focus on enterprise technologies. All colleagues support craftsmanship and are very eager to learn new technologies. This is truly a great environment to work in.

Follow mrhaki on Mastodon Follow mrhaki on Bluesky

Posts by mrhaki

Nushell Niceties: Transform A Table Into Markdown Markup Table

Posted on by  
Hubert Klein Ikkink

Nushell has built-in support for creating Markdown markup. The to md command can turn several Nushell data structures to Markdown. One of them is the Nushell table. The output is Markdown markup of a table with the contents of the Nushell table. You can add the option --pretty (or shorter option -p) to have a vertically aligned Markdown table, which gives a more readable Markdown table. Finally you can make certain columns of the table centered horizontally by specifying the --center option.

Continue reading →

Nushell Niceties: Display Text With Gradients

Posted on by  
Hubert Klein Ikkink

In Nushell you can use the ansi gradient command to display text with a color gradient. You need to write a pipeline where the text that you want to be in a gradient first and then after the pipe (|) symbol use the ansi gradient command. The command accepts several flags to define for example the start and end colors of the gradients for the foreground and background. The value of the color is a hexadecimal value. Nushell also supports named themes with predefined gradients that can be used as foreground and/or background of the text. All these flags can also be combined together to have a colorful output.

Continue reading →

Mastering Maven: Failing Faster With Failing Tests

Posted on by  
Hubert Klein Ikkink

Maven uses the Surefire plugin to run unit tests and the Failsafe plugin to run integration tests. The default behaviour of Maven is to run all tests and show a summary at the end. The summary shows how many tests have run and how many failures, errors and skipped tests happened. So every time when you run mvn test or mvn verify all tests will be executed, even when tests are failing. You can speed up your build by stop running tests once a test fails. You must use the Java system properties surefire.skipAfterFailureCount and failsafe.skipAfterFailureCount to make sure Maven will skip running any tests after a test failure has occurred. You can specify a number with the parameter to set how many tests should fail before other tests are skipped. It is possible use these parameters in the plugin configuration in your pom.xml as well.

Continue reading →

IntelliJ IDEA: Use Breakpoints Debugging Lombok Constructor Annotations

Posted on by  
Hubert Klein Ikkink

As a consultant I am part of a lot of different Java projects. Some of these project use Lombok. When you use a Lombok annotation code gets generated when the code is compiled. This code is not visible in the IntelliJ IDEA editor which could be a problem when you want to debug your application and need to add a breakpoint for the generated code. Suppose you have a Java class with a simple constructor without using Lombok annotations. You can place a breakpoint in the constructor and when you debug the application in IntelliJ IDEA the execution stops at the breakpoint. Now you can check for example the values of parameters that are passed into the constructor call. But when you use a Lombok annotation like @RequiredArgsConstructor the code for the constructor is generated and not visible in your editor. If you want to check the values of parameters passed into the constructor you need to set a breakpoint at the line that has the @RequiredArgsConstructor statement. When you debug your application IntelliJ IDEA will stop execution when the constructor is invoked and you can check values of parameters.

Continue reading →

Nushell Niceties: Writing XML

Posted on by  
Hubert Klein Ikkink

In Nushell almost everything is a data structure. This mind set is also applied to XML structures in Nushell. A XML tag can be described as a record with the attributes tag, attributes and content. The tag attribute has a string value that is the tag name. Attributes are defined with a record structure. The key is the attribute name and the value is the attribute value. Finally the content attribute is a list containing a string value for text content or new record structures for nested XML tags. With this basic record structure you can describe XML content. To actually transform it to a XML string value you can use the command to xml. This command will use the data in the record structure and will output XML.

Continue reading →

Kotlin Kandy: Get Text Before Or After A Delimiter

Posted on by  
Hubert Klein Ikkink

Kotlin adds the substringBefore, substringBeforeLast, substringAfter and substringAfterLast extension functions to the String class. Instead of using indices to get a substring you can use a string or character value. The functions without Last use the first occurrence of the delimiter and the methods with Last use the last occurrence. If the delimiter is not found the original string is returned. You can supply a value that should be returned when the delimiter is not found.

Continue reading →

Kotlin Kandy: Get A Random Element From A Collection

Posted on by  
Hubert Klein Ikkink

Kotlin has very useful extensions functions for working with collections. These extension functions make working with collections more easy and fun. One of the extension functions is the random function. When you call random() Kotlin returns a single element from the collection using the default random source. The function also accepts a Random instance as argument. This instance has a seeded value to return repeatable random values.

Continue reading →

Kotlin Kandy: Transform Map Keys Or Values With mapKeys And mapValues

Posted on by  
Hubert Klein Ikkink

Sometimes you want to transform only the keys in a Map, or only transform the values. Kotlin has two useful methods to achieve this: mapKeys and mapValues. You can use mapKeys to transform the keys of the map while keeping the values the same. With mapValues you can transform the values of the map while keeping the keys the same. Both methods accept a lambda function as asrgument of type Map.Entry and must return the new key or value. In order to transform the keys or values and add the result to an existing Map you can use the methods mapKeysTo and mapValuesTo. The first argument is the existing (mutable) Map and the second argument is the lambda function.

Continue reading →

Nushell Niceties: Wrapping External Commands With def --wrapped

Posted on by  
Hubert Klein Ikkink

The def keyword in Nushell is used to define a custom command. By adding the --wrapped flag you can tell Nushell to accept unknown flags and arguments and pass them on as strings. In the command parameters you use a "rest" parameter defined by …​ to capture the remaining arguments. Then in the command body you use the spread operator …​ to expand them again. This is very useful when you want to create a small wrapper around an external command with lots of options, but without having to define all those options yourself.

Continue reading →

Nushell Niceties: Check Semantic Version Is A Match

Posted on by  
Hubert Klein Ikkink

In a previous blogpost you can learn about the semver command in Nushell to transform a string value into a semver type. The command has a subcommand match-req. You can use this command to check if a version matches part of the semantic version parts. The result is a boolean value. The version to compare with doesn’t have to defined fully, but could exist of only the major, minor or patch parts. The value you pass can also be used to check if a version is greater or smaller than a given version. A range with a lower and upper version to match on can be defined as well. The boundary values are separated by a comma.

Continue reading →

shadow-left