Fri, Jun 6, 2014

Modifying the bash prompt and adding Git completion to terminal

At work we use Git and I use Console2 to control my terminal envrionments eg/Git Bash, Powershell, Dos and when using Git I can type part type a git command press tab and it will auto complete the command or offer suggestions to commands. By default on OSX this behaviour is not present and it frustrated me enough to go and find out how to enable that behaviour.

Fire up your terminal and type in this command:

curl -o ~/.git-completion.bash

This will download a git completion file into your home folder to a hidden file called git-completion.bash.

If the file ~/.bash_profile does not already exist create it with the following command.

touch ~/.bash_profile

Now open it and paste this in:

if [ -f ~/.git-completion.bash ]; then . ~/.git-completion.bash; fi

Now if you type a git command and press tab, BOOM!, you have auto complete for Git!

Wed, May 7, 2014

Introducing Owin.StatelessAuth with Nancy/Angular demo

If you’re writing an API, current thinking is to provide a token in the Authorization header for your app to validate when the request comes in. I have used the Nancy.Authentication.Stateless package in the past for my APIs and even have a demo of it here if you’re interested (there are more Nancy demos at This is a great package and does a great job but what if one day you want to use SignalR v2 that uses OWIN and you want to validate not just requests to your Nancy app but also the SignalR requests? You’re going to need to validate requests as they come in before they get to SignalR or Nancy.

For those of you who are not quite up to date or unsure what OWIN is let me try and give you the tl:dr, no doubt others may say its something slightly different. Imagine you are asked to create a ASP.Net MVC 3 app (ignore the fact that that person needs a slap) so you fire up Visual Studio and create the app. So what has it done? Its created an app that runs on IIS and all requests come straight into your app.

Sat, Mar 22, 2014

Using NodeJS and FTP with Promises

I’ve played with node in the past but as of the new year I decided to try and make a more concerted effort to get stuck into node properly. I decided to go back to the beginning to try and get a better appreciation for the language so read “JavaScript: The Good Parts by Douglas Crockford”. I found that exercise fulfilling and resulted in a few light bulb moments that made some dots join up so I’d recommend reading it if you haven’t already.

Real World App

As I stated earlier I have already played with node in the past using Express and have read quite a bit on node and read many examples but I wanted to write a non-web app as I felt this would give me a better opportunity to get to grips with the language and Node. Using Express allows you to get up and running very quickly without to much head scratching so I felt a standalone script would give me more exposure to things.

Thu, Jan 2, 2014

Unit Testing with SqlException

So after a nice Christmas break I get to some code that needs some unit testing around a try/catch. Something similar to this:

catch (EntityCommandExecutionException ex)
    var exception = ex.InnerException as SqlException;
    if (exception != null)
        if (exception.Number == -2)
            //Do something special

Fri, Dec 20, 2013

Using SQL Server with node.js

I like to keep eyes and ears open for new technologies and methodologies in order to become a better developer and I’d heard about edge.js many months ago but made a mental note of it and waved it goodbye. edge.js lets you have two-way communication between node and C# libraries. When I first looked at it I thought that sounded a bit hacky, I’ve spent my time communicating with COM libraries in Delphi and OCX libraries with C# and didn’t like it so I felt this was pretty much the same thing. A long time passed and I was writing a console based Windows app as a service and had wondererd whether I could quickly port it to node.

I was discussing with a colleague about using node at work and that we needed something seperate and small just to try it out and see how the whole developement process with it worked. As the database that this app needed to communicate with was MSSQL I looked into a library on NPM that would communicate with MSSQL and maybe act as an ORM. There was a Microsoft lib that seemed untouched and reading the comments on the issues list on Github it didnt favour too well. There were libraries that would communicate with MySQL & PostgresSQL but not MSSQL. In my search I came across edge.js again. It had 2 samples, one that used edge-sql and one that used ScriptCS so in laymans terms, one that used a precompiled dll and one that used a C# script that was executed at runtime.

Mon, Nov 25, 2013

Octopus XML Transformation in Services

We use Octopus Deploy at work and its a superb tool for deploying your applications whether they be websites or *.exes.

One of the great things it also provides is the ability to use Microsoft’s Transformation process for config files. However, when deploying a exe application its a bit trickier than a website. Unfortunately the documentation doesn’t mention the steps needed to get this working so read on!

Typically a web application will have web.config and a web.Release.config as well as other derivations you may use. Octopus also supports web.[Environment].config.

Thu, Nov 7, 2013

Using Git to update YouTrack via TeamCity

This post is mainly a reminder for me as I keep forgetting the command in Git to integrate commits to YouTrack items. YouTrack uses TeamCity to get the information about the commits and then scans the commit comment for a YouTrack item id and any commands that it can apply such as item status or time spent on said item. There is some documentation here but its not the greatest in terms of clarity and I’ve spoken to Hadi Hariri from JetBrains about improving this so hopefully they’re working on it.