Nowadays, it is easy to register a domain and find a hosting company to host it. The hard part is coming up with the name. I tried several times before finding a domain that hasn’t been registered yet. I didn’t want anyone to register it and I didn’t want to pay the full price of monthly web hosting service because my website was not ready. I found the perfect solution. 1 & 1 Internet. Domain registration only costs $6.99 a year. In addition, I get many things like emails, private domain registration, a 5-page website, etc. 1 & 1 Internet also offers Linux and Microsoft web hosting. The price looks pretty good, although I haven’t tried it.
August 10, 2008
August 7, 2008
NBC Olympics 2008 Website - No Support For Linux
I was very disappointed to see this when I went to the NBC Olympics website. Companies still focus only on Windows and Mac. I was wondering if I could use Wine. When using Windows, the website requires Silverlight 2.0 (beta?). The executable is Silverlight.2.0.exe, but I thought Silverlight is still in beta. A search on Wine AppDB reveals that Wine doesn’t support Silverlight.
August 5, 2008
C# Partial Class - Code Generation
I found C# Partial Class to be very useful in code generation. I could create a new class with the same class name and add my custom methods to that class, without having to worry about the code generator erasing what I wrote. Before, code generators usually put some special tags in the code to identify an area where only the code generator can modify. This is fine, but sometimes, either the code generator or the developer would make mistakes and make the code uncompilable. With C# Partial Class, I could have something like this:
// MyClassGen.cs - this is generated.
// The file ends with "Gen" to denote a generated class.
public partial class MyClass
{
// put generated code here
}
// MyClass.cs - this is where I add my custom methods
public partial class MyClass
{
}
This probably would be the only time that I would use C# partial class.
July 13, 2008
Installing RealPlayer in Ubuntu
How to install RealPlayer in Ubuntu 8.0.4 and play RealPlayer video in Firefox 3.0.
1. Download RealPlayer
- Go to http://www.real.com/linux and download the RealPlayer11Gold.bin file.
2. Make RealPlayer11Gold.bin file into an executable file.
- Open a Terminal window.
- Navigate to the directory that contains the bin file. For example:
-
cd download
-
- Make the bin file into an executable file.
-
chmod +x RealPlayer11Gold.bin
-
3. Run the bin file
-
sudo ./RealPlayer11Gold.bin
- Accept the default values by pressing the Enter key.
- By default, RealPlayer will be installed in /opt/real/RealPlayer
4. Setup RealPlayer
- In the “Application” menu, select “Sounds & Video | RealPlayer 11″
- It will display the RealPlayer Setup Assistant. Just follow the setup instructions.
5. In Firefox, go to a website and try to play a .ram file.
- If you don’t know a website, you can skip this and go to the next step.
- After it downloaded the .ram file, Firefox will ask you what program to use to open the file. The default selection is “/opt/real/RealPlayer/realplay”. Enable the checkbox: “Do this automatically for files like this from now on”. This will add a new Content Type to FireFox’s settings. We’ll need to change it later. Even though I told it to use RealPlayer, Firefox will use the Totem Movie Player. So we have to manually configure it in Firefox.
- Open the Firefox Preferences Dialog. Select the “Applications” button at the top. In the “Content Type” column, find the RealPlayer content type. It should have something like “RA file” or “RealPlayer document”. In the “Action” column, select “Use other…”. Browse to select the RealPlayer program which is “/opt/real/RealPlayer/realplay”. After the program is specified, it should display “Use realplay” in the “Action column”. Close the Preferences Dialog.
- Try to play the same .ram file again. It should automatically use RealPlayer to play the video. If it doesn’t work, restart FireFox.
6. Setup Firefox to play embedded RealPlayer file.
- Type “about:plugins” in the Firefox address bar. Find the RealPlayer plugin. Note that it uses Totem player.
-
Helix DNA Plugin: RealPlayer G2 Plug-In Compatible (compatible; Totem) File name: libtotem-complex-plugin.so The Totem 2.22.1 plugin handles video and audio streams.
-
- I don’t know why the RealPlayer setup program didn’t install the RealPlayer plugin in Firefox. Since we don’t want to use Totem player, we have to remove the plugin.
- Find where the Totem RealPlayer plugin is located.
- Type “about:config” in the Firefox address bar. Go ahead and agree that you’ll be careful.
- Type “plugin” in the “Filter” field. Find the “plugin.expose_full_path” preference. Right click on the entry and select “Toggle” to change the value from “false” to “true”.
- Type “about:plugins” in the Firefox address bar again. Find the RealPlayer plugin. It should display the fullpath of the plugin.
- For example:
-
File name: /usr/lib/totem/gstreamer/libtotem-complex-plugin.so
-
- Remove the Totem RealPlayer plugin.
- Open a Terminal window. Go to the Totem plugin directory.
-
cd /usr/lib/totem/gstreamer
-
- Remove the plugins.
-
sudo rm libtotem-complex-plugin.*
-
- Restart Firefox. Type “about:plugins” in the Firefox address bar. Make sure there is no RealPlayer plugin.
- Open a Terminal window. Go to the Totem plugin directory.
- Copy RealPlayer plugin to Firefox.
- Copy the RealPlayer plugins into the Firefox plugins directory. For me, Firefox is installed in /usr/lib/firefox-3.0 and RealPlayer is installed in /opt/real/RealPlayer.
-
sudo cp /opt/real/RealPlayer/mozilla/*.* /usr/lib/firefox-3.0/plugins
-
- Restart Firefox. Type “about:plugins” in the Firefox address bar. Make sure RealPlayer plugin is installed.
-
Helix DNA Plugin: RealPlayer G2 Plug-In Compatible File name: /usr/lib/firefox-addons/plugins/nphelix.so Helix DNA Plugin: RealPlayer G2 Plug-In Compatible version 0.4.0.4005
-
- Copy the RealPlayer plugins into the Firefox plugins directory. For me, Firefox is installed in /usr/lib/firefox-3.0 and RealPlayer is installed in /opt/real/RealPlayer.
- Test if the plugin works or not. Go to a website that has embedded RealPlayer file. For example:
I think the entire process is too complicated.
References:
July 4, 2008
How to lower cholesterol
Two years ago, a friend found out she had high cholesterol, about 230. If the cholesterol level is above 200, it is considered bad. Instead of taking medicine to lower it, she wanted to see if she could lower it by changing her diet. I’ve always been interested in nutrition and health. At that time, I was reading The China Study which showed that you can change your health by changing your diet. So together we changed our diet, and the result was remarkable. After six months, my friend’s cholesterol level dropped to 170. The book has changed my life and hers. Here is what we did.
1. Eliminate All Meat (Except Fish)
- No beef, pork, chicken, turkey.
- Fish is a good source of Omega-3. So we did not remove it from our diet, but we did not eat a lot.
2. Eliminate All Dairy Products.
- No milk, cheese, yogurt, egg.
- Egg is hard to eliminate completely. The only time we had egg was if it were used in baking whole grain bread.
3. Eliminate All “White” Products.
- No pasta, white bread, white sugar, etc.
4. Eliminate All Junk Food.
- No chips, candy bars, cake, brownies, donuts, etc.
5. Eat A Lot Of Vegetables and Fruits.
- broccoli, cauliflower, spinach, cabbage, lettuce, beans, mushrooms, etc.
- orange, kiwi, apple, tomato, blueberries, mangoes, avocados, etc.
6. Eat Nuts.
- walnuts, almonds, cashew, pistachio, etc.
- Trader Joe’s is a good place to buy nuts. The store has many different kinds of nuts.
7. Eat Whole Grains.
- brown rice, barley, oats, whole grain bread, etc.
- The Bulk Food section in your local grocery store is a good place to buy these things. I find Whole Foods has the best selection.
8. Exercise.
- walking, play sports, etc.
- If you don’t have time, at a minimum, you should walk for at least 30 minutes a day.
We continued with almost the same diet. Sometimes, we did have some snacks or turkey sandwiches. It has been more than two years and my friend’s cholesterol level remains the same, around 170.
Reference:
June 28, 2008
Virtual CD-ROM
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
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)
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:
- I have used VMware Workstation before. But since it is not free, I can only use VMware Player.
- Use Microsoft Virtual PC.
- 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
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
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.
