Friday, January 25, 2008

Virtual Machines

This is an article I wrote for a magazine some time ago. I thought of publishing it here. Good for new programmers and computer science students.

In this article I’m going to discuss about what are virtual machines, their uses and the help we can get from them for our software development work. Even if you haven’t heard about virtual machines before, you may find them quite interesting when you get to know about them.

The term “Virtual” means something that does not physically exist. It’s something that allows us to interact with it in an imaginary sense. Consider playing a game. The game world does not really exist but it’s just a simulation that allows us to play in it. In the same manner virtual machines are machines (computers) that exist only as a simulation.

How to create a virtual machine

When you install the necessary software, you can create your own virtual machine on your real computer (on Windows or Linux). This virtual machine can have a RAM, hard disks, a BIOS and other configurations as you specify. Here are some virtual machine software that are currently available:

Commercial. Mainly used on Windows

VMWare Workstation
Microsoft Virtual PC

Free and open source. Mainly used on Linux

Virtual Box

Once you create the virtual machine you can install an operating system to it just as you would do in your real machine. Insert the operating system CD and boot the virtual machine. (The OS on the virtual machine is called the Guest OS. The OS on your real machine is called the Host OS.). You can see the screen of the virtual machine inside a window that appears in your virtual machine software. (See Figure 2)

The Uses

You may wonder what is the use of having a virtual machine on your computer. Well, the use is obvious. You could work on several operating systems at the same time without having to reboot your computer or moving to another real computer at a different physical location.

Suppose you are writing a software or a website on Windows and you want to test it on Linux. With a virtual machine, you can easily switch to the Linux machine (Just like in Figure 2) and test the software on that machine. Of course, modern virtual machine software support drag-n-drop facility so you can easily drag your files into the guest OS.


You can connect your virtual machine to a real network at your home or workplace. So the other machines on your network will see the virtual machine as a real machine. If you don’t have a network, you can create a small network between your real machine and the virtual machine. So you can test your software and do other network related stuff, just as you would on a real network (but no wires involved!).

You have nothing to loose…

Here is the best part about virtual machines. You don’t have to spend money to create them. So you can have any amount of memory or hard disk space you want on the virtual machine in a matter of few mouse clicks. (Of course, it is limited by the hardware configuration of your real machine). So you can experiment on the virtual machine without having to fear about breaking something or corrupting your operating system. If you break it, you can simply delete that machine and create a new one. It’s just simple as that.

So, begin digging. Test some virtual machine software and get a feel of it.

Madura English-Sinhala Dictionary

Madura dictionary can find english/sinhala synonyms of any english/sinhala word. Visit [URL Removed; see Update 2]. Great product.

Update 1
URL updated; thanks to a visitor comment.

Update 2
There has been some discussions in the user comments for this post stating that Madura and several other dictionaries are copied from the Thibus dictionary database. So I'm removing the link to Madura dictionary until I get to know the truth of this. Although I don't have access to Thibus dictionary, some idea can be gained by comparing the definitions of the free dictionaries available.

Wednesday, January 23, 2008

Vista Sinhala Typing Fix

Vista has built-in Sinhala support. But it has few problems when typing certain letters. This fix addresses those problems. Easy to install.

Link Updated:

This works on Windows 7 as well.

Sunday, January 20, 2008

Vista Hibernate problem fix

I think this is a bug in vista. Sometimes there is no way to hibernate the computer. Hibernate feature is gone. This can happen when you run disk cleanup. You can turn on Hibernate again by running this command in command prompt (Run as administrator).

powercfg /h on

Hibernate should appear in the shut down menu now.

if you don't want it, run:

powercfg /h off

Change Vista start menu power button action

By default vista start menu power button is set to "Sleep" mode (Indicated by Orange). That means when you click it, the computer does not shut down. It goes into sleep. This is pathetic and is cursed by most users. You can set the button to power off mode so when you click it, the computer actually shuts down.

1. Go to Control Panel -> Power Options.

2. You will see 3 power plans. Balanced, Power Saver and High Pwerformance. One of them should be selected.

3. Click 'Change plan settings' under the selected choice.

4. Click 'Change advanced power settings'.

5. Expand the category 'Power buttons and lid' and expand 'Start menu power button' section.

6. Change action to 'Shut down'. If you are using a laptop, select 'Shut down' for both 'On battery' and 'Plugged in' states.

7. Click OK.

That's it. Now the start menu power button should appear in Red. When you click it, the computer will shut down.

Saturday, January 19, 2008

Ubuntu Gutsy: Getting compiz-fusion working under ati fglrx driver

First of all I have to say compiz-fusion is really cool! And with Gutsy we don't have to play with custom scripts for xserver anymore. Getting it working is so easy.

Follow these steps:

1. Refresh your package list using Synaptic.

2. If you haven't done so already, select and install package "xorg-driver-fglrx" and Restart the computer.

4. Select and install package "xserver-xgl".

5. Ubuntu will notify that the xserver setup has changed. Restart the xserver using Ctrl+Alt+Backspace.

Compiz-fusion should be working now. To check, go to System -> Preferences -> Appearence -> Desktop Effects and select Normal or Extra effects.

Installing compiz settings manager

The standard appearance dialog box doesn't allow custom configuration to compiz visual effects. You have to use Compiz settings manager for advanced customizations and for some extra cool effects.

1. Using Synaptic, select and install package "compizconfig-settings-manager".

2. To access settings, Click the "Advanced" button in Desktop effects tab.


Monday, January 14, 2008

C# 3.0 Extension Methods

The new extension feature in C# 3 allows us to add New definitions to existing classes. In other words, we can introduce new methods to any class without inheriting our own type from it.

For an example, take the String class. This calss already has some methods for string manipulation like Split(), Trim(), .... Suppose we would like to add a new feature to the String class, like GetWordCount() so we could use it like this:

string str = "The new feature";
int words = str.GetWordCount();

Note that we have not created a new type. We are using the same old String class but with a new member method. We can achieve this by extension method.
static int GetWordCount(this string s)
//Word count logic goes here
return count;
This method can be inside any class. The only thing matters is in what namespace the method is. If the GetWordCount method is in a namespace called MyExtensions, you can load the extension by adding the using directive like:

using MyExtensions;

So the String class will appear to have an extra method called GetWordCount whenever you use this namespace.

Refer to MSDN for better in-depth article.

Visual Studio 2008

Visual Studio 2008 is now available. These are the download link for free editions:

Visual Studio Express 2008 (900 MB ISO Image All-in-one DVD)
(go to the link at the bottom of the page)

MSDN 2008 (2GB), MSDN Express 2008 (300MB)

.Net Framework 3.5 redistributable package (197MB)