Thursday, December 22, 2011

JavaScript Globalization

I am leading a project that is now going to go from running in the US to running across the world over the next 6+ months.

It currently uses a lot of different tech: ASP.NET MVC3, HTML5, jQuery, jQuery UI, KnockoutJs (w/Mapping), jQuery Templates, jQuery DataTables, EF4 and a host of other home-grown and one-off type technologies.

So, I started browsing the usual suspects, especially a previously bookmarked Scott Hanselman blog post (suspiciously a 7-month-old "part 1" with no "part 2" yet *holds breath*).

Well, the most confusing part I have run across so far is how to handle JavaScript and jQuery globalization.  There was one project by Microsoft that was donated/accepted/rejected by the jQuery folks (sounds familiar... jQuery Templates had the same problem) which, apparently went through a few renamings (one, two, three), the last of which was a renaming to "Globalize", total api change and removal of any dependency on jQuery (not sure if there was ever one, but didn't bother to get into it).

Confusingly, this library (not a plugin anymore) is maintained/developed by the jQuery UI team now, even though there's no dependency.

So, apparently, the supported(?), in-development code is now the "Globalize" library whose wiki is here (on the jQuery UI site, where else? ... O_o)

Hope that helps save someone else some time.

Saturday, November 19, 2011

Chain Of Responsibility Implementation

I was reading my twitter feed and came across a retweet from Glenn Block. The original was from Anoop Madhusudanan which pointed to his blog post called “Implementing Chain of Responsibility Design Pattern in C# using Managed Extensibility Framework (MEF)”.  It sounded very interesting, so I dug in.

[UPDATE: I have since updated this post.  Look for the block at the bottom]\

Monday, November 7, 2011

Hmm.. which one’s broken, Linq, Debugger, IDE?


So, I ran into an as of yet unsolved problem today.  I don’t know if this is a Linq bug, a debugger bug, or a Visual Studio bug, but, for your viewing pleasure:


If I can figure out what’s going on, I’ll post an update

EDIT: Figured it out..

This is one of the big reasons I don’t like operator overloading…

The items inside the FilterList overrode the comparison operators, but did not handle “null” properly…


Thursday, November 3, 2011

CSS Transform help

Just a quick blurb here...

I decided to try to do some fancy CSS stuff for my client website.  It involves gradients, transforms and stuff like that.  Anybody who's messed with that stuff knows that it's a huge pain in the butt to get it working in all the browsers, never mind one!  So, here you go:

You're welcome :)

Wednesday, October 26, 2011

Windows Azure AppFabric Cache's Miniscule Features


Just wanted to warn/inform people who are considering using AppFabric Caching in Azure…

Here’s a list of things it won’t do:

  • Regions
  • Named Caches
  • Allow you to get a list of cache keys currently in use
  • High Availability Mode (redundant copies across machines for durability)
  • No sliding window expiration
  • No events for things like eviction, add/remove, etc.
    • so you can’t update a local cache with events from the global cache
    • You don’t get notified if something is removed, so you only know when you get “null” back from a Get()
  • No Powershell integration (if you’re into that)
  • No tag support (tagging is basically used for some extra metadata besides the key without pulling the whole object)

So, basically, ALL you get is a simple, Get/Set distributed cache that doesn’t even support the whole set of features you get from the basic ObjectCache in .NET 4.0

They really shouldn’t be calling it “AppFabric Cache” at all, since it doesn’t really support anything that comes with that API

I must say that I’m really disappointed

We waited a LONG time for this feature and got something that could have been coded in a month.

Bad form, Microsoft.  Bad form!

Conflicts Between Versions Of Assemblies


I just upgraded a project from the Azure SDK 1.4 to SDK 1.5.  I started getting the "Found conflicts between different versions of the same dependent assembly" warning on the Microsoft.ServiceBus.dll file.

I thought to myself, "Self, I've seen this before.  You're just referencing the wrong copy of an assembly somewhere"

So, I checked every reference to Microsoft.ServiceBus.dll … Hmm… they're all correct. ??

I did a full rebuild… still there..

I did a super-duper clean (close the project, delete every "bin" and "obj" folder, open the project and rebuild)… nope…

Time to get medieval on this stuff… So, I opened the topmost assembly (in this case, my Web application assembly) in ILSpy. I stared looking through each and every referenced assembly until I found the culprit:


Microsoft's own Transient Fault Handling library (used for retrying database calls in Azure).  Now, I've contacted the team who wrote that, hoping that they will update their NuGet package.  Otherwise, I'll have to add that ugly Binding Redirect in my config file.

For now, I'll just stare at the warning for a while and hope the NuGet package gets a quick update Smile

Thursday, October 13, 2011

Useless Properties

[WARNING: hyperbole ahead!]

So, apparently the UserData property on the ASP.NET FormsAuthenticationTicket object is basically useless.

The UserData isn't persisted if you're not using cookies.  So, you get no errors, no warnings, the code runs fine, it just doesn't actually persist that data.

Nice going, Microsoft!

Monday, October 3, 2011

I volunteered for Give Camp in Baltimore

Geeks doing geeky things for charity!

Seems like a good idea.  I haven't done it before, so it should be a novel experience.
I'm one of those people that always wants to be charitable, but never really gets around to it.

Helping to make a functional website for a non-profit organization over a weekend seems like a pretty good way to do it.

Oh, it turns out that my employer is one of the Corporate Sponsors of the event as well!

Tuesday, September 6, 2011

Modular JavaScript Tracing

UPDATE (2/18/2012) -- I have moved the source code to Codeplex

Much to my chagrin, I have been doing a LOT of JavaScript debugging lately.  In order to handle multple "levels" of debugging information, I started using Ben Alman’s “ba-debug” javascript library (

ba-debug is really nice, but it's unfortunately "global", meaning that the setLevel() method and all the messages are switched with a single global switch.  After using it for a while, I decided I needed something more modular.So, I took his library and modified it heavily.

Being a fan of the .NET System.Diagnostics library, including the TraceSource/SourceSwitch objects, I decided to emulate that somewhat. result is the Trace file I’m including here.

Here’s a brief overview of how to use it.

(NOTE: When I say "module", I mean a closure/module as defined by this -- and many other-- article:

The idea is that, in some sort of module, you do this:

   var _trace = new Trace('ModuleName');

Then, when you want to trace out any level of diagnostics, you do:

   _trace.debug('ItemsListView - redrawing...');

Supported methods are: error, warn, info, debug, log
The current default level is “error” for all Trace objects.

If you want to increase that level for a particular module, you insert a line like this into your web page:

   Trace.traceLevel('ModuleName', Trace.Levels.log);

Trace.Levels contains all the method names and “off” as options.

Additionally, I continue the functionality that ba-debug gives you so you can set a callback function for Trace messages like this:

    Trace.setCallback(function (args) {
        // do something with the arguments array here.
    true, // force it
    50); //  give me the last 50 at most 

  1. A method that receives an array of the arguments that were passed to the trace message (the level should be the first argument in the array).  Pass null to turn it off
  2. Boolean on whether or not to “force” the callback.  If this is true, it will always call the callback for every message.  Otherwise, it will only call the callback if the browser doesn’t support the “window.console.log” method (at the very least).
  3. A limit to the number of messages to be given up front.  Since messages could have accumulated before you call the callback, there may be a flood of messages right away when you set the callback up, so this will stop you from getting too many messages in the beginning.
The 2nd and 3rd parameters are both optional.

The callback will be called for every existing message (up to the optional "limit") and for all subsequent trace messages.  Note also that the callback does NOT get filtered, so it receives all trace messages.

If there is any expressed interest, I can go over the implementation of the object in detail as well in a follow-up post.


Download the whole file here:

Preventing accidental deployments to Azure

Your Azure Roles won't start. You're in the painful loop of "Busy", "Stopped", "Busy"... maybe they're reporting themselves as "unhealthy". It's Azure Deployment Hell and we (those of us who do Windows Azure dev) know it well.

Well, one of the situations that casuses this is easy to prevent: Deploying the wrong configuration to Azure.

In the name of pride, we need to avoid this embarrassing time sink and I'll tell you how. On my current project, the production scenario consists of using a "Production" Service Configuration and an "AzureRelease" Build Configuration. So, I want to make sure that these two things are selected when Packaging/Deploying the software.

So, we turn to MSBuild tasks:

Manually edit the ".ccproj" file and insert the following before the tag.
  1. <PropertyGroup>
  2. <PublishDependsOn>
  3. VerifyAzureRelease;
  4. $(PublishDependsOn);
  5. </PublishDependsOn>
  6. </PropertyGroup>
  7. <Target Name="VerifyAzureRelease" Condition="'$(Configuration)' != 'AzureRelease' Or '$(TargetProfile)' != 'Production'">
  8. <Error Text="Should Not Be Deploying non-AzureRelease Code" ContinueOnError="false" />
  9. </Target>
The tag redefines the standard group to include your new "VerifyAzureRelease" <Target> Task where we test for the conditions we want and spit out an error if they are not fulfilled.

Hopefully, this will help some other unfortunate souls out there from going through this problem as many times as I have.