It’s annoyed me for some time that the player size option in YouTube has become increasingly hidden away, and is forgotten every time you restart your browser.


Thankfully the option is stored simply in a cookie (wide=1), which is easy enough to set so that it is reasonably permanent without using any browser plugins or extensions.

Google Chrome

If you use the Google Chrome browser follow these instructions:

  1. First go to youtube.com (important, otherwise the cookie will not get set)
  2. In your browser address bar type javascript: (lowercase, the colon is important)
  3. Paste this code after the javascript: you just typed:
    document.cookie = "wide=1;domain=youtube.com;expires=Fri, 31 Dec 9999 23:59:59 GMT"

Now any videos you watch from now on should be in the larger video player every time you visit YouTube.

Internet Explorer

Recent versions of Internet Explorer don’t seem to allow you to type in arbitrary JavaScript into the browser address bar so you have to use the F12 Developer Tools to run the script.

  1. First go to youtube.com (important, otherwise the cookie will not get set)
  2. Press the F12 function key , or choose F12 Developer Tools from the Tools menu button at the top right:
  3. In the window that appears, click the Console tab and at the very bottom at the >> prompt paste the following code;
    document.cookie = "wide=1;domain=youtube.com;expires=Fri, 31 Dec 9999 23:59:59 GMT"

You can now close the F12 Developer Tools window and enjoy the larger video player every time you visit YouTube.

Hope that helps!


There have been a number of posts on this already by Scott Hanselman and Rick Strahl, but I needed a simple way to detect if .NET 4.5 was installed from somewhere basic like a batch file.

I’m not sure where I came across this but it works well for me. The solution is to query for the existence of the following registry key:


So in my batch file I can simply use reg query to do the work:

reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v4.5" 2>nul
if errorlevel 1 (
    echo .NET Framework 4.5 is NOT installed
) else (
    echo .NET Framework 4.5 is installed

Note that there’s a more complicated way documented on MSDN, but the above method is easy to use from a batch file and works well for my purposes.

Hope that helps!


One of the regularly requested features for AppHarbor is a way to get full backups from SQL Server databases there. The official line so far has been to use the AppHarbor-SqlServerBulkCopy tool to bulk copy the data from the hosted server to a local copy. This requires you to have an empty target database into which to squirt the data.

I've found a more convenient mechanism to get a simple backup of AppHarbor hosted databases using the *.BACPAC files, which it seems were created originally for getting databases in and out of Microsoft's Azure cloud-hosting platform.

BACPAC files are Data-Tier Applications (aka DAC) packages which are essentially ZIPs that contain an XML representation of the schema:

… and the actual table data stored in JSON format:

Schema-only packages have a DACPAC file extension instead.

(Bob Beauchemin has some good info on Data-Tier Applications (DAC) on his blog)

You can backup and restore databases in SQL Server Management Studio 2012 (the Express version is fine) - look for the Import/Export "Data-tier Applications" commands on the context menu.

I think "Data-tier Applications" are what we are supposed to call databases now...


If you want to do this programmatically, use Microsoft.SqlServer.Dac.dll which can be found in C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin if you have some flavour of SQL Server 2012 installed.

Exporting is simple enough:

using Microsoft.SqlServer.Dac;
// Export
var dacServices = new DacServices(remoteConnectionString);
dacServices.Message += (sender, e) => Console.WriteLine(e.Message);
dacServices.ExportBacpac(@"C:\temp\MyDb.bacpac", "MyDb");

And importing is similarly straightforward:

// Import
var dacServices = new DacServices(localConnectionString);
dacServices.Message += (sender, e) => Console.WriteLine(e.Message);

var package = BacPackage.Load(@"C:\temp\MyDb.bacpac");
dacServices.ImportBacpac(package, "MyDb");


There is a command-line tool called SqlPackage which provides access to the same functionality, but it wasn't until recently that it got the ability to export a bacpac for some reason. The SqlPackage.exe export feature was included as part of the SQL Server Data-Tier Application Framework (September 2012) update.

Download (http://go.microsoft.com/fwlink/?LinkID=266427) and install the appropriate flavour of DACFramework.msi.


"C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" ^
    /Action:Export ^
    /SourceConnectionString:"Server=foo.sqlserver.sequelizer.com; Database=dbXYZ; User ID=blah; Password=Pa55w0rd" ^


"C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\SqlPackage.exe" ^
    /Action:Import ^
    /SourceFile:"C:\temp\MyDb.bacpac" ^
    /TargetConnectionString:"Server=.\sqlexpress; Database=MyDb; Integrated Security=True"

Hope that comes in useful for you!


I had an odd issue where SQL Server Management Studio (SSMS) 2008 R2 would start up, display the following error message, then exit:

Package 'Microsoft SQL Management Studio Package' failed to load

Using SysInternals Process Monitor tool to monitor SSMS.exe it seemed that it was looking for the following registry key but not finding it:

HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server\100\Tools

By renaming a parent key (rather than delete it - just in case it didn't fix the issue) solved the issue for me. The key I renamed was:

HKEY_CURRENT_USER\Software\Microsoft\Microsoft SQL Server

Running SSMS again recreated the \100\Tools sub keys and all was well again. I hope it works for you too.


Here's an ASP.NET MVC HTML Helper that helps in the following scenario. Let's say you have a partial that can be included a number of times in a view but has a bit of common code that need only be included once. Typically that bit of common code would be some script.

In ASP.NET such a scenario is addressed by RegisterClientScriptBlock. In the Spark View Engine it's taken care of by the once attribute.

So, inspired by Phil Haack's Templated Razor Delegates post from earlier this year I knew you could write helper functions for Razor that could take arbitrary markup. The key to it is taking a Func argument that returns a HelperResult.

To use it you invoke it like so:

@Html.Once("some unique key", @<div>arbitrary markup that gets rendered just once</div>)

More typically, for including script, e.g.:

@Html.Once("TABLE_SORTER_INIT_SCRIPT", @<script type="text/javascript">
    $(function() {
        $('table.sortable th').each(function(){
            // . . .

Here's the implementation that adds the Once extension method to HtmlHelper:

using System;
using System.Web.Mvc;
using System.Web.WebPages;

namespace Foo
    public static class HtmlUtils
        public static HelperResult Once(this HtmlHelper html, string key, Func<object, HelperResult> template)
            var httpContextItems = html.ViewContext.HttpContext.Items;
            var contextKey = "HtmlUtils.Once." + key;
            if (!httpContextItems.Contains(contextKey))
                // Render and record the fact in HttpContext.Items
                httpContextItems.Add(contextKey, null);
                return template(null);
                // Do nothing, already rendered something with that key
                return new HelperResult(writer => { /*no-op*/ });

Hope that helps!