Ehsanul Haque

Welcome to my personal site & blog

Archive for the 'Playground' Category

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!

11 December
0Comments

Take a Screenshot with iPhone 3GS

We are all used to taking screen shots for various purposes on a PC or Mac. In case if you’ve something on your screen you want to share with someone quickly, this is a handy feature. There are many other reasons why we would like to take a screen shot, to create a documentation or user manual for example.

As I am getting used to different features of my newly bought iPhone I discovered it also has the option to take screen shot. The process is very simple. Press the Sleep/Wake button (on top) with the Home button (at the bottom) together and your screen shot will be saved in the Camera Roll section of Photos application.

sspecs_controls_20090608

Source: Apple.com

I believe iPhone 3GS has lot more features and I will keep posting them as I explore.

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.

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.

05 March
1Comment

Turn off the feature of Google Toolbar to display web history on new tabs of Firefox 3 for Mac

The other day when I was browsing on my Mac (using Firefox 3) I noticed everytime I open a new tab it shows the recent websites I’ve visited and few more items under Google Toolbar title. At the begining I liked the idea. I thought it saves me time to type in URL of the sites I frequently visit. But this feature was not available on my PC.

Although I initially liked the feature, it started to bug me when I opened new tab in front of someone (visiting me – for example) and it was showing the cached page of my online banking. It actually cached the account detail page! I didn’t like the idea that if someone is looking over my shoulder will get to see my account balance.

Anyway I started digging into it to turn off that feature. Then I found it was something that needed to be turned off from Google Toolbar’s settings. So to turn it off go to Tools > Add-ons. It should take you to the Extensions tab. Click on the Google Toolbar for Firefox extension and then click on Preferences button. Preference window will start with Search tab and under “Web-browsing tools” section uncheck the option “Enable the Google new tab page”. You should now get back your homepage, whatever it is set to.

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.

15 May
2Comments

Setup sub-domain on the localhost

When I work on my local machine on a website, I usually setup the virtual host on a sub-domain setup on the localhost. I feel comfortable using a sub-domain rather than setting up an Alias. I’ve seen many people know about it, but there are many who don’t, and this is for them.

So what do you have to do to setup a sub-domain on the localhost? It is not a rocket science but one must know where to do it, especially on a Windows box.

On Windows OS browse to {Drive on which your Windows OS is installed}:/{WINDOWS/WINNT}/system32/drivers/etc/. Open “hosts” file into a text editor, and you will see something similar to this:

# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost

The last line represents the hop any request to http://localhost/ will go through. The IP 127.0.0.1 is used (usually) for you localhost, and going to http://localhost/ will access the files under the root of directory setup for it. Now if you want to setup a sub-domain called “myself”, i.e. http://myself.localhost/, then you add the following line at the end of the file.

127.0.0.1       myself.localhost

On a Linux box, “hosts” file is located under /etc/. You will require “root” access to edit this file or the user access who has priviledge to edit this file. Similar to Windows system, add the following line into the file:

127.0.0.1       myself.localhost

You don’t have to restart your web server for this change to take effect. But you will have to setup the virtual host to point to this sub-domain, which will require you to restart the web server.

Thank You.