Thursday, February 12, 2009


I'll be away on holiday for 2 weeks and I've got next week to finish all of the work assigned to me, so no new blog posts for a while. I'll try to sneak in a blog post or two if time permits, but I'm making no promises here. I hope you'll be back to read more from me on the 8th of March, 2009.

Happy surfing and stay out of trouble!

Wednesday, February 11, 2009

Kindle 2 announced

Kindle 2, the new ebook reader, has been announced with lots of new features over it's older version. It's got 2GB of storage, has text-to-speech capabilities and can run PC-free with a 3G Internet connection. Kindle 2 costs $359.

Tuesday, February 10, 2009

Default User Files in Linux

When you create a user account, the home directory of the user is pre-populated with files that are in the /etc/skel directory. This is useful for distributing a copy of the usage policy for your system to all new users. You can use the "-k dir_name" option to specify an alternate directory of "-k /dev/null" if you do not wish to copy any files to the home directory.

Sunday, February 8, 2009

Linux On Old Hardware: More Progress

After getting Turbo Linux 10 OEM to run on my computer, I decided to install ndiswrapper. To install ndiswrapper, I needed the kernel sources, which I obtained from the Turbo Linux 10 updates FTP link. I also used the RPMs to upgrade my kernel from 2.6.0test to 2.6.0-24.

I set the KBUILD environment variable to my Linux kernel source directory with a:
export KBUILD=/usr/src/linux-2.6.0
...and ran "make" overnight, which compiled the kernel sources and ndiswrapper. After it was done with its buzzing, I did a "make uninstall" followed by a "make install". It would always fail on the installation with a:
ndiswrapper install: cannot stat ndiswrapper.ko No such file or directory

I then tried to set the KVERS variable, as I found the symbol in the Makefile within the drivers directory of ndiswrapper with the following:
export KVERS=2.6.0-24

That didn't seem to make much of a difference either as I still got the error. I also tried manually copying ndiswrapper.ko from the Linux source directory to the directory it was trying to install to. I did a Google search, but the only suggestion I could find was to do a manual copy and run make install again, but I already did that so it wasn't of any use to me.

From the output, I can tell that the installation wants to copy ndiswrapper.ko from one directory to another, but I can't seem to tell which the source directory is. I'll run "make install" again and will look at the final output with a more analytical eye.

UPDATE: I noticed it was leaving the /root/ndiswrapper-1.54/driver directory after the error, so I figured I had to put the ndiswrapper.ko in there. That got "make install" working without errors, but when I do a "modprobe ndiswrapper", I get a "FATAL: Module ndiswrapper not found".

UPDATE: The ndiswrapper.ko was copied to the wrong directory... after I moved it, I did a "modinfo ndiswrapper" to ensure it was in the right place, followed by a "depmod -a" and a "modprobe ndiswrapper". Now, it complains "loadndisdriver: main(542): version
1.9 doesn't match driver version -a". I think I should get a newer kernel to work with ndiswrapper 1.53.

More Web Reference vs Service Reference

Today, a co-worker wanted to try creating a web reference instead of a service reference in Visual Studio. The result of his little experiment was interesting... we had a Guid typed parameter that we were passing to a function. The proxy class generated by adding the service reference maintained the Guid type, while the proxy class generated by adding the web reference had a string type instead.

Also, in my previous post I mentioned that the service references (which uses "svcutil.exe" to generate the proxy classes) can only be used by .NET 3.5 clients, so older clients can only use web references (which uses "wsdl.exe" to generate the proxy classes).

Saturday, February 7, 2009

Linux for Old Hardware

I have an old Thinkpad 600E, which is like a grand daddy to my Thinkpad T60. It's get a Pentium II 366MHz with 64MB RAM, an 8GB hard disk, a 56kbps modem, an IrDA port, a serial port, a parallel port, firewire, 1 USB port, and a DVD drive. I decided to bring it back to life for checking my email as it's small, portable, and a lot like a netbook.

I decided to install some flavor of Linux on it, so I started off with Knoppix. Knoppix booted up from the LiveCD, but after installing it to the hard disk, it simply refused to boot up with all kinds of errors... first, there was a problem with DMA so I disabled the DMA and started it up again but it simply crashed at some other point in the startup process.

I then tried Turbo Linux 10 Desktop OEM, which installed and booted up the computer. That was cool! An ancient beast running Linux to keep up with the new boyz. Since it doesn't have an ethernet adapter to connect to the wired LAN, I decided to get something to hook it up.

I got a Siemens USB wireless adapter, which I regret because the only way to get it running on Linux is to use ndiswrapper. Using ndiswrapper isn't the actual problem, but the one I got with Knoppix on the LiveCD was probably too old to run the drivers while Turbo Linux simply doesn't include ndiswrapper. I tried installing ndiswrapper, but the kernel sources folder was missing a ".config" file, and I didn't find a copy in /boot/config as a forum-post suggested.

I finally decided to go with something more recent so I got a copy of Sidux Linux, but that wouldn't even boot from the LiveCD.

Anyway, I guess I'll have to just hope I can find a PCMCIA ethernet card supported by Linux (more specifically, by Turbo Linux 10, the only distro that would successfully boot).

Friday, February 6, 2009

When an EntityCollection isn't an IEnumerable...

I usually convert all my entity collections to plain old Arrays and I use the List.ToArray method to make the conversion. I push the data into a List via the constructor by casting the needed data to an IEnumerable.

This all goes well when I do a:
var data = (from iterEntity in Db.Table
select iterEntity);

I can do a:
var myList = new List((IEnumerable)data);
MyEntityType[] myArr = myList.ToArray();

However, when I select a set of related entities like so:
var data = (from iterOtherEntity in Db.OtherTable
where iterOtherEntity.refId = 911
select iterOtherEntity.MyEntities);

I can no longer cast data to an IEnumerable type, and so can't push data into a List via its constructor... I now have to write a foreach loop to do the same conversion to an array. :-(

UPDATE: There is an AsEnumerable extension method that you could try on the EntityCollection object (data). I didn't get a chance to try it yet, but I will as soon as I boot up in Windows again.

Wednesday, February 4, 2009

Are you trying to be funny, HAL?

Way back in the old days, we had a Dummy Operating System... it was just an application that run with an entry in Autoexec.bat and it said weird stuff when you tried to do anything - a "del " would result in a "I won't delete it. Delete it yourself!" and a "copy " would say "Copying is so not original. I don't want to copy. I want to create something new and original."

Today, I came across a dummy ASP.NET error page that said: "System.ServiceModel.FaultException: Unable to cast a spell on class String". After amusing 404 messages, they now come up with funny error pages that look so much like the real thing.

Monday, February 2, 2009

What is JPEG 2000?

OpenID Bootcamp Tutorial

New Features of Java 7 SE

Java readLine Problem

A problem with using the readLine method to read the contents of the file is that you never know whether the last line in the file has a line break at the end. The readLine method can return either due to a line break or due to the end of the file so when you don't know which, you can either add a line break in which case you could be adding an extra character to the file, or you can assume that there was no line break in which case you may be removing a character from the end of the file.

If you're building a text editor (such as nText, an open-source project hosted on SourceForge... I committed a fix to the project already), checksum utility, or anything along those lines that are sensitive to the EOF/EOL issue, you really ought to stop using readLine and use a regular read with a character array instead.

This could've been solved by including a readToEnd method that developers are more likely to want to use than the readLine method.

Java 6 Combo Box-Gtk bug

Sun Java 6 has a bug that goes way back to November 2007. The problem is with using a combo box in GTK. A workaround is to use the metal look and feel instead and the fix is available only in beta of Java 7. The beta is still unstable so if you're looking for a fix for the bug, you'll have to wait till Java 7 goes RTM. That makes it 15 months and counting for a resolution to the bug.

You can read more about it here and here.

Here's the output I get when running the open-source nText editor with java 6 (1.6.0_10-b33).

nitin@nitin-laptop:~/Desktop$ java -jar nText.jar

(<unknown>:19134): Gtk-WARNING **: Attempting to add a widget with type GtkButton to a GtkComboBoxEntry (need an instance of GtkEntry or of a subclass)

(<unknown>:19134): Gtk-CRITICAL **: gtk_widget_realize: assertion `GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed

(<unknown>:19134): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed

(<unknown>:19134): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed

(<unknown>:19134): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed

(<unknown>:19134): Gtk-CRITICAL **: gtk_paint_box: assertion `style->depth == gdk_drawable_get_depth (window)' failed

UPDATE: Java 7 is expected to go RTM in early 2010. That's an estimated 27 months before the bugfix is available for production systems :-(

Linq-to-Entities doesn't support Collection.Contains

My Linq-to-Entity woes just won't come to an end. I tried doing a query like:
var rset = (from iterRow in db.TableA
where myArray.Contains(iterRow.Id)
select iterRow);

...but I just get the exception along the lines of:
LINQ to Entities does not recognize the method 'Boolean Contains(Int32)'
method, and this method cannot be translated into a store expression.

As the Linq to Entities framework (from .NET 3.5 SP1) still doesn't support the Contains method, that just one more thing that makes me wonder why the stars didn't reveal that Linq to SQL would be a better choice for my project.

There's a solution suggested here (scroll down to the post by Hongye Sun from Microsoft - no pun intended) that I didn't try out yet, but there is another post here saying the solution was successful.

LINQ to Entity Joins

Joins with LINQ-to-Entity are pretty straightforward - you don't have to write join conditions manually!

However, sometimes you do get an error that looks a little like this:

An expression of type PkTableEntity is not allowed in a subsequent from clause in a query expression with source type System.Data.Objects.ObjectQuery<FkTableEntity>. Type inference failed in the call to SelectMany.

It simply means that you've put your tables in the wrong order. I did something like this:

var rset = (from iterFkEntity in objDbEntities.FkTableEntity
from iterPkEntity in iterFkEntity.PkTableEntities
where iterPkEntity.ColumnA == 3
select iterFkEntity);

To correct it, I simply had to flip over the PkTable and the FkTable and turn it into:

var rset = (from iterPkEntity in objDbEntities.PkTableEntity
from iterFkEntity in iterPkEntity.FkTableEntities
where iterPkEntity.ColumnA == 3
select iterFkEntity);

Re-compile and the error is gone!

UpdatePanels are not a drop-in replacement for Panels

I always thought an UpdatePanel was just a regular Panel with AJAX capabilities. Yesterday, a co-worker tried setting the style (CSS) attribute on an UpdatePanel and it just dropped an ASP.NET error. You can apply the style attribute to Panels but not to UpdatePanels.