Friday, April 10, 2009

Cache-Control Header

The Cache-Control HTTP header directive is used to specify the behavior of proxy servers or caches for caching data.

This setting enables caching on shared as well as single-user caches

This setting disables caching on shared caches but allows caching on single-user caches

Prevents caching by storing to persistent storage

Prevents caching entirely

Sunday, April 5, 2009

An Architect Is...

I came across this on a set of slides on SlideShare, but only one of the seven slides had actual content so instead of embedded the entire presentation, I just posted this text:

Accepting my responsibility as an architect, I will strive daily to learn and perfect my trade.

Readily will I defend my organization’s I.T. investments from complexity, our greatest enemy.

Changing requirements will not break my design for it will be flexible and able to change with the requirements.

Helping developers to understand the reasons for the architecture and seeking their input is of great importance to our success.

I will never use acronyms or suggest technologies that are not pertinent to the problem at hand.

Technologies evolve and I know that solid architectures should accommodate and enable these evolutions.

Every day, I will strive to help our software achieve ideals that will make it flexible and easy to maintain.

Concern for the success of my organization’s I.T. investments will drive me to make appropriate decisions.

Teaching others about my trade will be an overarching responsibility that I accept as a part of my duties.

Twitter Tools For Recruiting

10 Social Media Resources for Executive Job Search

PostgreSQL 8.4

Thursday, April 2, 2009

Top-N query

I've been Googling for how you would implement a Top-N query with different databases and here's what I could find on a discussion thread at StackOverflow:


Informix, InterBase/Firebird:


MySQL, PostgreSQL, SQLite:


Unfortunately, ANSI-SQL doesn't provide any way to do this :-(

Monday, March 30, 2009

Serve A Different Stylesheet To IE

I've been trying to get browser specific stylesheets without having to resort to server side code and, thanks to an IE feature, this was actually possible. Check out my article on The Picometric on rendering IE-specific HTML/CSS:

My New Blog

My new blog is up and running at

It's an attempt to fill in the void left by this blog going inactive. I hope to get your input on the new blog soon.

Saturday, March 28, 2009

Going Inactive

The number of posts I've been making to my blog has been dwindling down and it is time for the inevitable. All things that start must come to an end and here I go, giving my blog the InActive status. You can still go over all of my archived articles and I might post an entry or two every once in a while. I hope all of you have had as much fun reading my blog as I've had writing it. More from me, in the not too distant future.

UPDATE: I'll be starting up a new blog later this week at

Online Virus Check Against Multiple Engines

Do you want to double-check the results of your anti-virus to confirm what it tells you about a file on your system? Go to to check a file against multiple antivirus engines - they run your file through well over a dozen different antivirus engines and give you the results of the scan.

Saturday, March 21, 2009

Back Into Service: Thinkpad 600E, Presario 2132EA

I put my old IBM Thinkpad 600E and Compaq Presario 2132EA back into service. Here are the specs on the machines:

IBM Thinkpad 600E:

Intel Pentium II 366MHz processor
56kbps modem
1 USB port, 1 VGA port, 1 parallel port, 1 serial port, 1 PS2 port, 1 IrDA port
DVD-ROM drive (front-loading!!!)
External floppy disk drive
Crystal Audio

Compaq Presario 2132EA:

Intel Pentium III 1 GHz processor
56kbps modem, 100Mbps network interface
2 USB ports (inaccessible), 1 VGA port, 1 parallel port, 1 PS2 port, 1 IrDA port
DVD/CD-RW drive
Internal floppy drive

The problem with the Thinkpad is that it's too slow and doesn't have enough RAM to run a web browser. I can, however, use the USB port to connect to my ADSL router which effectively turns it into a network interface. The Presario, on the other hand, can get onto the 'net and do all kinds of stuff but the power connector is loose so I have to keep a paperweight on it, which makes the USB ports inaccessible. Also, the Spacebar and the 'B' keys on the keyboard don't work. The batteries on both laptops no longer work.

My current setup has the Thinkpad running Windows 98 Second Edition. I've installed the Terminal Service Client for Windows, which enables me to connect to the Presario running Windows XP SP2 (I plan to upgrade to SP3 sometime soon). That solves the low resources problem of the Thinkpad as well as the keyboard and loose power connector problem of the Presario. I'm hoping to install a wireless USB interface on the Thinkpad so I'm not tied down to the ADSL router but that's a plan for later.

Wednesday, March 18, 2009

The Case of The Polluting GridView

When I use a GridView control on my ASP.NET page, the TABLE tag generated automatically gets the attributes:
cellspacing="0" rules="all" border="0" style="border-collapse:collapse;"

I've tried using:

...but they didn't seem to work so here's what I ended up doing.

Getting Rid of the Rules="all" Attribute

Simply set the GridLines property to None in the GridView tag. Example:
<asp:gridview id="gridWExp" runat="server" gridlines="None">

Getting Rid of the CellSpacing="0" and style="border-collapse:collapse;" Attributes

Set the CellSpacing attribute to -1 in the GridView tag. Example:
<asp:gridview id="gridWExp" runat="server" gridlines="None" cellspacing="-1">

The border="0" attribute remained in the generated HTML and I guess the only way to remove it would be to inherit the GridView class and create my own control.

See the rant at VelocityReviews about the GridView

PS: This is my 400th post!

Monday, March 16, 2009

Back from Holiday

I'm back from my 2-week long holiday! I've been busy last week with un-packing, taking care of stuff at work. It was lots of fun in a very retro way.

Anyway, more from me soon.

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.

Saturday, January 31, 2009

10 Things You Might Not Know About MySQL

Customer Support Web 2.0 Style

If you've been calling up the customer helpline only to find yourself on hold for over 10 minutes waiting for the first-level tech support script monkey to ask you a bunch of totally unrelated questions, then you ought to check out . It's like a social network of users who use a product and more often than not, you'll also find staff who know what they're dealing with to pitch in and help out.

Get People To Your Meetup on

If you're getting complete strangers from your region together for a meetup on just about anything, check out . It helps organize the meets by keeping a count of how many people are visiting, hosting polls & pictures, and pretty much anything you would want to do for a meet up.

PostgreSQL vs MySQL

LINQ to SQL and Entity Framework

UML Use Case - Includes vs Extends

A couple of developers I know asked me about the includes and the extends for use cases. "includes" is used when the included use case is always executed as a part of another user case. "extends" is used when a use case is executed as a part of another only when an exceptional condition occurs.

Thursday, January 29, 2009

More Linq2Entities From The Real World

I've built a WCF service that takes as a parameter an entity object with a reference to another entity (a foreign key-primary key relationship). When I try adding it to the database (context object) with LINQ, I get the following exception:

The object cannot be added to the ObjectStateManager because it already has an EntityKey. Use ObjectContext.Attach to attach an object that has an existing key.

I tried manually attaching the entity reference, but that didn't seem to work either so I finally had to get the primary key value of the reference, re-fetch the object from the database and set the reference again with the newly-retrieved object.

They make this so much harder than it should be :-(

Wednesday, January 28, 2009

WCF in the Real World - a case of two definitions for a class

I've been using 2 WCF web services on my project - Service1.svc returns an entity object which I have to pass to Service2.svc. Now, after I add a service reference to both in Visual Studio, I get 2 classes - Service1.Entity and Service2.Entity and I can't cast one to the other.

The solution is to either take the properties of one class and put it into another within the client-side code, or put the class into a class library used at both the server and the client side. At the client side, you simply have to add a reference to the DLL before you add the service reference to prevent svcutil from creating the class in a new namespace.

UPDATE: You can find more about it here and here.

Tuesday, January 27, 2009

Firefox CacheIt Plugin

The Firefox CacheIt plugin lets you view cached versions of pages - it comes in pretty handy if the original source server is not accessible or if you want to view an older copy of the page.

CacheIt uses the Google Cache, Way-Back Machine, and the Coral (...and perhaps Dot Cache too?) caches to get cached copies of the page.

I used the Way-Back Machine to get a copy of David's Diary on Getting a Girlfriend, a popular Internet diary/blog from the late 90s. David's account no longer exists on the server so the diary was lost forever till Way-Back Machine traveled back through time and space and fetched a copy for me :-)

Monday, January 26, 2009

Increasing Wanda's Vocabulary

Wanda is the fortune-telling fish you can add onto your *nix menu bar. When you click on her, she displays a random quote from William Shakespeare, Mark Twain, or other humorous quotes and riddles. If you don't have it, right-click your menu bar, click Add to Panel, select Fish and click Add.

Behind the scenes, Wanda relies on the "fortune" command line application that displays random quotes from the fortunes file located at /usr/share/games/fortunes. You can view a list of all messages used by fortune from the file /usr/share/games/fortunes/fortunes. To edit this file, do the following:

cd /usr/share/games/fortunes
sudo vi fortunes

At this point, the vi editor starts up. If you aren't familiar with the vi editor, you can use gedit instead - type "gedit fortunes" instead of "vi fortunes". You have to end every entry with a "%" sign on a blank line. After you've edited and saved the file, type the following command

sudo strfile fortunes fortunes.dat

Now, Wanda (and the command-line fortune) will display the new messages which could be anything from the Java Factoid of the Day, or a quote from Star Wars - "Who's the more foolish: The fool, or the fool who follows him?".

Sunday, January 25, 2009

HttpException: The Controls collection cannot be modified because the control contains code blocks

A team mate had a pretty odd error from ASP.NET that comes up like this...

Server Error in '/LaaziWeb' Application.

Stack Trace:

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
System.Web.UI.ControlCollection.Add(Control child) +8674071
System.Web.UI.PageTheme.SetStyleSheet() +478
System.Web.UI.Page.OnInit(EventArgs e) +8694828
System.Web.UI.Control.InitRecursive(Control namingContainer) +333
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +378

The error was a little hard to put a finger on, but I eventually traced it to a script that used a <%= txtBox1.ClientID %> with a document.getElementById. The script was in the HEAD section of the page and to make the exception disappear, I moved the script into the BODY section.

Cooliris: Web Image Viewer

A co-worker introduced me to the Cooliris, a remarkably cool image browser for web galleries. It gives you an slightly iPhone-like view of the gallery and goes a step further in diminishing the boundary between what's on the web and what's on your desktop.

I went onto the Cooliris website with Firefox running over Ubuntu 8.10, and I got a "Cooliris is not supported on this browser." :-(

Friday, January 23, 2009

Seagate firmware upgrade wreaks havoc with 500GB HDDs

The firmware upgrade Seagate provides to fix the problem with 1TB Barracuda drives seems to work, except that when you've got the 500GB Barracuda, it bricks your disk.

It's yet another case of lack of testing... their test engineers probably weren't curious enough to think "What if we tried the firmware on a system that also has 500GB drives?" Unlike what many people imagine, test engineers are more than just script monkeys - they've got to figure out ways to break something that seems to work perfectly.

Starting off with GDB

The GNU Debugger is pretty handy when developing applications in C for the Linux platform. Using it is pretty simple...

Compiling for Debug

Compile your program with gcc, adding a "-g" option to include debugging symbols

Example: gcc -g nitin.c

Run with Debugger

Execute GDB, providing the executable as a parameter

Example: gdb a.out

Start Execution

Get into the main method by typing "start main" followed by any parameters

Example: start main hello

Step Through

Go line-by-line by typing "n" or "next"


Display variable values using the "print" command

Example: print argv[1]


Set a breakpoint with the "b" or "break" command followed by the filename:line number

Example: b nitin.c:25


Run till the next breakpoint using "c" or "continue"


Press Ctrl+C to stop execution, and "q" or "quit" to close GDB.

Thursday, January 22, 2009

HOWTO: VPN from Ubuntu 8.10

I have a Microsoft Windows based network at the office and they've setup a VPN connection for me to be able to hook up to the servers to take care of a couple of ASP.NET applications and manage the server.

Ever since I installed Ubuntu 8.10, I've been a bit disconnected from the office as I can only access the services exposed by the web gateway, so I finally decided to setup a VPN connection from Linux.

I started off by clicking on the network icon on the top-right of the menu bar and then Configure VPN (under VPN Connections). The VPN tab had the Add button disabled so I went to the command prompt (Application, Accessories, Terminal) and typed the following command:
sudo apt-get -y install network-manager-pptp

I then entered my password (for the sudo), after which it downloads and installs PPTP support. To make sure Add button under VPN is now enabled, I also type the command:
sudo NetworkManager restart

Now, I simply click the network icon (from the top-right of the menu bar), click Configure VPN (under VPN Connections), I click the Add button, type in the IP address of the VPN server for the Gateway, my ActiveDirectory (from the Windows domain) username and password, followed by the domain name. I click the Advanced button and check the "Use Point-to-Point encryption (MPPE)" checkbox and click Ok on both dialog boxes.

To connect to the VPN, I click the network icon and under VPN Connections, I select the VPN connection that I just created.

Going Multi-Lingual With Parallel Folders in ASP.NET

As with any other programming problem, there are many ways to go about serving pages in multiple language to your visitors. The approach I'm trying out is using a folder for each language (EN, HI etc) and getting pages from both folders to point to the same code behind file. ASP.NET does require you to place the code behind file outside the App_Code folder, which did seem a little odd to me at first.

In the end, I ended up with a folder structure a little like this:

You might want to try the globalization & localization features in ASP.NET. They are totally awesome when you don't need to change the look of a page by much (think about changing left-to-right to right-to-left) when displaying the same page in a different language.

Java OpenGL (JOGL)

I'm hoping to try out the Java OpenGL wrapper tonight. It's based on the JSR 231 spec. You can find some sample source code on Wikipedia at:

You can get the JOGL binaries for your platform on the JOGL site here. It's for the May '08 release. If you've been working with the C API for OpenGL, the JOGL will seem pretty close, which makes it an easy transition.

Finding OpenSource Developers

If you're looking for developers to work on your open source project, you ought to try posting to the Help Wanted section of SourceForge at:

Tuesday, January 20, 2009

ADO.NET Data Service

If you use LINQ, you'll definitely like ADO.NET Data Services. It lets you perform LINQ queries remotely so your database can be with a web server behind a firewall, and the client can access the database through the web server.

The ADO.NET Data Service is a class that inherits from a DataService generic class (the context class is used for the generic type). Example:
public class WebDataService : DataService<NitinEntities>

The InitializeService method is used to set access privileges. Example:
public static void InitializeService(IDataServiceConfiguration config)
config.SetEntitySetAccessRule("*", EntitySetRights.All);
config.SetServiceOperationAccessRule("*", ServiceOperationRights.All);

You can add additional methods that return the IQueryable generic type. Think of them as the equivalent of views over tables.

The client application needs to have a service reference. After adding the reference, you'll find a context class (WebDataService.NitinEntities) that you can use. You can run LINQ queries over the context remotely.

Evolving SlideShare

SlideShare has been given a makeover - check out the new Embed feature. From too many icons and annoying hover-over DIVs that cover up icons, they went on to display Blogger, Facebook, Twitter and a "more" link.

SlideShare is also integrated with Google authentication if you are posting to Blogger.

Spring 3 MVC CodeMash 2009

Check out this SlideShare Presentation:

LINQ to Entity Trash

I know, I know, everyone's talking about usin LINQ to Entities instead of LINQ to SQL, but there's so much that simply doesn't work when using LINQ to Entities.

First off, if you need to run a stored procedure that has nothing to do with any of the entities you are working with, the Entity framework simply can't handle it.

Secondly, there's the lack of support for using Contains to mimic SQL's IN operator. (You can use the Contains method as the equivalent of SQL's LIKE)

The Entity framework does have potential and version 2.0 is something I'm really looking forward to, but what I'm saying is that it is just not fully developed to use in all of your applications yet.

Monday, January 19, 2009

Quiz Engine: XML Parsing in Java

I've made up a port of the Quiz Engine in Java, and I've re-structured the source code repo to accomodate the port too. The XML parsing but in Java looks a little messy; I put it together as a hack to simply work.

You can find it on sourceforge at:

JAXP Switching Implementations

I was thinking about the kind of effort it would take to switch between different implementations underlying the JAXP API so I did a Google search and came across an article on the Sun website with the following. It basically means you can switch between JAXP implementations with absolutely zero code changes.

The factory APIs let you plug in an XML implementation offered by another vendor without changing your source code. The implementation you get depends on the setting of the javax.xml.parsers.SAXParserFactory, javax.xml.parsers.DocumentBuilderFactory, and javax.xml.transform.TransformerFactory system properties, using System.setProperties() in the code, <sysproperty key="..." value="..."/> in an Ant build script, or -DpropertyName="..." on the command line. The default values (unless overridden at runtime on the command line or in the code) point to Sun's implementation.

iText: A PDF library for Java/.NET

I've been trying the iText library lately. It makes generating PDFs quite simple. Check out this C# code snippet of inserting an image (JPEG, in this case) into a PDF:

Document doc = new Document();
PdfWriter pdf = PdfWriter.GetInstance(doc, new System.IO.FileStream("fileout.pdf", System.IO.FileMode.Create));

#region Getting my byte array
//You don't have to do this if you are using a database - read the image as a byte array from the database instead
FileStream fstream = new FileStream(@"C:\rosewhite.jpg", System.IO.FileMode.Open);
byte[] byteBuf = new byte[100000];
int actualSize = fstream.Read(byteBuf, 0, 100000);
byte[] byteBufNew = new Byte[byteBuf.Length];
for (int i = 0; i < byteBuf.Length; i++)
byteBufNew[i] = byteBuf[i];

//provide the byte array you got from the database in place of byteBufNew
doc.Add(new Jpeg(byteBufNew));

You can do lots of other stuff with iText too, such as inserting tables, add digital signatures, bookmarks etc. iText is a free library and can read more about it here.

Sunday, January 18, 2009

List of Software Development Methodologies

Software Project Methods

From: craigwbrown,
2 days ago

Software Project Methods
View SlideShare presentation or Upload your own. (tags: pmi pmbok)

A summary of the more popular software develpment processes and methods.

SlideShare Link

XML Parsing .NET Example

I spent about an hour yesterday cooking up a sample on XML parsing and I came up with a minimalist quiz engine. It reads an XML file, gets the users answers, and displays a score at the end.

I've uploaded it onto SourceForge, so check it out at:

Entity Framework - Don't Forget to Detach

Often in the web programming model, we make use of disconnected data sets. When using LINQ-to-Entity to fetch data, you have to remember to call the Detach method of the context. If you do not detach the object, the context continues to maintain a reference which keeps it from being garbage collected.

Here's an example:
public Customer GetById(int aId) {
DataEntities de = new DataEntities();
var retVal = (from iterCust in de.Customers
where iterCust.Id = aId
select iterCust).FirstOrDefault();
de.Detach(retVal); //detach the object from the context
return retVal;

You do not have to do this when you set the NoTracking MergeOption (set de.Customer.MergeOption).

More On Writing XML In Java

After trying JDOM, I just had to check out the built-in XML features of the Java Development Kit. I used the Java API for XML Processing with the Apache Xerces underneath (included with Sun's JDK 6). Here's the sample I came up with:

import javax.xml.parsers.*;
import org.w3c.dom.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DOMImplementation di = dbf.newDocumentBuilder().getDOMImplementation();
Document doc = di.createDocument("", "rootElement", null);
Element el = doc.createElement("childElement");
Transformer trans = TransformerFactory.newInstance().newTransformer();
DOMSource ds = new DOMSource(doc);
FileOutputStream fostr = new FileOutputStream("xmlout.xml");
StreamResult strResult = new StreamResult(fostr);
trans.transform(ds, strResult);

Saturday, January 17, 2009

CSS Generic Fonts

When specifying fonts through CSS using the "font-family" attribute, you might have users who can't display some of the text correctly when they don't have the font you are using. Sure, you can provide multiple fonts with a comma separated list, but does it have to be so hard?

CSS provides 5 generic fonts that you can provide at the end of the CSS list so you don't have to list every font in existence just to get your page to display in a particular way. The 5 generic fonts are: cursive, fantasy, monospace, sans-serif, and serif.

Reflection in .NET

The Microsoft .NET Framework makes it really simple to dynamically load a type based on configuration info provided. It comes in pretty handy for building plug-in based systems.

In today's code sample, we'll start off with a simple class:

namespace GateLib
public class Neptune
public string GetAString()
return "Nile River";

After compiling the class into a class library (DLL), we start work on our code to call the class method. Let's build a console application for simplicity sake. Here's the code we put into the Main method:

Assembly asm = Assembly.LoadFile(System.Environment.CurrentDirectory + "\\GateLib.dll");
Type ty = asm.GetType("GateLib.Neptune");
MethodInfo meth = ty.GetMethod("GetAString");
ConstructorInfo ci = ty.GetConstructor(Type.EmptyTypes);
object obj = ci.Invoke(null);
object retval = meth.Invoke(obj, null);

In this code sample, I'm using the default constructor for the Neptune class that takes no parameters (notice the Type.EmptyTypes and the null in the ci.Invoke), and the method GetAString that takes no parameters (it's the null in the meth.Invoke).

After compiling the console application, I place the class library in the same folder as the EXE, and execute the console application to get "Nile River" on-screen.

I know it doesn't do much but it's just a start. You'll probably end up doing so much more with it.

JDOM For Generating XML

As you've probably figured out from my blog, I'm an ASP.NET C# web developer who loves trying out alternative technologies. There has always got to be another way to do something and if there isn't, then it's time to fire up the IDE and write some open source software!

After being pretty impressed with the XML API for writing XML documents with the Microsoft .NET Framework, I wanted to check out what Java had to offer. At the start, it was pretty confusing as there were so many different libraries and APIs so I didn't know what to pick. When I asked around, a developer suggested that I try out JDOM. JDOM is a pretty simple library for working with XML and is pretty close to Microsoft .NET's API. I decided to take it for a spin and here's what I came up with:

import org.jdom.*;
Document doc = new Document();
Element elroot = new Element("root");
elroot.setText("This is the root");
output.XMLOutputter xo = new output.XMLOutputter();
FileOutputStream fos = new FileOutputStream("xmlout.xml");
xo.output(doc, fos);

JDOM's simplicity makes it very appealing to use when dealing with small amounts of data.

Friday, January 16, 2009

MS Office 14 Alpha Screenshots

ArsTechnica has a couple of screenshots of MS Office 14 from the Alpha version released earlier this week. The new version features the ribbon interface for Visio, the Office Anytime update (to purchase additional features), and a USB Office device option (to take MS Office with you to work when you don't have MS Office installed on another device?).

There hasn't been a major shift from the Office 2007 interface, which is a big plus as firms don't have to re-train their staff to use a new interface.

Seagate's 1TB Barracuda Bug

Seagate has been experiencing problems with the 7200.11 Barracuda terabyte hard drives (ST31000340AS, but not the ST31000333AS). A defective firmware is the cause of the failure and the replacement drives that Seagate ships out have the same problem.

On the Seagate website, they still have a banner up (saying "The Barracuda 1 TB Drive in action") advertising their 1 terabyte model instead of the 1.5 terabyte model, which isn't affected by the bug. I don't know about them, but if I had a bigger hard drive, I'd switch all my banners to advertise the bigger one especially if the smaller one had a bug.

What's New for Developers in SQL Server 2008

SQL Server 2008 Overview

From: ukdpe,
1 month ago

SQL Server 2008 Overview
View SlideShare presentation or Upload your own. (tags: sql 2008)

SlideShare Link

Using Frameworks With PHP

Rasmus, Think Again! Agile Framework == Happy Php Developer

From: arnoschn,
3 months ago

Talk was held during the PHP Conference in Barcelona (27.09.2008), which was also attended by Derick Rethans, Scott MacVicar and other international speakers. It shows the advantages of using a php framework vs. spaghetti code for web application development in an agile manner.
A simple example based on the Akelos PHP Framework shows you how to implement a fulltext search in less than 20 minutes.

SlideShare Link

Thursday, January 15, 2009

Hello World With GTK+ Programming

Fixing the "Package gtk+-2.0 was not found in the pkg-config search path" error
getting the Hello World GTK+ example to compile.

Today, I thought I'd try my hand at GTK+ programming. Win32 GUI programming was fun, and I didn't go all the way till the edge of the world with it, but I wanted to try something different for more insight.

I started off by looking at the Hello World GTK+ tutorial here, and tried compiling the following code.

#include <gtk/gtk.h>

int main (int argc, char *argv[] )
GtkWidget *window;

gtk_init (&argc, &argv);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (window);

gtk_main ();

return 0;

Compilation failed with the error "Package gtk+-2.0 was not found in the pkg-config search path" so I figured I didn't have the GTK+ development library. A quick search from the Synaptic Package Manager revealed that there was a libgtk2.0-dev package that I didn't have installed.

As soon as I installed the package, compiled the source code and executed the program, a GTK+ window popped up! This could be a whole new beginning for me. Let's so how far it goes.

A Sick Day Off From My Blog


I'm taking a sick day off from my blog today. Sorry, I'm just feeling under the weather.

Hope you're having a good day out there.


Wednesday, January 14, 2009

Blogger Text Size

I seem to be having a problem with the text size on my blog. The first couple of articles on my blog look normal, but after the 3rd or 4th entry, the text size is small. I'm guessing it's a temporary thing that will go away just as mysteriously as it appeared.

In the meanwhile, if you're finding it difficult to read the text, use your browser to increase the text size. Under the View menu of your browser, you'll have an Increase Text Size, or Zoom, or something similar.

If the problem persists tomorrow, I'll see if I can create a workaround.

Introduction to OpenGL

SIGRAPH Asia 2008 Modern OpenGL

From: Mark_Kilgard,
4 days ago

SIGRAPH Asia 2008 Modern OpenGL
View SlideShare presentation or Upload your own. (tags: gpu kilgard)

A long-time implementer of OpenGL (Mark Kilgard, NVIDIA) and the system's original architect (Kurt Akeley, Microsoft) explain OpenGL's design and evolution. OpenGL's state machine is now a complex data-flow with multiple programmable stages. OpenGL practitioners can expect candid design explanations, advice for programming modern GPUs, and insight into OpenGL's future.

These slides were presented at SIGGRAPH Asia 2008 for the "Modern OpenGL: Its Design and Evolution" course.

Course abstract: OpenGL was conceived in 1991 to provide an industry standard for programming the hardware graphics pipeline. The original design has evolved considerably over the last 17 years. Whereas capabilities mandated by OpenGL such as texture mapping and a stencil buffer were present only on the world's most expensive graphics hardware back in 1991, now these features are completely pervasive in PCs and now even available in several hand-held devices. Over that time, OpenGL's original fixed-function state machine has evolved into a complex data-flow including several application-programmable stages. And the performance of OpenGL has increased from 100x to over 1,000x in many important raw graphics operations.

In this course, a long-time implementer of OpenGL and the system's original architect explain OpenGL's design and evolution.

You will learn how the modern (post-2006) graphics hardware pipeline is exposed through OpenGL. You will hear Kurt Akeley's personal retrospective on OpenGL's development. You will learn nine ways to write better OpenGL programs. You will learn how modern OpenGL implementations operate. Finally we discuss OpenGL's future evolution.

Whether you program with OpenGL or program with another API such as Direct3D, this course will give you new insights into graphics hardware architecture, programmable shading, and how to best take advantage of modern GPUs.

SlideShare Link

Working with Multiple SVN Repositories

At work, I've got 2 source code repos (repositories) to work with - one that is common to all the projects in the firm, and the other that is project specific.

Normally, that would mean I have to use 2 different repos, but instead we've got external references from our project-specific repo to the common repo so whenever I fetch the latest revision from the project-specific repo, the common repo is retrieved as a sub-folder.

To create the external reference, I defined the "svn:externals" property and used the value format " ".

Tuesday, January 13, 2009

Open Source Bounties

If you're out of work and are looking for a software development job, you could think about becoming a software bounty hunter. It's fun, it's a paid opportunity, and you would be doing the open source community a whole lot of good.

There are a couple of websites that list bounties, such as Open Source Experts, that you can look up for bounties. Bounties are usually small contributions by users for a feature that add up to form a larger bounty. Often, bounties are offered by firms to promote development in a particular area.

Stuff People 'Paste'

I always thought the only text people posted on and other similar sites was source code.

While browsing through some of the 'pastes' today, I came across compiler output (pointing out errors reported by the compiler), diff output, configuration parameters, command line statements (possibly instructions), ASCII representations of directory tree structures, CSS, and some hexadecimal values.

MSN Web Messenger Ignorant

Every day, I use MSN's web messenger via Mozilla Firefox 3 on Ubuntu Linux to IM my co-workers at the office.

When I surf to , MSN claims that it doesn't support my browser and suggests that I instead use: MS IE 5 or later, Netscape 7.1 or later, or Mozilla 1.6 or later, *running in MS Windows*.

The web messenger works fine for me either way - I just ignore the message and click Start MSN Web Messenger.

Monday, January 12, 2009

Convincing People to Go Ubuntu

Yesterday, I got a co-worker to switch to Ubuntu 8.10 as a primary operating system. The Windows key-Tab for switching between windows had her impressed. We use Sun's VirtualBox to run Windows XP so we can work on Microsoft Visual Studio 2008. The installation went perfectly well as both the partitions were primary partitions.

Today, I convinced another co-worker to use Ubuntu - it was mostly the Compiz Fusion 3D desktop cube that did it for him. Running Sun's VirtualBox for Visual Studio made the deal. However, the installation didn't work - an error was reported at the partitioning phase and apparently, the installer doesn't re-size the extended partition to make room for itself.

Windows is still a part of daily work though... it comes as a part of being in a team developing with the Microsoft .NET Framework 3.5.

VirtualBox Raw Disk Boot Fails

I tried to use a raw partition as a virtual disk and tried booting Windows XP. The farthest I could get was the boot loader followed by a text-mode progress bar on selecting Windows XP and it would just hang at that point.

Booting Ubuntu 8.10 off the raw partition didn't go much further either - the bootloader just choked.

I guess all I can do with a raw partition is use it alongside a virtual disk to access data :-(

Ping with .NET

.NET makes pinging a network host to check for availability a piece of cake.

Step 1: To start off with, import the namespaces System.Net.NetworkInformation and System.Net

using System.Net.NetworkInformation;
using System.Net;

Step 2: Instantiate the Ping class

Ping p = new Ping();

Step 3: Call the Send method of the Ping object with the hostname as the parameter. Store the return value as a PingReply object.

PingReply pr = p.Send(@"");

Step 4: From the PingReply object, obtain the ping status from the Status property, the time from sending the ping request to getting the ping reply in milliseconds from the RoundtripTime property, and the IP address of the host from the Address property.

IPStatus status = pr.Status; //IPStatus.Success
IPAddress ipAddr = pr.Address;
long pingTime = pr.RoundtripTime;

The IPStatus enumeration has many different values to describe the problem, if any does occur. For a simple check, you can simply compare the value with IPStatus.Success.

Sunday, January 11, 2009

DNS Query from .NET

Resolving a host name to an IP address (or several IP addresses) has never been simpler - .NET provides the GetHostAddresses method for the System.Net.Dns class that returns an array of IPAddress objects.

Here's a debugger view:

VirtualBox Guest Resizing

When running Windows XP in VirtualBox within a window, I noticed I could only set the resolution up to 800x600 (Display Properties | Settings), which had me disappointed. But, when I turned to a co-worker's screen, I saw a maximized VirtualBox window entirely filled with the Windows XP host and then my jaw dropped!

I set VirtualBox to full-screen on my system and I had the Windows XP guest doing a 1280x800 (the max. for my notebook's LCD panel).

I'm so loving VirtualBox now.

WCF services on IIS 7

If you're moving your ASP.NET WCF services from IIS 6 to IIS 7, you might not have the SVC handlers added and the 404.3 error might show up:

HTTP Error 404.3 - Not Found

The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

This fix is to simply need to register the service models with IIS 7. To do this, you have to execute "ServiceModelReg.exe -i" from within %windir%\Microsoft.NET\Framework64\v3.0\Windows Communication Foundation (leave out the 64 if you're running a 32-bit version of Windows)

Saturday, January 10, 2009

Measuring Blog Success

A Framework for Measuring Blog Success

From: gregverdino,
2 years ago

A framework and recommended "starter tool kit" for measuring and understanding the success of your blog.

SlideShare Link

Agile Software Development Overview

Agile Software Development Overview

From: srogers74,
14 hours ago

A high-level snap shop of Agile concepts.

SlideShare Link

ListView On An EntityDataSource - Not As 'Smart'

Hooking up the ListView control to an LinqDataSource is really cool - the ListView can tell that a column is an identity column so the textbox for inserting the ID is automatically removed.

However, using the ListView with an EntityDataSource seems to be a less-intelligent solution as the textbox for inserting IDs is displayed again, although the value is ignored. If you think that's bad, wait till you try using it with a table that has a foreign key reference. :-P

Friday, January 9, 2009

ListView: A GridView With Insert Capabilities

When building applications with ASP.NET, the GridView control is particularly useful in displaying and editing data. However, the GridView lacks the ability to create new entries. That's where the ListView control from ASP.NET 3.5 provides useful. When used with the Grid layout, the ListView control provides an additional row at the bottom of the grid to insert new rows. It also provides an enhanced paging user interface.

Palm Pre WebOS

Palm unveiled the new WebOS which powers the Palm Pre smart phone. Applications for the Palm WebOS can be built with standard web development tools, which means you can carry forward your HTML and Javascript skills to the platform.

From a user's perspective, the focus of the WebOS seems to be convergence - it provides the ability to merge emails from multiple mailboxes, combine multiple contact lists (MS Outlook, GMail etc) with social networks such as Facebook, and calendars. It enables users to run multiple applications simultaneously, switching between them just as one would switch between multiple browser tabs.

The Palm Pre itself packs quite a punch with bluetooth, 802.11g WiFi, GPS, 8GB storage, accelerometer, touch screen and a sliding keyboard. Palm Pre units will be available to Sprint customers.

Microsoft Windows 7 Beta Download

The beta release of Windows 7 was made available for download on the Microsoft website here. The Microsoft website was down for quite a while as users hit the site hoping to get ahead of the crowd and claim one of the 2.5 million activation keys.

Copies of the beta are also available on torrent networks.

Google Chrome 2 Pre-beta

Google's Chrome browser has reached the pre-beta stage of version 2.0. The new version aims to make the browser more complete and narrow the gap with competing browsers by offering form field autocompletion, page-level zoom, browser profiles, and browser-script support.

To get access to the v2.0 pre-beta release, download the channel changer from here and use it to change your browser channel from Stable to Developer Preview.

The Most Shameless Apple Knockoffs

The Most Shameless Apple Knockoff

From: candyweb,
3 weeks ago

SlideShare Link

Remote Desktop on VirtualBox 2.10

The remote desktop display feature in Sun Virtual Box 2.10 is really cool. I plan on using it to install virtual machines on old laptops and desktops for running Linux. As I don't have the space to put up the old computers, I can simply stow them away in a cupboard and access them remotely.

If you haven't read the manual, here's how you can setup remote desktop access...

With the virtual machine turned off, go to the settings for the virtual machine and go to the Remote Display section. Keep the enable VRDP server checkbox checked, enter a Server Port (3389 is already taken, if you've enabled Remote Desktop from Windows, select Authentication Method "Null" (for private networks only; this allows anyone to connect from the network without using a password), and click Ok.

When running the virtual machine, you can go to the Devices menu to toggle Remote Display, if it isn't already turned on.

You can now connect to the virtual machine using the standard Windows Remote Desktop client.

Thursday, January 8, 2009

Beej's IP v6 C-Programming Guide

I did a Google search today, hoping to revive my C socket programming skills and came across Beej's guide. Those of you who learned C programming around my time would remember Beej's guide as the best quickstart guide to C Socket programming that ever was.

Well, now Beej's guide just got better. Last month, the guide was updated to include a section on implementing IP v6 so you can fire up your browser to surf to this URL and print yourself a copy of the guide to hold along your screen while you re-discover your C socket programming abilities.

Asynchronous Service Calls

When adding a service reference, Microsoft Visual Studio 2008 only generates synchronous method calls to the services. You can easily change this by clicking the Advanced button, and...

Add Service Reference dialog box
...checking the Generate asynchronous operations checkbox.

Check the generate asynchronous operations checkbox

It now generates the Begin*, End* and *Async methods for you to call from your application.

If you've already added the service references, you do not have to remove-and-add them to generate the asynchronous proxy methods - instead, right click the service reference and select "Configure Service Reference".

OLPC Moves To Windows

I know the news of the OLPC (One Laptop Per Child) shipping with Windows last November would've come as a shock to most of you because you wouldn't expect to wake up one morning and read it in the paper - it would seem too much like a prank somebody was playing on you.

OLPC now goes a step further by pulling out of the Sugar project and cutting down on staffing. However, on the positive side, the OLPC is also aiming at a model where it can distribute laptops for free - the "$0 laptop"! You can find a statement by Nicholas Negropon here.

Wednesday, January 7, 2009

Introducing IBM Lotus Notes and Domino 8.5

Introducing IBM Lotus Notes and Domino 8.5

From: tcoustenoble,
23 hours ago

With IBM Lotus Notes and Domino 8.5, world-class business e-mail and collaboration take another exciting step forward, offering new approaches to enhance efficiency and creativity, while extending the value of current investments.

SlideShare Link

2 Terabyte SD-XC card announced

The SDXC card format was announced today at the Consumer Electronics Show 2009. The new format would support capacities of up to 2 terabytes and a transfer rate of 300MB/s.

The SDXC specification will be published at sometime around March 2009. The SDIO and SDHC specifications will also be updated to enable higher data transfer rates.