Creating a standalone Nancy server

Something I tend to be doing more often, is creating a standalone Nancy server and with each of them, I setup a lot of the same boilerplate code. So I thought I would put together what that setup looks like and throw the code up on GitHub.

This is an opinionated setup using the following packages: Nancy, Autofac, Serilog, ConfigInjector

Getting Started

Starting with a new empty web application in Visual Studio 2015:

image

Then add the initial nuget packages:

Install-Package Nancy.Hosting.Aspnet

Install-Package Nancy.Bootstrappers.Autofac

Next, implement the Autofac Bootstrapper for Nancy by adding a class called Bootstrapper.cs and implement the AutofacNancyBootstrapper:

    public class Bootstrapper : AutofacNancyBootstrapper
{
protected override void ConfigureApplicationContainer(ILifetimeScope existingContainer)
{
var builder = new ContainerBuilder();
builder.RegisterAssemblyModules(Assembly.GetAssembly(typeof(Bootstrapper)));
builder.Update(existingContainer.ComponentRegistry);
}
}

Finally create a NancyModule class for the endpoint:

    public class SampleEndpoint : NancyModule
{
public SampleEndpoint() : base("/sample")
{
Get["/"] = _ => GetSampleData();
}

private Response GetSampleData()
{
return "hello world";
}
}

Now if you run up the application, and navigate to the sample endpoint, you should get the hello world response.

image

In the next post I’ll add some logging.

Advertisements

Microsoft Arc Touch Mouse–First Impressions

After borrowing a colleagues Microsoft Arc Mouse last year I ended up buying several of them and have been using them   exclusively since, so when the Microsoft Arc Touch Mouse came out a few weeks ago I had to get my hands on one and take it for a spin. First impressions of the mouse is how flat it folds. The Arc Mouse when folded goes into a bit of a ball, but the Arc Touch folds complete flat and is only a couple of millimetres thick. Its super slim design is what really makes you sit up and notice, folding completely flat it has been built with portability in mind easily fitting into a pocket or the sleeve on the front of my laptop bag. When you first start taking it for a run, then next thing you notice is how lightweight it is. This is one of the reasons I loved the Arc Mouse and this does not disappoint. The USB receiver for the mouse is tiny and the underside of the mouse itself has a magnetic strip which allows you to simply stick the received to the bottom when packing it away. The one thing I don’t like about the Arc Mouse is that I run through the batteries pretty quickly. Unfortunately this is partly my fault as I keep forgetting to close the mouse which turns it off, but the new Arc Touch turns off when you fold it flat which I seem to be doing more often which I put down to the design. So far I’ve only had the mouse a couple of weeks so time will tell how the battery life compares.

So after a couple of week of usage, I have found that the mouse is not as comfortable to use as the Arc Mouse. Part of this I suspect is due to its lightweight design. Instead of having a middle button or a scroll wheel, as the name suggests the Arc Touch has a touch scroll area. This provides a vibration feedback as you swipe your finger up and down to scroll. Initially I thought this would be just a novelty, but as you start to use if, I’ve found it to be quite useful. The touch area not only works as a scroll wheel, but also as a middle click operation and also allows you page up and page down by clicking the top or bottom of the touch area. Scrolling works really well, but unfortunately I’ve struggled to master the middle click or the page up and page down functionality of the touch area. This feature has been very hit and miss for me.Arc Touch Mouse from Microsoft

When the Touch Mouse was first released, it was selling for around $80 which made it about double the price of the Arc Mouse, but a quick search today has them selling for about $50 making it only $10 more now. All in all I still think my day to day mouse will remain the Arc Mouse, but for a more portable solution the design and size of the Arc Touch make it a very close second.

Telco’s Holding Us To Ransom–An Update

In my previous article Telco’s Holding Us To Ransom I discussed my dissatisfaction at the way in which Windows Phone 7 updates are blocked by the Mobile Carriers. This doesn’t just affect the Windows Phone 7 platform, but also the iPhone and Android devices. It was interesting to read an article today discussing Microsoft’s strategy to break the hold that the mobile carriers have over them:

Microsoft has a good mobile OS, they just bought a soft carrier in Skype, and whether the rumors of a potential acquisition of Nokia pan out or not, Microsoft’s recent deal with Nokia seems to go beyond a simple OS licensing agreement. If Microsoft is trying to turn the cellular industry on end, it’ll start out with Nokia hardware built to Microsoft specifications…

And of course Microsoft isn’t alone in this ambition. Apple and Google each appear to have been moving to the same destination by different paths. Apple’s integration of FaceTime, first into the iPhone, then the iPod Touch, iPad 2, and Mac OS, is a clear move toward carrier independence.

Read the full article at Is Microsoft trying to end the reign of mobile carriers?

Tips and Tricks for Overseas Business Travel

A few weeks ago I went to the NZALM conference in Wellington and next week I’m off to Bali, so I thought I’d try to gather a few tips and tricks for overseas business travel.

International Roaming

Firstly, when it comes to international roaming and smart phones you have a choice, either disable your data usage, or be prepared for a huge bill when you get home. Prior to the trip I prepaid for a data plan, but on my return I still found that I had an excess data usage bill of $70. On a pay as you go style data plan this actually only equates to less than 5MB of data (cost is $15/MB). Half way through the trip I remembered that my Kindle DX has free internet access through their WhisperNet service so I tried to use this where possible. Now this may not be the best experience for web browsing, but for things like sending and receiving emails, I found it worked a treat. To access Google Mail on a mobile device, navigate http://m.gmail.com and you will get a very text based view of your emails cutting down on a lot of the extras that you just don’t need.

clip_image001

With the Kindle web browser, there are obvious limitations such as the fact that you only have a black and white screen, you don’t have a mouse so you have to use the 5-way controller and previous and next page to navigate around, but if you are prepared to live with these you’ll save yourself a fortune in roaming data charges.

Most of the Google apps are easily viewable on the Kindle Gmail. Navigate to http://m.google.com and you will be presented with a list of many of the Google apps including Gmail and Google Reader that you can access.

Other great sites that work well on the Kindle are Lonely Planet (http://m.lonelyplanet.com), Yahoo Mail (http://m.yahoo.com) , Facebook (http://touch.facebook.com) and Twitter (http://mobile.twitter.com). There is also a great service which collects some of the most popular links at http://kinstant.com. Be sure to check out the great lightweight Google maps app they have at http://kinstant.com/maps/.

clip_image002

clip_image003

Power Converters

Fortunately NZ use the same power points and voltage as in Australia, so I didn’t need to take a converter for my previous trip, but for my next trip I’ll need to take a power adapter. One trick I learned was make sure you not only take a power adapter, but also at least a double adapter. Not only will there be times when you need to connect more than one device, but also just in case any fellow travellers you are with forget theirs.

 

So what tips and tricks do you have for overseas business travel? Please add them to the comments below.

“Down Under” Tax Strikes Again

You may recall from a previous post I talked about the "down under" tax that Harvey Norman had applied to the Samsung Series 9 laptops, well today Lenovo has had to defend its aussie pricing of its new X1 laptop.

Over the weekend Harvey Norman had a 30% sale on all laptops, so it just goes to show the kind of mark-up they have on these to be able to simply chop nearly a third off the price tag. This brought the laptop within my budget, plus I’m heading overseas next week so I’ll be able to get the GST back. All up this brings the price down to $1570 – a much more reasonable price I think.

Game of the Week – Flight Control

imageAs I mentioned in last weeks game Wordament, the keys to a successful portable game are firstly, the game need to be easy to learn but takes a while to master and secondly, you can play for as little as a couple of minutes or a couple of hours. Flight Control is one of those games that will keep you playing all day and not want to put it down.

The game is quite simple, aircraft enter from the edges of the screen and its your job to direct them to their runway to land. The only real rules are that different aircraft types have specific runways that they need to land on, and don’t let them crash. Simple enough hey, but as I said earlier, it will keep you coming back for more as you try to squeeze dozens of aircraft on the screen at the same time and keep them from crashing into each other.

Flight Control was originally developed for the iPod touch by Australian game maker Firemint and has remained in the top all time games for several years now. Flight Control is one of those success stories which has racked up over 4 million downloads and has since been ported to the iPad, Android, Windows Phone 7, Nintendo DS, Playstation and also the PC and Mac. Recently Firemint was acquired by EA Games which will hopefully mean some more capital investment to allow them to keep coming out with more great apps like this.

When the Windows Phone 7 update goes pear shaped

imageYesterday I advised that the NoDo update had been released by Telstra, unfortunately the update process didn’t go so smoothly. At the second last step it was supposed to do a reboot, but unfortunately the phone vibrated 7 times then hung on the boot screen. I left the phone and Zune update process for a considerable amount of time, but it was obvious the upgrade had failed. Attempts to reboot the phone by switching it off and on all simply returned to the same state. Further attempts to get it working including a factory reset also failed. Unfortunately the process of performing a factory reset effectively wipes everything off the phone and takes you back to the raw ROM, but seeing as the ROM is in a partial state – this is not possible. After much research on the web trying to find a solution I came across the following blog: http://barrymoves.blogspot.com/2011/05/did-you-use-chevronwp7updater-on-your.html which provides instructions for downloading and reloading the original Telstra ROM. So thankfully I now have a nice clean phone at its original state when I first bought it, all I need to do now is re-install all the apps and reconfigure all the settings again.