10 Mar 2013

jQuery Toolbar Placeholder Plugin

No Comments JavaScript

In creating a templating system for people to insert placeholder text, I wanted a toolbar with buttons which would insert text at the position of the cursor when clicked.
jQuery toolbar plugin
This plugin takes an array of button IDs and the text to be inserted when each button is clicked. EG:L

var buttons = [
	{ 'buttonId':'btnName', 'insertionText':'%%NAME%%' },
	{ 'buttonId':'btnAddress', 'insertionText':'%%ADDRESS%%' },
$('#toolbar').hypotoolbar(buttons, 'txtBody');

When the btnName and btnAddress buttons are clicked, %%NAME%% and %%ADDRESS%% will be inserted into the textarea with ID txtBody at the cursor position.
Read more

22 Feb 2013

jQuery Text Progress Meter

No Comments JavaScript

This small plugin will display a progress meter which fills up as text is entered into an input or textarea. Useful for indicating to a user how much remaining text they have in a field with a maximum length.

jQuery.textprogress Demo


  • messageFormat – The format for the count label. Available placeholders are {current}, {total} and {percent}
  • showCounttrue/false – Whether or not to display a total of the current length/maximum allowed length.
  • max – The maximum allowed length
  • allowOverLengthtrue/false – Whether or not to prevent more text being entered than allowed.
  • classes An object containing two keys:
    • standard – The progress bar class if less than the allowed length of text is entered.
    • over – The class if equal to or more than the allowed text length is entered
  • textbox – The textbox/input element to measure.

Source on GitHub

17 Feb 2013

Bootstrap CSS Image Buttons

No Comments JavaScript and Programming

One of the repetitive things I found myself doing with Twitter’s Bootstrap framework was creating buttons which had a background gradient and an image. (Doesn’t work in < IE9, but does in Fx, Chrome and Safari).This makes use of the multiple backgrounds CSS3 property. The CSS I was typing every time was this (eg: for an ‘add’ button):
Read more

17 Feb 2013

Working with IsolatedStorage

No Comments Windows Phone 7

IsolatedStorage lacks some of the convenience methods which FileInfo and DirectoryInfo provide. These are some methods which simplify the process.

  • GetAllFilePaths – Recursively gets a list of all files in IsolatedStorage.
  • GetSafePath – Gets the usable safe path for a file/directory in IsolatedStorage.
  • GetLastWriteTime – Gets the last write time for a file/directory in IsolatedStorage.
  • GetFileSize – Gets the size of a file in IsolatedStorage.

Code after the jump.
Read more

05 Feb 2013

Custom logging with Log4Net

No Comments Programming

Using log4net, it’s possible to log to a number of different sources such as ADO.NET, the console or a text file. This works fine if the parameters for logging (eg: username, password) are static and don’t change, but you run in to difficulties when trying to use dependency injection. One way to get around this is to add a custom appender which picks up your configuration before logging.

Read more

24 Jan 2013

Synchonising a Textbox and Checkbox List

No Comments ASP.NET and JavaScript

Choosing a selection from a list of items is fine when there are only a few choices, but if there are ~100 or more options, can be unsightly on a page.

It’s better to give the user the option to type a code if they know it or browse the list if they don’t. For this, I recently implemented a jQuery Dialog which keeps the contents of a TextBox in sync with a list of checkboxes. The open and close events of the dialog are used to keep the textbox and checkbox list in sync.

Read more

28 Dec 2012

Templating with Spark and WPF

No Comments ASP.NET and WPF

Generating text from a template can be a powerful tool to make markup cleaner and simplify creation of emails or other text.

I needed to format a template from WPF, and after trying in vain with ASP.NET’s Razor engine I eventually found Spark, a templating engine which, with very little effort, enables formatting a template to produce a string.

Read more

31 Oct 2012

jQuery Stylesheet Switcher

No Comments JavaScript and Programming

Small customizations in a web app always seem to add a depth to the user experience. I wanted to add a simple theme switcher to a web app I was creating but couldn’t find anything which fitted my needs.

Theme-a-Go-Go is a simple CSS theme switcher plugin. It takes a configuration array and creates swatches which, when clicked, throw up a loading div while a set of stylesheets is swapped out. The user’s preference is saved via a web service with AJAX.

Read more

16 Sep 2012

Debugging Windows Services

No Comments Programming

I was recently developing a Windows service which crashed on startup. This proved particularly difficult to debug at first, partially because there didn’t seem to be a clear way to step through it. The only thing recorded in the event log was:

The application caused an unhandled exception at

The SomeServiceName service terminated unexpectedly. It has done this 3 time(s).
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

At first I used log4net to log messages to a text file – like an old fashioned ‘got to here’ type approach, then reinstalling with every new build:

Read more

01 Sep 2012

Deploying Files to Documents Directory

2 Comments iOS

Ever needed to bundle a collection of files with your app to dump into the documents directory on first launch? I needed to copy a few directories and a couple of files for ChickenPing

First you need to drag your sample data folder into your project in XCode as a folder, not as a group. This gives it a blue icon instead of yellow (in XCode 4).

Read more