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.

Wednesday, April 30, 2014

Tip: IntelliJ IDEA : Do not want unlimited whitespace at the end of each line

File menu -> Settings -> Editor -> Virtual Space and uncheck 'Allow placement of caret after end of line'. 

Also uncheck the other options in the Virtual Space panel.

If you want to remove trailing whitespaces, you can do
File menu-->Settings --> Editor --> Strip Whitespaces on Save   to either "All" or "ModifiedLines".

Tuesday, January 07, 2014

Clean Up Root Partition on Fedora

If you have the following problems:
  • Root partition / is using 100% of allocated disk space
  • Root partition / is close to using 100% of allocated disk space

Then,

$>  sudo yum install bleachbit
$>   su - -c "bleachbit"

Use bleachbit to clean up unwanted files.