bondigeek.com Rotating Header Image

Microsoft buying Skype. A stroke of genius?

It’s been a while blogosphere and this post has been a long time coming. Fortunately I have been distracted by way more important things, mainly welcoming two new little geeks to the planet. My wife and I could not be happier with our two little bubs and having kids really puts things in to perspective.

As much as I love what I do for work  it’s just a job and family, without a doubt, comes first.

Anyway, that’s not what this blog post is about. It’s about Microsoft purchasing Skype last year. At the time a lot of people reported that it was insane paying however many billion it was for Skype. Madness even. But hold on a moment, I think it may well have just been a (calculated) stroke of genius.

Continue reading →

Simple Azure Warmup Task

Ok, gonna squeeze out a quick blog post cause it’s been way to long between drinks. I have been coding like a mad man on a new project,  hence the tumbleweeds on the social front.

So todays post is about creating a simple task for warming up your Azure Web Roles.

Why is this important? Well if there is a lull in traffic to your site IIS will nod off and all that cached data that makes your site responsive and snappy will be lost. You are caching your data right?

So there are various techniques out there and this simple one is based on a post of another tech blogger, extending it to allow pings to multiple pages.

Read on for all the geeky lovelyness.

Continue reading →

Json serialization with Windows Phone 7, WCF Data Services & Azure

I have been working/collaborating on a project the past while that will be a mobile application and a location based service.

At the back-end it is being designed and developed from the ground up to be scalable and high performance. It has to be cause we want this thing rolled out on the millions of mobile phones out there be they iPhone, Android or Windows Phone 7.

At the back-end all data, with the exception of some reference data that is retrieved from SQL Azure and loaded in to a memory cache, is retrieved from and persisted to Azure Table Storage.

To expose some data and make it portable to all the devices I am making use of WCF Data Services which enables simple queries against the data store for things like lookup data (think genders, countries, anything that is relatively static) and expose them as an ATOM feed.

For everything else I am using good old Json serialization of objects.

Now I don’t know how iPhone and Android handle the de-serialization on their side, I am leaving that to the devs that are coding up the apps for those phones, but I did need to know how to do this for the Windows Phone 7 platform which I am working on at the moment.

Read on for how I handled it.

Continue reading →

Facebook Login Integration

This past week I was tasked with integrating Facebook Login with a new MVC3 site I am working on and the whole process is made remarkably easy with the help of a few NuGet packages.

Now I was following along with the documentation that can be found on Codeplex here but I have to confess I did get a little confused with it (maybe it was me being blonde) as it didn’t appear to give me the complete picture so I figured it was worth my while documenting my findings in the hope of saving someone else a little time, or myself in the future.

Read on below the break for all the details.

Continue reading →

A simple C#, Thread Safe Logging Class

I was doing some work for a client recently that had all sorts of issues with logging due to some old code from the original developers. It had multiple threads all trying to write to the log file simultaneously. Needless to say loads of logging just fell by the way side as the file could not be locked for writing.

The Singleton class below implements an internal queue that stacks up Log Messages and when 1 of 2 thresholds is reached (number of items in queue or queue age) the messages all get flushed to disk.

Calling the class is done with 2 lines of code:

LogWriter writer = LogWriter.Instance;
writer.WriteToLog(message);

Full source code below the break

Continue reading →

Simple MVC3 Ajax Feedback Form with AntiForgeryToken to prevent (most) CSRF attacks

One of the really great things about MVC3 is it’s support for forms. This might sound like aasp-net-mvc-3 simple and basic thing but the handling of forms in ASP.NET MVC3 is vastly improved over traditional ASP.NET

The code below implements a simple Feedback form which is used site-wide on http://www.bondigeek.com and utilises a couple of the nice MVC3 features such as Ajax Forms and an AntiForgeryToken.

Somebody asked the question on Forrst the other day as to why they would want to use the built in Ajax support of MVC3 over and above just posting data back with Ajax and jQuery. The AntiForgeryToken is one good reason why.

Code below the break

Continue reading →

jQuery Icon Peek animation

As I am continuing to refine the design on the new look BondGeek website I wanted to make the toolbox page a little more animated. I decided to have the square icons dropdown to reveal a text link for some of the icons that were not obvious what they are, unless you followed the link over the image. You can see the animation in action here http://bondigeek.com/Toolbox

I have always liked the way that the tiles drop down on the Windows Phone 7 home screen for contacts, where the image slides down to reveal the name, so decided to adopt an approach similar to that.

The code shown below is called when the toolbox page loads and gets the collection of images wrapped inside a div with the .image_wrapper class and animates all of them in a random fashion with a random interval. This is done by calling the Peek() method on a timer.

One thing you will notice is that the background-color of div.image_wrapper is set to #ffffff. This is so that the white text of the link text does not show through when the image slides up.

Each of the square images also has a hover event on it so that the animation can be manually fired to reveal the link text. This also pauses the timer whilst you are hovered over an image so the automatic animation pause

Code below the break

Continue reading →

DataCache<T>: A simple (but effective) caching class

I have been using this code for a while now and thought I would post it out to the community as a simple C# DataCache class that can be re-used.

This is only really applicable to non-web farm solutions as the data will be stored in process per IIS instance. If you want a distributed solution then look to pay big(ger) bucks or if you are hosting your site in Windows Azure then  AppFabric Caching is the go and very reasonably priced.

With that disclaimer aside though this works nicely for any single server solution and will cache any type of data.

I chose to have a DataCacheItem enum for each project I use this on, which is one of the parameters to the Insert, Get, Contains and Remove methods but you could always change to a string if you like. I prefer the strongly typed approach as it saves on typing errors.

Code below the break

Continue reading →

Parsing WordPress ‘most recent items’ using XDocument and LINQ

I am in the process of re-working my personal website with a Win8 theme and wanted to retain my existing WordPress blog as is (for SEO and because WordPress is a great blogging platform) but wanted to also have the blog content on the new site.

Getting the feed from WordPress of the most recent items is dead easy as it is exposed as an RSS feed so all that’s required is to parse the feed and re-render the content on the new blog page which you can see here http://bondigeek.com/TheBlog.

I have added some of the additional stuff to the code above for clarity but the first block does all the work of parsing using XDocument and LINQ

Code below the break

Continue reading →

Automatic Slideshow with reverse direction and random intervals

This is a slideshow wrapper that you can re-use to display a slideshow on your site.

You can see the slideshow in action at bondigeek.com/

Prerequisites:

* jQuery

Tested In:

*IE8/IE9

* Firefox

* Chrome

* Safari for Windows + MAC

It comes with the following features:

  • create slideshow in 1 line of code
  • Will handle any number of (same dimension) images that you care to load
  • automatically slides at a random interval
  • initial direction of slide (left or right) can be specified
  • automatically reverses slideshow at the end and beginning of the list of images
  • allows for setting of the initial slide operation to allow time for other slideshow images to pre-load
  • Provides parameters for min and max length of interval between slide operations
  • minimal css config with initial background image whilst other slide images pre-load

Known Issues:

When the browser windows is hidden for a time period and you go back to the window you get some erratic behaviour (whilst the events catch up I imagine). Looking in to a fix for this which pauses the slideshow when the window is no longer visible.

Code below the break

Continue reading →