Rahul Ravikumar

Software Engineer, Google

Page 3

Kotlin Futures

I have been experimenting with Kotlin (a new JVM language) from the makers of Intellij (the IDE). If you are someone who writes a lot of code for Android and are languishing in the Java 6.5-ish world - then checkout Kotlin. It’s a breath of fresh air.

I am working on an implementation of Future‘s for Kotlin. The objectives of this module are:

  • Be minimal and simple.
  • Help clean callback ridden code (and support higher combinators like map and flatMap).

Here is the basic implementation and a quick-start. If you have ideas or suggestions, pull requests are welcome.

View →


I wrote a simple Android application, that uses the Android Renderscript APIs to create a neat image filter. This filter makes the output image look like a poster color drawn version of the input. So create your masterpiece and share away.

The app is on the Google Play Store. Looking forward to the reviews, if you have any suggestions for improvement.

Here is an example output image; The Bay Bridge at the Embarcadero in San Francisco.

Posterized Image

View →

ProGuard and Debugging

Android’s infamous dex limit is a huge problem. One of the ways you can fix the problem is to use ProGuard. If you decide to use it, the you can look forward to 2 things.

  1. Longer build times.
  2. Not being able to debug your application, especially if you enable ProGuard in dev mode.

The first problem does not have a silver bullet solution; however the second one does. Adding the following 3 lines of code to your proguard-rules.pro file will make your life a lot easier (and you will be able to debug your code).

-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-printmapping outputfile.txt

View →

Security Providers and BouncyCastle

BouncyCastle is a pretty cool library, but lacks useful documentation. The website is a mess.

If you want to setup BouncyCastle as your Java Security Provider (you should, the defaults are pretty bad) you need to do the following.

First add BouncyCastle’s provider to the list of Java Security providers. One of the easiest ways of doing this is, to include BouncyCastleProvider as one of the Security providers when your application starts up.

For e.g. in Play 2.2.x / 2.3.x you could do:

import org.bouncycastle.jce.provider.BouncyCastleProvider;
import play.Application;
import play.GlobalSettings;
import java.security.Security;

public class Global extends GlobalSettings {
  public void onStart(Application app) {
    Security.addProvider(new BouncyCastleProvider());

Now that you have added BouncyCastle to the list of Security Providers, you also...

Continue reading →

Retrofit + Play

Retrofit is an amazing HTTP client scaffolding library. It makes writing and testing HTTP clients really easy.

To make it easy to use Retrofit in Play, i wrote a small library that uses the Play’s WS library as the HTTP stack for Retrofit, while exposing convenient scala scala.concurrent.Future[A] wrappers on top of the java retrofit.Callback<A>.

The source code is on Github here.

View →

An Introduction to Iteratees with the Play Framework

Iteratees are an important concept when writing reactive applications. Being able to deal with streams of data is fundamental to web applications.

Before I delve into the details about Iteratees (in Play Framework), and what they are all about - let me try and introduce the fundamental concepts behind Iteratees.

Lets start with the humble fold method, a staple in Scala collections. This is what the signature of a fold method for List[A] looks like:

def fold [A1 >: A] (acc: A1)(op: (A1, A1) ⇒ A1): A1

The fold method uses an accumulator acc to store intermediate state, as the collection is being reduced to a single element of type A1. For e.g. if you needed to compute the sum of all elements in a list, you could do the following:

val list = List(1, 2, 3, 4, 5)
val sum = list.fold(0)((a: Int, b: Int) => a + b)

Now, lets go back to standard Java Iterators. The Java Iterator<E> defines...

Continue reading →