Sunday, 22 March 2015

Need to make a quick json fixes - JSONPath for rescue

From time to time I have a need to do some fixes in my json data. In a world of flat files I do this with grep/sed/awk tool chain. How to handle it for JSON? Searching for a solution I came across the JSONPath. It quite mature tool (from 2007) but I haven't hear about it so I decided to share my experience with others.

First of all you can try it without pain online: http://jsonpath.curiousconcept.com/. Full syntax is described at http://goessner.net/articles/JsonPath/

Tuesday, 3 March 2015

Enums for scala

Scala has very limited implementation of Enumeration. Enumerated objects can't extends other classes. Partial replacement for it is to use sealed classes. You can do pattern matching on them. When you ommit some possible value you will get compiler warning for not exhaustive pattern matching. One missing feature is that you can't get sorted values of all objects extending them. You can simple got it using my (40-lines) EnumOf class from scala-enum. Examples below.

Declaration

sealed abstract class Color(red: Double, green: Double, blue: Double)

object Color extends EnumOf[Color] {
  case object Red   extends Color(1, 0, 0)
  case object Green extends Color(0, 1, 0)
  case object Blue  extends Color(0, 0, 1)
  case object White extends Color(0, 0, 0)
  case object Black extends Color(1, 1, 1)
}

Sunday, 22 February 2015

micro-burn has Trello integration

After a few long evenings I've finally integrated micro-burn with Trello. All you need to run it for your Trello board is to write short configuration and run fat jar. It renders burndown chart visualising progress of cards on your board.

You can specify story points adding them in curly braces inside card title, use Scrum for Trello browser extension or define default story points number for user stories. Completed checklist items are treated as a part of work done inside card. You can manage sprints on your own: creating new, specifying start/end/name, finishing or turn on full automatic mode: sprints will be created periodically.

Sprint management in usage:

Saturday, 3 January 2015

Sample for lift-ng: Micro-burn 1.0.0 released

During a last few evenings in my free time I've worked on mini-application called micro-burn. The idea of it appear from work with Agile Jira in our commercial project. This is a great tool for agile projects management. It has inline tasks edition, drag & drop board, reports and many more, but it also have a few drawbacks that turn down our team motivation.

Monday, 15 September 2014

Use asInstanceOf[T] carefully!

Background


Scala has nice static type checking engine but from time to time there are situations when we must downcast some general object. If this casting is not possible we expect that virtual machine will throw ClassCastExeption as fast as possible. Although it is not always true. Consider code below.

Monday, 4 August 2014

Multi phased processing in scala

Last time in our project we had to add progress bar for visualization of long time running process. Process was made of a few phases and we had to print in which phase we currently are. In first step we conclude that we need to create a class of Progress which will be passed as an implicit parameter to our service. Then we will wrap method calls be inProgress method which will notify some e.g. akka actor about phase begin and phase end.



But this approach has some disadvantages. Firstly before we start service's operation we need to init progress with count of all phases to get know ratio of progress finish. With this approach we had to add some extra counting before operation start.

Sunday, 24 February 2013

Journal.IO 1.3 released

About


Just a moment ago (in February 17th) Journal.IO 1.3 has been released. Journal.IO (https://github.com/sbtourist/Journal.IO) is a lightweight, zero-dependency journal storage implementation written in Java. We use it in our project for storing application events (Event Sourcing pattern). It is a good, stable solution if you want to have simple in use event storage e.g. if you want to implement lightweight queuing mechanism and JMS is overhead for you.

New version resolves some bugs and improves delete operation performance. Unfortunately new version uses new log format which isn't backward compatible. Therefore we decide to write a simple migrating tool for migrate 1.2 version compatible logs to 1.3 version.

Migrator


Migrator was written in groovy. It is available on github (https://github.com/arkadius/journalioMigration). Also link to the tool is available from official Journal.IO homepage. To use it simply run:



oldLogsRoot is recursively scanned for logs which are migrated parallel in 5 threads (used ASYNC read mode additionally speed up this process). Migrated logs are written in the same hierarchy in newLogsRoot.