Monday, 17 November 2008

The Pixel Chicken

I just found out that my mate Liz has buggered off back to Australia without somuch as a good bye! The cow!

So anyway, I thought I'd link her up... If you're reading this, you're based in Sydney and you're looking for a top class interactive designer / developer then give Liz a shout and check out her blog over at

Liz, next time try saying good bye ;)

Wednesday, 12 November 2008

Book Review : ASP.NET 2.0 Step by Step

Just over a month ago I moved in with Smithy, during the expected packing and unpacking I came across a book that I bought close to 3 years ago when I started working at twentysix Leeds and was forced to learn .NET.

The book is "ASP.NET 2.0 Step by Step" from the Microsoft Press which and I've got to say, my initial opinion was not a good one, after getting just over half way through, I became disenchanted with and put to one side. I have since spent the last 8 months looking high and low for it, and even accusing my co-workers of losing it for me :S (sorry guys) as I found a desire to finish it.

My first attempt at reading the book was not a good one. I was coming from a solid 5 years of scripting things like Lingo, ActionScript, JavaScript and most importantly PHP; I was struggling with the structured and strict way that ASP.NET works when compared to (loose and, dare I say, sloppy) PHP pages. It also seemed a bit wordy for my liking. Some of my favourite programming books are the O'Reilly cookbook series which give you examples based around short, concise scenarios.

So, armed with my now solid 2 years of experience with C# and the .NET Framework I picked up the book again, found my old bookmark still stuck in at the end of chapter 13 and decided to have a little flick.

It just so happened that the next couple of chapters concerned subjects that have been on the agenda quite a bit recently, namely the caching of data and output within a web application.

These two chapters give a good introduction and now, with just over two years experience with C# and the .NET framework I find these chapters to be just enough to get me going on a subject. I now know how and where to look for further information on a subject from my time searching the usual places.

Having re-read the first 13 chapters I take back most of what I thought about it in the first place and can see that my original lack of enthusiasm for the book was not down to the book, but due to my inexperience with ASP.NET and all its in's and outs. I actually love this book now as it gives you insights into many of the key tools that you might use day to day in a ASP.NET web app.

Good book, get it read!

Tuesday, 11 November 2008

The ASP.NET Singleton, Singleton classes for ASP.NET

This is a little trick I learned recently. I had a situation where I needed to use a static class in one of my ASP.NET web apps. I wanted it to provide functionality on a per-user basis, but when I put this in to practice I got some funny results and then I realised the obvious. Static classes are shared throughout any single instance of a .NET application, and each website runs within it's own w3wp.exe process, as a self contained application. This explained the funny behaviour.

So I did a little digging around and found the following code, which adapts the singleton pattern to store the instance in a per-user manner.

Each user is assigned an HttpContext for thier time visiting an ASP.NET web application. This Context object allows you to store objects.

So a classic Singleton might look something like this

class Singleton {

// private instance field
private static Singleton _instance;

// public read-only instance property
public static Singleton Instance {
if(_instance == null){
_instance = new Singleton();

return _instance;

// private constructor
private Singleton() {
// constructor logic here

All we have to do is to replace the private field for an Item in the HttpContect object, like so...

class Singleton {

// public read-only instance property
public static Singleton Instance {
if(HttpContext.Current.Items["SingltonInstance"] == null){
HttpContext.Current.Items.Add("SingltonInstance", new


// cast the item to a singleton because it is stored as a generic object
return (Singleton)HttpContext.Current.Items["SingltonInstance"];

// private constructor
private Singleton() {
// constructor logic here

Tuesday, 30 September 2008

Working from home

So this Sunday I ran in the Horsforth 10Km race and finished in 46mins, not my personal best but it was a hilly course so it was always going to be difficult achieving that, and to boot I had pulled my left knee a little bit in training the Tuesday before.

This little pull has turned into a full blown injury which sees me working from home today and tomorrow and with a physio appointment 1st thing on Thursday.

Working from home has for a long time been a nightmare of mine. Simply because I do not (or did not) possess enough self dicipline to put in a full and productive days work. Until now!

I used to work part time at a University and then, in my "spare" time work on a few freelance bits and pieces, which seemed like a chore and I would always have to work late into the night to get to a point where I had achieved enough *work* for the day.

But I'm setting the record straight today. I was up at 7am with Smithy (mainely because I had a doctors appointment to get to) and then when I got back I was straight to the laptop and into the working. Had 40 mins for lunch and then more working. It feels good, this home working lark...

Luck I've got another day of it tomorrow then!...

Monday, 22 September 2008

Racing Time

Next Sunday sees the 24th Horsforth 10Km race which I will be running in.

I’ll be racing against some of my workmates, James, Tom, Jen and Sarah. So there should be some good fun and I’m looking to beat my most recent time at the Great Yorkshire run last month in Sheffield where I posted a time of 45:45 for 10Km.

Thursday, 11 September 2008

How to uninstall Adobe AIR on Windows

Here's some linkage for how to uninstall Adobe AIR on windows.

Download the latest installer and then from the dcommand line give it some of this

AdobeAIRInstaller.exe -uninstall

Thanks to flashmech for the original post (

Wednesday, 27 August 2008

How to de-dupe a record set using a temporary table (MSSQL)

Following on from the SQL Fire we witnessed a while ago I've just wrote this rather snazzy little query that does something similar.

The Problem:
The original problem is we have a little game with a scoreboard and one very dedicated player. Well, not only one player, many players but one is more determined to win than the rest. So to keep the small scoreboard looking inviting we decided to only show each player once, and to only show that players highest score.

I really wanted to do this in SQL as I figured it’s sorting and ordering abilities would be far easier than writing something in C#.

The Solutions:
Select the data into a temporary table which has a unique index on the user ID. The order of the select will ensure that only the highest score for each user will make it into the temporary table. Then select everything out of said temptable.

The Practical:

CREATE TABLE #tmpTable (
strFirstName NVARCHAR(255),
strLastName NVARCHAR(255),
intScore INT,
intUserID_PK INT

CREATE UNIQUE INDEX ix0 ON #tmpTable (intUserID_PK) WITH (ignore_dup_key = ON)

INSERT INTO #tmpTable SELECT strFirstName,strLastName,strValue, intUserID_FK
FROM tblScores

SELECT * FROM #tmpTable
DROP TABLE #tmpTable

Update: If you use this within a stored procedure you will need to remove the GO statements or the SP won't compile

Tuesday, 26 August 2008

Code updated, Blog not-so-updated

After a comment that an anonymous reader made I have revised and updated the ASP.NET Image Upload and Resize article. So BIG thanks to Anonymous for that one!

I''m struggling to finish the couple of posts i've started about recent activities so in absence of any real new content why not check out some of my other C# posts.

Monday, 11 August 2008

Photoshop CS3 (Wndows XP) Crashes when I open more than one document.

The last couple of weeks at work have been HELL! All of a sudden Photoshop started bombing out any time I tried to have more than one image open at a time.

If I opened 2 or more images at the same time... CRASH!
If I created two new images... CRASH!
If I created one image then opened another from disk... CRASH!
If I opened an image from disk then created a new one... CRASH!

Why? Because I'd recently deleted a printer and set a new one as my default.

I just reinstalled Photoshop.. still the same.

Simply changing the default printer however; That sorted it out...
Come on Adobe, such an amature piece of codeing... How can opening multiple documents rely on the default printer... sort it out!

Check out

Saturday, 2 August 2008

Saturday Morning: Website Security Time...

Recently a couple of our sites have been subject to SQL Injection Attacks but non have suffered so hard as the one I'm currently securing.

I spent all day yesterday on it and I've been up since 9AM when the head IT guy from our client called (and woke) me.

So after I get this thing done, and then enjoy what is left of my weekend I plan on writing up my learnings and educating my co-workers. Keep an eye out for a blog post or two.

Monday, 21 July 2008

twentysix Leeds are recruiting again!

We're looking for a couple of graduate Flash monkeys/developers to come in and help us out on some top class work for about a 6 month period.

Applicants should be strong annimators with good ActionScript skills.

We're looking for people who can start ASAP!

So if you're in the Leeds area, rock Flash daily and want some high profile work at an ACE digital agency, then hit me up at and check out our work.

Shout out's...

Just a quick shout out to Gav who's just got his blog up and running by the looks of things.

Check out

And to the inyerface folks for another excellent production this Friday and Saturday at the Library Theater in Sheffield.

Tuesday, 15 July 2008

PHP Search plugin link updated

We just moved offices (Photo's here and here) and as such some of our IP addresses changed.

I've recently had a couple of hits to the "Firefox PHP function search plugin" post. So I updated the link so you can now download it again. Sorry for the slight outage.

Thursday, 26 June 2008

How to move the viewstate to the bottom of your page source (C# ASP.NET 2.0, 3.0, 2.5, Visual Studio 2005, Visual Studio 2008)

Last week one of our new SEO bod, Ryan, asked Sel to move the viewstate to the bottom of the page source for the rest assured site. This helps to improve your SEOness as a lot of search engines only take so much of your source into account when spidering. So you really don't want to be feeding them 32k of base64 encoded gibberish when you could be giving them some beautifully crafted copy!

Andy did a couple of Google's and found some code which did the trick perfectly.
protected override void Render(System.Web.UI.HtmlTextWriter writer) {
System.IO.StringWriter stringWriter = new System.IO.StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);

string html = stringWriter.ToString();

int StartPoint = html.IndexOf("<input type="hidden" name="__VIEWSTATE");

if (StartPoint >= 0) {
int EndPoint = html.IndexOf("/>", StartPoint) + 2;
string viewstateInput = html.Substring(StartPoint, EndPoint - StartPoint);
html = html.Remove(StartPoint, EndPoint - StartPoint);
int FormEndStart = html.IndexOf("</form>") - 1;
if (FormEndStart >= 0) {
html = html.Insert(FormEndStart, viewstateInput);

This was ace and so today when I was asked to upload some ammends to a couple more of our clients sites I thought I would implement this for the same reasons as it only takes two seconds.

While it worked a treat on one of the sites, the other was not so good. Here's what the page should look like:

And here's what I got:

What has happened is this. The un-styled UL that you can see at the top of the page is the top half of the left hand navigation you can see in the 1st picture. This menu was implemented as a .NET user control and as such is treated like a page all of its own. The reason this happened is because the page was rendering out via our overridden method, but the control was not. So the HTML that the control generated was getting written to the output stream before the HTML of the Page ("Page" in the .NET Class sense, not the "web page" sense).

So this got me thinking, wouldn't it be nice to be able to have a single piece of code that could be applied to a site once, regardless of UserControls, MasterPages or any other intricacy, that would take care of moving the ViewState on every page of the site!?!

The answer: Yes!
The solution: an HttpModule...

An HttpModule is a piece of code that sits between your web application and IIS on the web server. What this module is going to do is intercept every response our application makes to a client and then, if the response is a HTML (read ASPX) page, look for and move the ViewState.

To do this we will filter the response stream using the Response.Filter property. I'll leave the full code until the end of the post but here are the main bits.

1) Create a new class that implements IHttpModule.
public sealed class IHttpViewstateMover : IHttpModule {

2) Add an event handler to the current request. This even then decides weather to add our filter to the response stream based on if it is outputting HTML.

public void Init (HttpApplication context) {
context.ReleaseRequestState += new EventHandler(context_ReleaseRequestState);

void context_ReleaseRequestState (object sender, EventArgs e) {
HttpResponse response = HttpContext.Current.Response;

if ( response.ContentType == "text/html" ) {
response.Filter = new ViewstateMover(response.Filter);

3) If the entire HTML file has been output ...

Regex eof = new Regex("</html>", RegexOptions.IgnoreCase);

if ( !eof.IsMatch(strBuffer) ) {
// code to follow...

re-position the viewstate and output the altered HTML to the stream.

    string finalHtml = _output_buffer.ToString();

int StartPoint = finalHtml.IndexOf("<input type="hidden" name="__VIEWSTATE");
if ( StartPoint >= 0 ) {
int EndPoint = finalHtml.IndexOf("/>", StartPoint) + 2;
string viewstateInput = finalHtml.Substring(StartPoint, EndPoint - StartPoint);
finalHtml = finalHtml.Remove(StartPoint, EndPoint - StartPoint);
int FormEndStart = finalHtml.IndexOf("</form>") - 1;
if ( FormEndStart >= 0 ) {
finalHtml = finalHtml.Insert(FormEndStart, viewstateInput);

byte[] data = UTF8Encoding.UTF8.GetBytes(finalHtml);

_output_stream.Write(data, 0, data.Length);
Simple as!

Now all you need to do us take the full code listing (below) and paste it into a C# file. Then add the following to your web.config inside the element:

So here's the code.
// Source code for IHttpViewstateMover.cs
using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;

/// <summary>
/// IHttpViewstateMover is a HttpModule that moves the viewstate
/// to the bottom of the HTML source to help with SEO
/// </summary>
public sealed class IHttpViewstateMover : IHttpModule {
// the class is sealed so it cannot be inherited

public void Dispose () {
// nothing to dispose

public void Init (HttpApplication context) {
context.ReleaseRequestState += new EventHandler(context_ReleaseRequestState);

void context_ReleaseRequestState (object sender, EventArgs e) {
HttpResponse response = HttpContext.Current.Response;

// Uncomment the following line if you only want to recieve a single call to ViewstateMover.Write
// context.Response.Buffer = true;

if ( response.ContentType == "text/html" ) {
response.Filter = new ViewstateMover(response.Filter);

/// <summary>
/// ViewstateMover is the workhorse of the IHttpViewstateMover
/// </summary>
private class ViewstateMover : Stream {
// this class is private as it serves no real purpose outside this implementation

private Stream _output_stream;
private long _position;
private StringBuilder _output_buffer;

/// <summary>
/// Creates a new instance of the ViewstateMover class
/// </summary>
/// <param name="input_stream">The HttpResponse.Filter to work with</param>
public ViewstateMover (Stream input_stream) {
_output_stream = input_stream;
_output_buffer = new StringBuilder();

#region Stream Members

public override bool CanRead {
get { return true; }

public override bool CanSeek {
get { return true; }

public override bool CanWrite {
get { return true; }

public override void Close () {

public override void Flush () {

public override long Length {
get { return 0; }

public override long Position {
get { return _position; }
set { _position = value; }

public override long Seek (long offset, SeekOrigin origin) {
return _output_stream.Seek(offset, origin);

public override void SetLength (long length) {

public override int Read (byte[] buffer, int offset, int count) {
return _output_stream.Read(buffer, offset, count);

public override void Write (byte[] buffer, int offset, int count) {
string strBuffer = UTF8Encoding.UTF8.GetString(buffer, offset, count);

// check for the closing HTML tag
Regex eof = new Regex("</html>", RegexOptions.IgnoreCase);

if ( !eof.IsMatch(strBuffer) ) {
} else {
string finalHtml = _output_buffer.ToString();

// original code from
int StartPoint = finalHtml.IndexOf("<input type="hidden" name="__VIEWSTATE");
if ( StartPoint >= 0 ) {
int EndPoint = finalHtml.IndexOf("/>", StartPoint) + 2;
string viewstateInput = finalHtml.Substring(StartPoint, EndPoint - StartPoint);
finalHtml = finalHtml.Remove(StartPoint, EndPoint - StartPoint);
int FormEndStart = finalHtml.IndexOf("</form>") - 1;
if ( FormEndStart >= 0 ) {
finalHtml = finalHtml.Insert(FormEndStart, viewstateInput);

byte[] data = UTF8Encoding.UTF8.GetBytes(finalHtml);
// write the page countents out to the user
_output_stream.Write(data, 0, data.Length);

As ever, the code is provided as is, with no kind of waranty so please test thoroughly before you place in a production environment. You use this code at your own risk.

Friday, 20 June 2008

How to stop Outlook 2007 from letting off a beep when a new email lands

This is possibly the single most annoying thing Microsoft have ever done!

Especially when you're listening to some really loud music with ear plugs in.


"Mother F***er" !

So, how to get rid of it...

Check out this guys post on how to stop outlook 2007 beeping at you when you get a new email.

Monday, 16 June 2008

Not the "world's first internet balloon race"

Just seen the Orange online balloon race and I really like the creative of the site though I do need to correct their incorrect claim in their title bar that it is the "worlds first internet balloon race".

I'm gonna take this opportunity to big up on of my ex-students, Nick Goward for the work he did in his 3rd year at the Hull School of Art and Design.

Nicks Big Balloon Race was his major project which took him about 9 months to build and after all that hard work he not only won the Student category at the 2006 BIMA, he also won that years Grand Prix for his efforts.

So nice website Orange, but get your facts right ;)

Saturday, 14 June 2008

On Aire

I started thinking about On Aire ages ago as a project that would enable me and my work mates to do things we don't get chance to look at and explore in our 9-to-5 but to date all that has come from it is a blog post and a domain registration...

Now that summer has (almost) got a hold of the UK I find that Gina and myself are asking more and more where we could go out for food or a relaxed drink in comfortable yet stylish (poncy twat?) sorroundings.

And so this has started me thinking again about the idea behind On Aire, to provide a personalized guide to *evening entertainments* (tm) in the area of the river Aire (which is about 90% of Leeds depending on how liberal you are).

So hopefully my ever expanding network of half started projetcs will be growing once again with the addition of a social network stylée food/drink bar/resturante recomendation thing.

I'm going to try and get Brain and the Flash guys on board with a nice AIR app (half of the projects name sake, trying to be all web 2.ohhhhhhhhhhhhhhhhhhh or something) that will make suggestions where you might eat or drink that day or evening.

In theory this could be expanded to any and all kind of events and other fandangled features but I think I want to get some feature, no matter how small, online soon so that it might start getting used and so spur me and the (possible) team on to expan the thing.

So hopefully I and some of the other guys at work will start posting over on the On Aire blog and might even get something on the site. I've got some ideas for the design of the site and features of the app so I'm gonna try and pitch them to the lads and see if I can get something rolling.

Watch this (or that) space for more...

Wednesday, 28 May 2008

The internet is a funny thing

When I first started this blog I couldn't help feeling a little self concious about "baring my soul" to the internet and thinking, what is the point? What have I got to say that anyone might be even slightly interested in?

However; In true Field of Dreams "If you build it, they will come!" styleee this blog has gone from getting bugger all hits to now getting "a few" hits from all over the world, and the bounce rate, time on site and pages per visit are on the decline/up/up respectively.

It's interesting to see which articles are getting the most traffic, courrently most popular is my little write up of an easy way to upload and resize in C#. Which is almost nice to see as I did intend on making that one quite big on the search engine front. So that seems to have worked / It's a very popular search topic (which is why I wrote it, Because I was sick of searching for it so I thought I'd use my blog as a kind of extended / shared note book for code snippets).

So the ramblings keep on coming (although I had another drought the last month or so) but I think the next thing I'm going to try and write will be an article on securing ASP.NET applications as we recently had a little incident at work where some rogue links go into one of our site and as a result I got volunteered to write some best practices. Bugger... and on the theme of writing articles I'm going to look at an article on versioning web services too. I know there has been pleanty written about this already but I haven't really read any of it and it's one of the things I want get my head around and writing it up will probably help me drum it in.

So watch this space for more absolute cobblers and other possibly useful things.

Friday, 18 April 2008

Ohhh so close

Christ I'm slack!

About a million years ago I prommissed some old friends a website for their youth theatre group, I said I'd do it for free as they have alway been good to me and so I set about being really really reaaaalllyyyy lethargic about the whole thing! It comes in fits and spurts, that last one being around the beginning of February, which as Is pretty slack.

So I've done it again; I'm spurting into another fit of enthusiasm and I'm going to put it to good use! I spent an hour last night and I was in the office at 7AM this morning getting it ready. I'm going to sent Hillary and Steve a link and isntructions to the first version of the site, Complete with a few basic pages, a news section and a place where they can document the past, pressent and future production of the theatre company.

I'm going to hold their hand through the innitial setup and hopefully watch the traffic pour in!

The photo gallery bit is about 70% done but I'm going to go live without it now as I reckon watching the hits pile (?? trickle) in on google analytics will spur me on some more to get the gallery up and running. The site looks a bit bare without it so it definitely needs to happen, and this time I think it will! i really really reaaallllyyyy do!

Thursday, 10 April 2008

Beta software, Microsoft, Windows and other shit things

A while ago when the first release candidate of Windows XP Servcie pack 3 came out I read a couple of reviews and got sold on the fact that it promised some speed increases over SP2. Now I'm no fool and I knew it wouldn't be anywhere near the equivalent of getting some hardware underneath the thing but I didn't think I'd experience anything near as retarded as I have done.

Shortly after the release candidate was made available I formatted my laptop ready for a clean install. The first thing I installed after my fresh windows was SP 3. Now I know you're about to say "It's your own fault for using pre-release software" and it completely is! I doubt I'll ever use a pre-release of something so fundamental as an operating system ever again.

So what happened? Well, I came into the office Tuesday after being ill on Monday to find I couldn't use remote desktop as "this beta software has expired"...
After a quick chat to James I discovered he had had the same problems and that you needed to install a "technical refresh". This involved uninstalling the previous version, which was installed before any other software on my system.

So I uninstalled it, spent about half an hour trying to get IE back on my system as the uninstall had shagged it up royal and made the decision never to use pre-release software again.

Now I don't blame myself completely for my world of shit. Sure I installed it in the first place but Microsoft made it a bag of shit!!!

Why and how?? Well this is many-fold

1) By making it time limited in some way

This is ridiculous; if someone has gone to the trouble of installing Beta/RC software you can pretty much guess they are going to be tech-savvy enough to know when to upgrade to the full release or get the new / updated release candidate. Don’t all of a sudden make their system unusable!

2) Make uninstallers that work.

Once I’d taken the plunge into uninstalling SP3, and waited hours for it to happen I decided NOT to install the technical refresh and stick with good old SP2. Which you would have imagined would be what I was left with after removing SP3 as it was a SP2 disk I used in the first place. But no, it wasn’t! It was some clagged up hybrid crock of shit which windows update wouldn’t even recognise. I had to download the SP2 installer and run all of that again to get my system back to “working”

2.1) Make installers that work / don’t fuck your computer up

So after all that I was left with IE6 so I installed IE7 and which now refuses to accept cookies, loads of sites complain about security and loads of other shit has gone wrong.

At 1st opportunity I’m installing Mac OS 8.1 and having done with it! Well maybe not but it just baffles me why developers make things so overly complicated. Ok, it’s Beta and you’d prefer people not to run it forever so stick a warning in there. Don’t cripple their system for them and force them to brick their computers. You have a responsibility to the end user as much as to the business objectives, unless one of those objectives it to piss users off!

Tuesday, 1 April 2008

Recruitment consultants are a special breed of idiot

Following up on Matt's article about recruitment consultants I want to rant about them myself!

Ten minutes ago I recieved an email from someone at Senitor offering me an excelent Desktop Support candidate.

Now, having nothing to do with desktop support as all our IT is provided by our parent group I wrote said recruitment consultant a polite but concise email stating that I am a web developer, I am only concirned with web development and that I wish to be removed from any mailing lists for IT Support staff, but that it was fine for them to keep emailing me about Flash or Web Development candidates they might have.

So two mins later I recieve my read-receipt and all is well. THEN, five minutes after that I get a phone call from some other chap at senitor saying he's just recieved word from this other chap (who I just emailed) saying that I'm looking for a freelancer and can he be of any help.

So I spent five minutes explaining what I had previously wrote in my email and then informed him that we are acutally looking for a Permanent Senior Flash Developer and that he could rind Matt about that.

He mumbled that one of collegues deals with permanent developers and said he would get him to ring through. The conversation ended.

Wonder if I'll get any more IT support emails from them, or maybe a freelance chef or a mechanic?

Good work recruitment consultants!

Saturday, 29 March 2008

Drunk please

Nothing sorts a hang over like a full english!

Wednesday, 26 March 2008

Adobe AIR comes to the UK

On April the 9th me and Brian (I wish he would start to update his twitter again) will be attending the Adobe AIR tour in London.

I'm going to try and think up a little AIR app to celebrate this but I'm going to wait untill the top secret project has finished before I get stuck into that.

I'm also going to try and get Brian to help me out with the ideas and production.


Over the Easter weekend Gina and myself went up to Newcastle and spent a few days with her family.

Her mom came up with the crazy idea of making some Easter eggs... and here are the results

Tuesday, 25 March 2008

How many developers does it take to figure out some stats

Matt, Andy and Rich stress over some numbers

Mumblings of a web developer

Thought I'd link up my twitter in here

check it out if you dare

Help wanted

Apply within,

As you may or may not have read, recently I have been revisiting places long forgotten in im persona and filling some boots as a hardcore Flash developer. During this time it has become apparent that we need a Senior Flash Developer!

So it gives me great pleasure to announce that the company I work for, twentysix Leeds are recruiting a new Senior Flash Developer.

The role requires years and years of expert experiance of Adobe Flash, ActionScript 2 and ActionScript 3. Knowlage of Object Oriented techniques and all the other usual stuff is a must! Knowlage of other web technologies are a bonus so don't forget to tell us about them when you email Matt with your application ( ).

If you think you might be interested then why not head over to our portfolio and see what kind of work we do for fantastic clients such as HUGO BOSS Fragrances, Lacoste and Silent Night Beds amongst others.

Saturday, 15 March 2008

Click this shit

Just found this on my phone along with a bunch more crazy photos of last nights ridiculousness. Might get up and get a shower, or i might lay here and feel sorry for my self some more.

Click that shit!

Friday, 14 March 2008

The Razz

we're off out on it! Our 1st birthday. Photo's to follow...

Friday, 7 March 2008

HTTP monitoring on windows

As a web developer watching data being sent over your network connection is often important and sometimes essential for reliably debugging your work (when you're not sure if you clagged togheter code is making spurious requests in the background or not).

Today I'm still building the top secret Flash project which is going well and is now into thousands of lines of code and it's starting to get complicated. Flash 8 on my Dell M70 takes around 30 seconds to build the swf.

Any way, so I needed to watch the HTTP trafic coming out of my SWF to make sure it was doing what it was supposed to do. I considdered running it through a web page and using firebug's net monitor or getting Charles installed but it occured to me that the most reliable source (on windows at least) would be a microsoft tool that I'd seen Matt pratting about with a while ago, Microsoft Network Monitor 3.1.

Once you have downloaded and installed that, simply click "Create a new capture tab" and then in capture filter tab paste the following:

contains (Property.HttpHost, "")

where "" is the host name of the server you wish to watch traffic for then press the start button and you will see all your HTTP (web) traffic from any application to that domain

Friday, 29 February 2008

The western front...

All is quiete around here and has been for a while.

This is mainly due to me having to learn ActionScript (again) to pull a project out of the gutter so I will be spending most of the weekend (and any other *spare* time I might have) living and breathing AS2 classes and wishing I was a lot better versed in the drawing API and the old EventDispatcher. Although I'm not doing bad having not done any serious ActionScript in the last 18 is months.

The project is top secret so I can't say much more but maybe I'll have some lovely little learnings to write about if and when I get the time.

Tuesday, 26 February 2008

Shrinking Log files in SQL Server 2005

So you, like I, have a database in SQL Server 2005 who's log file (.ldf) has grown massive.

Here is a quick but of SQL that should help you shrink the file to reclaim some disk space. be warned, this might impeed your ability to restore the database later if it all goes wibble.

First run the following

USE nameOfTheDatabaseHere
SELECT * FROM sysfiles

Now, take note of the fileid of the log file (usualy 2 for most databases) then do

( fileIDGoesHere, TRUNCATEONLY )

This will truncate the log file to as small as the DB Server will allow.

See for more info

Thursday, 21 February 2008


This is ace.

It's like all that microsoft *seadragon* or what ever it was called

Wednesday, 20 February 2008

Downloading and Deleting Temporary Files

Recently while working on some functionality for one of our clients I found myself in a position where I needed to add some images to a zip file. This zip file then needed to be sent to the end user as a download (Content-disposition: attachment;).

Once the user had downloaded the file, the zip file needed to be deleted so as not to leave temp files on the servers disk.

I tried a few things like calling File.Delete("path/to/") after doing Response.TransferFile() or Response.WriteFile() but I found that the page never loaded. I guess it was deleting the file bfore it had chance to stream the file to the client.

Eventually I came up with the code below which reads the entire file into a BinaryWriter and the write it out to the Response's OutputStream. The stream is then flushed and the file can be deleted.
    string theFile = "path/to/your.file";
FileInfo theFileInfo = new FileInfo(theFile);

if(theFileInfo.Exists) {
// Clear any output
Response.BufferOutput = true;
// should be the MIME-Type of your file
Response.ContentType = "application/x-zip-compressed";
// set the name of the file as it will be downloaded
Response.AddHeader("Content-Disposition", "attachment; filename=the.file");

// Open the OutputStream into a BinaryWriter
BinaryWriter br = new BinaryWriter(Response.OutputStream);
// Read the entire temporary file and write it into the BinaryWriter
// Flush and Close the Writer

// Fulsh the Response object

// Delete the temporary file
// End the execution of the page

While this does get the job done it isn't perfect. The entire file is read into memory before being sent to the client. This means if you are sending large files to many clients at the same time you could have some trouble with the server running out of memory and all manner of other crazy things happening (possibly).

As ever, use at your own risk.

Monday, 18 February 2008

IPod what!

I'm sat on to virgin cross country service from Leeds to Sheffield and there is a girl sat next to me seemingly using an old laptop kitted out with iTunes to do nothing else but listen to music. I on the other hand am listening to music on my IPod, while blogging from my phone. Technology ay?!

Friday, 15 February 2008


More mindless drivel and ramblings now available free over at twentysix Opinions.

Wednesday, 13 February 2008

SQL Noise

Someone's going to be annoyed when they end up here looking for how to add "noise" to an SQL query.. oh well, sorry...

However, it is an appropriate title because after adapting Matt's SQL on FIRE, I truly feel I'm bringing the noise (to SQL [in my own little way])!

Today really is SQL Day 2008 (another dead end search result there! :)

SQL : Multiple Order By's

Just trying to sort a query with an ORDER BY clause where I needed to order by two columns in different directions so I tried it and it works! Didn't know you could do that...
SELECT * FROM tblTableName
WHERE column1='x'
AND column2='y'
ORDER BY column3 ASC, column4 DESC

(tested in MySQL and MS SQL)

Monday, 11 February 2008

Banana Cake v0.011111 alpha beta gama delta something or other LIVE!

Today I put the first version of Banana Cake live on an internal web server and invited my co-developers here at twentysix leeds to become my testers.

We've got a couple of current projects set up on there and I hope the guys will use it to track what they are doing and hopefully provide me with some excellent and useful feedback over the next few weeks.

If they do and and they find it useful day to day then my plan is to roll it out to the entire office ( a whole 25 users !) . With a bit of luck I'll have come up with a real name for it by then and sorted out the dicey interface although gay Dave says he likes the way it looks as it is...

I'm off to look at the bugs list for Banana Cake and get some issues sorted.

Wednesday, 6 February 2008

Blog code formatting tool

While I was writing that last post I went hunting for a code formatting tool for my code inserts and came across Format MY Source Code for Blogging.

It's not quite what I wanted but I'm not about to write a C# syntax highlighter so it'll do for now

Tuesday, 5 February 2008 Image Upload and Resize (in C# .net 2.0, 3.0, 3.5, visual studio 2005, visual studio 2008)

Please excuse the ridiculously long title but I kinda want to make search engines love this post because I keep having to google for it.

What follows is what I have found to be the simplest and most elegant method of uploading, resizing and saving an image in ASP.NET. So let's get to it.

Ok, lets assume we have a FileUpload control (named fuImageFile) and a Button control (btnUpload) and we're going to upload the image when we click our button. The simplest method of uploading our file might look something like this

protected string savePath = "~/uploaded/";

protected void btnUpload_Click (object sender, EventArgs e) {
string fileName = fuImageFile.FileName;
string saveName = Server.MapPath(savePath) + fileName;

So now we can upload an image to our server, what about resizing that image? For this to work you will need to add a using directive for System.Drawing and System.Drawing.Imaging

using System.Drawing;
using System.Drawing.Imaging;

Next we'll look at how we go about resizing an image (in the form of a Bitmap object) and then at how to integrate that into our upload page.

public Bitmap ResizeBitmap (Bitmap src, int newWidth, int newHeight) {
Bitmap result = new Bitmap(newWidth, newHeight);
using ( Graphics g = Graphics.FromImage((System.Drawing.Image)result) ) {
g.DrawImage(src, 0, 0, newWidth, newHeight);
return result;

This method takes a Bitmap object and two numbers specifying the height and width of the required image. We then create a new empty Bitmap at the desired size (result) , we then obtain a Graphics object from it (NB: the Graphics object remains associated with the Bitmap) and draw our source image into it.

When we return the result we have an Bitmap object with the image data we drew into the Graphics object.

So now lets work it into our page

protected void btnUpload_Click (object sender, EventArgs e) {
string fileName = fuImageFile.FileName;

// Get the bitmap data from the uploaded file
Bitmap src = Bitmap.FromStream(fuImageFile.PostedFile.InputStream) as Bitmap;

// Resize the bitmap data
Bitmap result = ResizeBitmap (src, 200, 200);

string saveName = Server.MapPath(savePath) + fileName;
result.Save(saveName, ImageFormat.Jpeg);
What we do here is take the InputStream of the FileUpload's PostedFile property and create a Bitmap with it, once we have this bitmap object we can call it's Save method to save it to the local disk.

Proportional Resizing

The problem with this ResizeBitmap is that it will stretch and pull your input image to fit the dimensions supplied which 99% of the time is not what we will want. We usually want to scale an image keeping its proportions. Take a look at the ProportionallyResizeBitmap method below:

public Bitmap ProportionallyResizeBitmap (Bitmap src, int maxWidth, int maxHeight) {
// original dimensions
int w = src.Width;
int h = src.Height;

// Longest and shortest dimension
int longestDimension = (w>h)?w: h;
int shortestDimension = (w<h)?w: h;

// propotionality
float factor = ((float)longestDimension) / shortestDimension;

// default width is greater than height
double newWidth = maxWidth;
double newHeight = maxWidth/factor;

// if height greater than width recalculate
if ( w < h ) {
newWidth = maxHeight / factor;
newHeight = maxHeight;

// Create new Bitmap at new dimensions
Bitmap result = new Bitmap((int)newWidth, (int)newHeight);
using ( Graphics g = Graphics.FromImage((System.Drawing.Image)result) )
g.DrawImage(src, 0, 0, (int)newWidth, (int)newHeight);
return result;

This method takes a maxWidth and a maxHeight instead of a newWidth and newHeight, it then does a bit of maths to figure out which is the longest, the original height or the original width, works out the ratio of these two numbers and applies them appropriatley to the target size and resizes the image accordingly.

Just like ResizeBitmap, ProportionallyResizeBitmap returns a Bitmap object so you can simply substitute the call to ResizeBitmap in the button click method and it will all play nicely!


If you get a "Generic Error from GDI +" like Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+ then you should check the following points:
  • Make sure the destination folder exists
  • Make sure the the local machine user ISS_WPG has write permissions to the destination folder
  • Make sure the save path is correctly escaped
[more to follow maybe]

See the Microsoft Knowlage Base article for more posibilities

Done it again

So I did it again... I was close to getting inyerface ready for it's next/first launch and then I started faffing with Banana Cake which is getting near a point where I feel I might let the gang on the development team at work be my alpha testers although I've realised there are a few more little features need adding before it is actually useful.

Then, I've decided, for the inyerface image management module, instead of learning ActionScript 3 I'm going to cobble it out in AS1/2 just to get it up and running then maybe one day I'll re-make it in ASWhatever.

Sunday, 27 January 2008


Tax returns are shit, I've decided.

Come tomorrow I shall be promptly de-registering as self employed after having just submitted (well almost) a tax return for gross annual earnings of ZERO pounds and ZERO pence.

What a fucking waste of time and all for the luxury of potentially being fined or dragged through court if I, in my flagrant disregard for the laws of this lovely land, have inadvertently made a bollocks of of the frickin thing.

Ohh well, I can only sit here and cross my fingers and hope that I'm not one of the unlucky percentage that actually get their forms checked over and that I will *get away with it*.

Christ, It's hard work being a honest citizen!

Pissing governments...

Friday, 25 January 2008

My Transatlantic Lover

So I've been blogging now for all of 3 weeks and I completely wasn't expecting anybody to read this diatribe at all. I didn't even think my work mates would find it mildly amusing...

HOWEVER; wading through the four visitors I've had, google analytics has revealed that I've had a visitor from Reston in Virginia.

Who are you mystery person? and did you find my blog interesting

Good Morning

So last night was Heidi's leaving do! good luck (riddance?) Heidi in Japan. Enjoy it as much as I'm enjoying my hangover. It's ace.

Here's to binge drinking

Thursday, 24 January 2008

Mail Me Do!

So today, on of our servers wouldn't send emails from a registration form which lead to a few of us scratching our heads (non of us are linux nerds [appart from jim - a bit]).

After a bit of digging we remembered that the server relays it's mail through one of the windows workstations. Matt checked the mail root on this box to find that it was crammed full. The drop box had 11,000 unsent mails from the last two days. The bad mail folder wouldn't open.

So Matt started set about deleting the items from a command prompt... It's now been running for over two hours and no sign of easing up. We're guessing at a couple of million emails in there.

Maybe it'll be done by tomorrow morning

Tuesday, 22 January 2008

Still no internet

The internet at work is still Jaffed so for the last two days I've been using my K800i as a modem via the wonderful T-Mobile Web 'n' Walk plus which connects at a staggering 115Kbps (about 40KB/s download if i'm lucky) which beats the pants off our poxy broadband here at work(connects at 8Mbps and downloads at about 2KB/s. But hopefully that should all be changing next week when we get a second line installed.

So for now, I'm not doing much online (this blog is turning into a blog about not being able to style up this blog!) but I have got a couple of other things on the go.

inyerface theatre company
This website is a favour for some friends and I'm going to meet them soon to get phase 1 (news and performances sections) live while I work on phase 2 which will bring images to the site in the form of photo galleries.

Banana Cake...
... is the working name for a simple bug tracking app that I'm in the process of building.
This came about after my moan the other day that I was bored with work/the internet and so I decided to get off my arse and do something about it.

Banana Cake is about 15% done (in about 4hrs spread over 2 and a half evenings) so I'm hopeful I'll actually produce something before I lose steam (like I usually do). Once I've got it to a reasonable state I'm going to unleash it on my work colleagues where it will hopefully fill a gap in our infrastructure (have you ever tried setting up bugzilla, nightmare) and get some useful feedback for it.

I might even buy a domain for it and try and make something of it! But before any of that happens I've got my tax return to do before the end of the month... bloody inland revenue!

Thursday, 17 January 2008

Firefox PHP Function search plugin

15/07/2008 : Updated the link to the plugin as we have moved offices. I might try and get a wordpress blog set up instead of this thing.

A while ago I was bored in the office so I decided to have a faff about for twenty minutes making something that might be useful to the folks I work with.

Most of the development work we do here at twentysix Leeds is done in .NET but most of us (everyone apart from the TD) are from a PHP background and while at one point it was my language of preference, the amount of .NET I have learnt recently has forced most of the PHP knowledge out the other ear! and this seems to be the situation for the other lads too. So I thought I'd do something about it and create a search plug-in for Firefox and IE7 that allowed us to search the on-line PHP docs directly from your browser.

So after having read a few articles I wrote the plug-in that is now available from this page, just click the search provider in Firefox (next to the search field) and then click ‘Add “PHP Function Search: By Greg Brant” ' and there you go.

I would apologies to IE users but I'm not going to because it's not my fault that it wont work for you guys. My original intention was that the plug-in would work for Firefox and IE after having read that they both support the OpenSearch format for search providers (Firefox also supports MozSearch plugins too). However; the PHP search only works with GET method forms and IE only supports search providers the use POST.

OK. so, this software (if you can in fact call a search provider software) is provided free of charge with no warranty of any kind what-so-ever! install it at your own risk. All copyrights remain with the owner and all the rest of it.

Tuesday, 15 January 2008

Damn Internet

So after my post last week about redesigning this blog the internet at work has been bloody slow so all I have managed to do is hack the template and change the background colour.

But I like it. One day I'll follow up what I say...

Wednesday, 9 January 2008

back to work

I'm back in work today after a long weekend (Friday to Tuesday) in the lakes with Gina and I'm feeling a little bit uninspired.

We had a team meating before lunch where a few of the guys recounted some notes on industry events they have attended recently and it made me realise that not so long ago I was interested and messed around with far mor than I do at the moment. Right now I just seem to be building .NET shopping cart after .NET shopping cart and I'm a bit bored with it so I've decided to start getting back into things, exploring bits and pieces around the web and making bits and pieces that are fun.

I think I'm going to start by (re-)designing this blog with a nice stylesheet and naybe a JPEG or two.

Lets see how it goes from there...