Tuesday, September 16, 2014

JSONP: Escape JSON String

Assume you have a JSON string that you are going to send as result value back to Javascript, then you need to do the following:

        String dataString = stringWriter.toString();
        dataString = dataString.replaceAll("\\u2028","\\\\u2028");
        dataString = dataString.replaceAll("\\u2029","\\\\u2029");

Basically, you need to escape the unicode characters.

Monday, July 21, 2014

Tip: Apache Kafka

If you get the following exception:
$ ./zookeeper-server-start.sh  ../config/zookeeper.properties
Error: Could not find or load main class org.apache.zookeeper.server.quorum.QuorumPeerMain

then you will have to do the following:
$ ./gradlew  jar

to build the Kafka distribution and get the dependencies.

Friday, May 02, 2014

Tip: Linux Determine File Sizes in your home directory


anil@localhost:~$ du -sh * > largefiles

You can then look inside the file largefiles.