This blog has, IMO, some great resources. Unfortunately, some of those resources are becoming less relevant. I'm still blogging, learning tech and helping others...please find me at my new home on http://www.jameschambers.com/.

Thursday, September 16, 2010

Firefox is Really Slow Testing Sites on Localhost

If you are developing web sites and are trying to test on the major browsers you’ll likely notice that IE and Chrome are quick like bacon but Firefox poots along like a hamster on crutches.  This is true when you have an IPv6 IP address on your NIC and you are working on localhost.

It is particularly frustrating when you’re doing Ajax scripting…especially with autocomplete-type functionality.

The Fix

Here’s how to bury it and fuel Firefox to surf your development server at superhighway speeds:

  • Open up Firefox and type about:config in the address bar
    image
  • Promise to be careful…seriously ;o)
    image
  • In the filter input, type ipv
    image
  • Double-click on ipv4OnlyDomains, and type localhost
    image
  • Click OK to confirm changes.

I didn’t have to restart Firefox to get this to work, but YMMV.  Now she should run like a beauty.

Hope this helps!

Thursday, September 9, 2010

Good for a Smile

Been really busy at work and with a couple of side projects (including a writing contract that I will announce shortly). 

A buddy emailed this to me (sorry, I can’t credit the original artist, if you know, please pass it on!) and I thought it was worth sharing.

 

image

This is particularly funny to me because:

a) I do shadow puppets with my kids all the time, and,
b) I’m actually pretty tired.

Wednesday, September 1, 2010

Getting Started in Azure - The PhluffyFotos Sample Application

I initially wanted to create a post that would get someone up-and-running with Windows Azure, start to finish, but the reality is that there is no “simple” app you can create. While you can create a simple data service, or a simple MVC web site, or even walk through the implementation of a simple worker role, there are many parts to an Azure application, each warranting their own series of posts.

However, I found an out: the Azure samples and training site.  I have been around long enough to develop within most of the paradigms required for Azure development, so, with my head as big as it is, I didn’t want to go through a walkthrough that was dozens of pages long.  There is something that is instantly gratifying about having a working app in front of you that you can poke and prod and change and learn to understand.

What this post is not

This is not a comprehensive walkthrough or a hand-holding exercise to get you up-to-speed in Azure development. You will not be a professional Azure developer ready for your first cloud app assignment.

I am not sharing the code as text in this post.  If you’re going to follow along, you’re going to have to have the sample downloaded (the link is inline in the post).  My assumption is that you’re able to navigate your way through a solution and find the code files I’m discussing.

What this post actually is

The first part of this post should take you less than 30 minutes and you will have PhluffyFotos running locally.  The application makes use of Azure data services, workers, and the ASP.NET MVC 2 framework.  It’s billed as fairly 2.0-ish, and has a functional Silverlight 2.0 slideshow viewer to boot.

image

The second part of the post breaks down some of the UX elements and explores some of the tech that powers said UX.

I have a fairly clean install of Window 7 with Visual Studio 2010 running on it, so there should be no surprises if you’re running with a similar setup.  As I progressed through the procedure I have taken notes so that you should be able to replicate my steps.  If you find that I have missed anything, please let me know!

Enable Azure tools through the Visual Studio 2010 Project Templates

Create a new project and select the category of “cloud”.  Walkthrough the download, exit VS and install the tools.  You can obviously omit this step if you’ve already setup Azure tools on your machine.

Download the sample app

This is located here on CodePlex.  Unzip it to it’s default location.

Enable PowerShell Scripts for Scripts Signed by a Trusted Source

To do this, run PowerShell in administrator mode and use the following command:

Set-ExecutionPolicy RemoteSigned

Build PhluffyFotos

Open Visual Studio 2010 in administrator mode, then navigate to and open up the solution in the code directory.  It’s located in the root of the folder you unzipped in the second step.

Do a CTRL+SHIFT+B on the solution to build out the bits.

Close down VS2010.

Provision Local Queues and Storage

This is required so that you do not have to sign up for an Azure account.  At this time, only residents in the USA have the opportunity to create one (even for test purposes) without a credit card.

Open up a command prompt in administrator mode and navigate to your setup/scripts directory in the project folder.  Type the following command and hit ENTER:

provision.cmd

You don’t technically have to run this from a command line, but if you just execute the script without a command line you’ll miss any feedback/error messages should any surface.

Run the App!

Finally, open Visual Studio 2010 with administrative privileges. Open the PhluffyFotos solution and press F5. 

Create yourself an account and start uploading some images.  You can try to navigate around the site, add additional albums and use the slide show.

image

This concludes the first part of this post, and you should be running the app without much fuss.

First Thoughts – Interface and Basics

There’s a lot to set up here, but keep in mind that we’re actually jumping into a project that essentially complete.  You’re required to do all of the things a project would require as you develop it, but you have to do it all at once to get it setup.

The sample application isn’t robust enough to be production quality, but as a sample, that is to be expected.

After uploading a new foto…erm…photo, the image does not seem to appear:

image

However, after navigating back to the same page through the album/photo selection process (or waiting several seconds and pressing refresh), the photo appears:

image

After deeper review, this seems to be as a result of the worker process not finishing the thumbnail generation prior to the site returning the view which requires the image.  I don’t know if this has to do with local performance of the fabric at this point or other variables (such as the 2-second queue sleep in the config).

Another glitch (in my mind) would be that albums without photos are not represented in the interface until you have a picture.  While this makes sense for people who don’t own the albums (you, visiting my profile), for the person who just created the album, it’s a little confusing.

For example, if I create an album called “My Cherished Family Photos”, then navigate to my list of albums, the newly created album is not there.  If you then try to create a new one with the same name (assuming that the “add” didn’t take), the application just throws an exception.

Finally, and without an extremely deep dive, once you’ve selected an album to view, the MasterPage link to Home is broken, only ever returning you to the album cover and not your full list of albums.  Either the link text should be changed, or the link, or both.

Interesting Technical Bits

I was a little worried when I first opened the app as there were several projects in the solution. As a first-stop for Azure exploration, this might be a little intimidating.

image

Let’s have a quick look at the breakdown here, but a little out of order:

  • PhluffyFotos.WebUX
    • Used to render the interface, this is an ASP.NET MVC 2.0 project.  There are some very simple view models, the appropriate controllers and expected views and references to all the other projects, save Worker.
    • There is a third-party component here as well, Vertigo.SlideShow, which is a Silverlight control used to display a slide show of the photos.  It accepts an XML string of photo URLs and renders the images from the selected album on the site.
  • AspProviders
    • These are the ASP.NET role, membership, profile and session state providers that will be used with the application.  This goes back to the beauty of ASP.NET 2.0 – we are still able to use the good bits in ASP.NET like authentication and authorization, but we can sub out our providers to use the back-ends that we like.  In this case, it’s built on the Azure StorageClient and linked to the MVC site in the project with entries in Web.Config.
  • PhluffyFotos.Data & PhluffyFotos.Data.WindowsAzure
    • Data is where the models for the site – Album, Photo and Tag – are defined.  We also have the definition of the IPhotoRepository interface which sets up the contract for creating and manipulating the above models, as well as searching for photos based on tags.  A few other helper methods support some lower-level procedures such as initializing the user’s storage and building the list of photos for the slideshow.
    • Data.WindowsAzure takes the models and Azurifies them, primarily by adding simple wrapper classes that inherit from TableServiceEntity and store the model objects as Azure-compatible rows.  This project also contains the PhotoAlbumDataContext as well as conversion classes for moving the Azure version of the entities back to project models.
  • PhluffyFotos.Worker
    • The WorkerRole class in this project is the implementation of the abstract base RoleEntryPoint class for the Azure worker.  There are OnStart, OnStop and Run methods common to all services.  When run, it will execute one of three predefined commands: CreateThumbnail, CleanupPhoto or CleanupAlbum.  This worker is executed until processing in all queues is completed.
  • PhluffyFotos
    • This is the project that defines the roles that are used in this Azure application: WebUX and Worker.
    • The configuration defines the HTTP endpoints, the maximum number of instances of a role, and any custom settings that may be required for the roles.
    • This is also the default start-up project for the solution.  The magic of Visual Studio uses this project to ensure that the local development fabric is running then deploys the service and launches our web site (the default HTTP endpoint on port 80).  Pretty slick.

The Azure Bits

After you get a good lay of the land, there’s not really too much going on to make it tick.  As I implied, I thought it could be a little intimidating to get an Azure solution running if you needed five projects to make it tick.  With a better understanding, that’s not really the case.

For all intents and purposes, the web UX site behaves as you would expect any MVC 2.0 site to behave. You have an album controller with an Upload view.  When submitted, the photo is pulled from the forms collection and passed to the repository.

image

The Azure part comes in at this point: the photo’s on the way to the storage cloud after adding a new object to the data context.  There are two parts to this, the table entry and the blob storage.  This is great, as we can now explore this and know how to send binary objects to Azure storage. 

Next, the image properties are sent to the queue for further processing by this private method in the repository: 

image

That worker role we saw earlier will now have some work to do with an image waiting to be processed.  This queue behavior is similar to other bits in the project when albums or photos are deleted.

Next Steps

The one thing I would like to spend more time exploring is the provisioning of tables and queues in the cloud.  The PowerShell script for queues is quite straightforward (a single call for each queue) and the table provisioning is only slightly more complex (a call is made to a method in the PhotoAlbumDataContext) but all this is done without explanation in this project. 

Data and queue provisioning is part of the setup you perform to get running, but it’s also critical to the project working.  PowerShell is fine locally, but how do you reproduce this creation in the cloud?

I also want to understand better some of the architectural decisions on this particular project…like, why is deleting a photo an operation that needs to be queued?  Are blob storage operations inherently slow enough to justify this?  Was it simply for demonstration purposes?

Wrapping Up

Creating this post was a great way to contextualize the basic components of an Azure application.  Sure, I’ve created sites, services, models and setup endpoint bindings before, but not in the context of Azure.

I could have joined any team and crafted an MVC site that sits on top of a repository such as the one in the project, and I would never have to know skip-lick-a-beat about Azure – it is that seamlessly integrated into the solution – but I much prefer to get my hands dirty and learn about what’s going on behind the scenes.

I hope this post helps you navigate through the PhluffyFotos sample application and gives you a grounding in Azure-based cloud development.

Thursday, August 5, 2010

Too Many Computers

Many have cited the demise of the PC. Now that tablet X is on the market or that smartphone y has sold millions, it’s only a matter of time before you pitch your PC out the window, right?

I actually believe it’s going to be around for a long time (and that’s not just because I need to get paid).  What we are starting to witness is the transcendence of functionality beyond what our devices were originally used for.

Let’s be honest, here: you don’t need a PC to check email and surf the web.  The way I see it, too many people have computers; the evolution of smart, integrated devices will correct the size of the PC market.

Workstations used to be used for solving problems, not checking your bank balance and surfing Facebook.  I think they are entering a time of homecoming, where people who use computers for their original intent will reclaim the PC and purpose-driven devices will fill in the void for others.

The Need For PCs

Let’s consider a worldwide acceptance of the tenet that PCs are dust.  On International Ditch Your PC Day, everyone throws out their computer in favor of whatever device they are carrying around.  What happens next?

Nothing.  All the applications you have on your device will be all you ever have.  Device development would halt.  There would be no new gaming systems, much less games.  There would be no new prototypes for handheld devices (as many of these start out by taking up several square feet, built off of an emulator on a superfast PC).  Advances in medical research would be crippled.

They can’t all go away, simply for the reason that the bulky little buggers we’ve grown used to on our desktops over the last two decades are needed to advance the things we take with us when we leave our desk.

I don’t mean to discount mainframe computing and virtualized workstations, those will have their place as well, but there are types of folks – myself included – that will need the localized, on-demand power and processing capabilities of a personal workstation.

Cheap Things and Consumerism

This whole situation we’re in is partly a problem with the way we’ve taken everything in our culture to the extreme.  I won’t rant on this too much, but if a 21 year old office clerk can service the debt of an SUV, she does.  If there’s a new computer out that is 8x the speed of your old one with 4x the memory, and it’s only $400, you tend to want to purchase it.  Bigger, better, faster, shiny-er.  That’s how we roll.

So computers fall below $1000 and lots of people start to buy them.  Lots too many, actually.  Then reasonable PCs come in at $750 and you’re shopping with Grams so she can get pictures emailed to her of your new kids.  Then $500.  Now $400, monitor included.  Laptops at $379, netbooks running at $289.  Everyone getting something.

The Balance

We won’t ever see PCs abolished from planet Earth, but they will start to sell less and less.  Prices will even adjust to reflect demand, and we can expect to see PCs priced back up around $1000 (in today’s dollars, that is, not just due to inflation).

This will happen because Grams doesn’t need a laptop to see pictures, she needs a digital picture frame.  Your dad doesn’t need a PC to surf the web, just a small touch tablet.

Desktops will not go away, and their end is not nigh, but I suspect they have peaked in popularity.  They will morph, take new shapes, miniaturize and maybe even become a remote device to our desktop (which has only inputs and a display of some kind).

For anyone who actually uses computers, they will be here for a long time to come.

Wednesday, August 4, 2010

2 Media Families are Expected

I’ve just got a couple of 1TB drives (WD Caviar Blacks…woohoo!) as my new boot stripe and I’m getting prepared to start builing my new workstation.

I stage many of my spike solutions on this machine, so I need to backup my web sites and databases that are used to show these snippets of functionality off and allow users to play-test them.  There are usually 3-4 of these active at any given time.

Through SSMS I tried to backup one of the databases and got the 2 Media Families error:

The media loaded on "c:\path\database.bak" is formatted to support 1 media families, but 2 media families are expected according to the backup device specification.

I’ve run into this before, so I had a good inkling that there was a bad backup set.  This isn’t good news if you’re in a production environment, but it’s not so bad in my case.

While it’s not “fixing” the issue, you can get around this error by performing the following steps:

  1. Remove the existing/offending backup locations from the list.  You can do this in the backup task window or by generating a backup script and removing the DISK="your_bad_path" from the command.
  2. Specify a new backup filename in a pre-existing folder.  If the folder doesn’t exist you’ll get an OS3 error with no text, but it just means you’re trying to write to a directory that doesn’t exist.

The NOFORMAT, NOINIT, NOREWIND texts come from tape backup origins and the documentation is not really clear on how they affect system drives.  For example, the MSDN documentation suggests that using FORMAT will render the media set useless.  So what does that do to my C:\ drive?  FORMAT will rewrite the headers for instances where there are different media family counts (whereas INIT will not).

So, I maybe don’t want to use FORMAT?  I don’t have a striped backup set of tapes, so I don’t think this matters.

At any rate, I don’t need whatever corrupt backup file was on my disk, so I changed my destination, removed the bad file from the backup list and carried on.

Wednesday, July 28, 2010

Visual Studio Wish List - IntelliThings

As I continue my daily use of Visual Studio 2010 I find more and more treasures in the IDE.  For instance, did you know that CDN-hosted JavaScript files with corresponding VSDOC files give you IntelliSense?

But I’ve been thinking about some things I’d like to see, as well as a few things I’d like fixed.

Intellisense Doesn’t Work Inside Script Blocks

To be clear on this one, if you are editing inside a script block and try to escape to a server-side tag you will not get CLR object IntelliSense.

For example, I don’t get IntelliSense here:

image

or here:

image

This one is likely a challenge, though, because now the IDE has to sort out if you are wanting JavaScript IntelliSense or if you want it for the CLR types.  Still, would be nice to have.

Let’s just get IntelliFix in there already, mmmkay?

When there are simple or even semi-complex errors that are common enough that a robot should be able to fix them…let the robot fix them.

Consider a missing semi-colon:

image

I would like to have an actionable interface here.  When I hover over the error, double-clicking should (and does) take me to the line.  Double-clicking again should fix it.  Voila, IntelliFix!

How about other scenarios?  A method that doesn’t return the expected type?  IntelliFix inserts a NotImplementedException for you (bypassing the compiler error).  Member has the wrong level of access for use?  Widen the scope to internal (or public, whatever satisfies the error).  Missing a using statement?  IntelliFix it.

How about IntelliTagTips?

Okay, I totally ‘shopped this one wrong (pay no mind to the types of brackets or the misspelled function) but the idea is what I’m after.

image

Here’s the concept.  If I pause, cursor (and eyes) blinking, at some point in a bunch of brackets, a little tool tip should fade in to show me where I’m at.

I don’t think it should do this for just one (you could use IntelliFix for that!), but two or more would be handy.  It would be a lot easier than trying to go back and count braces and brackets.

Normally I’m pretty good about keeping track as I write and nest code, so this might be a little annoying if it pops up too aggressively.  It would come in most handy when I’m: a) interrupted, b) tired, and c) fixing someone else’s code.

Yeah, the Names Suck…

…but I think these ideas stand up fairly well and Microsoft has teams of folks in marketing.  Therefore, I have added them to my wish list for Visual Studio versions of the future and hope to see IntelliThings there down the road.

Now, don’t mind me, I have to go geek out over IntelliTrace for a while…

Dear Microsoft: Give Us Zune

image North of the border we’ve gotten the shaft: Microsoft hasn’t released the Zune HD, nor the Zune pass service to Canada.  The implications of the licensing issues, by the way, extend to the Xbox 360 where we Canucks have not been able to access the content library our brothers in America have been entitled to.

And now our motherland – home of our Queen – is getting Zune pass too.  But, here in Canada, nada.

Heck, I even won a contest on CodeProject, the prize for which was a Zune HD, and they had to send me prize money instead because they couldn’t ship the device to Canada!

I want to make this clear

Not everyone in Canada is an Apple fanboi.  Seriously.

We have three media players in my house.  Two iThings and a Creative Labs MuVo.  I actually prefer the MuVo.  Sorry, five media players, because we have a laptop and a desktop PC.  Oops, make that six, because we have an Xbox 360.

I want to have media that can play on all these devices.  Seemlessly.  I don’t want to have to burn CDs, rip them and then re-title all the tracks I have.

I buy my music.  All of it.  I pay for my movies.  We even rent them on the Xbox 360.  I have a Gold Xbox Live membership.  I want my content on demand, I want a library that can grow and change as my preference does.  I want to be able to listen to the music I want to listen to on the devices I want to listen to them on.

I want to listen to it on a Zune HD.

If the Zune subscription service was available in Canada I would be the first in line to sign up (Microsoft readers: you can contact me directly for my credit card number).  I would even organize an iPod burning party and offer a free service to uninstall the pathetic version of iTunes that Apple has crapped onto the plates of PC users for all my friends and family.

Everyone is doing it

Netflix has announced that it is bringing its service to Canada.  I, for one, hope this is a resounding success story for them and a solid earning opportunity.  Why?  Because I want Canada to lose the stigma of being a bunch of media pirates.

If there are successes with Netflix, hopefully this will open the door for Microsoft.  While that would be great, I wish they didn’t need to wait.

We will pay our dues

I promise.

We believe in artists.  We enjoy the content.  Heck, we have a whole media company producing television and radio programming that is run by taxpayers just to prove it!

Because we believe and we enjoy we will also compensate.  Just give us a chance.  And a change!

Start with me!

So, Microsoft folks, I am offering my help and assistance.  I will show all my friends.  I will help my family’s iPods go ‘missing’ and encourage them to replace them with Zune HDs. 

I will stand in front of the Apple kiosk in Walmart and show everyone who is stopping by for an iPod how cool the freekin’ Zune HD is.  I will send emails out to old class mates and post about it on Facebook.  I will Tweet about the awesomeness of the player.

Just send me one.

Heck, send me five and I’ll find homes for them…all in different markets…and I will help get the word out that there is more than one game in town.

I was this close to having one before getting the carpet pulled out from under me.  So I ask, one more time, please make them available north of 49.