Windows 8 Start Menu Toggle


Posted on 20th September 2011 by r2 in Windows 8

Since getting my hands on Windows 8 this past week, I (like many others) have really grappled with the constant accidental returning to the metro tiles every time I try to search for something in the new neutered Start Menu that appears in the Developer’s Preview of Windows 8.  To say I hate that would be an understatement. 

Today, a colleague forwarded me a link to a blog entry that showed the magic registry key to get my beloved Start Menu mostly back the way it was.  Apparently, there is a small GUI app on CodePlex that will take care of this as well. 

I decided I didn’t want to see anything, I just want to toggle.  So, I threw together a quick Console App to take care of this.  I can place this app on my desktop in Windows 8 classic mode and just toggle back and forth without having to see anything but a quick flash of the console. 

Here’s the code:

  1. using Microsoft.Win32;
  3. namespace ToggleStartMenu
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var rootKey = Registry.CurrentUser;
  10.             var subKey = rootKey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer",
  11.                 RegistryKeyPermissionCheck.ReadWriteSubTree, System.Security.AccessControl.RegistryRights.FullControl);
  13.             if (subKey != null)
  14.             {
  15.                 var value = (int) subKey.GetValue("RPEnabled");
  16.                 subKey.SetValue("RPEnabled", value == 0 ? 1 : 0, RegistryValueKind.DWord);
  17.             }
  18.         }
  19.     }
  20. }


Here’s the source

How to Scale a jQuery Mobile Site for iOS


Posted on 25th July 2011 by r2 in iOS |jQuery Mobile

I was recently working on a jQuery Mobile application and everything looked great on my 21” touch monitor on several browsers, but when I deployed to the server and then hit the page on my iPhone, I ran into a few issues that I needed to work through in order to make the site what I’d call usable.

The first issue was that the site wasn’t scaling properly when it first loaded and everything was so small that I could barely click on it with my finger.  Certainly, this is not what I’d call optimal for a mobile site.


I originally played around with increasing font-size for the body and a few other quick CSS tricks, but nothing really did the trick.  I finally came across a meta tag which seemed to fix this issue. 

  1. <meta content="width=device-width, initial-scale=1" name="viewport">

This is what it looked like after adding this meta tag.


However, this created a new issue.  This second issue was that when I rotated from Portrait to Landscape mode, the web page did not scale properly and my toolbar buttons were now cutoff on the right-hand side like this:


I found numerous references to this known issue with iOS scaling and even found a few javascript fixes available around the web.  However, after a bit of experimenting, I found that I could fix the issue with just a few tweaks to the meta tag above and using no javascript.  The final meta tag looks like this:

  1. <meta content="width=device-width, minimum-scale=1, maximum-scale=1" name="viewport">


This is what the site looks like now when it’s rotated.


How to Include and Deploy Data using a Visual Studio Database Project


Posted on 24th July 2011 by r2 in Data |Visual Studio 2010

I’m a big fan of Visual Studio’s Database Project and I’ve used them successfully in several client projects.  If you are not familiar with using the Database Project, I encourage you to give it a look.  It gives me a nice warm feeling to see that the database schema and even necessary seed data is maintained in source control in the solution right along with the other projects.  For developers that need to get up and running locally, the joy of simply right-clicking and choosing “Deploy” is hard to beat.  

Most any reasonably-sized application will have lookup lists and other data that need to be there for the application to function properly. To my knowledge, there’s not really an automated way in Visual Studio to tell the Database Project that you want to bring the data into the project and have it be part of your deployment. However, there is a way to tap into the scripts that Visual Studio creates when it creates a new Database Project.

This post specifically addresses including and deploying data and is not intended as a general overview of Database projects.  There is plenty of decent material available on doing that.  To follow along with this post, you can simply add a new project in Visual Studio and choose the Database | SQL Server project type and select the SQL Server 2008 Database Project.


If you take a look in the Database project, you’ll see a folder called Scripts and under Scripts there are folders for both Pre-Deployment and Post-Deployment.  As we are interested in inserting data into tables, we obviously need to insert code in the Post-Deployment step when the tables actually exist. If you open the Post-Deployment folder, you’ll note a file called Script.PostDeployment.sql.  This script is run automatically after the database is deployed by the Database project.  The scripts that are created here can contain any valid SQL.  


You could place all of your post deployment INSERT statements into this Script.PostDeployment.sql file directly, but that can get ugly quickly. Instead, I like to create separate files for each table for which I want to INSERT data.  I generally name the files Data.[TableName].sql.  You can simply right-click on the Post-Deployment folder and choose Add | Script.   For instance, here I have added a Data.State.sql file that will insert all of the States into my State table after the database is deployed.  


Rather than hand-type my INSERT statements, I use SQL Server Management Studio (hereafter, SSMS) and let it do the lifting for me.  In SSMS, right-click on the database name and choose Tasks | Generate Scripts.  This will launch the Generate and Publish Scripts Dialog,  Under Choose Objects, you can make the choice of which tables you want to export.  Below, I selected the State table and clicked Next which shows the Set Scripting Options page. 


In the Set Scripting Options page, you’ll want to select where you want to export the INSERT statements.  I usually just select Clipboard and then paste that into the appropriate file in Visual Studio.  The most important part of this page is the Advanced button.  You’ll need to click this and go into the Advanced Scripting Options.


The default behavior of the Generate and Publish Scripts Dialog is to only script the schema generation and no data.  To change this to data only, you change the Types of data to script setting to “Data only”.   You can then click OK and run the export. 


Once the Generate and Publish Scripts Dialog has completed the generation of your INSERT statements, you can paste these INSERT statements back into the sql file you created earlier in Visual Studio.  Here you see I’ve pasted these into the Data.States.sql file that I created above.


Now that you have the INSERT statements in your sql file, you need to tell Visual Studio to run your sql file after the deployment.  Recall that the Script.PostDeployment.sql file created by Visual Studio is automatically run after deployment.  However, custom sql files that you create are not.  If you open the default Script.PostDeployment.sql file, you’ll see comments that tell you that you can use SQLCMD syntax to include a file and even gives you an example.  Here is my Script.PostDeployment.sql file with my custom Data.State.sql file included. 


You’ll likely notice that there are squiggle lines and you’ll likely get a build error on the 
Script.PostDeployment.sql file.  To fix this, you’ll need to change the mode to SQLCMD.  You can do this by 
clicking the SQLCMD button in the T-SQL toolbar.  



You should now be able to click the Execute SQL button to test run your Script.PostDeployment.sql file.  When you are ready to deploy your schema and seed data to a new database, you can now simply right-click on your Database project and select Deploy.  Remember to update your Connection Strings as needed and you should be off and running. 

Admittedly, this is a bit more manual than I’d like but the initial creation of the scripts goes pretty fast and the fact that the seed data and data schema are part of source control makes up for it in my book. 

If anyone has a way that works better for them, I’d love to hear about it.  

Portable and Efficient Generic Parser for CSV


Posted on 11th July 2011 by r2 in General .NET |Third Party

I recently had some pretty ugly CSV files to parse and decided to have a quick look around to see if there were any libraries around that would handle the specifics of these particular CSV files without me having to write yet another CSV parsing class.  I found a couple that seemed to fit the bill on Code Project and I downloaded them both.  The two specific ones that I looked at were Sebastien Lorien’s Fast CSV Reader and Andrew Rissing’s Generic Parser.  The first one I tried was the Fast CSV Reader since it had some nice looking performance metrics on the Code Project page.  Unfortunately, it blew up on the first file and I decided to give the other parser a try rather than trying to debug why Fast CSV Reader choked. 

I next tried the Generic Parser and it handled the file and even managed to return me just my specific data and skipped all the miscellaneous comments and headers in the CSV files using just the default settings.  On a couple of the CSV files, I made a few tweaks to the default settings of Generic Parser to get the exact data values I needed.  So far, it has performed like a champ.   

There are many CSV parsers out there that are part of larger libraries of utilities and such, but for a quick solution to CSV parsing, I would definitely recommend having a look at Andrew Rissing’s Generic Parser.  I’d love to hear other’s experiences and recommendations for CSV parsing libraries. 

Atlanta Code Camp Demos


Posted on 7th July 2011 by r2 in Presentations |Silverlight

Another fantastic Atlanta Code Camp!   Big kudos go out to the crew that threw this together this year in record time and did a fantastic job.  I heard nothing but positive comments from everyone that I talked with.  Big thank you to the sponsors, volunteers, organizers, speakers, and attendees!

I gave two presentations this year: Intro to MEF for Silverlight and Intro to Jounce MVVM Framework for Silverlight. Thanks to the folks that made it out to the talks and especially those of you that stuck with me for both of them.

Here are the links to the slides and code:

Intro to MEF for Silverlight

Intro to Jounce MVVM Framework for Silverlight

(Note that these are zip files with 7z files embedded so you will need to unzip and then “un-7z” them. The files were huge as straight zips and the server wouldn’t let them through as 7z files. 7-Zip is free and will work on both zip/7z files).

Moving further towards the Dark Side


Posted on 28th June 2011 by r2 in Visual Studio

I’ve been a proponent of dark coding environments for many moons, back to Turbo C++ and that blue.  In fact, my current Visual Studio template started way back in the first version of Visual Studio for .NET. I actually painstakingly hand-copied my colors from HomeSite.   

At the recent Atlanta Code Camp, I overheard someone mention a Visual Studio Theme Editor that goes beyond your personal editing colors and extends into the actual Visual Studio shell (drool).  After a quick look around, I found the Visual Studio Theme Editor and a really great .vstheme file that gets me pretty close to the Expression products. 

Below is what I’m looking at now.  I am a happy man. 



Safari on Windows fail


Posted on 23rd June 2011 by r2 in Uncategorized

After years of being nagged to install Safari for Windows by iTunes (every time I update), I finally gave in this morning.  Minutes later, a colleagues emails about a problem he is seeing with a Sharepoint site we use for internal collaboration and that he only sees the issue on Safari on his Mac. 

So, I fire up my brand new Safari for Windows to give the link a try and this is what I see:



In fact, no matter how many times I try to launch Safari for Windows, all I get is this AppCrash.  I’m certain there’s an explanation, but I don’t think I care enough to investigate right now.  I’ll likely just un-install it.    

Atlanta Code Camp is open for Registration


Posted on 15th June 2011 by r2 in Uncategorized

Atlanta Code Camp has finally been confirmed for this year and will take place on Saturday. June 25, 2011 at Southern Tech in Marietta, GA.  I’ll be reprising my CodeStock talks on Intro to MEF with Silverlight and Intro to Jounce MVVM Framework for Silverlight.  There are a lot of other really great sessions planned for the day.

Registration for this FREE event is available immediately here.  There is limited space, so you should jump on this right away. 

So long Das Blog, Hello WordPress


Posted on 9th June 2011 by r2 in Uncategorized

I just completed the move from DasBlog to WordPress.  It wasn’t without some bumps, but I did it in one evening.  Since there was no WordPress plug-in that directly supported importing from DasBlog, I was forced to use the RssImporter and then manually clean up all of my old blog posts.  I was very impressed with the ease of installation through my host, WebHost4Life.  So far, I’m enjoying the Admin part of WordPress and I’ve seen no real bumps using LiveWriter to clean the old posts and to post new ones.  I also went ahead and added the Paste as Visual Studio Code Plug-in for LiveWriter and I’m really liking that so far. 

I’m still playing around with themes, so look for that to fluctuate a bit until I find one that I can’t live without. 

Another Great CodeStock!


Posted on 7th June 2011 by r2 in Presentations |Silverlight

Once again, CodeStock was awesome and the CodeStock crew took care of everything and made it look easy!  All of the attendees that I had a chance to speak with had nothing but good things to say.  Big thank you to the CodeStock sponsors, volunteers, organizers, speakers, and attendees!

I gave two presentations this year:  Intro to MEF for Silverlight and Intro to Jounce MVVM Framework for Silverlight.  Thanks to the folks that made it out to the talks and especially those of you that stuck with me for both of them.

Here are the links to the slides and code:

Intro to MEF for Silverlight

Intro to Jounce MVVM Framework for Silverlight

(Note that these are zip files with 7z files embedded so you will need to unzip and then “un-7z” them.  The files were huge as straight zips and the server wouldn’t let them through as 7z files.  7-Zip is free and will work on both zip/7z files).