Ehsanul Haque

Welcome to my personal site & blog

Archive for March, 2009

13 March
1Comment

Letter to Employees

Dear Employees,

Due to the current financial situation caused by the slowdown in the economy, Management has decided to implement a scheme to put workers of 50 years of age and above on early retirement.

This scheme will be known as RAPE (Retire Aged People Early).

Persons selected to be RAPED can apply to management to be considered for the SHAFT scheme (Special Help After Forced Termination).

Persons who have been RAPED and SHAFTED will be reviewed under the SCREW programme (Scheme Covering Retired-Early Workers).

A person may be RAPED once, SHAFTED twice and SCREWED as many times as Management deems appropriate.

Persons who have been RAPED could get AIDS (Additional Income for Dependants & Spouse) or HERPES (Half Earnings for Retired Personnel Early Severance).

Obviously persons who have AIDS or HERPES will not be SHAFTED or SCREWED any further by Management.

Persons who are not RAPED and are staying on will receive as much SHIT(Special High Intensity Training) as possible. Management has always prided itself on the amount of SHIT it gives employees.

Should you feel that you do not receive enough SHIT, please bring this to the attention of your Supervisor, who has been trained to give you all the SHIT you can handle.

Sincerely,

Management

PS
Due to recent budget cuts and the rising cost of electricity, gas and oil,as well as current market conditions, the Light at the End of the Tunnel has been turned off. We apologize for the inconvenience

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.