Sunday, December 29, 2013

Google App Engine Project using Maven

Since folks from google have created the archetypes for Google App Engine Web projects it is takes seconds to actually create a sample web application and deploy it!
In the post I am going to show you how to do just that, read on..
#Create a maven project using app engine archetype 
mvn archetype:generate

#Select an archetype of choice 
#At the time of writing this blog post, following are the options available
Choose archetype:
1: remote -> (-)
2: remote -> (-)
3: remote -> (-)
4: remote -> (-)

Note: Run the following maven commands inside the project directory where the .pom exists
#Verify the demo application
mvn verify

#Start the app engine devserver on your machine 
mvn appengine:devserver

#Test the demo application locally

#Update the 'appengine-web.xml' with the following details

####### Deploy the application on app engine 
mvn appengine:update

#The END!
Now you will be able to use the app url and access the application default being

Thursday, November 28, 2013

HBase Query Results to File

1. Create a file hbase_query with all your HBase Queries
2. Run the following command
cat hbase_query | hbase shell > hbase_output

Sunday, November 24, 2013

How to type control characters into a file using Vi

Its simple.. For example if you need to write ^@ in a file in unix
1. Open the file in insert mode using vi
2. Use the keys in the order they have been listed
(ctrl+v) + (ctrl+@)
All it means is keep the ctrl key pressed and use v & @ in close succession

Thursday, November 21, 2013

Most frequently used Maven Plugins

A plugin to package a runnable jar with all its dependencies.
'SkipAssembly' property when set to false packages the dependencies inside the jar!
'manifest' tag can be used to set the jar manifest entries


A plugin to create java-docs using the java-doc comments in your codebase

Tuesday, November 19, 2013

Sunday, November 17, 2013

CSS 2.0

I thought CSS was simple, I underestimated the power of CSS
Only when I started evangelizing did I know how cool CSS is
Here are the slides to the CSS tutorial I came up in the process :)

Saturday, October 26, 2013

Remote Debugging using Eclipse

   Your java application is running on a remote machine, something goes haywire and the only way to debug your application is through making changes to a piece of code at random and redeploying it multiple time rather than actually stepping through the code??
   Well here is a better solution to that problem. Remote Debugging using Eclipse.

1. Install the Remote System Explorer

2. Establish an ssh connection to the remote server using the Remote System Explorer plugin

3. Start the java application debug server in the remote location(say with -Xdebug, -Xrunjdwp VM argument
java -Xdebug -Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=y -jar

3. Right click on the eclipse project that you would like to hook it to Remote Debugger as in the picture

4. Right click on the Remote Java Application and select 'new'

5. Configure the connection details as shown below

6. Run the debug!
Happy bugging :)
To understand more about how it works.. Head over to
Java Debug Architecture

Thursday, October 24, 2013

Aspiring Software Architect!??

A good way to start is by reading about how huge systems are built.. So where do you start? Here is where..

Dozer: Bean Mapper Toolkit!

Dozer is a Java Bean to Java Bean mapper
A neat tool to map the beans which uses XML based mapping!

Wednesday, October 23, 2013

Flume-ng, Hello World Quickstarter Guide!

For a bare minimum flume implementation we need to have the following components
1. Client : Java Program : Generates event(s) based on the fluctuating source

2. Source : Java Program : Must extend 'AbstractSource'. It is used to interface with the client, where the source acts as a server which listens to the events generated by the client. Based on kind of behaviour expected the source can implement or extend one of the flume source's in the 'org.apache.flume.source.*' packages
 OutOfTheBox sources: Avro, Exec, NetCat, Sequence Generator, Syslog, Scribe

3. Channel : Java Program : Connects the Source and the Sink. Acts as an event conduit between Source and Sink. There are multiple implementations of the Channel that can be used out-of-the-box which could be found in ''. Most common one is the 'memory' channel
 OutOfTheBox sources: Memory, JDBC, File

4. Sink : Java Program : Must extend 'AbstractSink'. It is used to collect the events coming out of a client and write it to file system Based on kind of behaviour expected the sink can implement or extend one of the flume sink's in the 'org.apache.flume.sink.*' packages
 OutOfTheBox sources: Avro, Logger, IRC, File, HBase

## To demonstrate how flume works. Following is the simplest example ##
##### flume-agent.conf #####
#Agent Definition
myagent.sources = mysource
myagent.channels = mychannel
myagent.sinks = mysink

#Channel Definition
myagent.channels.mychannel.type = memory
myagent.channels.mychannel.capactiy = 1000
myagent.channels.mychannel.transactionCapacity = 100

#Source Definition
myagent.sources.mysource.type = exec
myagent.sources.mysource.command = tail -F /user/shashi/Somefile.txt
myagent.sources.mysource.channels = mychannel

#Sink Definition
myagent.sinks.mysink.type = hdfs
myagent.sinks.mysink.hdfs.path =  /shashi
myagent.sinks.mysink.hdfs.fileType = DataStream = mychannel
Flume command to get the agent started
##### flume command #####
#Command to start flume agent
flume-ng agent --conf-file flume-agent.conf --name myagent

Shell script to increment the file being tailed by the flume
for i in `seq 1 $max`
    echo "$i" >> /user/shashi/Somefile.txt

Want to know more about it? Head over to the flume wiki page!

Code link for custom flume components:

Monday, October 21, 2013

Google Developer!

Every developer should compete in the dev challenge by Google at least once in a life time :)

Google Dictionary API

Power packed evening with the leaders of India Inc!

Apache TIKA: Content Analysis Toolkit

Apache TIKA - is a very powerful tool for analyzing documents of almost any format!

Wednesday, September 25, 2013

Cassandra frequently used CQLs

Some of the commonly used Cassandra CQLs

1. List all the keyspaces in Cassandra
use system;
select * from schema_keyspaces;

2. List all the tables in a keyspace
use {keyspace_name};
describe tables;

3. How to dump CQL output on to a file
{cassandra_home}/bin/cqlsh -f cquery.txt > cquery.out

Link to an exhaustive list of CQL query examples

Below is the snip of how the CShell would look like

Tuesday, September 24, 2013

Load a resource file in Java

Read a resource file from a web application
new PropertyConfigurator().getClass().getClassLoader().getResourceAsStream("")

Sunday, September 15, 2013

Java Official Tutorial Page

Where to start learning about Java?

Java Memory Management

Saturday, September 14, 2013

Java Interview!!

Couple of links that I came across to prep for the Java Interview


What is the o/p of the code blocks below and why is the difference in o/p's?
  String helloWorld = "Hello, world!";
  if(helloWorld=="Hello, world!"){
   System.out.println("== is true");
   System.out.println("== is false");
  if(helloWorld.equals("Hello, world!")){
   System.out.println(".equals is true");
   System.out.println(".equals is false");

  String helloWorld = new String("Hello, world!");
  if(helloWorld=="Hello, world!"){
   System.out.println("== is true");
   System.out.println("== is false");
  if(helloWorld.equals("Hello, world!")){
   System.out.println(".equals is true");
   System.out.println(".equals is false");

Wednesday, September 11, 2013

Adding code syntax highlighter to your blog post!

Click me to know how to add code snippets to your blog like below!  
public class HelloWorld {
 public static void main(String[] args) {
  System.out.println("Hello, World!");