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.
Posts by mrhaki
The intersect command can be used on lists and tables to find the same elements that are in the input list or table and a provided list or table.
The input is passed to the command and the other list or table is an argument for the intersect command.
Continue reading →
The following blog post by Karl Tryggvason shows a simple script to get data from a JSON Web Token (JWT) using jq.
It is basically splitting the token on the . and then convert each part from base64 encoding.
As extra functionality the timestamp fields exp and iat are converted to human readable dates.
Continue reading →
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 →
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 →
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 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 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 →
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 →
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 →
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 →
The semver Nushell plugin can be used to work with string values as semver type as you can see in a previous post. You can use the semver sort command to sort string values with ordering rules for semantic versions. With natural ordering of string values a value of 10.0.1 is placed before 2.1.0, but if you use semver sort the ordering will be correct. The command will look at all the parts of the semver type. So a major version of 2 is placed before 10. If the major version part is the same than the minor part is used for ordering and so on. To sort in descending order you can use the option --reverse or the short option -r.
Continue reading →
In a previous blogpost you can learn about the semver command in Nushell to transform a string value into a semver type. With the semver bump command you can increase one of the components of the semver type. For example to increase the major version part you can use semver bump major. This command will also update the minor and patch parts if needed. The result is a semver type and you can use into value to transform it to a string type.
Continue reading →
