Chris Roberts

Blog

Welcome to my blog.

About

Posts about Programming

Mercurial: skipping unreadable ignore file

On a particularly busy day recently (these things never happen on a quiet day), the project I was working on stopped building on my local machine.

Our build server, and my colleagues, were all able to build the repository - it was just me. It didn't take long to track the problem down to a step in the build process which extracts revision information from Mercurial. This was failing with the following error message:

Drawing Triangles with HTML and CSS

One of the great things about working with a team of creative designers and developers is that I get exposed to more new techniques and tools than I'd ever have time to find for myself.

One example of this is a something that Joe Sergeant showed me the other day - a technique to draw triangles using nothing more than HTML and CSS. "But how", I hear you say, "do you draw a triangle with a box model?!".

Base32 Encoding and Decoding in VB.NET

Like the more common Base64 encoding, Base32 encoding is a method for turning binary data into a string composed of a small, defined set of ASCII characters. Base64 takes advantage of the entire alphabet in both upper and lower case, the digits 0 to 9 and the '+' and '/' symbols. This can be problematic where, for example, the encoded data needs to be used as part of a URL where the '+' and '/' symbols have special meaning and where case-sensitivity can cause problems.

Base32 addresses these issues by using a further reduced set of characters - the entire alphabet (but only one case) and the digits 2 to 7. The digits '0' and '1' are ommitted due to their similarity to the letters 'O' and 'I'. This makes Base32 even more useful in situations where human readability is a concern.

PNG Colour Rendering on the Web

When is a colour not a colour? When it's in a PNG image file and you want to display it in a web browser!

I have recently been working on a website which includes a number of PNG images which are generated at run-time by a piece of VB.NET code. During testing we noticed a number of discrepancies between the colours being rendered in the image and the colours specified in the site's CSS file.

Automatically Adding SVN Revision Numbers to Assemblies

Source code version control is one thing that no developer should ever live without. If you're working on some code that isn't in a version control system, stop what you're doing now and get yourself one!

There's no excuse - there are plenty of free ones available that are simple to install and use. My personal favourite is Subversion (SVN). The particular flavour I use is VisualSVN which has a simple server configuration system and a convenient Visual Studio plugin. If you're really new to version control, you could do a lot worse than to read the SVN book, too.

Visual Studio with Roaming Profiles

I have been having a problem with Visual Studio constantly reconfiguring itself on startup. Quite often, when launching the environment, I get this message...

"Microsoft Visual Studio is configuring the environment for first time use. This might take a few minutes."

ASP.NET MVC. Like ASP.NET, but without the Voodoo!

Much has been written about Microsoft's new Model-View-Controller (MVC) framework for ASP.NET. The initial reaction of many developers - me included - is that Microsoft are driving us back to the bad old days of 'tag soup'; Server side code sits nestled amongst the HTML just like the traditional ASP pages we were all so glad to move away from.

When you delve a little deeper though, and learn more about the MVC pattern it really starts to make sense. Most of the code you'll write will be in the Controller classes, completely separate from your HTML. Yes, there is a little server side code in the HTML (the View), but if done properly this can really be kept to a minimum.

Automatically switching to SSL in ASP.NET

At first, it seems like quite a simple requirement - to automatically transfer a visitor to an SSL connection when they visit a certain area of our site (everything in the 'secure' folder in our case), and to transfer them back to a plain old HTTP connection when they leave.

Our initial implementation of this was a simple HTTP Module. This intercepted incoming HTTP requests for the '/secure/' folder and redirected the user to an HTTPS version of the same page. Conversely, if an HTTPS request comes in for a page which isn't in the '/secure/' folder, a redirect is issued to the HTTP version.

Avoiding JavaScript and CSS Stylesheet Caching Problems in ASP.NET

We frequently run into problems related to caching when building ASP.NET websites. In particular, changes to CSS Stylesheets and JavaScript files on which the sites rely. After a new release our clients often have problems until they manually clear their browser cache. Some of our clients sit behind a proxy server which has its own cache, making the situation even worse.

The problem also extends to our development environment. As more of our UI work is moved into the browser through JavaScript and AJAX, we more frequently run into caching problems ourselves.

Saving processor time AndAlso writing tidier code, OrElse!

Every once in a while, you stumble across something new and you wonder how you ever survived before you found it. This happened to me most recently when I came across the AndAlso and OrElse operators in VB.NET.

The official description of the AndAlso operator from Microsoft is that it "Performs short-circuiting logical conjunction on two expressions".