amy's lab

June 28, 2008

Virtual CD-ROM

Filed under: Utilities — Tags: , — amy @ 42

Recently, I downloaded a huge .iso image.  I didn’t have a blank DVD handy.  Instead of rushing to the store to buy a blank DVD, I used Virtual CD-ROM from Microsoft.  It is very easy to use.

The program runs on Windows XP Home or Windows XP Professional.  I don’t have Vista.  So I don’t know if it works.

1. Download Virtual CD-ROM from Microsoft.

2. Run the exe.

3. Follow the instructions in README.TXT.

Eventually, the .iso image will be mounted to a drive and you can click the setup program to install whatever program is on the .iso image.

Here is the content of the README.TXT.

Readme for Virtual CD-ROM Control Panel v2.0.1.1

THIS TOOL IS UNSUPPORT BY MICROSOFT PRODUCT SUPPORT SERVICES

System Requirements
===================
- Windows XP Home or Windows XP Professional

Installation instructions
=========================
1. Copy VCdRom.sys to your %systemroot%\system32\drivers folder.
2. Execute VCdControlTool.exe
3. Click “Driver control”
4. If the “Install Driver” button is available, click it. Navigate to the %systemroot%\system32\drivers folder, select VCdRom.sys, and click Open.
5. Click “Start”
6. Click OK
7. Click “Add Drive” to add a drive to the drive list. Ensure that the drive added is not a local drive. If it is, continue to click “Add Drive” until an unused drive letter is available.
8. Select an unused drive letter from the drive list and click “Mount”.
9. Navigate to the image file, select it, and click “OK”. UNC naming conventions should not be used, however mapped network drives should be OK.

You may now use the drive letter as if it were a local CD-ROM device. When you are finished you may unmount, stop, and remove the driver from memory using the driver control.

June 26, 2008

Watching ESPN 360 Video in Ubuntu

Filed under: Using Linux Exclusively — Tags: , , — amy @ 51

In Ubuntu, if you go to the ESPN 360 website, it will tell you that the video player is only available for Windows and Mac. What to do? Before ESPN 360 released a new version of Move Media Player, I was able to watch videos in Ubuntu by doing the following:

  • Install Wine
  • Install Firefox for Windows.
  • Use Firefox for Windows to go to the ESPN 360 website and install Move Media Player plugin.

Recently, ESPN 360 released a new version of Move Media Player which is incompatible with Wine 1.0. When I played video using the new player, it made the entire screen black. I had to do a hard reboot.

This is one of the reason I have to keep Windows around. Somethings just won’t work in Linux :(

June 22, 2008

Running Ubuntu in Windows (Using VirtualBox)

Filed under: VirtualBox — Tags: , , , — amy @ 47

Continuing with my exploration of Ubuntu…

I want to run Ubuntu as a guest operating system in Windows XP so I can easily switch between the two. To do this, I have three options:

  1. I have used VMware Workstation before. But since it is not free, I can only use VMware Player.
  2. Use Microsoft Virtual PC.
  3. Use VirtualBox.

I chose to use VirtualBox because it is open source. I can look at the source code and figure out how the software works.

I am using:
- VirtualBox 1.6.2
- Ubuntu 8.0.4

1. Create a new VM.

The VirtualBox User Manual is very helpful. It was easy to create a new VM. VirtualBox stores the VMs in C:\Documents and Settings\<user name>\.VirtualBox. The location can be changed in VirtualBox Preferences. I used mostly the default settings with the following exceptions:

  • Base Memory Size: 512 MB.
  • Video Memory Size: 8 MB.
  • Hard Drive: 8 GB.

2. Specify the location of the Ubuntu Installation files.

Mount the Guest CD/DVD-ROM to point to the Ubuntu .iso image or if using the Ubuntu CD, point to the Host CD/DVD-ROM drive.

3. Start the new VM to install Ubuntu.

When the new VM is started, it will boot from the CD-ROM drive and start the installation process. Just follow the steps. At the end of the installation, it would reboot the VM.

4. Install Linux Guest Additions

  • Click the “Devices | Install Guest Additions…” menu. It would automatically mount VBoxGuestAdditions.iso in C:\Program Files\Sun\xVM VirtualBox. If it doesn’t, mount it manually.
  • Open a Terminal Window in Ubuntu.
  • Go to the cdrom directory.
    • cd /cdrom
  • Run the VBoxAdditions file.
    • sudo ./VBoxLinuxAdditions.run
  • It would install all guest additions. Restart Ubuntu after the installation.

After Ubuntu is restarted, the VM window is larger and the screen resolution is higher. Mouse integration will automatically be enabled. If you want to auto-resize the guest display, enable the “Machine | Auto-resize Guest Display” menu item.

I think this is cool.

June 21, 2008

C# region / endregion

Filed under: C#, How Not To Program — Tags: — amy @ 26

Use #region sparingly. Do not use #region inside a method.

From MSDN website:

#region lets you specify a block of code that you can expand or collapse when using the outlining feature of the Visual Studio Code Editor.

When I write code, why should I care how it will be displayed in the Visual Studio Code Editor? Again, like Partial Class, I think #region is unnecessary and open to abuse. With #region, I could write code like this:

class BigClass
{
    public void BigMethod(int val)
    {
        #region Perform Logic on X
        // begin to write 100 lines of code
        #endregion

        #region Perform Logic on Y
        // begin to write 100 lines of code
        #endregion

        #region Perform Logic based on val
        switch (val)
        {
            case 1:
                #region Handle Case 1
                // write 100 lines of code to handle case 1
                #endregion
                break;
            case 2:
                #region Handle Case 2
                // write 100 lines of code to handle case 2
                #endregion
                break;
            case 3:
                #region Handle Case 3
                // write 100 lines of code to handle case 3
                #endregion
                break;
            default:
                #region Handle the default case
                // write 100 lines of code to handle the default case
                #endregion
                break;
        }
        #endregion
    }
}

As you can see, the method could get really long. If used with Partial Class, the class could get really big. It would be a nightmare maintaining code like this.

Use #region sparingly. Do not use #region inside a method.

C# Partial Class

Filed under: C#, How Not To Program — Tags: — amy @ 54

Do not use Partial Class.

From MSDN website:

It is possible to split the definition of a class or a struct, or an interface over two or more source files. Each source file contains a section of the class definition, and all parts are combined when the application is compiled.

So I could have something like this:

// BigClass1.cs
public partial class BigClass
{
    // put lots of methods, properties, etc here.
}

// BigClass2.cs
public partial class BigClass
{
    // put lots of methods, properties, etc here.
}

...

// BigClass50.cs
public partial class BigClass
{
    // put lots of methods, properties, etc here.
}

Obviously, it is really hard to maintain code like this. It’s hard to see what methods, properties, etc. are in a class. Although you can use the method drop down in Visual Studio to see all methods, it is still hard to find a particular method when the drop down contains many methods. What happens if you don’t have Visual Studio around and have to use a simple text editor?

Do not use Partial Class.

June 20, 2008

Removing Ubuntu

Filed under: Using Linux Exclusively — Tags: , — amy @ 49

I find it cumbersome switching between Windows XP and Ubuntu. So I decided to remove Ubuntu. Here is how I removed Ubuntu.

1. Use MbrFix.

2. Reboot.

  • It should automatically reboot to Windows.

3. Insert GParted CD into CD Drive and reboot.

You can create the CD by going to the GParted website.

4. Use GParted to remove Linux partition and create new partion on the old Linux partition.

  • I had problem formating the new partition in GParted. So I created the new partitions using Windows Disk Utility. Maybe I didn’t have to use GParted.

5. Reboot.

June 14, 2008

WineHQ

Filed under: Using Linux Exclusively — Tags: , , — amy @ 57

I wanted to see if I can still watch videos on my favorite websites in Ubuntu. Those websites require plugins to play videos. Unfortunately, the plugins do not work in Linux. Luckily, there is Wine. This is how I was able to watch videos in Ubuntu.

  1. Install Wine.
  2. Install Firefox (Windows version).
  3. Run Firefox (Windows version).
  4. Go to the website.
  5. Install the plugin that is needed to play video.
  6. Restart Firefox.

Installing Ubuntu 8.04 with Windows Dual-Boot

Filed under: Using Linux Exclusively — Tags: , — amy @ 39

Is it possible to use Linux exclusively?

To find out, I need to install Linux first. I chose to use Ubuntu. My laptop has Windows XP Pro. This is how I installed Ubuntu 8.04.

Create Ubuntu CD.

  1. Download Ubuntu iso image.
  2. Use ImageBurn to burn the iso image to CD.

Prepare Windows Partition.

  1. Backup important files.
  2. Disable virtual memory.
  3. Disable hibernation.
  4. Run Windows Defragment Tool to move data to the beginning of the partition.
  5. Run chkdsk.

Partition the hard drive.

  1. Download GParted iso image.
  2. Use ImageBurn to burn the iso image to CD.
  3. Boot from GParted CD.
  4. Resize the Windows partition to make room for the Linux partition.
  5. Create Linux partition.

Install Ubuntu.

  1. Boot from Ubuntu CD.
  2. Just follow the installation instruction.

After the computer is rebooted, it will have a menu that allows you to choose which operating system you want to use.

References

[1] Creating a Dual-Boot Windows XP and Ubuntu Laptop
http://www.linuxdevcenter.com/pub/a/linux/2006/05/08/dual-boot-laptop.html

[2] Moving the Unmovable: Windows Disk Defragmentation Strategies
http://lyratechnicalsystems.com/?p=9

[3] GParted website.
http://gparted.sourceforge.net/
http://gparted.sourceforge.net/larry/resize/resizing.htm

[4] The Perfect Desktop – Ubuntu 8.0.4 LTS
http://www.howtoforge.com/the-perfect-desktop-ubuntu-8.04-lts-hardy-heron

Blog at WordPress.com.