Ehsanul Haque

Welcome to my personal site & blog

Archive for the 'Interest' Category

18 January
0Comments

Tricks for MS Excel: Add a frozen header row and set alternate background colors for rows

Here are couple of tricks for MS Excel users.

First we take a look at how to add a “Frozen” header row. Frozen header row is the one you could have for a very long worksheet. This row will be frozen (to act as the column header) and rest of the rows will scroll. Here’s how to do this.

1. Select the row below the one you want to be the header (or be frozen)

2. From Window menu select Freeze Panes (for MS Excel 2007 click on the View tab and inside Window panel click on Freeze Panes and pick the first option which is also Freeze Panes)

The frozen row will have a border at the bottom. Simple but an essential option for MS Excel users.

Second trick is the alternate background color for rows in the MS Excel worksheet.

1. Select the rows

2. From the Format menu go to Conditional Formatting (or in MS Excel 2007 under Home tab click on Conditional Formatting from Styles panel and click on New Rule)

3. When the window appears select Formula Is… (or on MS Excel 2007 select the last option Use a Formula to Determine Which Cells to Format)

4. Add this formula: =mod(row(),2)=1

5. Then click on Format button and go to Fill tab

6. Pick the color that will be used as the alternate color

7. Hit OK and go back to the worksheet

You will see the worksheet has alternate background colors.

12 January
0Comments

Grab Yahoo class is in “coma”

Grab Yahoo class was one of my works that has been used by many people around the world. Since I released this class I did  not have a single month without comments or questions or suggestion about this class. Some people have copied the class, released it under their name (simply taking out my comments and added their own) to increase traffic to their site probably. But more importantly this class was appreciated by many. This was one of my finest contribution to the open source world.

How did I come up with this idea?

Well, I cannot remember which user group but in one of the groups I participate in had a discussion over if PHP can pull data off from places like Yahoo and use it for some purpose. Users on the group said this can be done (easily) with Java, but cannot be done with PHP. So I started researching over it. I found the cURL extension for PHP which seemed the good candidate to do the job. So I started working on it. After days of coding I finally wrote a script that will allow someone to login to their Yahoo account and fetch data from their address book. Initially I simply had a script but then I converted it to a Class allowing people to grab their address book, messenger list, number of new emails and calendar data.

What is happening now?

As per the title of this post this class is in “coma”. The reason is the update to Yahoo address book export mechanism. They have placed a CAPTCHA validation page in the export feature and, therefore, my Grab Yahoo class cannot go any further to grab the content it needs. Same thing happened with the LinkMeIn class which stopped working after LinkedIn added the CAPTCHA validation.

Why is this class in “coma”?

I have looked at the Yahoo address book export feature and found the CAPTCHA validation which will not allow the class to work. But I’ve not done my complete research on it yet, to make sure there is no other way to make this class functional. So, for the time being, this class is in “coma”. If I fail to revive this class I will probably officially pronounce it “dead”.

Can you help?

Yes, of course, you can. I hardly have time, these days, to sit with these side projects. If anyone from the community has time to research and help me revive this class it will be appreciated. Your name will go into the credit section of the class, well that is all I can offer!

30 November
0Comments

Import contacts from Blackberry to iPhone 3GS

If you are switching from Blackberry to iPhone 3GS, you must be trying to import all your Blackberry contacts to iPhone 3GS. When I switched to other phones before I always copied all my contacts to SIM and import them to the new phone. Most of the time the format would be different for the phones so you will end up editing the contacts. But with Blackberry to iPhone 3GS the process was really simple and clean.

I downloaded Blackberry Desktop Manager on my Mac Book Pro. After installing the BDM I had to reboot my Mac. After Mac restarted I plugged in my Blackberry on USB and started BDM (Blackberry Desktop Manager). Synced the contact with my Mac Address Book. After it was done I plugged in my iPhone 3GS with Mac and synced it using iTunes.

In few minutes and with few easy steps I’ve all my contacts on iPhone 3GS from Blackberry. I didn’t try to do it on my PC but I believe the process will be close to Mac, if not similar.

Enjoy!

06 November
2Comments
16 September
3Comments

Wordpress Plugin: Recently Updated Pages

Today I’ve released a Wordpress plugin called “Recently Updated Pages” which is a Wordpress Widget that displays your recently updated page list on the sidebar.

I was looking for a similar plugin but after searching for a while I wanted to write my own plugin. I followed some instructions on couple of websites and created this plugin. It uses WP_Widget class from Wordpress core and extends it to build the widget. You can download it form Wordpress Plugin page at http://wordpress.org/extend/plugins/recently-updated-pages/

In case if you want to make a small donation you could do so at http://resource.bdwebwork.com/WordpressPlugins/RecentlyUpdatedPages/

Thanks

UPDATE AS OF SEPTEMBER 17, 2009:

I’ve updated the plugin and committed the latest version (1.0.1) to Wordpress plugin directory. The updated version will allow users to include list of blog Posts in the Recently Updated list. Originally the plugin only displayed list of updated Pages and now with this optional choice you can toggle between the option.

25 June
1Comment

Others may forget you but never will I….

3659975703_5aa2a99de3

When night comes then sleep comes,
When sleep comes then dream comes,
When dream comes then you come,
But when you come then sleep and dream never come,
Give a little love, have a little hope,
Make this world a little better,
We can do it together,
And we can make it better only if we try,
People laugh and cry!
Some giveup, Some will try !
Some Say hi while Some Say bye !
Some honest others lie !

Others may forget you but never will I….

- Tithi forwarded me this poetry back in 2002 …. suddenly found it in one of my old documents!

22 June
0Comments

How to delete a locked file in Windows?

Sometimes when you try to delete a file on Windows it says file cannot be delete as it is used by another program; you must close the program to delete the file. Well, almost all the time you actually know which program to close in order to delete the file (also rename the file). But today when I tried to delete a file (which was not open in any program nor did I use this file for over three months) Windows was showing the message. You cannot really say which program or process is using it. So I downloaded Process Explorer from Microsoft’s site which you can use to see which process or program is using the file you are trying to delete.

After you run the Process Explorer go to “Find” menu and click on “Find Handle or DLL …” (Ctrl+F). Type in the file name (full or partial) you are having trouble deleting or renaming and hit Search. Process Explorer will list all the processes or programs using this file. When I searched for the file I was having problem with it showed that the “Explorer” is using it! So what can I do in that case?

From “Task Manager” if I kill the “Explorer” process I cannot browse to the folder so using “Task Manager” I ran “Command Prompt” and from command line I changed directory to the desired location. Typed the command to delete the file “del filename.ext”. I was able to delete the file and then using “Task Manager” I started “Explorer” again. It was easy but “Process Manager” made it easy to find the process. So many hidden stuff that we have on Windows!

13 March
1Comment

“sed”: Find and Replace Command on Linux Command Line

Sometimes we use IDE to find and replace strings in our file(s). IDEs have features to search for a keyword in all the files in a directory and replace with a given string. When you’re on Linux and using command line you can easily do this using the command “sed”.

According to the linux manual (man sed) “sed” is a stream editor which is used to perform basic text transformations on an input stream. With this command you can efficiently find and replace text in one or multiple files or you can keep the original file and make a new file with the replacement text.

To find and replace text in the original file the command is:

sed -i 's/find/replace/g' original.php

In the command above, “-i” option instructs to edit file(s) in place. “s” command attempts to match the pattern space against the supplied “find” string (which is a regular expression pattern). If the match is successful, then that portion of the pattern space which was matched is replaced with “replace” text. “g” is used to specify a global change, i.e. the string will be changed everywhere in the file(s) where it finds them. As mentioned earlier the “find” string is basically a regular expression pattern, and the replacement may contain special character (&) or escapes (\1 through \9) to refer to the corresponding matching sub-expressions in the “find” regular expression.

To find text in a file and output to a different file with the replacement the command is:

sed 's/find/replace/g' original.php > replaced.php

In the last command if you do not specify the output filename, it will simply show the file content on the screen with replaced string. There’s another command (similar to “sed”) which can be used for the same purpose is from perl.

perl -pi -e 's/find/replace/g' original.php

This command will find the word “find” and replace with the word “replace” in original.php. For this command “-p” option assume a loop like “while (<>) { …. }” (which is similar to the option -n but it prints the lines as well). The following option “i” performs the same task as it does for “sed”. Then “-e” says anything after it is a online of program. According to the manual several “-e program” can be used.

29 January
1Comment
22 August
1Comment

Photography

It has been a long time since I posted something. Anyway, for past few months I have grown a new hobby – photography. Last year when I went to Bangladesh, I bought a Fujifilm FinePix S9600 SLR camera. I have not had too many chances to use it until I went to Québec City. I enjoyed shooting photos there, but the picture quality wasn’t that good. Since then I started reading the manual whenever I could; try the tricks and tips on the camera.

My creation

I am still learning and sharing my photos on different groups on Flickr. My photo gallery is http://www.flickr.com/photos/ehsanul/ and I have joined few groups related to Bangladeshi photographers. These days people are making comments on my pictures, tagging my pictures as their favorite etc. These are really inspiring.

Trying to learn more from the pictures everyone uploads. It is nice to see how people openly share their creativity with the world and the power of internet has brought us closer. We can now share, learn, teach and do everything, which was probably impossible about 15 or 20 years ago.

Photography has become my hobby, and feel that it will become my passion very soon. Whenever I go out, I try to take my camera with me. I also have a point and shoot camera so that I can carry it wherever I am going. But overall the experience is cool. When I take a good shoot, it makes me feel great. Sometimes one or two pictures turn out good among ten or fifteen shots I take. Even that feels great, because one good shot pays off.