Random Link Post

Cocoa is my Girlfriend 

Simple Bank

Google Diff Match Patch 

How to Build a Tardis Replica 

Mr Data Converter 

Project Euler





Revisiting Invaders

So a long time ago, I posted code for what basically amounts to a clone of the Atari 2600 version of Space Invaders, rewritten in XNA.


I got bored the other day and ported it to Windows Phone. I went with Phone 7 so I could be lazy and continue using XNA, since Microsoft hates us and hasn't/probably isn't porting XNA to Phone 8 ever.

I had to hack around some custom config code I had to dynamically load different 'skins' for the invaders, but for the most part the majority of it went very fast (took about 3 hours).

Screenshot for now, once I clean it up I'll post the code.

I would submit it to the Windows Store, but I can't imagine it going through without someone suing me. There is, however, a version that looks like it is a clone of the arcade version, so who knows, maybe I'll do it and just see what happens. 

Convert NULL to nil

A macro I stole off of the internet, but didn't want to lose.

I found when I was parsing a nullable type from web api -> JSON into my objects in iOS, it really didn't like the NULL values much and this sorted it nicely, converting them to nul inline.

Just wrap whatever you are assigning in NULL_TO_NIL() and you are good to go.

Just add it to the top of the page, or to some common blah blah whatever.

#define NULL_TO_NIL(obj) ({ __typeof__ (obj) __obj = (obj); __obj == [NSNull null] ? nil : obj; })


Random Link Post

PNG Gauntlet 
Angled Brackets 

Getting the apps version number in iOS

We deploy a bunch of our iOS apps to our internal enterprise store, and one feature it is missing is the ability to notify users that there is a new version of the application available.

Using the following code (it includes all of the version magic, the one I am actually using just returns minorVersion), we can compare it to the version in the store and notify the user on launch that there is a new version.

- (NSString *)appNameAndVersionNumberDisplayString {

    NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
    NSString *appDisplayName = [infoDictionary objectForKey:@"CFBundleDisplayName"];
    NSString *majorVersion = [infoDictionary objectForKey:@"CFBundleShortVersionString"];
    NSString *minorVersion = [infoDictionary objectForKey:@"CFBundleVersion"];
    return [NSString stringWithFormat:@"%@, Version %@ (%@)", appDisplayName, majorVersion, minorVersion];

To add a bit more excitement, the enterprise store maintains its own version numbers, so you have to make sure when you publish that you increment your version number in your project to match what is in the store.

Stop VS 2012 from auto checking out sln files

Basically there is an issue with the way an older Unity edited the solution file.

Open the sln file, get rid of the 'GlobalSection(ExtensibilityGlobals) = postSolution' section and save.

Adding APN to Nokia Lumia 920

Some of the 920s don't have the add APN under the Cellular/Mobile menu. To add the APN, you do it under Settings -> Access Point


For AT&T I used the following settings:

Connection Name:I called mine ‘Bob is awesome’

Access point name: wap.cingular




I left everything else blank and I seem to be working.

Changing Namespace of your EDMX

I have mostly used Linq2Sql in the past, but as I find myself in a position to support both a website and mobile devices through oData, I have switched to using Entity Framework.

I don't really like Entity Framework better, but I did stumble across something cool today. If you decide to say, refactor a project and totally redo the namespaces, there isn't an obvious way to change the namespace of your EDMX through the GUI. The solution ends up being really straightforward though. If you change the default namespace of the project, the next time you build, it fixes the namespace of the EDMX.

Maybe Entity Framework isn't so bad after all...

Dark Souls for the PC

The Pre-Order for Dark Souls on the PC is up on Steam.

Article I followed to set up spam filtering in Exchange 2010



Just so I don't forget later Embarassed

Linq OrderBy with a String Column Name

This is not new by any stretch, it is posted a thousand places on the web, but I cleaned it up a bit and changed the return type to IOrderedQueryable so you can chain ThenBy after it.

using System.Linq;
using System.Linq.Expressions;

namespace System.Linq
    public static class LinqExtensions
        public static IOrderedQueryable<TEntity> OrderBy<TEntity>(this IQueryable<TEntity> source, string sortExpression) where TEntity : class
            var entityType = typeof(TEntity);
            var property = entityType.GetProperty(sortExpression.Split(' ').First());
            var parameter = Expression.Parameter(entityType, "p");
            var orderByExp = Expression.Lambda(Expression.MakeMemberAccess(parameter, property), parameter);
            MethodCallExpression resultExp = Expression.Call(typeof(Queryable), "OrderBy", new Type[] { entityType, property.PropertyType }, source.Expression, Expression.Quote(orderByExp));
            return (IOrderedQueryable<TEntity>)source.Provider.CreateQuery<TEntity>(resultExp);

        public static IOrderedQueryable<TEntity> OrderByDescending<TEntity>(this IQueryable<TEntity> source, string sortExpression) where TEntity : class
            var entityType = typeof(TEntity);
            var property = entityType.GetProperty(sortExpression.Split(' ').First());
            var parameter = Expression.Parameter(entityType, "p");
            var orderByExp = Expression.Lambda(Expression.MakeMemberAccess(parameter, property), parameter);
            MethodCallExpression resultExp = Expression.Call(typeof(Queryable), "OrderByDescending", new Type[] { entityType, property.PropertyType }, source.Expression, Expression.Quote(orderByExp));
            return (IOrderedQueryable<TEntity>)source.Provider.CreateQuery<TEntity>(resultExp);

Zerg Cake

Found this on the internet, this is definitely what I want for my birthday.

Acer W500

So, I picked up an Acer W500 to have an x86 tablet to play with while waiting for Windows 8 to get all official on us and, within its limitations, it has been great.

I started looking up options to increase the size of the 32 gig mSATA SSD (I already added a 32 gig SD card) and the only real option looks like this one:


$159 for 120 gigs, which isn't really bad though I don’t know if it is worth it since the RAM is soldered on the board, so you are stuck with 2 gigs, with part of that going to the video card.

I think I am just going to wait it out, I am betting on medfield tablets running windows 8 (arm power envelope, full x86 support). I like the idea of ARM, but I don't know if I am ready to give up x86 quite yet.

Here is one running ICS: http://www.engadget.com/2012/01/10/intel-demos-lenovo-made-medfield-tablet-running-ice-cream-sandwi/

Custom 401 in ASP.NET

Because IIS intercepts your request before you can handle it, you can't just set a 401 page in your custom errors block. While you can still change the default 401 page in IIS, the user will typically get challenged first when you set security with location in the web.config.

You wouldn't do this at all anymore, but I ran into it making a change to a legacy webform app and figured I would save what I found in case I see it again (I am moving 50+ apps).

To handle this you would do something hacky like this:

protected void Application_EndRequest(Object sender, EventArgs e)
        HttpContext context = HttpContext.Current;
        if (context.Response.Status.Substring(0, 3).Equals("401"))

One point to note, you can't do this in integrated mode, you would have to drop your app pool to classic mode.

Or you could be one of the cool kids and just rewrite the whole thing from scratch without telling anyone.

Random CSS Link Post






We could only be so lucky.

Random Link Post

Some MetroRT questions answered 

Crazy awesome Microsoft site 

Project Management and being more awesome site 

Awesome Microsoft Robot SDK stuff 

Advanced NT Debugging blog 

Microsoft blog on Globalization 

Global Authorization and allowing Anonymous 

DJ Sures and ez-robot

Good News and Bad News

The good - the new version of Chrome Beta for Android finally supports the desktop user agent string.

The bad - Bluestacks still doesn't let me use touch in the Android app when running on my tablet. They hint that it may work if I install Windows 7 on the tablet, but they are too wishy washy about it to get me to actually try it.

401.2 Access Denied from VS 11

Note to self, when you install Visual Studio 11, it disables NT auth for IIS Express by default. To turn it on, go to My Documents, IISExpress, config and modify the applicationhost.config file, changing <windowsAuthentication enabled="false"> to <windowsAuthentication enabled="true">.


If you haven't seen it, some awesome guy named Kevin Gadd has made created a compiler to convert XNA to HTML5 named JSIL.

This should really come in handy soon considering Microsoft is saying they are not supporting XNA in Metro.

One thing to note, be careful when you are pulling down all of the magic from github, make sure you get his fork of ILSpy instead of the official one.


I originally pulled this down to convert Invaders to HTML5, it isn't compiling yet, but I had a good bit of stuff in there that wasn't XNA specific (using configurationmanager to dynamic load resources), so I most likely just need to slim it down a bit and give it another go.


If you haven't tried it, it let's you run Android apps on Windows. Really impressed so far, though touch isn't working for me in  Windows 8. When I contacted them, they said touch is working in Windows 7, they just aren't supporting Windows 8 yet.

It is in open beta, so go check it out.

Enterprise Developers Guild

I used to go to the Enterprise Developers Guild here in Charlotte pretty often until they moved it downtown. Just found out they are having them in the Microsoft Campus again and went to the one this Tuesday called 'Build for All Devices with jQuery Mobile & HTML5' by Dan Thyer.

Had a great time and free pizza, will definitely be going to them more often than not now. Great turn out, must have been at least 80 developers there.

IIS 7(.5) and Anonymous Access

An interesting change I found today is when you choose to allow an application to accessed anonymously, it creds to resources as IUSR by default and not the application pool's identity. To fix it you go to where you configured anonymous access and right click on anonymous access and choose edit.

This is more of a reminder to me, I assume most people already know this, I just rarely ever use anonymous access so it caught me a bit by surprise.

Code Camp in Charlotte May 5th

The Enterprise Developer's Guild is hosting a Code Camp on May 5th at the CPCC campus in Matthews.


You an get more information here : http://codecamp.developersguild.org/


From what I have heard, they will have some advanced sessions, and if you are a presenter, they are still looking for people to be awesome.

If you aren’t familiar with the Enterprise Developers Guild in Charlotte, they have decently advanced sessions, and currently meet on the 4th Tuesday of each month at the Microsoft campus right down the road from our office at 6PM and the sessions are always free.


The one this month (on the 27th) is about jQuery mobile and HTML5.


As a plus, there is also free Pizza and soda!

You can get more info at their main site: http://www.developersguild.org/

Code Palousa Final Day

So, day 3 opens with a keynote from Jim Benson, and I am definitely going to have to preface my comments with the fact he is definitely more successful than I ever will be,  and most likely smarter. Having said that, he has this aversion to PowerPoint, and while I definitely can't disagree with him for that, I found his 'solution' even less palatable. This is actually unfortunate, as I get what he was trying to say, I just wasn't able to sit through it.

On to the first session of the day. I went and checked out 'Mobile Cross Platform Decisions' by Christopher Judd (Judd Solutions) and it was actually really good. He covered a lot of great ways to do mobile development, especially in an environment where you need to target more than one platform.

For the second session, I went and checked out 'The Evolution of Patterns' by Chris Eargle (Telerik) since he had done such a great job on day 1. I definitely wasn't disappointed. The only thing I would have done different in that session was tack a couple more hours to it. The hour was up and he was really just getting rolling.

For the third session, I went to 'Responsive Design in ASP.NET MVC - A Crash Course in Responsive Design' by Ed Charbeneau (Sypris Solutions) and it was phenomenal. I walked in thinking it was going to be about responsive in the context of performance, but liked the actual topic better, how to respond to a large range of screen sizes and features to support a wider audience.

Unfortunately, I didn't get to go to any more of the conferences, as the latest flight out to get back to Charlotte was slated for 5:50ish PM. If I were able to stay, I would have checked out Enterprise Users Bill of Rights: 10 Things Every Developer Must Know about User Experience, and probably Validating Data in OData for Mobile Solutions, though the track record for OData sessions was sketchy up to that point.

I guess long story short, Saturday was definitely a better return on investment than the first two days were, and if we were local developers, it would have been great either way. Having paid (our employer, not personally) for tickets, plane, hotel, lost work etc the value just wasn't there. If I want basic 101 classes, I can get them free right here in Charlotte. If I am going through the drama and expense of flying somewhere, I am expecting my brain to hurt when I get back.

Recommendation for next year? I think we are going to pass, if it was local, we would go for sure, but we aren't interested in travelling to it.