I am going use Windows 7 for the next two weeks as my primary operating system to give it a chance and to be fair. I will post my likes and dislikes in two weeks. Who knows, I might turn into a Microsoft fanboy in two weeks. Yeah. Fat chance.
Wiki to go…
TiddlyWiki is a great way to organize information such as notes, links, figures, etc. in a portable and editable manner without requiring full blown office software or a web server. The entire wiki is contained in a single file and all you need to view or edit it is a web browser. This is a great way to carry your notes around with you. I have a copy of TiddlyWiki on my phone, for example.
Reading BIOS information in Linux
A lot of information about a personal computer is stored as part of the BIOS and can be retrieved using data structures defined in the SMBIOS specification. On Linux operating systems, this information can be easily viewed using the dmidecode utility. This allows one to look up information such as system manufacturer, model name, serial number, BIOS version, asset tag, etc. Here is some sample output of this command running on a Lenovo ThinkPad:
[pagey@thunk]$ sudo dmidecode --string system-version
ThinkPad SL410
[08:36:24][~]
[pagey@thunk]$ sudo dmidecode --string system-serial-number
LRX4278
The dmidecode package includes some other handy utilities such as biosdecode, ownership, and vpddecode. No need to turn the laptop upside down just to look up the serial number or model number.
[pagey@thunk]$ sudo vpddecode
# vpddecode 2.9
BIOS Build ID: 6JET69WW
Box Serial Number: LRX4278
Motherboard Serial Number: 1ZNKE9A6206
Machine Type/Model: 28427PU
Mathematical Equations in WordPress
There are several WordPress plug-ins available for including mathematical formulas in WordPress articles. However, a lot of these plug-ins require that LaTeX be installed on the server. This is not an option for my site as I am using GoDaddy’s (cheap) shared hosting plan where I do not have root access. This is where the PHP-based WP Math Pub plug-in comes in very handy. Even though the quality of equations generated by this plug-in is not as good as LaTeX, it is still quite respectable. Needless to say, it does not require LaTeX and does most of its work in PHP. Here are a few examples:

![f(x)~left~ sum{kappa=1}{infty}{delim{[}{{1/(x_kappa)^kappa}}{]}} f(x)~left~ sum{kappa=1}{infty}{delim{[}{{1/(x_kappa)^kappa}}{]}}](http://pagey.info/wordpress/wp-content/plugins/wpmathpub/phpmathpublisher/img/math_924.5_986e795be329dce8f55319c5664f5184.png)
Pretty nice, eh?
Check if a TCP port is in use on Windows
A combination of netstat and findstr commands can be used on Microsoft Windows to check if a specific TCP port is being used by another application. For example, to check if any application is accepting connection on port 80 use the following command:
netstat -aon -p tcp | findstr ":80 " | findstr "LISTENING"
Here is a sample output of this command when a web server is running on the machine:
C:\Documents and Settings\pagey>netstat -aon -p tcp | findstr ":80 " | fi
ndstr "LISTENING"
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 2724
See the Window XP command line reference for more information regarding the netstat and findstr commands.
This is equivalent to the following Linux command:
netstat -ant | grep 80 | grep LISTEN
The output of the Linux command looks something like this:
[pagey@thunk]$ netstat -ant | grep ":80 " | grep LISTEN
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN
Clearly, Linux is superior in this case (okay, that was unnecessary).
Preventing RDC Timeouts
So, a client provides you with remote access to their network via (ughh) Microsoft Remote Desktop Services. As a die-hard Linux user, you launch tsclient to connect to their network and all is good. Right? Alas, when you start doing some real work, you soon realize that the session timeout for the Microsoft Remote Desktop Services is set to a couple of nanoseconds; you blink and your session is over. You can try to remember and visit the remote desktop window every once in a while and press a random key to keep the session alive. But that cannot work for long. Fortunately, Linux has an easy solution to all your problems. In this case, the xdotool utility can be used to automatically send a harmless keystroke to the remote desktop window at regular intervals, pretending that you are doing real work. I use the following script to keep the session alive all day long. This script sends the XF86KbdLightOnOff key to the remote desktop every 60 seconds. This key does not mean anything to most applications you are likely to run on Microsoft Windows. So it will not affect any real work that you might actually be doing (fat chance). Enjoy. (P.S. Please see a doctor immediately if your session lasts for more than four hours.)
#! /bin/bash
export DISPLAY=:0.0
export PATH=/usr/bin:/bin:$PATH
CURRWID=`xdotool getwindowfocus`
RDPWIN=`xdotool search --class rdesktop`
while true
do
if [ "x$RDPWIN" != "x" ]
then
for window in $RDPWIN
do
xdotool windowfocus $window
xdotool key "XF86KbdLightOnOff"
done
xdotool windowfocus $CURRWID
fi
sleep 60
done
Putting date and time into Linux clipboard
While entering notes on Trac or during meetings or commenting code, I find it useful to quickly enter a time stamp in the text. Some text editors have built-in support for entering a time stamp using a keyboard shortcut while many do not. In order to have a uniform/consistent way to enter time stamp in any application, I prefer having a global keyboard shortcut, Ctrl-Shift-T, that places a time stamp in the Linux clipboard. I can then paste this time stamp in any text editor (or a text field in a web browser, for example). As I switch between Gnome and KDE all the time, I wanted to have a way to do this without using any desktop-specific features. The following script does the job pretty well:
#! /bin/bash
/bin/date +"%Y-%m-%d-%H:%M:%S-%Z" | /usr/bin/xsel -b -i
Processing outdoor pictures using Gimp
Gimp is an extremely powerful and useful tool for processing digital images. I have been using it to process my pictures from hiking and backpacking trips for almost twelve years now. However, I did not know about many of its features till I started using it to process raw images from my Nikon D90 camera. Gimp can import Nikon raw images via the ufraw plugin. After this, several built-in functions and plugins may be used to process the image for color correction, sharpness improvement, white balance, etc. After reading through several techniques on the web, I have created a Python-based Gimp plug-in that does a fairly good job on most outdoor images. In many cases the images may appear overly saturated but these can be manually corrected. This plug-in allowed me to batch-process over 2000 images in just about a day on my MacBook Air. I will post the code for this plug-in and usage instructions in a separate article. Meanwhile, here is a sample. The “before” image was obtained by importing the raw image into Gimp with the camera’s default settings. The “after” image is the output of the new plug-in.
Python for Window$
I use Python programming language for a lot of scientific work and projects. Even though I do most of my work on either Linux or Mac OS X, occasionally I come across cases where a client uses Microsoft Windows. Installing Python and external modules such as PyQt4, Matplotlib and NumPy on Windows can be painful as compared to Linux. Recently, I came across a Python package for Microsoft Windows that bundles a large number of Python modules that are useful for scientific research. This package is called Python(x,y) and is released under GPL. You can download a free copy of this package from here. This package can make Python programming lot easier on Microsoft Windows. Please beware of Windows because it sucks.



