Friday, June 29, 2007

Event Mailer

The spark happened when there was a discussion in the college group, "how prompt people are in sending birthday wishes". Somehow I am never prompt in this one. I wish to make a mark every time a wish is sent. Another reason is to kill the time when I get locked in office (happens during most of evenings). Thirdly wanted to have a hands-on on a couple of Java technologies which I know only conceptually.

Technologies Used:
JDK 1.5
Java Mail
Java Servlet
Apache Commons HTTPClient

Flow chart:
There are two parts to this project.

Getting the event list
1. Got the recurring birthday list from the Group Calendar
2. Converted it into a CSV file format
3. Used JAXB to create a events xml file from the CSV file

Sending the mailer
1. Read the events xml
2. Check for any events scheduled for today
3. Send out a request to Event mailer servlet with subject, message and mailId.
4. The event mailer servlet sends a mail

The events xsd is made generic such that it can span more than birthday list. I had to use event mailer servlet (hosted in myjavaserver), since could not make SMTP connections (I am behind the firewall). Made a cron job (using windows scheduler), to run the mailer everyday.

Tuesday, June 26, 2007

Sony Ericsson K550i - Network icons

Just pondering over the 'G' and 'E' icons displayed near the network tower indicator on the top left corner of the phone screen. Lately found that it represents the network capability of your mobile service provider.

For more information refer the network tutorial on the Learning Center in SE site.


Monday, June 25, 2007

Sony Ericsson K550i review

After a span four years with Motorolla C350i, I moved to Sony Ericsson K550i.

I guess I am the one to use Motorolla C350i to the max extent. This cell phone's battery started cranking out about 6 months back, I somehow managed extending its life (because of under usage).

Before starting to lookout for a new mobile, I just framed my must-have requirements.

1. Good call quality
2. Good battery life
3. Good camera (~2 MP)
4. MP3 player support
5. *No* 3G (no affordable 3G support in any near future, that is my prediction)
6. Price range Rs ~10K
7. Form factor - Candy Bar (easy single hand handling)
8. Connectivity - Bluetooth, IR, GRPS, Quadband

This restricted search resulted in a couple of options. I blatantly ignored LG, Samsung and Motorolla for their poor battery life and build quality.

So the options were
1. Sony Ericsson K550i
2. Nokia 6300

Nokia 6300 didn't pass the litmus test with its poor battery (before this phone I believed that Nokia had the reputation of good batteries, but in the reviews it has been stated that Nokia changed their battery to gain the slim factor). So the best choice I am left with is Sony Ericsson K500i. Before hitting the stores, I read through the reviews on CNet Asia and GSM Arena.

Somehow these reviews lacked that feel good factor. Eventually when I had the phone on my hand, I was impressed. The build quality is much superior than I expected. Based on a couple days of use, the phone is beating all my expectations.

1. Good camera with better options
2. Comes with all standard connectivity options (read the specs)
3. Good battery (with full charge running for 2-3 days, avg use)
4. Mp3 player is awesome (generates easier navigation list)
5. Accessible keys
6. Speaker phone support
7. Neat look
8. Slim - 14mm
9. Value for money

1. Smaller keys (do not bother much unless you message a lot)

What is in the pack:
1. K550i phone
2. Battery (Li-ion)
3. USB cable
4. Hands-free
5. Charger (universal)
6. Software CD and Docs

Recommended for those with aforesaid requirements.

To munch on a rainy day

For the past week, Rain God is showing mercy and the authentic bangalore cloudy climate is back. With the chill weather around, it makes awesome if you have something crispy to munch.

Tried preparing baby-corn fry and it came out well.

(Photos: taken with SE K550i)

Thursday, June 21, 2007

Home Loan tips and tricks

While I was frantically searching for a home loan, I happen to see some tips and understand some tricks.

1. Banks are never under loss
Will ever the loan lending bank reel under loss if they finance a home and the borrower defaults? NO, for PSU banks, for private banks, they use some unparliamentary means to recover the money back.

Before approving a home loan the bank checks for sufficient credibility of the borrower. As per the general trend, the borrower would be paying the EMI for a few years. During those initial years the bank will recover most of their interest part of the loan. And since the home is mortgaged to the bank, they can recover the capital from the home.

2. When to prepay?
The best time to do prepayment is the initial years after taking the loan. Since the initial years are the period when the bank recovers a lot of interest. If you see the EMI calculation, during the initial years, most of the EMI goes towards interest.

3. On prepayment, what to reduce?
Some banks gives you the option of either recalculating the EMI or period of loan on prepayment. The best option is to reduce the period of loan. Because you pay less on reducing the period and keeping the EMI constant.

Things to consider while writing public APIs

When you expose public class/APIs, there are certain things that you need to consider

1. Arguments/Parameters
Carefully consider the arguments that gets passed into the API.

2. Method Name
Choose an apt meaningful name for the public methods or classes. Avoid ambiguity.

3. Exceptions
Throw only non-runtime exceptions, so that clients can handle them. Do try to handle all the exceptions in the method. If you have logging framework, log the exceptions and rethrow them.

4. Backward Compatibility
Once the APIs get released and you need to support them for an extended period of time. So if you modifying existing public APIs take care of backward compatibility, such that you wont break client code.

5. Intented use
The public APIs should do only what it is intended to do

6. Java docs
Provide clear crisp java docs. The best example is the one that comes with JDKs.

7. Trace / Log / Debug
Provide support for tracing/logging. Both serves different purposes. Trace is used to find the control flow inside the public APIs. Logging is used to log any error messages and exceptions.

8. Error statements
In case of wrong parameters getting passed, log descriptive error messages. The error message should typically say what went wrong and what is the corrective action.

Monday, June 18, 2007

Find java class files in JAR

Typically in a development environment of a big J2EE product, you often cross the step of including the right jars in your library path to get your product compile/run/debug. With lot of jars lying in you lib folder, you face the daunting task of including the needed few.


In case if you want to find from which jar a particular class gets picked up, you face the same daunting task of opening the various jars and looking out for a particular class file packaged inside it.

To get rid of this one, I came up with a java program that takes a path and class name and spits out the jars which contains the class. The usage of FindClass is simple

java FindClass C:\j2ee\product\lib MyClass

FindClass iterates through the folder (and subsequent subfolders) to get the list of available jars and list out the jars, which contains the specified class.

I used JarFile and JarEntry to read a jar file. Rest is all simple File operations.
If you love to use this util class, drop a comment.

Aquaguard: Chase for invoice begins

When I see my referring links on my blog stats, many of them are from google with search query "aquagaurd" (notice there is a mis-spell over there). So taking a suo-motto cognizance of the visit trend I have decided to document the horrible experiences a customer goes through after purchasing the noble water purifier (aha, see my frustration).

The honest intention of the aquaguard related posts on this blog is to educate the intelligent net-savy customers about the horrible services offered by the aquaguard people. Nothing more and nothing less.

So the first chase begins here.

When you buy a water purifier from the "well-informed" (read it sarcastic) sales rep from Aquaguard, little will be known to you about their invoice process. At the completion of the sale, the happy sales rep will handover a slip stating that you had paid on the delivery of the device. It is not an invoice or a bill stating that you had bought the product. The sales rep will promptly inform you that you will get an invoice within 15 days by mail.

That 15 day deadline will never happen. I have bought the product about 4 months back and still haven't received any invoice.

One more thing that you will not know is that the sales rep from whom you have bought the device, would have done either of one these in the following few weeks

1. Changed his mobile number, so that you cannot reach him
2. Changed his job
3. Changed his department with in aquaguard

In my case, it was option 3. I am chasing them through their customer care and every time they tell me the same crappy story. They ask me my mailing address and receipt number, stating that the invoice will be delivered in 2 days. Again nothing happens.

This is not an one off case. My friend has ended up calling them more than 100 times to get the invoice. Many more are in the process. Some are blissful enough with out caring that they require a legitimate invoice some time later when their device starts mall-functioning.

Tuesday, June 05, 2007

MyJavaServer - Signup Challenge

When I tried to sign-up for MyJavaServer service, I was quiet amused by their sign-up challenge. The challenge is to write a small Java program (just to make sure that you are conversant with Java). The site then compiles your program and runs a couple of tests to validate the program. Quiet a novel way to authenticate the users.

Signup Challenge
Master a simple Java programming challenge (STATUS: NOT PASSED)

As the principal engineer of an HTTP web server, you are responsible for implementing the request processing subsystem of the server.
An incoming request for a specific resource, identified by an URI, must be dispatched to the appropriate handler according to the server configuration which maps URIs to request handlers. 'HandlerFactory.getHandler' must be implemented:

public class HandlerFactory
public String getHandler(String[] config, String requestUri)

The string array 'config' contains URI patterns and handler names. Two consecutive values form a key-value pair comprised of URI pattern and handler. 'requestUri' represents an incoming request, the URI to match against the configured handlers. 'getHandler' must return the correct handler for a given URI as a string value.

An URI pattern never contains wildcards and represents the start of an URI string, a prefix. Matching must be implemented accordingly. The handler with the longest matching URI pattern wins if more than one pattern matches. If no handler can be found, "XqAoLy" must be returned.


Found that MyJavaServer is a free online java application server that one could use to host their web applications for free. They offer the following services on their site for developers.

Java SE 6.0 based application server
Servlet 2.3
Java Server Pages (JSP) 1.2
Pre-installed third-party libraries

RDBMS services
Embedded: HSQLDB, InstantDB

SMTP service
Unfiltered HTTP responses (no ad placement)
WAP/WML, Java WebStart MIME extensions

5 MB initial filesystem quota
Full native filesystem read/write access
File Transfer Protocol (FTP) file management

Quite cool. They use Tomcat application server to provide the service. So if you just want to host any simple web app for free, MyJavaServer is the place to go!

Sting operations by Private News channels

One good fallout of the private news TV channels. Recently NDTV exposed through a sting operation the nexus between defense and prosecution in the BMW hit and run case. Such clandestine deals could prevent people from getting a fair justice.