Tuesday, September 16, 2008

Tunneling to the inside - using SSH

Many networks are setup in such a way that you can access a machine (lets say GGG) in the network through SSH and then you can access any other machine (lets say XXX) in that network using protocols like SSH, telnet, samba etc. But wouldn't it be great to access those services right from the machine (lets say LLL) you are sitting at itself?

Enter the SSH Tunnel. SSH tunnel could be used to create an end to end SSH connection between the local machine (LLL) and the gateway machine (GGG). Then you can access any machine (XXX) from (LLL) itself. The best part is you do not have to be root for this!

First establish the SSH tunnel connection between GGG and LLL using the following command on LLL
ssh user@GGG -L 2000:XXX:22 -N

where, 2000 is the local port on LLL which will act as
a gateway (this can be any port you want)
22 is the remote port on the machine XXX to which you
want to connect to (For example this will be 23
for telnet, 139 for SMB, 22 for SSH etc)

Now your tunnel is setup. Just connect to the machine by connecting to LLL on port 2000 - you will be automatically forwarded to connect to 22 on XXX machine!

The Bursting Oil Bubble - Aftermath

The Oil bubble has more or less burst for now as expected. with the price of crude down to nearly $94 from the peak of $147 in July. The main reason for the decline is that the US Dollar is once again stronger than earlier. Since Crude is priced in dollars, any fall in dollar value will increase the dollar price of crude and vice versa. Oil is one of the main commodities that is also used as hedge against the dollar, and now that the dollar is doing good, Oil is getting dumped in favor of US Treasuries and the like. The price of Oil is expected to drop further, since the Lehman bankruptcy will possibly unwind some Oil trades.

The global economic downturn is also playing its part, by reducing the demand for Oil. The last time the world economy was down after the 1997 East Asian crisis etc, Oil fell to under $10 a barrel. The cracks in the OPEC are once again out in the open, with Saudi Arabia not wanting to reduce its production. Politically also, the fall in Oil price is significant with the tide turning away from the Oil producers - especially the politically active ones like Russia.

The presumed demand from rising economies like India and China causing a global upward price spiral proved to be unfounded at least in the short run. And it also showed that however inelastic the price demand curve of oil is, there is still a curve there which causes unrealistic prices to throttle demand. Airlines can once again breathe easily.

Now-a-days, none of the bad news is really affecting the crude price slide very much. News such as Hurricane Ike likely to impede Oil production in the Gulf of Mexico, increased terrorist activity in Nigeria or likewise, which would have caused massive rallies earlier, are causing no more than a whimper, and the price slide stops temporarily before resuming its journey down to a more realistic value.

On the negative side, the push for alternatives to oil is once again reducing, indicating the short sighted nature of the public. Also the reduction of premium on Oil, removes the financial incentive for private investors to pursue alternative renewable fuels. Oil has also stopped being a major campaign issue. This is high time the coming Govt in Washington takes a stand and pumps money into the research for alternative fuels, instead of bailing out companies like the Detroit Big Three to prop up the economy in the short run.

The dent made by the spike of oil prices, made the American consumer more aware of the risks of owning a gas guzzler. It will be a while before this harsh lesson is forgot, which is good news.

The American consumers at the Pump still see Oil at more than $4 since Hurricane Ike destroyed the refining capacity on the east coast, resulting in serious Oil shortages. But this is a temporary phenomenon which should pass in a week or so.

I really applaud the Indian govt's decision to NOT reduce the price of Oil at the pump, even though it is the election year. This goes a long way in reducing the oil subsidy to more manageable levels, and will leave the image of India as a good investment destination intact.

Nightmare on Wall St - Failures of Lehman, Merryl, AIG, WaMu....

In The Simpsons Movie, when Bart Simpson, utterly embarrassed by a situation, moans - "This is the worst day of my life!", his father replies - "This is the worst day of your life, SO FAR". The same could be said about the happenings in the last week of the US Financial sector.

What a week it was. just when you were thinking that the worst was over, the financial sector keeps hitting new lows. Couple of months back Bear Sterns was taken over by JP Morgan in a Shotgun wedding arranged by The Fed. Markets were a bit stable, and now it spread like wildfire in the last week. These are a couple of things which went bad in the financial sector in the last week.

- Freddie Mac & Fannic Mae were nationalized
- Lehman Brothers stock in free fall resulting in its declaring Chapter 11 bankruptcy
- Merryl Lynch bought over by Bank of America, after a free fall in its stock
- AIG group stock going down, resulting in its "restructuring"
- Washington Mutual (WaMu) Bank's stock tumbling
- Wachovia Bank's stock nose diving

So now out of the big Five wall street investment firms, only two - Goldman Sachs & JP Morgan were left standing. This extreme uncertainty in the financial sector trashed the DowJones, making it face the worst percentage fall in 6 years.

The ticking timebomb here is that the investment firms make a lot of trades with one another. Since there are a very few big firms taking up both sides of most of the trades, the trades suffer from counterparty risk. i.e. if you make a trade which realized a profit on the books, but the counterparty to the trade cannot pay up since it went bankrupt, then you lose too since you wont be seeing any real money from them. Now that Lehman has gone down, all the trades done with it need to be unwound, or a loss taken. When these losses start appearing on the books of other investment firms, they too will start taking a hit.

Lehman's is the biggest bankruptcy filing ever with $639 billion in assets. So there are bound to be repercussions everywhere in the financial sector. UK regulators have already asked firms to declare their exposure to Lehman. Citi group looks like it has a serious exposure to Lehman, which if it did, would seriously undermine its current precarious position.

Already there is a talk of a further rate cut by the Fed, which, at current inflation levels, can only be bad.

So is the rock bottom hit? is this the worst? I cant help thinking of the answer given to Bart Simpson...

Sunday, September 14, 2008

Continue Browsing during Power failures

Power cuts (or load shedding, black outs, or however you want to call them) are very frequent and frustrating here in hyderabad. Other times we face the low voltage situations (also called the brownout). In such cases I would be able to continue using my laptop (given that its a 9 cell Thinkpad), but lets face it - Very little work of value (or timepass, as my friends like to call it) gets done without the INTERNET! It is even more frustrating when you tend to work from home, and you are cutoff due to power loss and have to rush to office.

The best way to beat this situation is to bring out the old UPS you used for your old desktop. Even if u never had a UPS, you can buy a cheap one for less than Rs 1500/-. Once you connect your modem and wireless router through the UPS, you will get a backup of almost 2 hours straight. However if you are using Sify or other ISPs which given you a direct ethernet cable to your house you might be out of luck, since the local hub at your operator will lose power. This was one more reason for me to switch from Sify Broadband to Airtel, other than Sify's pathetic customer care and reliability issues (15 days of no internet in a month makes you go crazy!).

Also, if you are watching a movie with friends and power goes out, you can connect the speaker set to the UPS, to get the enhanced volume. Or in emergencies you can charge your cell phone on it too.

Converting AVI/MPG to 3GP files in Linux

The best way to convert an AVI/MPG video file to 3GP (like for viewing them on your cellphone) is to use the opensource program - ffmpeg. The ffmpeg was also the starting point for the most famous movie player for linux - the mplayer suite.

To start using ffmpeg, First download the latest ffmpeg source code. Run configure on it using the following command line, followed by a make and make install.
./configure --enable-nonfree --enable-gpl --enable-libamr-wb --enable-libamr-nb
--enable-libmp3lame
If you do not have the libamr-wb and libamr-nb codecs installed, download the following packages - amr-nb-7.0.0.2 and amr-wb-7.0.0.3 - and configure, compile and install them. The description of these packages is given in detail here.

NOTE that if you have FFmpeg installed, you need to make sure that you see both --enable-libamr-wb and --enable-libamr-nb in the configuration. You can check the configuration of ffmpeg by running ffmpeg > /dev/null.

Then run the following command to convert the AVI/MPG files to 3GP
ffmpeg -i inputfile.mpg -s 176x144 -b 300k -r 10   -ar 8000 -ab 12.2k 
-ac 1 -f 3gp -aspect 4:3 outputfile.3gp
Upload to your cell, and it will help you get over lots of boring times :)

Monday, September 8, 2008

End of Credit Crisis in Sight - Freddie Mac & Fannie Mae nationalized

The Credit crisis which has roiled the markets for over 2 years is now hopefully nearing an End with the near-nationalization of the US Secondary Mortgage Market Majors - Freddie Mac and Fannie Mae, yesterday. This action has fed a lot more confidence into the credit markets reeling from the subprime crisis.

The US mortgage market is structured in such a way that, you have the primary lenders (banks like Wells Fargo etc) who make loans to individuals for the purpose of housing. However, these mortgages run into hundreds of thousands of dollars. So a normal lender can only give so many mortgages, before his cash flow is completely stuck in these extremely long-term (upto 30 year long) loans. So to add more liquidity to such a market, the US Govt established the Freddie Mac in c1970, which would buy the loans (at its discretion) from these primary lenders. Having got back their initial capital, the primary lenders can provide other people loans. Freddie Mac in turn pooled and securitized (oversimplification:bundled) these loans and sold the resulting securities to investors in various organizations. Freddie Mac, guaranteed the rate of interest on these securities and hence assumed the credit risk, for which it charged a fee. Essentially, this means that any non-payment of mortgage by a person, will be made good by Freddie Mac. Fannie Mae is also essentially similar, except for its beginnings. Between themselves, these organizations own over 50% of all home loans in the US.

Technically these organizations were supposed to be Government Sponsored Enterprises, but essentially private corporations owned by stock holders, without any Govt insurance for their loans. However, due to their size and presumed US Govt backing, they had acquired the tag of "Too big to fail", as in, if they fail, they would drag down the economy with them. This caused them to take up riskier mortgages from the primary lenders. At last count, Both Freddie and Fannie had over $12 Trillion exposure to the mortgage market.

Now that the Subprime crisis has precipitated a downturn in the US housing market, this downturn has resulted in a lot of mortgage defaults (although Freddie Mac does not buy subprime loans), which caused Freddie & Fannie to declare losses of nearly $15 billion last year. This has led to their credit rating dropping to Junk status, forcing the premium on loans to them (bonds) going over 2.5%, making it very difficult for them to raise much needed new capital.

To alleviate the crisis, the US Congress in July passed a law, with bi-partisan support, allowing the US Govt to step in and bail out these corporations if required. This was supposed to give confidence to potential lenders that their loans to Freddie would not go bad (thereby reducing the risk and hence premiums on the bonds). But this action backfired badly, since people know that any such nationalization would wipe out Freddie's stock value. This caused its share price to plummet to less than $5. This precipitated a crisis, forcing the Govt to act immediately and nationalize them both. As expected, Freddie Mac shares dropped to less than 25 cents.

So now the US taxpayers are "bailing" out these corporations. The impact of the bailout is not completely known, and is supposed to be in tens of billions of dollars, if not hundreds of billions. This will also cause tighter regulation in the housing markets, with people having even prime credit ratings facing difficulty to make a mortgage. The US treasury bills have also dropped.

On the brighter side, however, markets are very optimistic over the measure since the credit markets will now be more liquid, stock of various banks which gave loans to Freddie (like Citi Group) have gone up a lot, the premiums have also dropped on mortgages. The last one will once again hopefully rejuvenate the housing sector, which makes up over 25% of the US economy. So overall the housing sector can recover from the glut of unsold inventory, and once again start growing. These will also help to reduce the effects of the current recession the US economy is undergoing.

Saturday, September 6, 2008

MPlayer - Overcoming in-built low volumes of media files

Many times, the AVI files of movies end up with a very low audio volume causing a lot of pain for use with laptop speakers (esp like ThinkPad), which do not have a very wide range of volumes like headphones or traditional speakers. To overcome this issue, many media players provide an option to increase the volume more than 100% (upto 400% in case of VLC Media player).

After googling and RTFMing for a while I figured out that the way to do this in MPlayer is to use a software volume mixer instead of the soundcard's mixer. You can run mplayer with the following additional options
mplayer -softvol -softvol-max 400 

The 400 indicates that you want to increase the output by upto 400% of the base volume indicated in the media file.

This link has more information on using an audio filter instead of using a software volume mixer to do the same. Happy movie watching!!