Monthly Archives: June 2007

Can’t stream flash video in IIS

I’ve got more than one gray hair from this one. The symptom is simple: Cassini (the development web server) hosts streaming flash videos just fine. IIS shows a white box.

The answer is annoyingly simple:

1. Open IIS Manager, choose the website.

2. In IIS 7, choose “Mime Types”. In IIS6, right-click, choose properties, choose the HTTP Headers tab, and choose File Types.

3. Click Add. Extension is “.flv” (no quotes), mime type is “video/x-flv” (no quotes)

Not sure if you need to restart the website for changes to take effect. Now hopefully, I’ll remember that next time I’m ready to burn some time trying to figure it out…


“My VM disk is too small”

I’ve loaded up a Vista VMware session with all sorts of fun gizmos, and came to a perplexing dilema: “My VM disk is too small”.  Yeah, I could’ve just created a new virtual disk, called it D: and been done with it, but I wanted more space for Documents, Program Files, Windows Updates, etc, etc.  I didn’t want a D: drive, I wanted a bigger C: drive.

Here’s what I did:

1. vmware-vdiskmanager -x 32GB myDisk.vmdk  That was easy … kinda.  vmware-vdiskmanager expands the disk, not the partition.  C: is still the original 16 gigs.  vmware-vdiskmanager is in the VMware Workstation directory, the *.vmdk file is wherever your VM data is.

2 wrong #1. Vista has built-in disk resizing.  Wouldn’t I love it if I could resize the system partition.  Booting the VM and trying to resize the partition failed miserably.

2 wrong #2. vmware-mount the disk.  The host’s Disk Management didn’t see the mounted disk.  Unmount, and try again.

2 that worked. I copied the VM, opened the copy in VMware Workstation, and edited the new VM’s profile.  I added a second hard drive, pointed it to an existing disk: the original VM’s disk, and booted the new VM.

3. Vista’s disk manager is available by right-clicking Computer, choosing Manage, and choosing Disk Management.

4. Click on the second disk, right-click to choose expand, and enter the size.  This dialog confused me.  Apparently I’m entering the size to expand the partition by, not the new size of the partition.  Um, that was odd.  I click ok, and the partition magically resized.

5. Shut down this new VM, unlink the second disk, and delete.  (Yeah, having backup copies of VMs is kinda handy, and you spent all that time waiting for the huge files to copy already.  If you’ve got drive space, leave it be.  But do remove the original VM’s disk from the new VM’s profile.  Having the second VM think you’re potentially dual-booting is bad news.)

6. Boot back up the original VM.  Since it was used as a secondary drive, it’s boot info is toast.  Enjoy the nice “winload.exe is missing or corrupt”.  It’s actually just fine.  Power down the VM.

7. Put the original Vista disk in the drive or link the Vista iso to the VM’s CD drive.

8. Boot off the Vista DVD, and choose “repair my computer”.  As Vista’s setup repair was loading, it noticed my boot manager was hozed, and said, “Do you want to fix this and reboot?”  “Um, why, sure.  That is after all my purpose.”  I never even needed to bust out “fixboot” and “fixmbr” from the repair console.

9. Reboot the VM, unlink the Vista ISO or remove the DVD.

Vista now boots up just fine with the bigger hard drive.  But we’ve changed stuff.  Depending on how severe Vista thinks this change is, you may be in for a call to Microsoft to re-activate Vista.

While you’re on the phone with Microsoft, you can buy a second copy of vista for your new “backup” VM.  Or you can “delete” it.  After all, one of the questions is how many computers this license of Vista is on.  With that backup VM kicking around, your answer has to be 2.

Outlook 2007, the RSS Reader

I finally sat down to load up all my RSS feeds from Google Desktop to Outlook 2007.  Um, oops.

My RSS needs are simple:
– I want to group feeds and aggregate their results
– I want multiple groups of these aggregated results so I don’t lose infrequently posted sources

Group 1: I download my daily ‘newspaper’ by aggregating cnn, slashdot, abcnews, engadget, the register, wired, etc.  I consider this for the most part disposable knowledge: if I miss a post or a day’s worth of posts, so what.  I want to read my news as an aggregated list: newest first, combine all the feeds together.

Group 2: I have my list of code blogs: local .net user group members, 4guysfromrolla, codeproject, ScottGu, etc.  With few exceptions, I want to consume all this knowledge.  I don’t want to miss any.  Some of these feeds are posted frequently, some not so much.  I want to view two separate lists in this category: The frequently posted stuff (mostly Code Project), and the not-so-frequently posted stuff.  I don’t want to lose a ScottGu post because 8000 of my closest friends posted commentary on code project articles.  I want to see all new stuff in all feeds, sorted by newest first, but I also want to be able to aggregate only the infrequent lists separately.

So, now that we’ve got my needs arranged, let’s discuss Google Desktop and Outlook.

Google Desktop has served me well.  I use Google Desktop’s standard RSS reader to plug all my news feeds into.  It aggregates by date/time, old stuff falls off the bottom, I like.  Sadly, I can’t have 2 of this gadget, and can’t find the source to change the GUID so I could plug in two.  Bummer.  Well, along came gdRss.  It’s a second RSS reader plugin for Google Desktop.  Great: I plug all my code feeds into here, and I’m good.  As long as I cap the frequent feeds to 10 each, I probably won’t lose the infrequent ones … hopefully.  Really, I’d like 3, but so far, only 2.

Well, all is good, except gdRss frequently crashes Google Desktop.  Um, that’s very not good.  It seems to choke trying to parse a feed if it doesn’t end in something simple.  For example gives it fits.  As does  Apparently “.rss?p=1…” isn’t a valid extension?  Um, anoying, but ok.  The registration process is equally annoying.  It brings up this very beautiful activation screen (much prettier than the app itself, by the way) that requires I activate my purchase within 5 or 8 uses or something insanely short.  The theory goes that there’s a “free” version capped to 3 feeds.  Yeah, like that’d help at all.

gdRss must be abandon-ware.  I haven’t seen an update in more than a year.  Meanwhile, Google Desktop 5 brought about a black theme and all-but did away with non-JavaScript plugins.  (This was probably so Google Desktop didn’t crash with those C++ errors when some hack such as myself tried to cast null into a char* then increment it.)  So, here I am with a single white plugin tied to a machine that’s dying.  And I can’t get no lovin’ here.  Emails to the author get a quick auto-responder that I’ll get a response in 1 business day.  A week later, nothing.  Posts on gdRss’s Google Desktop forum are all about mortgage deals and fake watches.  And my normal post also goes unanswered.  Um, bad news.

Ok, the move to Outlook.  Outlook 2007 sports feed reading — part of the unified messaging concept.  Yeah, I know, get my voice mail as a sound file attachment to a message in my email inbox pushed to my PDA.  Yeah, cool, not what I’m after here.  I get my list of feeds (copy/paste from gdrss — oops, forgot the export function there), and copy/paste them nicely into Outlook.  I even arrange my folders nicely so they’ll aggregate nicely into the groups I’m looking for.  All is well … until.

I click on a folder.  It’s got mounds of content from each feed.  I’m just swimming in goodness.  And what does it show me?  Nada.  Apparently in Outlook, they “preserved the email feel” by not aggregating the results up through the RSS feeds folders.  A quick search for Outlook 2007 RSS turns up a lot of info on “aggregate” and “Office 2007”.  Apparently their definition of aggregate is I get to see multiple posts in the feed, like multiple emails in a folder. 

Um, Microsoft, did you miss the memo?  “The aggregator provides a consolidated view of the content … ”  ( source: )  Aggregate means combine.  Show me the combined, aggregated list of all my feeds in this folder.  Show me a “please click on a feed” link.  Show me a “you can combine these feeds by changing this preference setting” message.  Nope, the only folder that’s different is the one tied to Microsoft’s help site.  (And wonder if they’re using the hits on that page to track Outlook usage, by the way.)  Splunking through the preferences for the folder gives me options for archiving feeds — nice, perhaps, but not the goal at hand.  Nothing about changing what displays here.  Apparently Outlook doesn’t combine feeds together.  Oops.

So, the tally:
– gdRss: abandonware.  Wish I hadn’t bought it.
– Outlook 2007 RSS reader.  I guess what can I expect for a v. 1 product?

Anyone know a good RSS reader that will allow for many groups of combined results from diverse sets of feeds?

Curly Braces — the holy war

I sense I’m spurring a holy war discussion when I raise the issue, but some have asked why I code with curly braces on the same line rather than a new line. 

My answer is simple: readability.

The goal with any code is not solely to accomplish the problem at hand, but to make the code legible for the casual reader who will come by it later on.  Maintainable code is written legibly.

As an example, consider the Visual Basic type “variant”.  It defines a variable as “something”.  Um, gee, thanks.

Dim myvar as Variant
myvar = “1”
myvar = 1
myvar = 1.0
myvar = Workbook.Worksheets[0]

What is myvar?  Is it an int?  A string?  A float?  An object?  None of the above?  Is it a value type?  Is it a reference type?  Maintaining code that use variants is a nightmare.

Visual Basic has quite a few more features that make code difficult to maintain, but leaving them aside, the entire concept of variant is undescriptive.  It does not descriptively explain its intended use.  Though syntactically correct, it does not document itself very well.  It is “write only” code.

Curly braces in all C-style languages define code blocks much more susinctly than Visual Basic’s “End If”.  You can casually glance through code, watch curly braces open and close, and know you’ve changed a variable’s scope.  However, curly braces have a dark side.

Curly braces can define two sets of behavior.  Coding with { on a new line for both behaviors does not specifically define which use you are looking for.  Only by looking to code around the { do you know what the curly brace really does.


Consider the following:

{ defines the start of a scope and } defines the end of a scope.  Coders define blocks inside { and } to define scope of variables.  They document the scope by indenting contained code with tabs:

int i = 0;
       int j = 1;
// j doesn’t exist here
// i does
       string j = “value”;
       // this j has a different meaning and purpose than the j above


{ and } are also be used with looping structures (while, do … while) or iteration structures (for, foreach).  In these structures, { and } not only define the scope of the variables, they define the scope of the loop.

bool j = false;
while (j)
       int i = 0;
// i doesn’t exist here
// j does

Most now take it for granted that with looping structures, the { they see defines the start of the loop.

for ( i = 1; i …
       places[i].Z …

Our lazy coding brains combined with our speed reading skills single out the first few characters on the line, and produce the above comprehended text. 

Is i in places[i] in the same scope as the loop?

The actual code is thus: 

int i = 0;
for ( i = 1; i < places.Count; i++ ) { problems++ }

       places[i].Zip = “12345”;

We can see the loop has very little to do with the scope of places[i].  This type of error would likely be very difficult to find.  (Granted, in my overly simplistic example, it was easy to find.  But when conditionals or parameters get long winded, and white space is added to break up long lines, and curly braces get pushed around, the confusion is an easy one to make, and a difficult one to read.)

Add to this confusion that some don’t even put curly braces around simple loops:

for ( int i = 1; i < places.Count; i++ )
       places[i].Zip = “12345”;

If we train our minds to look for { as both the start of scope and the start of looping structures, we must mentally decide each time we see one if it is indeed a behavioral modification or just a scope change.

If we instead train our minds to look for looping structure words (for, while, foreach, do … while) as the start of a loop and { at the beginning of a line as the start of scope not in a loop, the distinction in code is clear:

for ( int i = 1; i < places.Count; i++ ) {
       places[i].Zip = “12345”;

while ( j ) {
       int i = places[k].Address;

int i = 0;
       int j = places[k].City;

These 3 sets of code are much more legible with the curly braces after the looping structure verbiage than on a new line.  The first two are looping structures, the third is a scope change.


This same methodology extends to higher level elements in C-style languages:

public void DoSomething( int …

is much clearer than

public void DoSomething( int …


Does the second example’s { start a new scope inside the function?  Probably not, but you don’t know this without reading to the end of the method declaration line.


This distinction is especially clear if the context around this code looks like so:

myevent.onclick += new EventHandler( {
            // declare anonymous method
            public void DoSomething( int a, string b, object c, int d, string e ) { return string.Format(“{0}{1}{2}{3}{4}{5}”, a, b, c, d, e; }
} );

myevent.onmouseover += new EventHandler( {
            // declare anonymous method
            public void DoSomethingElse( int a, string b, object c, int d, string e ) { return string.Format(“{5}{4}{3}{2}{1}{0}”, a, b, c, d, e; }
} );


I code specifically for readability and legibility.  When curly braces are concerned I use these rules:

– special words like for, while, public, namespace, etc define the start of a specific type of behavior

– { on a line by itself starts a scope not associated with unique behavior

– Every looping structure contains { and } even when it is technically correct to omit them

These are far from the exhaustive list of rules I use for legibility.  I also use rules like the following:

– Comment anything that looks unusual

– Use parenthesis and white space libarally

– Use incrementers ( i++, –j ) on their own line to specifically eliminate the confusion of “increment first then assign or assign then increment?”

– Use variable names that describe the context of its use, not of its variable type

– Add blank lines around specific blocks of functionality

– Make methods short and precise.  If the method goes on for 3 pages with 4 or 5 nested scopes, it is time to refactor.

– Add spaces between variables, operators, parenthesis, and braces:

       for( int i = 0; I < 10; i++ )

       for(int i=0;i<10;i++)

Though these two are syntactically identical, the first is much more legible.

The good news is Visual Studio makes these types of decisions painless to implement across all your code or your entire team.  In VS 2005, choose the Tools Menu -> Options -> Text Editor.  You can modify the settings per language or globally for all languages.  Adding spaces between variables, setting braces on the same line, and defining many other scenarios is simple as pie.

Did you just download a code sample that isn’t formatted the way you like?  Open up each file you need to read in Visual Studio, remove the last } from the document and retype it.  It will reformat the entire document to match the formatting preferences you’ve defined.

Now Visual Studio’s elegance starts to break down if you work in multiple formatting styles.  Some organizations may require formatting that does not match your personal style.  Visual Studio has no way to set curly brace styles per solution or per project.  The closest you can come is saving each set of preferences, and loading each as you start up the project of choice — hardly an automated solution.