Thursday, May 16, 2019

ip-num version 1.2.0 has been released.

NOTE: A cyclic dependency issue was found in the 1.2.0 release and has been fixed with the 1.2.1 patch release. It is thus advised to use version 1.2.1. The content of this post still applies. 
ip-num version 1.2.0 has been released.

This release contains the following enhancements/additions:

Switched JavaScript target to es5 to ease usage in ie11.

Based on this issue, the generated JavaScript for ip-num is now es5. This is to make it easier to use in browsers that do not support es6: like internet explorer 11. Unfortunately things won’t still work right out of the box, and a polyfill for string.prototype.repeat needs to be included. Trying to get things to work in ie11 is already sucking out the fun on working on the library, so I would not be spending any more energy/time on this. Perhaps in the future I will look into getting things to work out of the box with ie11...or perhaps not.

Moved some operations to the IPRange interface.

The following methods were moved to the IPRange interface:
  • isConsecutive - Indicates whether the given IP range is an adjacent range
  • Contains - Indicates if the given IP range is contained within the range
  • Inside - inverse of Contains. It indicates if the range is contained inside the given range
  • isOverlapping - Checks if two IP ranges overlap (which will always be false with CIDR ranges)

Added method to IPRange to return the adjacent ranges.

This enables the ability to check if a range has next or previous range and the ability to return such a range. So for example:

IPv4CidrRange.fromCidr("").hasNextRange() will return true and
IPv4CidrRange.fromCidr("").nextRange().toCidrString() will return

Added ability to validate if a CIDR notation represents a valid range.

Added isValidIPv4CidrRange/isValidIPv6CidrRange validation methods that returns true or false depending on if the given ip number represents the start of the CIDR range.

For example, validating should return true, since is the start of the CIDR range depicted, but validating should return false, since is not the start of the range.

This new validation is a stricter form of already existing isValidIPv4CidrNotation/isValidIPv6CidrNotation which only validates that the given string is of the format [ip number]/[range].

That is basically the summary of the 1.2.0 release. Work would start soon on the 1.3.0 version, which would focus mainly on adding operations for working with sets of IP numbers to the library.

Saturday, January 05, 2019

Ristex 0.1.0 Released

At about 11:46 pm, I got version 0.1.0 of Ristex released to Maven central. This marks the first Scala library I would be releasing! Yay!! 🎉

It should now be available for inclusion with the following sbt configuration:

// ${version} = 0.1.0
libraryDependencies += "io.geekabyte.ristex" %% "ristex" % "${version}"

And by the way, the release process was not as painful as I envisaged. Read further, for my thought on this.

What is Ristex

Ristex is a parser combinator library for parsing the RIR Statistics Exchange files. In theory it should work with the files published by all regional internet registry, in practice, it has only been used with files published by RIPE NCC.

Ristex uses Atto, which is a compact, pure-functional, incremental text parsing library for Scala. Infact, Ristex essentially extends Atto to cater for parsing the RIR Statistics Exchange files, and it makes no attempt to abstract it away, hence all of Atto's API are directly available for use with Ristex.

The idea for Ristex came up when I started working on a fun project to create a JSON format for the CSV like format of the RIR Statistics Exchange files. While working on this, it became apparent that it would be good to have a nicer way to parse the exchange files instead of relying on regex. And since I have always wanted to explore the idea of Parser Combinators in general and the Atto library in particular, it took little persuasion to temporarily shelf the project to create a JSON format, and create a parser combinator library to parse them instead.

Releasing to Maven Central Via SBT

Releasing the library to maven with sbt was relatively painless. I was expecting it to be much of a frustrating experience but I was pleasantly surprised. I guess having previously documented How To Publish Software Artifacts To Central Repository, also helped.

I found this post: An in depth guide to deploying to Maven Central with sbt by Leonard Ehrenfried to be particularly helpful.

The only snag I encountered was related to getting the PGP key published to a public key server. For reasons I still do not know, running the command:

`pgp-cmd send-key ${keyname} hkp://` 

as specified in the post above was not working. This caused the release process to fail a couple of times since maven could not verify the integrity of what was being published.

I had to result to manually uploading the PGP key using the web interface provided by Apart from this, everything went smoothly.

Anyways, the source of Ristex is available on Github, so do feel free to poke around!

Saturday, December 08, 2018

Understanding JavaScript Modules As A TypeScript User

This post, is the first in a series of post that I will be writing about Modules in TypeScript. It is a continuation of the process of jotting down the various things I learnt while building ip-num. The previous post like this one, was Declaration Files in TypeScript: An Introduction. In which I shared how I came to wrap my head around declaration files in TypeScript.

Since the topic of Modules is quite an expansive one, instead of jamming everything I need to write into one blogpost, I will be spreading it out, across various posts, that would be published in the coming weeks/months.

This post is to get the ball rolling on that, and It would focus mainly on introducing the concepts of modules as we have them within the JavaScript ecosystem.

Since TypeScript is but a superset of JavaScript and JavaScript is still its only transpiler target, one really cannot get away from having to understand how things work in the JavaScript land in other to be able to deeply understand how various aspects of TypeScript fits together.

Modules are just one example of this.

Saturday, September 22, 2018

Easing Into Cats, And The Case For Category Theory Inspired Abstractions

Cats is a lightweight, modular, and extensible library for functional programming in Scala. On its website, it is stated that the name “cats” is a playful shortening of the word, category - so it has nothing to do with the animal: cat (if you ever wondering), but with category theory :)

It is a library that I have personally found to be helpful in making functional programming in Scala less confusing. It does this by being more concrete and more obvious with regards the various patterns and abstractions that arises from a valid logical conclusion of programming with functions in a statically typed language that has higher-kinded types.

Unfortunately, due to the relative unfamiliarity with functional programming and the various abstraction that comes with it, the Cats library is usually approached with hesitation amongst a sizable amount of software developers.

The sentiments I have seen expressed directly or indirectly is that introducing Cats would inadvertently fling developers into the deep ends of various unknown, academic and good for nothing, category theory inspired abstractions, that only confuses and add complexity. Since nobody wants this, the decision usually gets made not to bother with a library like Cats.

Nothing can be farther from the truth.

Saturday, July 21, 2018

How to Make Aggregates Directly Handle Commands In Axon

In 2015, I created the exploringCQRSwithAxon example project while learning about CQRS and the Axon Framework.

When I did, I set up the example project in such a way that it uses command handler classes. The setup was as follows:
  1. A controller receives a request via an endpoint
  2. Controller turns the request into a command and put it on the command gateway
  3. The command handler classes listens to specific commands. When a particular command it listens to is published via the command gateway, it loads the aggregate from the repository.
  4. The command handler class calls method on the loaded aggregate with the command that was published.
The 3rd step, most of the time, is unnecessary and can be eliminated. This is because the command handler class usually just serves as a dummy proxy that proxies commands to the aggregates.