All Posts

Java 8 Features in a nutshell - Optional

Hope everybody already know that Java 8 is out. It brings a lot of interesting features to make Java easier and more comfortable to use. I will try to talk through some of those features in a nutshell. Lets start with Optional class. As with all Java 8 features, Optional existed before the release, for example in Guava libraries. Optional class allows you to handle null checks in really nice way.

How to install vagrant and virtualbox on ubuntu/debian server

Recently I’ve been playing with Vagrant and I find it to be really useful. I decided even to give it a go on a live server so I can play with different environments safely. Usually I am using Vagrant on my laptop which is running Mac OS and installing it here is not a big problem. On ubuntu server on the other side, installation is not so straightforward, so I decided to create an ansible playbook to do that.

Grails 2.3 exclude class in json/xml renderer not working

Recently I started to play with Grails 2.3.4 and discovered a lot of nice features around REST, grails team did really good progress here. When I was playing I noticed that I always had “class” field in JSON returned to me by grails server when I checked the doc, it was saying that you need to setup JSON renderer like this in resources.groovy file: import grails.rest.render.json.JsonRenderer // Place your Spring DSL code here beans = { deviceRenderer(JsonRenderer, Device) { excludes = ['class'] } } But when I tried it, it did not work.

Java chronicle library tutorial #1: Basic examples

Introduction I dont remember how, but occasionally I ended up reading amazing blog of Peter Lawrey about different aspects of Java programming, focused, particularly on performance. Peter also author of Java Chronicle library which he describes as: This library is an ultra low latency, high throughput, persisted, messaging and event driven in memory database. Basically, it allows an application to write and read high amount of messages which will be persisted to disc by operating system.

If I had the opportunity to give one advice to each developer

It would be “do your job best way you can do it, but expect others to screw up”. And this advice is not only regarding code, but everything you work with. If there is some chance that something can go wrong, eventually, it will go wrong. If there is possibility of Database getting files corrupted, eventually it will. If there is possibility that some query will take too long and as the result of it, your system will become unresponsive, it will.

java.lang.reflect.MalformedParameterizedTypeException exception in Grails when using HttpBuilder

Recently I encountered really nasty error in grails which took quite some time to fix. It was really hard to find reason because of the really weird stacktrace and it was only happening when being deployed on tomcat server. Exception looked something like this: First it seem to have something to do with log4j system, but it turns out that HttpBuilder was to blame! It has different version of groovy specified as dependency, which was conflicting with version of groovy coming with grails, causing this nasty error.

Grails locking rows for update in PostgreSQL with NOWAIT

One day I needed to lock a record in grails application for update so other transactions does not mess with it while I am updating it. I started digging through the doc and found a section about locking in official documentation. It was pretty straightforward: you just need to use *lock() *method. So I did this: And this was working fine. In this basic case. My actual scenario was more complicated, it involved constantly polling database for new messages to process which are not been taken by other workers.

Why test driven development works

This post will be not about technical stuff of Android or Grails, but about programming in general. Yesterday, when I was waiting for my program to start on android I start thinking that I lose quite some time for this start-click-see result cycle. If it takes 30-50 seconds to build upload and start new apk on android, then it can easily end up as half an hour a day just restarting the app.

Speak the code application on Google play

Recently, when I was going through 2-step verification process for my gmail account, I thought that it would be nice if I did not have to peek my phone and check the text. If there would be an app just to read that code out loud so I can enter it. So, I created it! It is now on google play and you can download it to your android phone here: speak the code

Protobuf and optional values

Just small note to all you guys if you are using google protobuf library for communicating with server. Lets say you have simple protobuf message with one optional numeric field: If you are using some dynamic language in your server backend, you can end up having code like this: Now question, what value of limit variable will be, if message will not have limit field set? Answer is: 0.