comments edit

Looking through my statistics today and I noticed that I received a lot of hits from this post about Google Maps using satellite photography.

Looking in my referrer logs, I noticed that most of the visits were rolling off of Google form users who were searching for the term “Google Satelite”. I just happened to be the fourth search result on the page.

“Cool” I thought to myself, “but they’re all misspelling “satellite”. Then it occurred to me that they weren’t the only ones who were spelling challenged. I had inadvertently misspelled “satellite” in the title of my post.

I’m probably dredging up yesterday’s news here, but it occurred to me that one could really get great search results for hot search words by misspelling them in ways that people commonly misspell them. This is the same thinking behind someone who tries to register “” or “” hoping that millions of typos will send users their way.

So if you want to be THE blog about “onomatopoeia”, start writing about your love of “onomatopeia” or “onomatopoea”. That’ll create some buzz.

I’ll have to figure out a way to register “”.

comments edit

UPDATE: As a commenter pointed out, the original code example did not properly demonstrate the problem with locking on the this keyword within a normal method. I have corrected this example and wrote a better example that demonstrates that this problem still exists even in a “normal” method.

Take a look at this code:

private bool isDisposed = false;
//... code...
            //Do Stuff...

Hopefully you can see the problem here right away. The lock statement takes an object instance as a parameter. So what happens to the boolean isDisposed within the lock statement? That’s right! It gets boxed, meaning a new object instance is allocated and passed to the lock statement. Thus every time you lock on a value type, you’re locking on a new object.

Ok, so let’s try to fix this up a bit.

private bool isDisposed = false;
//... code...
            //Do Stuff...

So is there anything wrong with this? You’ve probably seen the Microsoft examples locking on this. Well never give full trust to example code (especially as it’s unlikely you’ll add the code to the GAC) ;). Suppose this snippet is from a class MyClass. What do you think will happen with the following code:

MyClass instance = new MyClass();

instance = null;


You guessed it! Deadlock.

Every time you lock a .NET object, the runtime associates a SyncBlock structure to that object. Locking works by checking who owns an object’s SyncBlock when attempting to acquire a lock. Thus in the code sample above, the client code and the Dispose() Method are attempting to lock on the same object.

For a more in-depth discussion, I highly recommend Jeffrey Richter’s article Safe Thread Synchronization which is where I first learned about this subtle threading issue.

Likewise you might also take a look at Dr Gui’s Don’t Lock Type Objects post.

sql comments edit

In T-SQL, you can use the @@IDENTITY keyword to obtain the value of the identity column when you insert a new record. For example, the following query inserts a record into an imaginary table and returns a result set containing the ID of the inserted column.

    SELECT Value1, Value2


There’s the potential for a subtle bug here. Suppose later on, a coworker realizes that any time a record is inserted into [SomeTable] a record should also be inserted into the table [SomeTableAudit]. The simplest solution would be to add a trigger to [SomeTable] that inserts a record to [SomeTableAudit]. But in doing so, your coworker introduces a case of @@IDENTITY theft. Your original query will now return the value inserted into the IDENTITY column of the tabel [SomeTableAudit] instead of the IDENTITY value of [SomeTable] as you intended.

At this point some of you are shaking your heads muttering  

Well I never use Triggers. Triggers are bad umkaaaay.  

That’s beside the point, you never know when someone else is going to apply that trigger resulting in this unintended consequence. It pays to program defensively. The issue here is that although @@IDENTITY is constrained to the current session, it is not constrained to the current scope. Instead, use the SCOPE_IDENTITY() function which will return the last IDENTITY column value inserted in the current scope, in this case the value inserted into [SomeTable].

    SELECT Value1, Value2


As an aside, I’m fine with triggers in certain cases. One of the primary complaints about triggers mirrors the complaints about Aspects in AOP. Namely that triggers provide for unintended consequences that aren’t visible when examining a stored procedure. However when used sparingly for cross-cutting functionality, I think they can add a lot of benefit. Much like Aspects.

UPDATE: Steven Campbell adds a great tip.


Another tip I can offer is that you should not use ADO in combination with SQLOLEDB to retrieve IDENTITY values. I refer specifically to the technique of: \ myRS.AddNew\ …\ myRS.Update\ myId = myRS(“ID”)\ \ This fails to retrieve the correct ID, because (internally) the SQLOLEDB driver issues a SELECT @@IDENTITY statement to retrieve the newly created ID.

comments edit

Stewie This is old news, but I am so glad that the Family Guy is “uncancelled”. It truly is of “The Simpsons” caliber of humor.

The irony of my statement is that we pretty much don’t watch TV any more. Instead I look forward to new seasons appearing on DVD (and thus in our Netflix queue). We watched a DVD of old Family Guy episodes last night and I nearly burst a vein from laughing. I’m a very physical laugher.

My favorite character (shown) is the diabolical baby Stewie. He’s also the source of my favorite quote in the show so far.

Damn you vile woman, you’ve impeded my work since the day I escaped your vile womb.

comments edit

I’m feeling a little uninspired to write anything interesting because my hands are hurting from the keyboard pounding I’ve been doing. Instead, I thought I’d dig up this really simple (and hopefully useful) AddressInfo class for you. The code is extremely basic, but it might save you the hassle of typing all fifty states (and some territories and the District of Columbia) and their two letter postal codes into your own class because I did it for you! Free of charge!

If I save one hand out there, my work here is done. The basic premise is this, the U.S. isn’t adding states to the union very often, so it makes sense to have the list of states and state codes as an enumeration rather than a lookup table in the database. Makes it easier to re-use that information not to mention the speed. For example, here’s a snippet of one of the StateCode enum available in the class.

public enum StateCode


    /// <summary>Alabama</summary>


    /// <summary>Alaska</summary>


    /// <summary>American Samoa</summary>


    //,… Bunch of other states …,

    /// <summary>Wyoming</summary>



And here’s a snippet of the corresponding State enum.

public enum State


    /// <summary>AL</summary>


    /// <summary>AK (Home Sweet Home)</summary>


    /// <summary>AS</summary>



    ///,… Bunch of other states…,


    /// <summary>WY</summary>



The main AddressInfo class is used to hold an address, but isn’t all that useful nor interesting. The interesting methods are the static methods used to convert from state codes to states and vice versa. Here’s a couple examples of how you might use these methods:

// Get the state name based on the state code.

string stateName = AddressInfo.GetState(StateCode.AK);

Console.WriteLine(stateName); // Prints “Alaska”


// Get the state name based on the state code string

string stateCodeText = “CA”;

StateCode stateCode = AddressInfo.ParseStateCode(stateCodeText);

State state = AddressInfo.Convert(stateCode);

Console.WriteLine(state.ToString()); // Prints “California”

Let me know if you actually find this useful. The class itself can be downloaded here.

[Listening to: Psychedeliasmith / Give Me My Auger Back - Fat Boy Slim - On The Floor At The Boutique (4:21)]

personal, code comments edit

UPDATE: 2014/05/13 I lost it when I migrated it and honestly i don’t feel the need to have it up at the moment.

I put up an HTML version of my resume on my blog.

It has a slight bit more information than my Word resume which I think lends well to the online experience. For a moment I thought about using the Marquee and Blink tags all over and have animated dancing babies, but I don’t have the design skills to do that tastefully. I even forgoed adding Google and Amazon ads all over.

Since I’m now an independent consultant, I think it’s a good idea to have that sucker online, though I think my blog posts will give the potential client a better sense of my experience and abilities.

If you have suggestions for online resumes, let me know. I’ve thought about adding even more information in collapsible regions etc… in an effort to make it more “interactive” but I thought better of it. Maybe simplicity is best for now.

comments edit

Brian had some sort of conference to attend, so I didn’t get to see much of him. But last Thursday he was at Venice Beach so I took a break from my work and drove out there. Soon enough, we got to doing that which all brothers must do when they haven’t seen each other in a while.

Brothers at the Beach

Yeah, real nice to see you too!

comments edit

For some reason, I’ve always wanted to write a book. It started off as a desire to write the next Lord of the Rings classic, but has morphed into writing a reasonably useful technical book.

So after reading Mike Gunderloy’s 8 part “Advice for Writers” and Eric Gunnerson’s post “So You Want to Write a Computer Book”, I’ve come to the conclusion that it might be better for me to start off with a few print articles.

Ultimately I’d love to contribute an article to Wired (the best damn magazine on Earth…and beyond), but for now, I’m looking at various .NET technical journals and magazines. If you have experience writing for a magazine and have recommendations on publishers who were great to work with, please let me know.

comments edit

So I spent a bit of time today to “refresh” the look of my site. On the face of it, it’s not a dramatic change, but under the hood, I tore out the table driven layout and replaced it with a CSS driven layout.

For you aggregator readers, take a look and let me know what you think?

And if it looks really wack, try a hard refresh (CTRL+F5) because the stylesheet may be cached on your computer. If it still looks wack, try drinking 6 beers in quick succession and let me know how it looks with beer goggles on.

I should also mention it looks better in FireFox than IE.

code comments edit

As part of my site’s redesign, I wanted to keep the drop shadow effect on the left and right borders of my main content area. No problem I naively thought, I’ll simply add two background elements to the main div. I named the div “background” like so:

<div id="background">

And in my style sheet, I tried the following:

    background: url(leftBorder.gif) repeat-y left;
    background: url(rightBorder.gif) repeat-y right;

Unfortunately this did not work as only one of the background images showed up. What I ended up resorting to was using two nested divs. The inner div would contain the main content and the right border while the outer div would display the left border.

<div id="backgroundLeft">
   <div id="background">

At this point, I needed the two divs to overlap each other just right. The inner div needed to align over the outer div’s right edge. On the left side, the inner div needed to expose the outer div’s left edge so that the background image would be displayed. Here’s the CSS I used.

    margin: 0px;
    background: url(leftBorder.gif) repeat-y left;
    width: 784px;

    background: url(rightBorder.gif) repeat-y right;
    margin-right: -11px;
    margin-left: 11px;
    position: relative;
    top: 0px;
    left: 0px;
    padding-top: 3px;
    width: 783px;

So my question to you CSS gurus out there (if any), is there a better way for me to accomplish this?

comments edit

Yeahronimo, which owns the rights to the Commodore brand announced that they are nearing the release of a Commodore tablet PC called the Commodore 256, simply because that’s twice the number of the last Commodore 128.

comments edit

Ok, I’m in nerdvana. I got my 2 x 1GB PC 3200 DDR 400 cards today and my machine is noticeably snappier today. On a lark, I decided to open every application on my machine just for kicks. Ok, maybe not. But doing DotNetNuke development is no longer a pain for me.

comments edit

I’m sure you’re constantly asking yourself this, because I certainly wake up every morning in a cold sweat wondering. When you add a new project in Visual Studio.NET 2003 (friends call her VS.NET), you get the following dialog

Add New Dialog \ The beginnings of another bug ridden coding section…

Now looking at that familiar dialog underneath the “Project Types:” section, you probably noticed the usual suspects are there: “Visual C# Projects”, “Visual Basic Projects”, etc… But did you also notice there’s a few other folders there such as “Visual C# Projects for DotNetNuke 3”?

Now for the million dollar question: How do you add your own folder there?

Reading through what I could find online, I understand how to use your .vsdir and .vsz files to create a new template, but I couldn’t find anything that described how to create your own project type grouping.

So I did a little digging through the registry and found the following registry location:


Just to make sure that adding keys to this location in the registry was sufficient, I brashly took Regedit (without even backing up my registry, an incredibly stupid thing to do), and created a new sub key, using SQL Query Analyzer and the newid() function to generate a new GUID for me. Under that key I added a sub key named “/1”. Under that key I set the following three values as seen in this screen shot.

Registry Settings \ Must this egotistical idiot use his last name in everything?

And here you can see the registry keys structure. The one I added is at bottom.

Registry Keys \ Ahh, “Haack” is nowhere to be seen. Forturnately it’s not a proper GUID.

So the next step is to create a VS.NET Setup and Deployment project to package my templates and add this registry setting automatically. Hope you can sleep peacefully now.

comments edit

I will neither confirm nor deny that this is where I used to work before going independent. I’ll only say that they’ll be doing some interesting work with .NET and it’s worth checking out.

We are looking for Software Engineers. If you have a minimum of 3-5 software development experience - including at least 2 years of C#, ASP.NET and SQL Server and if you are interested in a position in Los Angeles (right near Miracle Mile) please post a comment.


comments edit

fire hose In my post entitled Drinking From an RSS Fire Hose I dealt with some of the issues surrounding the flood of incoming RSS entries within an RSS aggregator raised by Dare’s post “Nightcrawler Thoughts: Thums Up, Thumbs Down and Attention.xml”.

The Keep It Simple Stupid Solution\ Reading through some of the comments on both posts, I realize that for a great majority of users, a very simple system will satisfy their needs. One user mentioned that it’d be nice to be able to have items with specific keywords automatically marked as read. This is great if you’re tired of hearing about, say, Paris Hilton. Add the keyword “Paris Hilton” and no longer will you have to endure her name in your aggregator.

A Short Story\ I started to get a buttload of comment spam on this blog recently. I thought about using CAPTCHA, Bayesian Spam Filtering, etc… But in the end, I simply added a trigger modified from this one that simply blocks posts with a certain number of link. This resulted in a dramatic decrease in the number of posts about online poker and has been working quite well for me. At some point, I’ll probably need to employ more sophisticated tactics, but for the time being, this simple rule works.

Extensibily Model\ Personally, I think the initial solution isn’t a filter at all, but the extensibility model prototyped by Torsten.

Rules Engine\ On top of this, I’d probably build a simple rules engine plug-in similar to Outlook’s. For example, you might create a keyword rule associated with one of the following actions: Mark as Read, Flag For Review, Give Priority, etc… As my short story above illustrates (see, there was a point to it), a simple rules engine approach will often give you the 80% of the 80/20 rule.

The Goal\ The goal with this approach is to get something to the users quickly that will elicit feedback on what the pimped out “baysesian/collaborative/neural networked/throw dart at dartboard” filter should do. A collateral benefit is that users will inevitably create their own plug-ins (we hope) and we have the option to take the best ideas and integrate them as a first class feature.

[Listening to: So What’cha Want - Beastie Boys - Check Your Head (3:37)]

comments edit

Did you read about the Chinese online gamer who stabbed a competitor after the competitor sold his borrowed virtual sword?

One phrase in the article caught my attention:

But other experts are calling for caution. “The ‘assets’ of one player could mean nothing to others as they are by nature just data created by game providers,” a lawyer for a Shanghai-based Internet game company was quoted as saying.

I don’t buy that argument as I told my friend Walter who wrote about this from a legal perspective. The argument that the “assets” of one player means nothing to others just because its virtual actually applies to all property, physical or otherwise.

If society in general decides that virtual assets are somehow inherently different than physical assets, then it behooves the gaming companies to create a microcosm of the real world within the virtual space. Think about it for a second. If I’m paying $20 to $40 a month (not to mention my time) to play some online game, I want to make sure that if someone swindles me of property that has real-world market value, I have some means for recompense.

Can you picture it? Using a portion of the online gaming fees, these gaming companies might neet do hire virtual police force where characters can resolve violations of the “law”. Likewise you might start a character to be a virtual lawyer to handle arbitration between characters. Heck, I’d probably create a character and provide consulting work within the virtual market

Look, your dragon slaying operations is suffering from bottlenecks at the weapons manafacturing plant. I’ve got some magic potions here that will integrate your Dwarven procurement system with an EERP (Elven ERP) system providing efficiencies in your supply chain. I can also build you a portal.

The problem with this of course is that a game world is not meant to be like the real world. For example most MMORPGs involve a lot of killing. Some even allow killing other characters. If my character were to kill your character and then take your stuff, should you be able to sue me for the real-world material value of your character’s possesions? That would certainly put a damper on the game.

I don’t think many game companies anticipated that virtual assets would command such real world market value and did not prepare for thes scenarios. It seems to me that they ought to require waivers from players indemnifying all other players and the company from any loss involving virtual assets. Either that, or put an in-game arbitration system in place and have players sign waivers stating they agree to resolve disputes via the in-game system first.