Mix11 Video Downloader

I updated my PdcDownloader to be able to download videos from Pdc '10 and Mix '11. This probably warrants a renaming, but I'll deal with that later.

Unlike PDC, the OData feed does not have the download file information. So I hacked together a download url based on the pattern on the channel 9 pages. Early on there was some variability in the file urls, but this all seems to have been straightened out. The Keynotes seem to be the only videos that have not followed the convention. Also to note, the session title isn't coming back in the OData feed when I access it via code, so the files are saved with the session code.

The application now needs two parameters. The first being the key of the conference you want to download content for (either PDC10 or MIX11). The second parameter is the video quality you want. There are 4 keys: wmvhigh, wmvlow, mp4high, and mp4low. If you don't specify one, then wmvlow is defaulted as before.

pdcdownloader MIX11 wmvhigh

The application will then download all of the power point and video files from all of the sessions into the folder that you ran the application from. To skip a file, press 's', or to abort the processes, press 'q'.

Download the executable here.

The source is as before, up on GitHub.

    
Pdc 2010 Downloader

I still wish that Microsoft would create a torrent with all the content, but I realize that this is too much to ask. I decided to write a PDC downloader over the weekend since Microsoft does expose all of the session information via on OData feed. There are a couple of other downloaders out there, a couple in silverlight (here, and here).

Mine lacks any kind of visual flash as it is a simple console app that just downloads everything. It is safe for multiple runs (won't re-download something already downloaded) and does support some basic skip/abort functions. When you run the application, you need to specify what quality of video you would like. There are 4 keys: wmvhigh, wmvlow, mp4high, and mp4low. If you don't specify one, then wmvlow is defaulted.

pdcdownloader wmvhigh

The application will then download all of the power point and video files from all of the sessions into the folder that you ran the application from. To skip a file, press 's', or to abort the processes, press 'q'.

Download the executable here.

I will post the source soon.

The source is now up on GitHub.

  
Clearing the ClickOnce App Cache

I had a user complain that they were unable to launch an application that was published using ClickOnce. They were kind enough to pass along a log file that the error message provided making finding the issue very easy. The log file contained the following error:

Following errors were detected during this operation.
 * [6/7/2010 10:54:17 AM] System.Deployment.Application.DeploymentException (Subscription)
  - Unable to install this application because an application with the same identity 
    is already installed. To install this application, either modify the manifest version
    for this application or uninstall the preexisting application.
  - Source: System.Deployment

I took this to mean that the user needed to remove the currently installed version of the application, and remove it. However, the application must be launched from the deployment page, and cannot be installed local. So how do you clear this cache for ClickOnce deployed applications? Easy, Google knows. I just needed to use a simple command line tool mage.exe (Manifest Generation and Editing Tool). For me it was found in /Program Files/Microsoft Sdks/Windows/v7.0A/bin. Calling the tool like this mage -cc cleared the cache. However, on a machine for non developers, this was not an option, as they don't have the Sdks on their machines. So, I needed an alternative.

A little more Google-fu resulted in an alternate call that would do the same thing on a computer without development sdks. And I know some day I'll need to remember this, so here it is: rundll32 dfshim CleanOnlineAppCache

  
VB.NET Gotchas for C# Devs

I have been coding in VB.NET on contract for just under a year now. And having done so, I have come up with a small list of 'Gotchas' that I have encountered. At times, these differences have cost me quite a bit of time in debugging, and if I can save someone else even a small amount of this pain, it will be worth it.

VB.NET does not throw a compiler error when you create a function without a return type. Can you tell me the return type of the method below?

    Public Function GetNumberOne()
        Dim num As Integer = 1
        Return num
    End Function

VB.NET is also content compiling a Function without a return statement. It isn't frequent that I forget to add a return statement, but it has happened.

    Public Function WithoutReturnStatement() As Integer
        Dim bool = False
        Dim s = "A String"
        Dim concat = String.Concat(s, bool)
 
    End Function

Another good idea: turn on Option Strict. If you don't, the runtime will attempt to do a lot of implicit conversions for you. I wrote some code where I thought that I could call GetBoolean() on a DataReader passing in a string representing the column name. It compiled fine. After running the application, I realized that I needed to pass in the columns index instead. Sure, if I would have slowed down, Intellisense would have told me different, but I was cocky

    Public Sub TakesNumberParam(ByVal value As Integer)
        Dim result = value + 1
    End Sub

Without option explicit on, I am able to write a test for the above method, that passes in a string that cannot be cast to an integer, and the project builds. At runtime, the code will throw an InvalidCastException.

    
Wholesale Linqification, everything must be Linqified

I have been browsing through the source for the Subtext Blog Engine, and have come across a lot of cool ideas, and also, a lot of code that is showing its age. Subtext has been around for a long time, and in some places, the code could use some updating. Of course, the contributors to the project are probably not going to find a need to go through every line of code and modernize it, but it's hard not to see places where Linq can really make things more awesome. For instance, there are a handful of methods that try to determine what kind of request is being made, and specify a RequestLocation based on that. One of the methods that tests for a request to a static file looks like this:

private static bool IsStaticFileRequest(HttpRequestBase request)

{

    string filePath = request.FilePath;

 

    return filePath.EndsWith(".css", StringComparison.OrdinalIgnoreCase)

           || filePath.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase)

           || filePath.EndsWith(".js", StringComparison.OrdinalIgnoreCase)

           || filePath.EndsWith(".gif", StringComparison.OrdinalIgnoreCase)

           || filePath.EndsWith(".png", StringComparison.OrdinalIgnoreCase)

           || filePath.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)

           || filePath.EndsWith(".txt", StringComparison.OrdinalIgnoreCase)

           || filePath.EndsWith(".html", StringComparison.OrdinalIgnoreCase)

           || filePath.EndsWith(".htm", StringComparison.OrdinalIgnoreCase)

           || filePath.Contains("/images/", StringComparison.OrdinalIgnoreCase);

}

However, this can be made much more awesome with Linq. Behold the More Awesome:

private static bool IsStaticFileRequest(HttpRequestBase request)

{

    string filePath = request.FilePath;

    var extensions = new[]

        { ".css", ".jpg", ".js", ".gif", ".png",

          ".xml", ".txt", ".html", ".htm", "/images/" };

 

    return extensions.Any(e => filePath.EndsWith(e, StringComparison.OrdinalIgnoreCase));

}

I hope I never have to go back to .NET 2.0; I will most certainly weep heavily.

  
Older >
Recent Posts
Mix11 Video Downloader
Pdc 2010 Downloader
Clearing the ClickOnce App Cache
VB.NET Gotchas for C# Devs
Dreamhost 1 year Special
Can I Suggest Bit Torrent?
Moq and VB.Net are Frenemies
Google Buzz - Impressions
O Rly? Intellisense requires XML + DLL
Self Documenting Code - FAIL
The 'F' in TFS is for 'Friction'
Tag Cloud
.net   apple   asp.net   beta   borked   buzz   c#   clickonce   clio   code   code camp   cogsdb   console   database   deals   deployment   documentation   downloader   dreamhost   fail   friction   general   git   gotchas   hack   hosting   linq   lucene   mix   mocking   ndc09   nosql   note-to-self   opinion   orly?   patterns   pdc   practices   projects   r#   rant   refactoring   resharper   screencasts   sell-out   session state   skills test   sql   sql ce   sql server   stack overflow   strategy   tccc   testing   tfs   tips   troubleshooting   twitter   typemock   unit tests   vb   vb.net   video   visual studio   web 2.0