Wednesday, December 31, 2008

The Best Things in Life are always Free

Well, probably they are always not. But these days, information is. If you truly have the passion and drive to learn something, then the opportunities today are wide ranged thanks to Internet.

MIT Open courseware gives everyone an opportunity to experience the standard of its courses from previous semesters. Some of them might be outdated with respect to changes in technology but many core courses are usually not. Here is a link to MIT Open Courseware

Other universities offering free online courses that I have come across are below:

Carnegie Melon
UC Berkley
Utah State University OpenCourseWare
Johns Hopkins OCW
Notre Dame

To find courses available from several countries, use Open course ware consortium

If you are interested in a specific course use OCWFinder to find all the options that you have. Good luck.

Sunday, November 9, 2008

Notes/Thoughts from an accident

1. Life is too short. A minute or even a second could decide if you will see the next moment..
2. Live every moment of the life as if it is your last moment in your life. You never know what might come up in the next moment.
3. Nothing is permanent. You might not live to think about what you could have accomplished with your life. Spend at least 2-5 mins a day thinking what the day has meant to you, if you were given a chance to re-live the same day, what would you have done differently, and then try to implement that difference in the next day
4. Working out, looking good, trying to impress people don't have much to do when your moment arrives. It doesn't matter. Nothing matters actually.
5. If in each day, you could do something that would make you feel better as a person, as a human being, do it, you can find excuses to tell others, but there is no excuse from your conscience.
6. Procrastination could really be dangerous. If there is something that needs to be done, do it now or else have a fixed plan to do it on a particular day by a particular time. If its a big project split it into pieces and have a fixed time for completing each piece.
7. Before complaining about a thousand things that happened to you today, stop for a moment and be thankful for the fact that you are alive, you lived to see another day in your life, you got one more day to prove your essence in the world, whether you utilized it in the right way is a different story.
8. Have a fixed set of things that you really want to do in your life. Give them fixed years. do a bucket list for yourself and assign importance to them. For example, By 30, I want to own a BMW etc. Work out an exact plan how you would do it, day dreaming won't work, have an exact plan within the means..
9. When a moment can decide your life, live it up, live every minute part of a moment..

Friday, November 7, 2008

Oracle SQL group by on a portion of a clob field in the database

I work on an application which writes its internal errors in processing to a DB table. The input data that caused the failure due to a parsing error or missing configuration error is put in a clob column in the database. This input data is an XML message and one of the tags identifies each application that sends data to my application. We had one of the architects who requested us to give a split up on the number of errors that have occurred for each application.

This was significant from Oracle perspective because you cannot do a group by on a clob. In order to do a group by, you need to be able to sort and clob fields do not have a natural sort order. The workaround is to do a to_char function on the clob field but you can get a max of 4000 chars. For me, this suited the requirement because the substring I needed was a small string. But the issue is that I needed to sort a portion of an XML tag inside the clob field and group them based on that. Not only that I needed to find a specific type of error in the XML message and count them.

After a little food for thought, here is the final query that fetched the sweet results

SELECT k.application_name, COUNT (*)
(SUBSTR (clobfield,
( INSTR (clobfield,
+ 21
( INSTR (clobfield,
- INSTR (clobfield,
- 22
) AS application_name
FROM tableName
WHERE appID = 1
AND INSTR (clobfield, 'ns0:appName', 1, 1) <> 0
AND INSTR (clobfield, 'ErrorMsg', 1, 1) <> 0
AND INSTR (clobfield, 'Application Not Configured', 1, 1) <> 0) k
GROUP BY k.application_name

The INSTR function selects the index of the occurrence of a string inside another string, while substr gets the substring from a string. The numbers 21 and 22 account for the tag name lengths and the additional characters in the tag name like > etc.

If you need to count based a specific portion of a clob, just modify the above query and you are good to go..

Wednesday, September 3, 2008

Lifestyle savings etc. a nice comment from an enlightened person

Lately, thoughts have been springing into my mind as to what I should save for, what my real goals in life are, etc. I was navigating through some links and landed on this post about Lifestyle inflation. More than the post, this comment from Ron made a lot of sense. He sure must be an enlightened person. With his kind permission (haven't received it yet, since I have no way of communicating except leaving a comment on the same blog), I publish it here for my future reference and for any readers. I hope to emulate him some day..


Some very interesting comments and I see everyone is very committed to saving…but I wonder for what? What are you saving for, why do you want to earn more money? I am not being facetious; I really want to know the reason behind your efforts.

One of the seven habits: Begin with the end in mind. I see the blogger has a goal of a million dollar net worth…same question…why? What will having that net worth accomplish? And what are you measuring? And what is the nature of the net worth you are after, specifically?

I mean, do you want a million in equity (say, in real estate) or a million in the bank earning 5%? Two totally different scenarios.

Many people fixate on some number but it is often like leaning the ladder of success against the wrong wall. My clients come to me with that same idea sometimes; that is, to grow their net worth to some magic number as if it will resolve their financial issues somehow.

Look, as a goal I guess a million is as good as any but, really, if you are saving just to reach a number…what is the life you want? What would an ideal day look like, feel like?

Money is a tool…but for what? To build the life you want, IMO. So isn’t that the real goal? What is the life you want and, now, break that up into pieces and cost those pieces out:

The house I want: $x
The car I want: $x
Number of kids: $x

So on and so forth. Then you add that all up and you will have a bottom line and that is your real goal.

I wanted a small but comfortable home in a safe neighborhood and a five year old car that I would keep for five years and then sell and start over. Cost for that: $1,000 a month where I live. Plus expenses: Another $1000 a month.

My savings earn me $15,000 a year ($300K at 5%) and the rest I earn working three days a week doing what I really enjoy doing and what I would do for free if I could afford to do so. And I also manage to save some of what I earn so my savings are growing, as well.

I am married and we have a daughter and we look for all the world like a typical middle-class family. But we pay for it all with 24 hours of work a week; meanwhile both spouses work in all the other houses on the block.

We are not better or smarter, we were just able to decide what we wanted, price it out, and fund it with just enough work to get the REAL job accomplished (the life we wanted). Four day weekends are great!

Good luck!


Thursday, August 7, 2008

Log4j writing to a dynamic log file for every run

In my recent project, I was using Log4J and I had a requirement where I had to write to a new dynamic log file every time and the name of the log file was determined at runtime. In specific terms each run would produce a Project and the log file had to reflect the project name. Since this project name could be repeated across runs, the timestamp needed to be added to the log file. I searched across Google and didn't find much help in this regard. So I decided to post the code I wrote.

I didn't want to lose setting the log levels from the log4j.xml file and wanted all the options I could configure for the FileAppender except the file name. The file name was configured too, but the code had to overwrite and create a new file at runtime. Here is the code..

Date projDate = new Date(Long.parseLong(project.getTimeStamp()));
StringBuffer dateStr = new StringBuffer();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
dateStr = sdf.format(projDate, dateStr, new FieldPosition(0));
String logFileName = logsDir + File.separator + project.getName() + "_" + dateStr.toString() + ".log";"\n**************Log file for this run: " + logFileName + "\n**************\n");

Logger rootLogger = Logger.getRootLogger();
Enumeration appenders = rootLogger.getAllAppenders();
FileAppender fa = null;
Appender currAppender = (Appender) appenders.nextElement();
if(currAppender instanceof FileAppender)
fa = (FileAppender) currAppender;
if(fa != null)
{"No File Appender found");

That's it. The logs were created for each and parallel runs would write to different files...

Friday, July 18, 2008

Totally Annoyed with Toyota of Plano service guys

I went to Toyota of Plano and was pretty annoyed with their service department and this Chris guy who was upset that I didnt get the Dealer recommended maintenance for $300 and got just the factory recommended one. Here is the story..

I needed a 15000 mile maintenance for my car and I called up the Toyota of Plano guys and asked how much it would cost. The guy on the phone said it costs me $335 or so. I was indeed surprised at such high amount and checked the Toyota website. All the Toyota recommends for my car is the following. (Source)

Replace engine oil and oil filter 1
Rotate tires
Clean cabin air filter
Visually inspect brake linings/drums and brake pads/discs
Inspect the following:
Ball joints and dust covers
Brake lines and hoses
Drive shaft boots
Engine coolant 3
Exhaust pipes and mountings
Steering gear box

I then asked this service dept. guy if it was the factory recommended one or the Dealer recommended one. He said it was dealer recommended one and he went on to list a bunch of things they would do. He said they were very important for the car. The only question I had in my mind was if all those were so important for the car then why wouldn't Toyota recommend that. But I didnt ask him that and asked him how much would the factory recommended one cost me. He says $93.20. He said I could come in and talk to some Chris guy who would take care of it. I say okay and start out to get one.

I go there and wait for my turn and then some guy comes in and fills my request form. I mentioned clearly I needed 15k facory recommended maintenance and asked him how much it would cost. He said, oh it costs 80 bucks and notes 80 on the sheet. I say okay and ask are you Chris. He is like, no, that guy right there is Chris, I will fill it and keep it on Chris' desk so he can take care of it. I say okay and then leave my car and wait. After an hour or so, Chris guy comes and tells me its ready. I say okay and go to pay the bill. The lady at the counter says $85 and some change. I asked her if I could get a sheet that describes what all has been done and she shows me a billing list which doesnt contain most of those listed above. I asked if they have been done at all and like to see the detailed list and she tells me, Oh ask Chris and he will have the checklist that they check the boxes when they perform the inspections and all. I say okay, pay my bill and walk out to Chris.

I ask this Chris guy if I could get a detailed list, he is like, wait and he says, If you got a dealer recommended one, I would have the list, and then he answers his cell phone, and then says it would be in the maintenance guide you have in the car, and then brings me a list that has the above checked. And then he goes on, "See you just have tire rotation and oil change, there is no wheel balancing and all done because you took a factory recommended one and not a dealer recommended one", and I say, "Okay, so what difference does it make". He says "Oh you will not know that now, after a few miles when you hit 70 miles per hour and your wheels start vibrating then you will notice." I never knew thats a way to talk to a customer and in such derogatory tone. I got really pissed off and asked him, "So if its gonna affect my car and all, why doesnt Toyota recommend whatever your dealership is recommending. And he says "Look man, I am just trying to help you.." Great way to escape without an answer.

The checklist that he gave me says the service is $93.20 and I show it to him and ask if it costs $93.20 then how come, I was charged only $85 and change and he says, ya its lesser than that right. I say, of course, but I am just curious why the difference. And he says, the guy who talked to you put 85 on the paper (he had actually put 80 but may be taxes is 5), so I had to give it to you for 85. This was totally ridiculous. I dont know if they have a pricing system at all, some guy says its 80 to me and so he says he gave it to me 85 instead of 93. The difference might be a few dollars, but what I dont like is the fact that the same thing costs different amount to different people. So, you go to walmart and ask a rep what the price of a hdtv on a tv stand is. He mistakes the price of the tv stand to be that of TV and says 200, so now will Walmart give the TV to you for 50 bucks. Doesnt make sense to me at all..

And then I ask him, did you put the seal on my Toyota Passport guide, and he was like you didnt give it to me. The last two times, the service rep guys took care of it without me even asking them. I say, okay, let me get it for you, and then he walks with me to the car. I give him the booklet, and I say, I just need the signature and your seal and he goes "I know what I need to put in there, I have been doing this for some time". I wouldn't mind if he said that in a friendly way but he was outright rude. He goes, fills it up and comes back and I ask him, one last qn, is the blinking message on Dashboard that says "Maint Reqd" reset, and he says, it should have been, and guess what I start and the blinking is still present. And then he resets it and says, now it is reset. If I hadn't asked I needed to go back again for that.

I am totally surprised by the total inefficiency and the carelessness that they show towards the customers and the worst part is they are getting away with it. And I am also appalled at their discretionary variable pricing system. May be today was a bad day or I got the wrong guys, but in my opinion today, Thumbs down to Toyota of Plano...

Wednesday, July 16, 2008

Java: Loading an XML file from the CLASSPATH

Today, I faced this issue in Java coding. I needed to load an XML file which was in my classpath but not in the same directory as the classes. The deliverable was a jar and the properties and the configuration XML files were in a different folder and were appended to the classpath at the runtime. The issue was that the file could not be located through the the statement

String fileName = getClass.getSystemResource("config.xml").getFile;

Then I thought that it checks relative to the current class and so used the statement

String fileName = ClassLoader.getSystemResource("config.xml").getFile;

But then, it wouldn't still recognize the file. The reason is the same, it checks relative to the classes folder. I did not want to get the classpath from the system and browse through it for the config file since the class path could get larger. A couple of google searches and a little research later, I found the solution. The workaround is by using the following statement

String fileName = Thread.currentThread().getContextClassLoader().getResource("config.xml").getFile;

It only makes sense since in the above statement, you get hold of the context class loader and find the path in the entire classpath...

Wednesday, June 25, 2008

Dont ever say that you don't have enough time

Nice quote from Pravsworld

If you want to get inspired daily, subscribe to their email list. Its pretty cool :)

Wednesday, June 18, 2008

Mee Sreyobilashi - Suicide is not an option, so is giving up for an entrepreneur

Just watched the Telugu movie Mee Sreyobhilashi. Gist of the story. Around 10 people who are vexed with life and want to end it travel together in a bus to take the bus down to a valley and die together. Their journey to the realization of the value of life is the movie...

The movie spurred a bunch of thoughts. First of all, why should anyone commit a suicide. God has given us the life to live. Life is a challenge, we need to face it. If everyone starts ending their life due to some problems or the other, then what is the essence of life in itself. Death is just the absence of life, not an end to it. No problem on earth is big enough to force any one to death. People who are handicapped or have many other disabilities are living a happy life with tons of self-confidence. Why cant normal people do the same...

And then there is one more way of looking at the whole thing. If living the life symbolizes your dream of making it big, your dream of being a success, giving up symbolizes the death of a life, the death of an aspiration, the death of a hope.. A person never really is a failure until he gives up. One thing is for sure. Every one of us is going to die sooner or later. And that is one thing that we can never avoid. That is one thing we cannot run away from. Then whats the point of living life in an insipid manner. What is the point of giving up... Live life to the fullest and never give up... The day you give up is the day you fail, whether you give up your hopes or dreams or even your life... Dont quit your hopes, your aspirations, your life...

Wednesday, May 14, 2008

Power of Java, In deleting the files that Windows cannot

Today, in one of the programs, I messed up a little piece of code that creates a folder in another, which ended up creating folders in an infinite loop. The folder name was ae, but there were so many of them ae in ae in ae .... Then I just wanted to clear the folder and start afresh with the fixed code. But guess what. Windows would not delete the folder because the name is too long. This was the exact error..

"cannot delete the file name you specified is not valid or too long"

I tried from Command prompt and tried other solutions from Google search like assigning a name on shared and trying to delete from network. And nothing worked. That's when I decided, let's take Java's help. Wrote a simple piece of code to loop through until it reaches the final folder and deletes everything. Ran the code and 2 minutes later, everything was gone. One more reason to love Java and being a programmer. Here is the code in case you are interested..

public class FileDelete

private void deleteFiles(File file)
File child[] = file.listFiles();
for(int i = 0; i < child.length; i++)

System.out.println("Cannot delete file: " + file.getAbsolutePath());
public static void main(String[] args)
System.out.println("Attempting to delete files");
File _work = new File("");
FileDelete fd = new FileDelete();

Friday, May 2, 2008

Britain's got talent, hell ya with these kind of Michal Jackson + Bhangra, it sure does

Don't need to describe the video much. The audience reaction says it all :)

Tuesday, April 29, 2008

Impressed with Jawbone headset and its customer service support

A week or two ago, I purchased the Jawbone bluetooth headset which has got a lot of reviews as the best bluetooth headset in the market. I should say I am pretty impressed. The noise canceling feature is just awesome, people on the other side rarely hear any other noises other than my voice. After trying the multiple ear pieces and loops and fixed on a set. I haven't used a bluetooth headset before so I can't really compare. My long calls started turning effortless and I was pretty happy with the piece. Worth every penny, oh yeah..

And then the inevitable according to Murphy's law had happened. I broke the left standard ear loop. I was trying to remove it when it broke. I called up the Jawbone support guy. They wouldn't give their number on the website but a quick Google search revealed their support phone number 408-848-4348. The customer service guy was cool and he told me that he will send me a complimentary one in 7 business days. Now, how cool is that. I didn't know you could also buy the ear loops from their website, you pay $10 for the ear loops but then you will need to order the 4 piece set. I should say that I am pretty impressed both with the piece and the customer service. All the negative reviews on the web, I guess those guys were probably having a bad day :)

Monday, April 28, 2008

Too smart or too novice in Java: Relevance of for loops

During the course of my work, I have had to fix some code written by others and modify existing code for enhanced functionality. In one of such projects, I encountered this piece of code written by someone

for(boolean valid = false; !valid; valid = true)
sp = spf.newSAXParser();
parser = new ProjectParser();
sp.parse(projectFile, parser);
catch(Exception e)
throw new RuntimeException((new StringBuilder("Unable to parse ")).append(projectFile.getAbsoluteFile()).toString());

Let's see how this for loop works. It initializes a boolean called valid with a value false. The condition is until valid is false. The increment is making valid true. And then inside the loop, the coder wants to accomplish something. Now what is the point of this for loop at all. Was the for loop used because the coder didn't know that loops are used for, you guessed right, looping. If he/she just wanted it to run only once, then what is the point of using a for loop at all. How different is the below code from the above code.

sp = spf.newSAXParser();
parser = new ProjectParser();
sp.parse(projectFile, parser);
catch(Exception e)
throw new RuntimeException((new StringBuilder("Unable to parse ")).append(projectFile.getAbsoluteFile()).toString());

This would execute the code only once and that is the desired behavior that was accomplished by using the for loop for once. I think keeping your code clean and staying away from such unnecessary stuff helps you in keeping your code clean and reducing any unwanted bugs. Why turn the hand around the neck to eat something when you could directly eat it.. Is this trying to be too smart or being too much of a novice to know what loops are used for. Or is there something, that I am missing that is something great that I haven't realized in using this type of code. If someone could elaborate, I would be glad...

Friday, March 14, 2008

Pay auto/car Loan or Invest in a CD or other investment. When do you break even

The previous post of mine on auto loan had lots of discussion and ifs and buts. I decided to make it pretty simple this time. Here is the case. You have $10000 with you today, that you can use to pay off a car loan of equivalent amount which is at a interest rate of 5.5% or you can pay the monthly installment on the car loan and invest the current $1000 you have in a CD or shares..


Current car loan = $10000
Interest rate = 5.5%
Term = 2 years or 24 months

From Bank Rate Calculator the equal monthly installment is $440.96

Let us say Best CD rate available is 5% (which is impossible at this time). So the case under study is that you have $10000 in hand today and you have $440.96 from your monthly income available to you to pay the car loan

Pay the car loan

In this case you paid off the car loan and you put the $440.96 in a Savings account like ING Direct. Let us say in an ideal scenario you are making 4% on your savings account (ING doesn't offer this interest at this time). So putting $440.96 in a Savings account for 2 years, at the end of 2 years, (from dinkytown)

Total = $11,505
Taxes = 28% of (11505-10000) = $421.4
After taxes total savings = $1083.6
After paying taxes, money you have with you = $11083.60

Put in a CD

From Bankrate $10000 at 5% for two years will yield a total of $11,052.

Total = $11,052
Taxes = 28% of (11,052-10000) = $294.56
After taxes, net with you = $757.44
After paying taxes, money you have = $10,757.44

Paying the car versus CD

Difference you lose by not paying the car loan and investing in a CD = $11083.6-$10757.44 = $326.16

Incentives for not paying the car loan is the fact that you are only liable to $441 a month, if you lose the job or if you are on bench in consulting, then you have $10000 with you and you are only liable to $441 a month. So, that makes it easier for your mental peace

If you do not put in a CD and invest in shares or something, then what percent interest rate on your $10000 investment justifies your not paying off the car loan? lets calculate that. This means that your $10000 has to become $11,505 in 2 years. Using the formula for compound interest, that would be 7.26% assuming interest compounded annually. That is a very low interest rate compared to gains on Shares. But then, you never know about Shares. You might as well lose your money.

So, that's the calculation folks. Know your facts, analyze your situation and make a good decision :)

Wednesday, March 12, 2008

Overcoming cross domain issues through php proxy server in Flex for RSS Reader samples

Today, I took a second look at my home page and decided that the blog link should not directly point to this page and should have an in-built RSS Reader for getting these posts there. And then the troubles started. People who know me already know my website and know that it was built in Flex. I had this idea of an in-built RSS Reader in my home page for long, but whenever I started working on it, I would have weird exceptions on page load, which were not straight forward and I wouldn't have time to debug them. So it remained the same, a hyperlink to this blog. Today a post on DZone caught my attention and I again tried this. I found a simple example which I implemented in my home page and thankfully everything went cool. But when I put it on the server, another problem started. The cross-domain problem..

The thing about flex is that, while being cool and xml dominated, the biggest problem is with the fact that you cannot load the rss or xml from other websites, without a cross-domain.xml file on the serving domain that lists the calling domain. Now I cannot ask to put my domain name in their cross-domain.xml file. Can I ?? So I preferred the alternative route, which is widely written on the net, the proxy server route. And though I do not have Java hosting by my space provider, they support php and went for a simple php script..

header('Content-Type: text/xml');
$url = '';
$content = file_get_contents($url);
echo $content;

The script looks so simple like a no-brainer right. Nope, that wouldn't still solve my problem. Because, the blogger wouldn't let the php script open a stream and I kept ending up with this error

Warning: readfile [function.readfile]: failed to open stream: No route to host..

After changing the scripts from the net thrice hoping the other one would be different, I kept coming back to the same problem. Finally I realized that it could be an issue with Blogger not allowing an incoming connection. Boom, that was it. I changed the code to point to my feed in FeedBurner and that was it. My new code looks like this

header('Content-Type: text/xml');
$url = '';
$content = file_get_contents($url);
echo $content;

Now, The RSS Reader gets its content now and it looks like a nice addition. A Happy ending to lot of time spent indeed !!

If you are still wondering about the whole process, what you need to do, is to burn a feed in FeedBurner and put the above code in a file called proxy.php. Now upload this file to your domain and use the url for xml in your flash file as "" and thats it..

Saturday, January 5, 2008

Taare Zameen Par - Because every kid is special...

I haven't done my homework and prepared for the exam well. I was hoping and praying that the exam would get canceled, I was praying to God again and again that something should happen, a flood or earthquake should come so that the exam gets canceled, and I don't fail. Because failing the exam is a doom, that would set a downward spiral on, which would leave me with no future. I won't have a place to live or food to eat in future. What could I do now. The thoughts of "if only" run through my mind as I promise myself, if somehow I pass this exam by God's grace, I will always prepare well for every exam in m life.

Source: Movie Home

And boom, I suddenly wake up in the middle of the night realizing it was just a dream, realizing that I have finished my Masters and am in a stable job making a decent salary and set for a decent career. But why do I still get these dreams. My parents never compelled me for anything. Still there was fear of exams, fear of failing, fear of going nowhere in life, that has captured my thought process so vehemently that even at about one-third of my lifetime, I still get such dreams. Is it a psychological disorder. Of course not, it is the psychological set up of almost every Indian student who has gone through the rigors of Indian system of education, the stress of what the society would say if you fail. Is the fault with the Indian system of education. Nope. the fault is with the societal mind set in India or at least in Andhra Pradesh, where you have to be an Engineer or a Doctor in your life. Other career options don't even exist..

The thought process above was triggered in me, after watching the movie Taare Zameen Par. A wonderful movie that takes us through the journey of a kid who suffers from Dyslexia. Trying to camouflage his inability to read and write like other kids in a cover of stubbornness and frustration, Ishaan slowly loses interest in one thing he is the best at, painting. As Aamir points out, his parents and teachers were seeing the symptoms of the problem, but none try to understand the reason for his problem. It is not that he does not want to read and write, its just that he cannot. Having suffered through the trama himself in his childhood, Aamir sets out to help the kid. With the kids' Dad not understanding the situation, he gets the help of the Principal to get the kid to normality by giving him ample time to learn things his way in his own pace. And guess what, he brings progress in the kid by projecting his positive points and building up his confidence.

A really wonderful movie with superb action from the kid who portrayed the role of Ishaan. Aamir Khan performs well enough, but the best part in the movie is his direction. His sincere attempt at a heart touching story strikes an emotional cord or two by making you fell for the boy, because you have been there! Overall cent percent to Aamir Khan for a honest attempt at a genuine subject, instead of song and dance routine.. Do yourself and your kids or your future kids a big favor. Watch Taare Zameen Par, because it teaches you how to be a real parent. Because it lets you see a child's mindset from his point of view. Perhaps your kid might really benefit from your changed outlook. Perhaps India will see light in careers other than Engineering and Medicine !!