Author Archives: cairey

About cairey

Software Developer - C#

Dropbox, Google Drive and Microsoft SkyDrive

There are a few choice when choosing cloud storage. I’ve been playing with all 3 and they are all impressive. My observations so far suggest that Google Drive seems to be slower than the other when syncing data. Currently, Google Drive offers 5 GB of storage, Dropbox with 3GB and Microsoft SkyDrive with 7GB! They all follow the same principle of having watch/drop folders that sync, so just drop a file in the folder and it’s away! A handy tip in Windows 7/8 is to set-up a location that links to the storage folder, for access to your document, pictures etc.

Leave a comment

Posted by on June 11, 2012 in General


Tags: , , , , , , ,

Fluent Request Builder for Node JS

It’s on my github page, so get it from there.

The http lib can be a bit low level sometimes, so why not make it simpler. Use like so:

var requestBuilder = require('./requestBuilder');

var data = JSON.stringify({ 'important': 'data' });

var headers = {
'Host': '',
'Cookie': null,
'Content-Type': 'text/plain',
'Content-Length': Buffer.byteLength(data, 'utf8'),
'Accept': '*/*'

.makeRequest('', '/', function(body, response){

Leave a comment

Posted by on January 25, 2012 in JavaScript, Node, Software Development


Tags: , , , , , , ,

Hover Intent for Silverlight

Updated: Now on GitHub:

You have probably already used the Hover intent plugin for JQuery. Maybe you want to do the same thing for Silverlight? Well using the reactive extensions you can quite easily. Of course we are using MVVM so we can capture the elements mouse enter event and bind a command to it on the view model.

You can then bind in the XAML like so:
Button x:Name="Eyecon" commands:MouseEnterIntent.Command="{Binding Open}" commands:MouseEnterIntent.DueTime="50"

The MouseEnterIntent class creates the attached behavior using dependency properties. The MouseEnterIntentCommandBehavior class bind the events to the command.

Leave a comment

Posted by on September 21, 2010 in C# Development, Silverlight, Websites


Tags: , , , , , , , ,

JQuery plugin – showAge

Updated: See the plugin page.

I thought I would experiment, write and share a JQuery plugin. I have written simple plugins for applications, but this is a first time for a public release plugin. The plugin is designed to manipulate dates. For any date on the page, you can transform the date to show its real age. To overcome a few huddles, I will explain.

JavaScript DateTime is not a reliable source, for getting the current date. JavaScript runs on the clients machine, in turn it relies on the client system clock to be 100% correct. While this shouldn’t generally be an issue, it’s not reliable. So, to get the real date I am calling a .NET web service and returning JSON using JQuery’s built-in mechanism for handling this.

To return JSON from an ASMX service, JQuery can be setup like so:

I have simplified JQuery’s mechanism in the plugin, and by no means you don’t have to use this. However for my case, I wrapped it inside a function for ease. This is how it should be setup to request JSON from an ASMX web service. The web service will see in the request headers JSON is requested, and therefore return JSON. So how do we do this?

You can provide your own mechanism for getting the current date, but this shows how it works.

The function call to getJson() calls the web service, which returns an anonymous object. Notice that month is returning month – 1. Why is this? Well JavaScript date begins in January at Month 0, in .NET January begins at Month 1. So, we do a bit of correction there. The web service knows that an XML Request (Ajax Request) is being sent but also with the content type JSON. The web service is clever enough to know how to handle this async JSON request and will return a JSON object. The callback function returns a data object with our date. Do notice however that data.d is used. “.d” to access our returns object, as designed by Microsoft.

The plugin has the following options.

TodaysDate (optional): – this is a JavaScript Date object, to be set to the current date. (Default value sets the current date using JavaScript).
InsertMode (optional): – this controls how the age is inserted. (Default value is set to ‘append’).
CustomCompare (optional): – this takes a function to compare dates and return the number of years between them. (Default uses its own compare).

InsertMode consists of the following options.

‘replace’ – replace the date with the real age.
‘append’ – append the date with real age.
‘prepend’ – prepend the date with the real age.

In its simplist form:

Will display:

Although the example is a VS project, the JQuery plugin is not .NET specific.

Download – v1.1
Leave a comment

Posted by on January 12, 2010 in C# Development, HTML / CSS, JavaScript


Tags: , , , , , , , , , , , , , ,

Entity Framework for making structural DB changes.

We have all had to do it at some point… but it can get really tricky when you have a project that is constantly changing, especially when data is involved. We have a project where all the data needs to be remain intact, unfortunately these changes were not easy to script.

To migrate the live data into the new structure we used the Entity Framework to generate our old domain from the old database and the new domain from the new database structure. They were imported on different namespaces to determine which model was being dealt with. It was a doddle because it meant mapping the old domain object against the new domain object, then inserting the live data into the new structure.

Saved a lot of time and we weren’t writing SQL queries. What I also liked about this, is the project uses Fluent Nhibernate!

1 Comment

Posted by on December 28, 2009 in SQL Server


Tags: , , , , , , , , , , ,

Entity framework, session per request

I am releasing a HTTP Module, that will open and close the entity session, because this works for each HTTP request a new context instance is created for each user per request.



Posted by on October 14, 2009 in C# Development, Software Development


Tags: , , , ,

UML and Visual Studio

Much to my disappointment and after about 6 hours of trying to get it to work, Visual Studio 2008 does not support UML (Unified Modelling Language). Visual Studio 2008 allows you to create a class diagram that will self generate all the classes in the project (of course you would have done all your class diagrams first, ahem), but this is not UML! Microsoft Visio has UML support, but it cannot generate it from classes or a visual studio project, unless you have the “uber apparently works edition”. Great, so there you are with this huge project and you need to document it, but VS2008 does not know what the hell UML is.

The good news is that there will be full UML support in Visual Studio 2010! Yippee! However for me that will be too late 😦

Leave a comment

Posted by on August 12, 2009 in C# Development, Software Development


Tags: , , , ,