Imaginatively Named Blog

Notes about software development

05. November 2013

WIndows 8.1 Bootcamp on new Haswell MBP

THe long wait is over and I recieved my shiny new retina MBP with 1TB SSD and the new Haswll chipset. It feels screaming fast and so far I love it. And I want to be able to use that speed to play a video game occasionally, which means installing windows in bootcamp so you get all the best performance. My personal preference is to set up windows in bootcamp first, then have fusion or parallels create a VM that uses the bootcamp partition as it’s disk, so I can use the VM for day-to-day tasks, then reboot to native if I really need the power.

Armed with a USB key and a windows 8.1 ISO from MSDN, I proceeded to fire up the bootcamp assistant and start the long process of partitioning and installing windows. Actually, both partitioning and installing are surprisingly fast with the SSD, but downloading the drivers from apple can take a while. But then at the end of the windows installation, just before reboot, it throws an error “Windows cannot update the boot partition” and I can’t get any further.

Some googling turned up that I was not the only one with the issue. I found a [https://discussions.apple.com/thread/5474320?start=0&tstart=0 lengthy thread] on apple’s forums full of people with the same issue exploring various workarounds. I tried many of them, but finally found success with this:

I let bootcamp assistant partition my drive and create a USB boot disk. It rebooted to go into the windows installer, but I help down the option key and boot into OSX again instead. Then I had to use Disk Utility to format the bootcamp partition as ExFAT.

Manually rebooted with the option key again and chose the ‘Windows’ (not EFI) boot from the usb drive. Then in I let had the windows installer reformat the partition again as NTFS. After that it proceeded to install properly and all went well.

Whew! I’m still unsure why these incantations brought about success, but I thank the perseverant posters on the discussion board (especially maskedferret) for helping me get all set.

02. October 2013

Cloud Development Machine In Azure

I need a new development laptop. I prefer Macbook Pros. But it’s Oct 2nd and the highly likely rumor is that Apple will announce the new version of the MBP on October 15th. I will be VERY unhappy if the new line comes out so soon after such a major purchase, so I need to hold off and make due with something else for a while.

I have a nearly 10 year old 15” dell laptop sitting on a shelf in my office. It has a 2G of RAM (maximum, absolutely cannot be ugraded) and god knows how old and slow of a CPU. It currently runs Ubuntu VERY SLOWLY. I can’t imagine trying to run VS.NET 2012 on it without feeling a lot of pain. But it IS able to run an RDP client, and that can open up all sorts of possibilities for me.

I decided I’ll run my development machine IN THE CLOUD for a couple of weeks while I wait. Then I can just RDP to it from any terrible machine (even my ipad!) and get some work done! Doesn’t matter where I am as long as I have internet access, and I always have internet access dammit.

So first, picking a cloud provider to run it. I’ve used Amazon EC2 plenty in the past. It’s pretty easy to deal with. I checked it out. To run Windows on a decently powered “Large” VM it’ll cost $.364 an hour. They’ll let you run free VMs for a year, but those are only “Micro” which equals up pretty closely with the hardware on my 10 year old laptop. I also jumped on that free trial a long time ago and am no longer eligible. So at $.364 and hour I’d estimate a cost of $58.24 to run it 40 hours for 4 weeks while I get all set up. Not bad really.

But then I saw Azure has a free trial too. $200 free for one month. I hadn’t looked at Azure in a long time, but I keep reading about how much friendlier it has become. So I decided to give it a shot.

Amazingly easy to set up. Just entered my old hotmail/live/outlook.com/whatever you want to call it account name and password. Confirmed the account and entered billing information (for when I forget to turn this thing off at the end of the month and they can hit me). Within 5 minutes I was looking at the “portal” and ready to create a VM.

And that was easy too! Click “+NEW” on the bottom menu and choose “Virtual Machine”, then “From Gallery.” They have all sorts of nice options in here, ubuntu servers, suse servers, windows 2012, and… “Visual Studio Ultimate 2013 RC”! Looks like it’s a nice windows OS loaded up with VS.NET 2013 and all the fixings already. Let’s give it a try…

Choose your VM

After that you enter a simple name and VM size. I picked “Large” because it’s 4 cores with 7G of memory. Seems plenty enough for coding. After that you set up how it will be accessed (RDP enabled by default) and some other simple stuff I forget and then it spins it up.

After about 10 minutes it’s there, ready for me. I’m armed with admin credentials and I’m not afraid to use them. Install Chrome, cygwin, github for windows, node.js. Everything goes nice and fast. This is great!

So that’s my plan for a bit, until I’m sure my laptop purchase won’t immediately become obsolete. Development IN THE CLOUD free for a month.

Desktop Ready

27. September 2013

Resolving Arrays In TinyIOC

Well if I’m going to be writing about software development, I better actually get to some technical stuff.

We’ve been using NancyFX to create a pretty quick and easy API wrapper around a lot of our business logic. By default, NancyFX uses TinyIOC as an IOC contaner, and it’s pretty nice. It’s very simple and it does basic auto-registration of all the classes inside.

Most of our products use Windsor as the container. I’d considered doing the work to make Windsor the container in our NancyFX API project, but decided I shouldn’t have to. It seems the code should be container-agnostic and it shouldn’t really matter what container we use for a particular output. And for 95% of the stuff I was right.

But we did hit a snag. Some of our services depended on resolving an array of dependencies. Something like this:

public class SomeService
 {
   private ISomeInterface _dependencies{get;set;}
   public SomeService(ISomeInterface[] dependencies)
   {
     _depencencies = dependencies; 
   }

   public void DoSomething()
   {
     //Loop through the dependencies doing something with each of them
   }
}

Windsor has a subresolver that allows this pattern, resolving arrays instead of just single classes. Just do container.Kernel.Resolver.AddSubResolver(new ArrayResolver(container.Kernel) (what a mouthful). But TinyIOC didn’t do this.

But TinyIOC does let you register factories as anonymous functions. This was key to letting it resolve the array. I can’t do it automatically for any array of types, but I was able to do a simple one for this:

container.Register<ISomeInterface[]>((c, p) =>
{
    //Assuming all implementations come from the same assembly as the interface itself
    var allOfSomeInterface  = (from t in Assembly.GetAssembly(typeof (ISomeInterface)).GetTypes()
        where t.GetInterfaces().Contains(typeof (ISomeInterface))
        select t).ToArray();
    return allOfSomeInterface.Select(implementation => (ISomeInterface) container.Resolve(implementation)).ToArray();
});

Kinda ugly, but also seems to make sense to me. If I want to resolve all types matching the interface, I first use reflection to discover those types, then resolve each of those implementations from the container and return an array of them.