Archive for May, 2007

Blood diamond - leonardo’s master piece movie

Yesterday I saw an interesting english movie - “Blood Diamond” starring Leonardo dicaprio and Djimon Hounsou. This film was nominated for oscar awards in 2006. Essentially it is a look the diamond business from the african conflict zones (Some would argue there is no conflict zone, entire africa is the conflict zone!). Check out the following trailer,

Leonardo plays the role of a mercenary who trades arms for conflict diamonds. Djimon is a native fisherman looking for his family. Both team up to find Djimon’s family and to retrieve a rather “costly” diamond.

I like the movie, but not as much as apocalypto or the departed. But the movie is worth watching just to see leonardo’s superb performance.

The movie also contains some memorable quotes,

Soldier: Archer! You’re a dead man!
Archer: Yea, yea.

Archer: So you think because your intentions are good, they’ll spare you, huh?
Benjamin: My heart always told me that people are inherently good. My experience suggests otherwise. But what about you, Mr. Archer? In your long career as a journalist, would you say that people are mostly good?
Archer: No. I’d say they’re just people.
Benjamin: Exactly. It is what they do that makes them good or bad. A moment of love, even in a bad man, can give meaning to a life. None of us knows whose path will lead us to God.

According to wikipedia,

De Beers Group, which is the largest player in the diamond trade, has expressed reservations about the film, believing it could reduce public demand for diamonds. De Beers maintains the trade in conflict diamonds has been reduced from 4% to 1% by the Kimberley Process. It has been suggested the company pushed for the film to contain a disclaimer saying the events are fictional and in the past; however, De Beers has denied this.

In the movie, rebels are shown as barbarians and brutal. But the fact is in africa, government forces can be as bad or worse than the rebels. Or are you naive enough to believe that UN forces are angels when they go to africa? I wonder why so many people forget that any army is just a killing machine.

My rating : 7 out of 10.

PS: Do you know that if you resell your diamond jewellery you get only a small fraction of the original price?

Accessing your Website when DNS servers are down

Recently Dreamhost had DNS problems and my site was not available for almost 12 hours. But I managed to update my site even when the DNS server was down! The trick is to tell your browser that you know the IP address and there is no need to do a DNS lookup. Following example assumes that you use Windows system.

First search for a file named “hosts” inside your windows installation. It is typically located under “c:/SYSROOT/system32/drivers/etc”. Open this file. It looks something like below. Note the entry for “jaysonjc.com”. Substitute your IP and domain name here.

You local DNS cache

There are two ways to find your IP address. One way is to use services such as Host2IP. You can also find your IP address from the Dreamhost panel. Look for IP in panel->manage domain->DNS

My DNS entries in DH

Please note that domain to IP adress translation is not static. This means your IP address can change! So use this technique only when you know that DNS server is down. Once it is back online, delete the entry from hosts file.
 

Dreamhost problems

This site is hosted on Dreamhost - the so called “employee owned” hosting company. Dreamhost hosting is cheap and their customer service is pretty good.  But lately they seem to having real problems with the infrastructure. Today they had the ultimate problem - all DNS servers were down for over 5 hours! It is pretty funny that a company which hosts 400,000 websites cannot keep their DNS server up!

Now the real fun is on the dreamhoststatus.com site. This is a blog by Dreamhost which tracks the problem affecting their services. Whenever something major happens with Dreamhost, you see a pattern of response from the customers. It is very predictable and at the same time very funny as well! :-)

John : help! All my servers are down! I am loosing all my customers. Why is this happening every day?

Anna: It is funny that this problem is rated as medium. Do you call an issue critical when the data centre is bombed?

John’s Mom: Shut the f* up John. You are on a shared server and it is damn cheap. Be happy with whatever crap you get.

Chris: I am happy with DH. Please fix the problem whenever you have time.

Lis : I am devastated. Today I got the biggest business and my client says the site is down.

Dreamhost fan: Hey Anna, your site is up. Where are you from? Looking for a date?

DH Guru : for (int i=0;i<400,000;i++) {nslookup i; print result;}. It seems still some sites are down. Maybe we all should go for advanced custom DNS solutions.

Mike: Hey check out Lunarpages. They have some good schemes and they might even kick some DH ass. I also recommend registerfly.

Susan : You all are gay.

Now the above conversation is almost identical whenever Dreamhost posts a problem. Names and the words used may change sometimes :-)

Ruby - A programmer’s best friend?

Ruby Programming Language

I have been really busy for last few days. On the professional front, I am looking for some challenge. Couple of interviews,  but I am still to find a better job.

The other thing that kept me busy was the Ruby programming language. I had gone through python language couple of months back and wasn’t much impressed. So when I started on Ruby, I was very skeptical and it seemed like some Japanese propaganda.

But 2 days of Ruby programming had me fully excited. You can  say I am on the “programmer orgasm”. Ruby is a very compact language and you will be amazed at the code reduction when you convert something to Ruby.

I will soon be writing a quick reference on Ruby for a Java/C++ programmer like I did with PHP. After a month of programming in PHP, I think it is a very badly designed language. I think PHP became popular due to two major reasons; Almost all web hosting providers support it. Also for a novice Web programmer, PHP was an ideal choice.

If you were to develop a Java web application, you had to study the entire J2EE stack. Then after that you find out that not many Web hosting providers give Java or JSP support!

Now that is where Ruby shines. Ruby on Rails is a Web application framework built on top of Ruby. Interestingly, Dreamhost provides Ruby on Rails support. I am yet to dig deep into Ruby on Rails, but from a couple of simple tutorials it looks very promising.

Learn english grammer from Jayson

I don’t claim to be a big expert on English, but still there are a couple of English grammer tidbits you can learn from me.

Being a software engineer automatically means that you are considered an expert in all fields. So yesterday my cousin asked me a question on english grammer. He asked,

“How do I change the following sentence to passive voice?”

I made a mistake

It was long time since I tackled such a difficult English grammer question. After thinking deeply for 5 minutes, I replied:

I was made by a mistake

Why you should look for simple solutions!

One of the most memorable case studies on Japanese management was the case of the empty soapbox, which happened in one of Japan’s biggest cosmetics companies.

The company received a complaint that a consumer had bought a soapbox that was empty. Immediately the authorities isolated the problem to the assembly line, which transported all the packaged boxes of soap to the delivery department. For some reason, one soapbox went through the assembly line empty. Management asked its engineers to solve the problem.

Post-haste, the engineers worked hard to devise an X-ray machine with high-resolution monitors manned by two people to watch all the soapboxes that passed through the line to make sure they were not empty. No doubt,they worked hard and they worked fast but they spent a whoopee amount to do so.

But when a rank-and-file employee in a small company was posed with the same problem, he did not get into complications of X-rays, etc., but instead came out with another solution.

He bought a strong industrial electric fan and pointed it at the assembly line. He switched the fan on, and as each soapbox passed the fan, it simply blew the empty boxes out of the line.

Moral : Always look for simple solutions. Devise the simplest possible solution that solves the problems.

Live free or Die hard - John McClane is back!

Die hard movie series is one of my favorites. It is always good to see someone kicking some serious “bad ass”. Now the latest installment in the series , Live free or Die hard is scheduled for release on 29th June 2007. Check out the following trailer. Seems to be pure action entertainment.

Some of you may say that using a car instead of a bullet to bring down a helicopter is too much, but hey he was out of bullets! Yeah, Bruce Willis is getting old and I don’t think we will see a Die hard 5 movie with him in the lead role.

Thankfully I didn’t watch Superman 3. It is a shame that such bad movies go on to become box office hits. I overheard a girl saying that “she cried towards the end” while watching Superman 3. Sigh… 

Grandha 2007 - book exhibition in Technopark

Grandha 2007US Technologies is organizing a book exhibition named “Grandha 2007″ in the new Thejaswini building in Technopark. This exhibition is open till 11th May. The stalls are open till 8PM. If you are in Technopark, this is worth a visit.

Whenever I talk about visiting a book exhibition, you should see the expression on my wife’s face. She knows that I spend without any limits when I go for a book exhibition.

But this time I made only few purchases. I bought an interesting book by Nicholas Corder titled “Escape from the rat race” (Jaico publishers - Rs. 125). It is about living a relaxed and contended life and getting out of the “work syndrome”. I will write a detailed review on this book soon.

Also I bought two CDs created by pebbles for children. These are nursery rhymes volume -1  and Aesop’s fables.  My daughter is too young to enjoy them now, but she likes the music. I think these CDs are of only average quality and the price of Rs.99 is a bit high.

Enabling single sign on - Web applications in WebSphere 6.0

Recently I came across a requirement to enable single sign on between two different Web applications running on different machines but on the same domain. WebSphere does provide out of the box support of single sign on, but figuring it out took a lot of time for me. So I have written this step by step guide so that you don’t have to go through the torture again!

All the screenshots in this guide are taking from Rational Application Developer (RAD). I could configure everything except “roles to groups mapping” directly from RAD’s console. For configuring “roles to group mapping” I had to export and deploy the application from an EAR file.

1. Enabling WebSphere security

Check out the following screenshot which shows the settings I have selected under Security->Global Security.

Global security settings

a) LTPA is required when the Web applications are on the different machines but on same domain.

b) I used a custom user registry which checked the users against a database. A more common approach is to use LDAP.

2. Click on the “custom” link under user registries in Security->Global Security. Following settings were selected on this page.

a) userid and password given is a valid user id in the database.

b) MyUserRegistry implements com.ibm.websphere.security.UserRegistry interface and is copied to the “classes” folder inside WAS home folder.

3. Click on “LTPA” under authentication mechanisms. Single sign on can be enabled by clicking on the “Single Sign On” link on the right.

The above three steps completes the “Global Security” setup on WAS. Now we will configure JAAS for applying this security at the Web application level.

1. Configure web.xml of the application. This involves protecting Web resources using security-constraint entry. Following is a sample entry,

    <security-constraint>
        <web-resource-collection>
            <web-resource-name>Protected Area</web-resource-name>
            <url-pattern>*.do</url-pattern>
            <http-method>DELETE</http-method>
            <http-method>GET</http-method>
            <http-method>POST</http-method>
            <http-method>PUT</http-method>
        </web-resource-collection>
        <auth-constraint>
            <role-name>operator</role-name>
        </auth-constraint>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>     
    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>MyApp</realm-name>
        <form-login-config>
            <form-login-page>/logon.jsp</form-login-page>
            <form-error-page>/logonError.jsp</form-error-page>
        </form-login-config>
    </login-config>

2. Implement a login page for application which conforms to WAS standards. Following is a sample page,

<html>
  <title>Login</title>
  <body>
  <form method=”post” action=”j_security_check”>
     Enter user ID and password:
     User ID: <input type=”text” size=”20″ name=”j_username”>
     Password: <input type=”password” size=”20″ name=”j_password”>
     <input type=”submit” name=”login” value=”Login”>
    </form>
</body>
</html>

3. While deploying bind web.xml roles with groups from UserRegistry. For simplicity you could also attach the entire role to “any authenticated user”.

Some common errors and their solution,

1. When I start RAD after enabling Global Security, it is in “starting” mode forever!

Open soap.client.props in base_v6\profiles\default\properties folder and add the userid and password fields as shown below. The userid/password must be the same as the one given on “custom user registry” page.

com.ibm.SOAP.loginUserid=test
com.ibm.SOAP.loginPassword=test

Run the following command on the command as shown. Replace the cell name and node name with the values on your machine. This reconfigures FileTransfer application with authentication.

D:\Rational\runtimes\base_v6\bin>wsadmin wsadmin.bat -profile redeployFileTransf
er.jacl -c “fileTransferAuthenticationOn machine97622Node01Cell machine97622Node01
 server1″ -user test -password test

2. I am getting the following error,

Authentication failed for user: com.ibm.ws.console.security.ConnectToRuntimeException: null nested exception is com.ibm.websphere.security.CustomRegistryException

This means that custom user registry is not loaded. Ensure that you restart RAD after copying custom user registry class. Also ensure that custom user registry class is under classes folder (base_v6\classes on RAD)

3. I have an error which is not listed above?

Check the trace.log inside base_v6\profiles\default\logs\server1 folder. This should give a lot of information about the underlying problem. If you are still unable to resolve the issue, contact me!

Pagination in DB2 database

Pagination is required when you develop a listing screen which has thousands of records. The best way to implement pagination is to leverage features available on the database. In an Oracle database you can use RANK() function. On a DB2 database you can use ROW_NUMBER() function. Following example shows how to implement pagination on a DB2 database,

SELECT * FROM
  (SELECT a.customer_name, ROW_NUMBER() OVER
    (ORDER BY a.customer_name) AS RN FROM customer a
    WHERE a.customer_status=’ACTIVE’
  )
X WHERE X.RN BETWEEN 0 AND 100

This method won’t work if you are using AS400. On AS400, the only way seems to be iterating through the entire result set and then picking up records needed for the screen. For example, if you want to show records 100 to 200, start from 0, ignore upto 100 and then populate records from 100 to 200 and then stop. Obviously this means that if the resultset is huge and if you navigate to the last page, it might take a lot of time.

Top 5 ways to love your wife

Blogging guru Darren Browse is currently running a group writing project called “Top 5“. He is offering $1001 for the best blog post on “Top 5″. With the rise in the value of rupee, $1001 is not worth much, but still will fetch a decent laptop. So I decided to give it a try.

Top 5 ways to love your wife

1. Listen to her - This is one of the most important things that husbands normally miss. Listen to your wife and it is something guaranteed to improve your family life! Here is a tip - don’t pretend to be listening, trust me, it won’t work.

2. Express your love - It is something which is easily overlooked in our busy life. But expressing your love is so much important for the warmth and closeness of a married life. You know, sex is good for your health and mind :-)

3. Share responsibilities - There is a saying that “a man is incomplete until he is married”*.  Giving your wife responsibilities is an effective way to show that you trust her. Also help her in taking care of babies or in kitchen work.

4. Respect her - “Respect” has an unique property. You give it, you will get it back. So if you expect respect from your wife, first show it to her!

5. Surprise her - There are a lot of ways to surprise her. Throw a surprise party, go on an unplanned vacation or just buy her a simple gift. The smile on her face is worth a million bucks!

After writing this I have decided to change what I planned to buy with Darren’s gift. I would probably buy an all paid family trip to singapore ;-)

*- the complete quote is “A man is incomplete until he is married. After that, he is finished.”

On good government employees

Government departments in India are notorious for laziness, corruption and what not. So whenever you approach any government department, you approach it with apprehension and uncertainty.  But sometimes you come across good people working at these places. It is so rare that it takes you by surprise!

Last week I needed to sent a registered post and I went to the post office in Vattiyoorkavu. When I reached there it was already 2PM and I asked the lady at the counter till what time I can send registered post. She replied - “1PM”.  Oops, I am late by 1 hour and I was about to leave when she replied - “Give it to me, I will process it” !

The way she processed my registered post automatically made me thank her - “Thank you ma’am”.

Running Debian on your Windows PC

In this article I will show you how you can convert your Windows XP machine to run linux distributions such as Debian without risking your partition table! You would be wondering what I mean by “risking your partition table!”. Well, last week I had installed Ubuntu on my Windows PC and it had replaced Windows boot loader with Grub. After a while I decided to remove Ubuntu. I opened up the disk administration tool in Windows and re-partitioned the disk to free up the space used by Ubuntu. Then I realized that my Windows system won’t boot anymore! I had use the “Windows recovery disk” and then issue a “fixmbr” to fix my system.

This week I decided to try out Debian and this time I decided to install it on a virtual PC running on top of Windows. This has many advantages. First, there is no risk of corrupting your partition table. Secondly, you can easily add or remove more distributions. Thirdly, your WiFi may not be recognized by Debian net-install, but NAT translation by VMware ensures that WiFi is accessible as ethernet! Another advantage is that you can easily switch to Windows if you want to watch TV on your “Windows only” TV tuner card! :-)

There two leading virtual pc softwares in the market. Microsoft virtual pc and VMware server. Both these are free! I prefer VMware since almost any OS works on it.

Download Debian

You can download Debian ISOs which range from 30MB to 12GB! I decided to download 30MB network install ISO, which is a very minimal ISO.  If you use this, the components required for a base system will be downloaded during installation through an ethernet network available for your virtual machine. Also ensure that you download an ISO suitable for your hardware. For me it was an amd64 version(64 bit AMD processor).

Installing VMware

You can download latest version of VMware server from here (about 150MB).  You would also need to register to get your free serial key.  VMware asks for this key at the last step of configuring a new OS!

When you startup VMware, first you get “connect to host screen”. Select “localhost” since you are not trying out remote hosts.

From the File->New Click on “Virtual Machine”. This is used to configure a new virtual machine to run a different operating system.

1. Select “custom” for virtual machine configuration.

2. Select “Other linux 2.6.x kernel 64-bit” as the guest operating system. If you are not using a 64-bit system,use “Other linux 2.6.x kernel”.

3. Now select the file and directory for the new OS. Ensure that you select a disk which has enough space for the new OS.

4. For access rights, you can decide to make it private (accessible only for your userid) and accept defaults for the startup/shutdown options. You will need to change it if your account doesn’t have administrator privileges.

5. Allocate 50% of your total RAM for the new OS. I have 2GB total RAM and allocated 1GB for Debian.

6. Use NAT for networking and create a new virtual disk and accept defaults (SCSI). Allocate enough space of the virtual disk. I have 8GB for Debian.

Now you need to configure the downloaded Debian ISO as a CD Drive so that Debian installer will start when you boot up your new virtual PC. For this edit the new virtual PC and change the CD configuration as shown below,

vmware-new-pc3.png

Now start your new virtual PC from VMware. Now you should see the following Debian boot console.

 VMware and Debian

Follow the prompts and complete the Debian installation. Debian will download the required components by connecting to internet. If you don’t want this, you can use the complete Debian ISOs (instead of the 30MB business card version).

After installation, the first package I installed was the command line internet browser “lynx” by issuing the command,

apt-get install lynx
 

Restarting my linux love - the debian way

I have dabbled in linux long time back but never took it seriously. But this week something triggered inside me and I have decided to give it another try. My cousin sunil is a linux guru and with his blessings I have restarted my linux love! :-)

But hey, I have no intention to chuck Windows out. After all I have paid over Rs.6000 for it! So instead I decided to use Vmware (which is a virtual pc server and is now free!) as my new machine and install Debian on it.  Check out the Debian social contract to see why I am interested in Debian.

Earlier when you run linux on Vmware it used to be slow. But not anymore! With my machine (amd64 with 2GB RAM) speed difference is hardly noticeable!  Another advantage is that with NAT networking on Vmware, your Wifi network will appear as an ethernet network for the virtual pc!  (Configuring WiFi on Debian business card ISO seems to be almost impossible).

So I downloaded business card version of Debian (33MB) and I am currently running the net-install from it.

Debian on Vmware

A thought provoking quote on driving

“Have you ever noticed that anybody driving slower than you is an idiot and anyone going faster than you is a maniac”
-  George Carlin

To me this was a real eye opener! :-)

Software to manage personal finance - acemoney lite

One  of the simplest software to manage personal finance is the Acemoney lite from MechCAD. If you don’t want all the fancy stuff offered by Microsoft money or similar tools, Acemoney is the ideal choice.

My basic need is to track all the expenses over a period of time and then analyze it to see where my money is going. For this purpose I found Acemoney extremely useful. You can also export your expense/income details as a csv file or XML file.

The installer itself is less than 2MB and there are no adware or spyware with Acemoney lite. Only limitation is that only one account can be created on the lite version. For me, that is not a limitation at all!

AceMoney Lite screenshot