Browse a local Azure Web role from another computer

Leave a comment

So, you’re developing an Azure website that runs as a web role, which means you use the Azure Compute Emulator when running it locally. And now you want to test or debug that local website in an older browser, such as IE8.

In this situation I have IE8 running on another computer (or maybe a VM), so I need to open up access to my website which is running locally.

Step 1. Find out your IP address – ipconfig. Mine is 10.200.34.254.
image002

Step 2. Find out which IP address and port the compute emulator is running on, by looking in the System Tray at the IIS Express icon. Note that even though I access the website locally on https://127.0.0.2:447 in my browser, it runs on a different IP and port in the emulator, https://127.255.0.4:448. I don’t know/care why.
image001

Step 3. Download and install Pass Port from http://sourceforge.net/projects/pjs-passport/. Yes it’s old but it does the job of forwarding ports nicely, which is what we need to do.

Step 4. Set up a Pass Port port forwarding rule with your IP address and any port (I’m using 800) to the IP address and port of the emulator.

image004Step 5. Open up that port (800) in the Windows Firewall:

image003

That should be it. Now you can connect on the remote computer to your Azure Emulator running locally. Obligatory screenshot of my site running in IE8:

image005

 

Beginner’s guide to add a toolbar to an iOS iPhone app with a Storyboard

Leave a comment

I’ve been playing around with iPhone apps a little bit. I’m certainly no expert though, I’m still a beginner myself.

A basic task is to add a toolbar with buttons to your application using XCode.

Lots of samples online are using old versions of XCode. Allow me to demonstrate how to add a toolbar to an app, using XCode 4.2 with Storyboards.

Create a new Project

In Xcode, File -> New Project. Choose Single View Application. I named my application com.mattfrear.toolbars.

Add a toolbar

If you can’t see it, choose View -> Navigators -> Show Project Navigator.

If you can’t see it, choose View -> Utilities -> Show Object Library.

Open the MainStoryboard_iPhone.storyboard. Click on the View.

In the Object Library (which should be in a window at the bottom right of your screen), scroll to the bottom and choose Toolbar. Drag it onto the View. Your screen should look like this:

Screen Shot 2013-08-29 at 16.05.42

Wire up the button

Now we need to add some code which will be fired when the button is clicked.

Open ViewController.m. At the end of the file, before the last @end, paste the following:

-(IBAction) buttonClicked
{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hello world"
                                                    message:@"You clicked the button"
                                                   delegate:nil
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:nil];
    [alert show];
}

This is the code which will execute when the button is clicked, and it will display a simple Hello World popup.

Our final step is to wire up the button to this method. To make this easier we can use the Assistant Editor.

In Xcode, go View -> Assistant Editors on Right. Then View -> Show Assistant Editor.

If your screen is small, you might want to go View -> Utilities -> Hide Utilities.

The Assistant Editor should have ViewController.h open. In the Assistant Editor toolbar at the top, it should say Automatic > ViewController.h > No Selection. In that toolbar, click on ViewController.h and choose ViewController.m from the dropdown.

Screen Shot 2013-08-29 at 16.30.55

In the main window, click on the toolbar we added to our View, then on our “Item” toolbar button. Now right click it to bring up the “Bar Button Item – Item” menu.
Under Sent Actions, next to selector there is a + button. Click that and then drag it to the buttonClicked method in ViewController.m.

Screen Shot 2013-08-29 at 16.34.40 (2)

Hooray! Now our toolbar button is wired up to the method. Let’s run our app to test it.

In XCode’s toolbar, next to the big Run and Stop button you should see a drop down. Choose iPhone Simulator, then click the Run button.

Screen Shot 2013-08-29 at 16.40.16

Woop!

Upgrading a Haswell Macbook Air (mid-2013) to Windows 8

Leave a comment

I recently bought a new Macbook Air for work – a mid-2013 Haswell one. I got all the optional upgrades which means it’s an i7, 8Gb of RAM and 512Gb SSD. The main reason I upgraded from my mid-2011 Macbook Air was that I wanted more RAM – with 4Gb it was struggling to run Azure VMs in Windows. Also the 256Gb SSD was stretched, I was constantly having to fight to free up disk space in both Windows and OSX. Finally, I wanted USB 3.0, so that I could use an external HDD at full speed should I need more disk space. And the new PCI-based SSD sounded tasty.

macbook air

My Windows 8 Pro license is an upgrade only license, so in order to get Windows 8 on it I first had to install Windows 7 using Boot Camp. Which went fine.

Once Windows 7 was installed I ran the Windows 8 upgrade installation. It would go through the whole process but then after a few reboots and at the end of the setup process it would hang at the “Personalise” screen, where you choose a colour scheme and a name for your computer. It wasn’t actually hung, it was just that the keyboard and mouse didn’t work so I couldn’t click next. Neither the built in keyboard nor a USB keyboard would work.

So then I tried downloading and making a Windows 8 ISO and installing from that via Boot Camp (instead of installing Win 7 first), which worked fine, but then when I Activated Windows it wouldn’t let me because I have an upgrade only Windows 8 license. Poo.

So my third attempt, and this time I installed Windows 7 first, and the Boot Camp drivers in Windows 7. Then when I ran the Windows 8 upgrade install I elected to choose to Keep Windows settings, personal files and applications – the idea being that it would keep the Boot Camp drivers installed.

choose

Well, third time lucky anyway cos that worked.

Update: it looks like this is a known issue – see this solution.

So, how does the new Macbook perform compared to my older mid-2011 Macbook Air?

Here’s 2011’s Windows Experience Index:

wei

And here’s 2013’s. Not really much faster!
win 7 experience

Finally, here’s 2013’s again under Windows 8:win 8 experience

The only thing worth noting is the decent hard disk rating.

Another advantage of the Haswell chipset is longer battery life – up to 12 hours according to Apple, and the reviews seem to confirm that. BUT I bought the i7 version which is a bit more of a power hog, as confirmed by AnandTech – so I only get about 6 hours of battery life, a slight improvement on the 4 hours I was getting on the 2011 i7 version.

So overall, the 2013 Air is not much of an upgrade on the 2011 version really. Which is a bit of a disappointment.

Macbook Air’s SSD died – here’s my new backup strategy

9 Comments

My mid-2011 Macbook Air‘s SSD died last week. I’d spent a lot of time setting this up just how I wanted: dual boot OSX and Win 7 (then Win 8) – 50Gb for each OS, and a 150 Gb shared exFat “Data” partition which is writable by both OS. The Data partition contained all my music, photos, and source code.

promo_macbookair

My backup strategy was:

  1. OSX backed itself up automatically to my Time Capsule using Time Machine.
  2. Windows I never backed up because I don’t mind re-installing a new Win machine in the event of failure since it’s a good chance to start from scratch and get rid of old crap – old versions of Visual Studio etc.
  3. The Data partition – the most important one – I backed up manually both to my Time Capsule’s shared network disk and an external USB drive, using Syncback Free. I’d usually do this once or twice a month.

I’d had an inkling that the SSD was about to die for about a week before – every morning on boot the Mac would display a flashing question mark icon. Usually it would boot OK on the second or third attempt. Until it didn’t (on my birthday, no less)…

Cue the usual ranting and gnashing of teeth. Every day I’m not working is a day I’m not getting paid (contractor, ya see). All of the Mac service centres in London promised a 3-5 working day turn around, because they would have to order in a replacement SSD. Which means I’d have to make an appointment with the dreaded Genius Bar since they probably would have the part in stock.

The staff at the Genius Bar are always great, but I HATE the process you have to go through to see them – booking an appointment online. To cut a long story short, I was able to get a walk-in appointment later that day, and because I had AppleCare (which I bought specifically because SSDs are unreliable), the £600 replacement part cost me £0. But it still cost me a day’s productivity (and pay!).

In terms of lost data, not a lot. I lost a Linux VM which I could rebuild in about a day. Source code is on git / svn servers so none. Personal data – some photos of a trip to Portugal but I was able to get lower res copies of most of them from Facebook.

Since then I’ve changed my backup strategy slightly, so as to avoid downtime, by embracing the Mac way of doing things:

  1. No more dual boot – I’m gonna run Windows 8 in VirtualBox when the need arises
  2. Everything is on the one Macintosh HD partition. However, old habits die hard – I still have the content of my old “Data” partition located at /Data on that hard drive, organised how I like it to be and not how OSX wants me to have it organised.
  3. Time Machine + Time Capsule now backs up everything automatically when I get home.
  4. Super Duper backs up and creates a bootable version of my Macintosh HD on an external USB drive. This means that if my SSD dies again, I can boot straight off the USB hard drive and carry on working. At the moment I’m doing this every night, which takes about 20 mins (using the Smart Copy – I purchased a license). But if I think about it, once a week or so should be adequate since my personal files should be getting backed up by Time Machine, and I usually commit / shelve source code every night.

I still feel a bit uneasy about running Windows in a VM, but lately I’ve only been using OSX at work. I’ll see how it goes when I start coding in .NET again in a few weeks.

Book review – Instant Meteor Javascript Framework Starter

Leave a comment

Last year I started playing around with Meteor, a new javascript framework. I didn’t get much further than playing with and tweaking sample applications.

When it came time to start creating my own app in Meteor though, I was a bit lost. I didn’t really know where to start.

I was given a copy of Instant Meteor Javascript Framework Starter which I read over the weekend. The book was a good read – I especially enjoyed the opening chapters which covered what Meteor is and why it’s cool, better than the official Meteor docs cover.

It covered all the Meteor basics well, and I would recommend the book to anyone who wants to get started building their own app with Meteor. Reading it has gotten me excited about Meteor again!

RavenDB – Input string was not in a correct format

Leave a comment

In a RavenDB ASP.NET MVC app I was recently working on, I was constantly seeing good ol’ System.FormatException – “Input string was not in a correct format”.

My entities all use ints for their Ids.

After a while I noticed (via the RavenDB Management Console) that my entities had Ids like “tab/123″, but previously the Ids were like “tab-123″.

The problem turned out to be that I had accidentally removed this line while doing some refactoring:


documentStore.Conventions.IdentityPartsSeparator = "-";

Once I put that back in I stopped seeing the System.FormatException and all was right in the world.

 

Retrieve child items with an integer ID in a many-to-many with RavenDB

Leave a comment

I have a many to many relationship, like so

public class Movie
{
   public int Id { get; set; }
   public string Title { get; set; }
   public int[] ActorIds { get; set; }
   // etc
}

public class Actor
{
   public int Id { get; set; }
   public int Name { get; set; }
   // etc
}

When I load a Movie, I also want to load all of the Actors associated with that Movie.

This can be done using Raven’s Load<T>(IEnumerable<System.ValueType> ids) method, and casting the int[] to an array of ValueType, like so:

var movie = RavenSession.Load<Movie>(movieId);
var actorIds = movie.TabIds.Cast<System.ValueType>();

var actors = RavenSession.Load<Actor>(actorIds).OrderBy(x => x.Name);

Older Entries

Follow

Get every new post delivered to your Inbox.