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..

Analysis
--------

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 blogger.com 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..

<?php
header('Content-Type: text/xml');
$url = 'http://cognitivecache.blogspot.com/rss.xml';
$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

<?php
header('Content-Type: text/xml');
$url = 'http://feeds.feedburner.com/CognitiveCache';
$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 "http://mydomain.com/proxy.php" and thats it..