Archived Design Non Technical Opinion Uncategorized Wordpress

Pay it forward …

For a few years now I’ve been dabbling in a bit of 3D design here and there. Purely as a hobby though and I’d never even dream of calling myself any good at it.

Anyway, I used to learn from a bunch of talented dudes over, a site that unfortunately no longer exists (internal problems? I don’t know.) One of the members there was a Romanian guy by the name of Flavius, a very talented 3D designer with a pretty scary level of skill for someone his age, around 20 as I write this I think … no he’s not a Romanian scammer!

He’s in the unfortunate position where web hosting and all the bits that go with it are pretty hard to come by so I decided to do as the title of this post says – pay it forward. To do this I offered to pay for web hosting and domain registration for a website to be created, a site where Flavius could showcase his work, demonstrate his skills and get the word out there so that people know there are talented designers everywhere.

The site’s now live and, while it’s yet to have much content (it’s been live around an hour now but will undergoing plenty of changes over the next little while), is coming along nicely with a decent gallery to get started, backed up by a beautiful WordPress theme by Nick Roach over at Elegant Themes. Go there if you want themes – it’s the site I choose to use for all my WordPress themes.

Flavius’ new site can be found at and will have more content added as time goes on. Please feel free to let me know if you find any problems there as I’ll be doing the back-end maintenance of the site even though Flavius will be maintaining the actual content.

Cool. 🙂

Archived Uncategorized Wordpress

WordPress ‘How To’ Guide

So, as I usually ask near the start of my posts, what’s this post about? I’ve setup a whole bunch of WordPress blogs in my time. Some have been for personal use, some for friends that need help getting started, some I’ve helped friends with and some have leaned more towards being commercial in nature. All of them, though, have followed a pretty similar process when it comes to the installation and configuration steps required for WordPress best-practice (in my opinion anyway). This article is going to cover the process I follow when I’m setting a self-hosted WordPress blog. These steps do not apply to blogs hosted on

Please feel free to contact me through my contact page if you need clarification on or want to discuss any of the information in this post.

I apologise in advance for the length of this post … I tend to go into a lot of detail when writing posts like this. I hope it all helps someone though. 🙂

Assumptions & requirements

To begin with, you’ll need a few things before you even get started. Here’s a brief, but not exhaustive, list of things you’ll need.

  • A domain name. The domain registrar you choose is up to you – it would be irresponsible of me to say that any particular registrar is better than any other.
  • A web hosting account. I use ICDSoft – this is one situation where I’m happy to say they’re better than any other Linux host I’ve ever used.
  • A copy of the latest version of WordPress. As of today, September 1st 2010, this is version 3.0.1 and can be downloaded from
  • A theme. WordPress has possibly the best theme support around so this is quite important. Personally I use theme from Elegant Themes. Pick one, download/purchase it and have the files ready for later steps.
  • FTP credentials. You’ll need to know the DNS address or IP address of the FTP site that supports the final, published URL, as well as the username and password to login there. I use the free FTP client, FileZilla – it’s free and works on OS X (Mac), Linux and Windows.
  • MySQL credentials. You’ll need to know the connection address or IP address of the MySQL server that will support your WordPress installation, as well as the username and password used to connect.
  • An empty database ready for your WordPress installation. You don’t need to put anything in it – the WordPress installation scripts will do that for you.
Archived Software Uncategorized

Microsoft Excel – Delete matching rows

The problem

As part of my new role at Fujitsu here in Wellington I’ve been running a whole load of reports from the SAN I’ve been assigned to. I’m not going to go into any detail about the SAN itself other than to say it’s from HP (for obvious reasons) but the reports I get from the reporting tools aren’t that useful in themselves. Many tens of thousands of lines of reporting data is hard to read as it is and unfortunately these particular reports aren’t uniformly arranged i.e. there is a header at the top of the file, a set of performance data, a blank line and then another set of headers followed by more performance data. This pattern repeats for the entire file.

Microsoft Excel is ok at importing data from CSV files but can’t handle these files too well as there’s no uniform pattern that it seems to be able to match (it matches to the human eye but I guess not to Excel’s internal algorithms or something).

The solution

Anyway, to import these files into Excel I needed to do 2 things which seem pretty simple but that you really don’t want to do when the files are as big as these ones – 40MB+ of text. Yuck. Please note that the first step below works in both Excel for Windows and Excel for Mac but the second part, because it contains VBA script does not work in Excel for Mac (VBA isn’t supported in Excel 2008 for Mac). See the criticism section of this Wikipedia page for information on that.

Job 1: Delete all the empty rows. Thankfully this one’s easy. Select the entire worksheet or range of cells you’re working with, hit F5, select Special, check the box labelled Blanks and hit OK. This will select all the blank cells in the selection. From here select Edit, Delete and when prompted, select Entire Row. Alt-E then D will work in Excel 2007 as it doesn’t have an Edit menu as such. This will do exactly what it says and delete the entire row containing the selected blank cells. Be careful doing this with non-tabular data.

Job 2: Delete all the headers except the top row. Unfortunately I haven’t made this work without deleting the top row too but if you copy the top headers to a new sheet first you can easily paste them back later. In Excel 2007 hit the Developer tab (it can be enabled in Excel options if it’s not showing), click Visual Basic and add a new Module by right-clicking the top pane on the left. Paste the following code into the module that gets created:

The script

Sub DeleteRows()
    Dim Rg As Range
    On Error Resume Next
    For i = ActiveSheet.UsedRange.Rows.Count To 1 Step -1
        Set Rg = Nothing
        Set Rg = Rows(i).Find("Time")
        If Not Rg Is Nothing Then Rows(i).Delete
End Sub

Change “Time” to a text pattern that will match the rows you want to delete. In the data I’m working on all the header rows have a “Time” column so this works for me.

From here it’s just a case of hitting the Run button and all the rows containing the word “Time” will be removed. Please note that in Excel 2007 you’ll need to save the file as an Excel Macro-Enabled Workbook once a file contains macros or VBA code.

Handy and much faster than deleting them manually.

Archived Photography Uncategorized

HDR photography intro for beginners

It’s been a while since I put anything on this site that isn’t of a technical nature so I thought I’d throw something photography-related up here.  Today’s non-technical article is about HDR photography, i.e. the practice of combining multiple exposures to create a single high dynamic range or HDR image.  Here’s what I came up with.

Before I start, I’ll just say that this is just playing about with HDR – an actual attempt would probably produce much better results.  🙂

To make the images in this post I used a tripod-mounted Nikon D300 digital SLR camera w/ remote shutter release.  Although you *can* take the exposures necessary for HDR by hand-holding your camera it’s not recommended because all exposures must be of the same scene if you want to get the best results.  A digital SLR camera or compact with the ability to control both shutter speed and aperture is required.  The aperture must be set the same for all exposures to prevent parts of scene becoming ‘blurred’ due to depth-of-field changes.  The ability to control shutter speed is necessary as HDR photography requires you to bracket your exposures, usually by +/- 2 stops.  In case you don’t want to read the Wikipedia article linked to just there, bracketing is taking a ‘master’ exposure and (usually) adjusting the shutter speed up and down a certain number of stops so that you have a set of shots of the same scene but with a range of varying shutter speeds.

A typical bracketing sequence with the shutter speed being adjusted by 1 stop each time might be like this (note that the aperture doesn’t change).  The ordering of these shots is irrelevant – it’s the order my camera is set to though.

  • 1/125 f/4.5 – the ‘master’ image, correctly exposed.
  • 1/60 f/4.5 (-1 full stop)
  • 1/80 f/4.5 (-2/3 stop)
  • 1/100 f/4.5 (-1/3 stop)
  • 1/160 f/4.5 (+1/3 stop)
  • 1/200 f/4.5 (+2/3 stop)
  • 1/250 f/4.5 (+1 stop)

With those shots taken it was a case of loading them into Photomatix Pro, a trial version of which can be downloaded from HDRsoft.  The tone-mapping preferences are very much user- and image-specific so I won’t list them here.  The HDRsoft team has made a couple of good tutorials available to get you started if you’ve never used Photomatix Pro before.

Here is one of the exposures in my set without any post-processing being done.  I shoot RAW and obviously this shot could be cleaned up and improved a lot by using ACR, Lightroom or whatever your RAW-processing software of choice happens to be.  Personally I use Adobe Photoshop Lightroom.

Photo without any RAW processing done

And here is the same scene but as an HDR composite made up of 7 bracketed frames.  The colour of the water and the detail in the clouds are pretty crazy I reckon …

The same photo with HDR processing applied

I’ve got the same 2 images combined into a single image so they can be seen side-by-side too – check it out.

it’s available on Flickr for those interested in seeing it.

Obviously scene choice plays a big part in how well an HDR image comes out (the one above is just to demonstrate results, not photography) but it’s still good fun.  🙂

Archived Development Uncategorized

Making the W3C Validator work with ASP.NET

For as long as I can remember I’ve been making sure that the sites I play about with (published or not) produce markup that conforms with w3c specifications. The best-known way to do this is to run the markup generated by the web server through The W3C Markup Validation Service. Unfortunately it’s been difficult to make ASP.NET applications produce 100% valid markup, something that always frustrated me. There may have been ways to make this work before that I’m not aware of but here’s now to do it anyway.

It’s worth noting that the DOCTYPE declarations used throughout this article aren’t valid for HTML5.

I always write my sites to conform to XHTML 1.0 Strict specifications, despite currently making them HTML5-compliant wherever possible. If you’re unsure what this means I would recommend heading over the W3C website about XHTML 1.0. The Strict DOCTYPE is actually the way HTML and XHTML were designed to be used so I’d recommend using them over the older/legacy Transitional DOCTYPE. Depending on where you look or what you read, the transitional DOCTYPE is intended for sites making the transition towards standards-compliant markup. To me that sounds like pretty good reason to stick to the strict DOCTYPE.

Anyway, when you’re making your ASP.NET applications it’s possible to make Visual Studio generate applications that conform to the W3C recommendations and therefore work with the W3C Markup Validation Service. There are 2 things you need to do for this to work properly. Note that this isn’t specific to ‘standard’ ASP.NET applications – it will work with ASP.NET MVC applications, too.

Required steps

Step 1 isn’t strictly (no pun intended) required but it’s good practice. Edit Web.config and use the xhtmlConformance element to configure XHTML 1.0–conforming control rendering. Here’s what is in my Web.config files – this must be placed inside the section.

Web.config contents:

     <xhtmlConformance mode="Strict"/>
     <!-- the rest of the <system.web> section has been removed for the purposes of this article -->
  <!-- the rest of the <configuration> section has been removed for the purposes of this article -->

Microsoft’s MSDN page about the xhtmlConformance element can be found by going to

Archived Development Uncategorized

C# Full-screen application – Complete Source

Yesterday I posted a quick update to an article I wrote back in 2007 entitled “How to make a full-screen Windows app using VB.NET”. Aside from 1 or 2 people saying “Oh man why don’t you be a man and write it using C#?” I reckon it’s a good idea to do that anyway. Thanks Scott for the suggestion. 😉 And thanks Phil for pointing me in the right direction with the DLL import stuff. 🙂

So, without any mucking about here’s the exact same complete application example only this time in C#.

Please feel to ask any questions necessary. Thanks!

Form1’s complete source:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace Play
    public partial class Form1 : Form

        public Form1()

        [DllImport (&quot;user32.dll&quot;)]
        private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndIntertAfter, int X, int Y, int cx, int cy, int uFlags);
        private static extern int GetSystemMetrics(int Which);

        private const int SM_CXSCREEN = 0;
        private const int SM_CYSCREEN = 1;
        private IntPtr HWND_TOP = IntPtr.Zero;
        private const int SWP_SHOWWINDOW = 64;

        public int ScreenX
                return GetSystemMetrics(SM_CXSCREEN);

        public int ScreenY
                return GetSystemMetrics(SM_CYSCREEN);

        private void FullScreen()
            this.WindowState = FormWindowState.Maximized;
            this.FormBorderStyle = FormBorderStyle.None;
            this.TopMost = true;
            SetWindowPos(this.Handle, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW);

        private void Restore()
            this.WindowState = FormWindowState.Normal;
            this.FormBorderStyle = FormBorderStyle.SizableToolWindow;
            this.TopMost = false;

        private void button1_Click(object sender, EventArgs e)

        private void cmdRestore_Click(object sender, EventArgs e)

        private void cmdExit_Click(object sender, EventArgs e)
Archived Development Uncategorized

How to use SQL Server CE with C# 3.5

I’m writing this article because a small project I’ve been working on required me to look for information on using SQL Server CE with C# 3.5. I couldn’t find very many useful articles on the topic so I’ve decided to write my own and summarise some of the useful bits I found.

For starters, why use SQL Server CE? I think it’s an easy way of implementing a high supported and functional database solution for various types of applications although this article will focus on using SQL Server CE in a small Windows forms application. To begin with you’ll need to download SQL Server CE from the Microsoft website.

In the past I think I’ve gone a bit overboard with the length of my posts so I’m going to attempt to keep this one short. The application I used this code in is pretty well split up and uses a number of different layers but you don’t need to go this far to use SQL CE with your applications. The code below is a summary only and covers the key things I think you need to know – feel free to ask any questions you need to.

I’m also aware that the code below *will* need modification before you can just throw it into your own applications but, as mentioned above, please post questions on this post if there is anything you need clarification on.

Creating the database

Connecting to SQL Server CE:

string connStr = String.Format("Data Source = C:tempdatabase.sdf");
using (SqlCeEngine engine = new SqlCeEngine(connStr))

SQL query with no result

Running a SQL command that doesn’t return a result set (note that this is, in some cases, where you would execute SQL to create the database structure after using the code above to create the database file itself).

using (SqlCeConnection conn = new SqlCeConnection(connStr))
  using (SqlCeCommand cmd = new SqlCeCommand())
     cmd.Connection = conn;

     cmd.CommandText = "SELECT * FROM table_name";

Getting a record from the database

using (var conn = new SqlCeConnection(connStr))

  string query = "SELECT * FROM Applications WHERE id = @Id";

  using (var cmd = new SqlCeCommand(query, conn))
     // appId is a variable passed to the method that uses this code sample
     cmd.Parameters.AddWithValue("@Id", appId);
     var reader = cmd.ExecuteResultSet(ResultSetOptions.Scrollable | ResultSetOptions.Updatable);
     if (reader.HasRows)
        while (reader.Read())
           int Id = Convert.ToInt32(reader["Id"]);
           // more code here to deal with other columns in the record that was selected from the database, if any

That’s about as basic as it gets but I’m also in the process of writing another article about a basic application that uses this code in a “real-world” situation.

Archived Databases Uncategorized

How to backup SQL Server 2005 Express

A lot of my articles make use of or mention SQL Server Express, the light and cut-down and FREE version of Microsoft’s flagship database product Microsoft SQL Server.

One of the features of the full and very expensive version of SQL Server 2005 is the ability to run scheduled backups using SQL Maintenance Plans. SQL Server requires SSIS (SQL Server Integration Services) for these to be available – unfortunately SQL Server Express doesn’t include SSIS. There is a way to get scheduled backups for SQL Server Express though.

Before you begin you’ll need to install SQL Server Management Studio Express.

Part 1 – Create a backup script

  • Open SQL Server Management Studio Express and login as a user with sufficient permission to access the database(s) you want to backup. You can do this as ‘sa’ if you want.
  • Expand the name of your server or instance, expand Databases and select the database you want to backup.
  • Right-click the database name, select Tasks and then select Back Up.
  • Set the options you require for the backup. For example you might want to change the location where the backup files get created, edit backup set retention period etc.
  • Once you’ve set the options necessary click the Script drop-down option at the top of the backup window and select either ‘Script Action to File’, or, if you want to see/edit the contents of the script before saving it, select ‘Script Action to New Query Window’. I find it’s best to script the backup to a new query window because you can test it before saving.
  • Save the created script when you’re finished editing or enter an appropriate filename immediately if you selected ‘Script Action to File’.
  • If you saved the script, open it up – we’re going to test it before making it ‘live’.
  • Once you have the script open click the checkmark/tick button just to make absolutely sure the script is valid (it’s SQL Server-generated so it’d better be!).
  • Click the ‘Execute’ button if you want to run a test. If you are backing up a very large database this can take a while and you won’t get a whole lot of feedback while the backup is being run. When the backup finishes the results will be displayed in the Results pane, successful or not. If it fails, figure out why (e.g. check for sufficient disk space, permissions for the folder you’re backing up to etc).
Archived Databases Development Software Uncategorized

SQL Server 2008 Express Unattended Install

» If you’re looking for instructions on how to do an unattended install of SQL Server 2008 Express R2, please use the search function on this site – the other article is easy to find, I promise.

On the previous version of Digital Formula I wrote an article called "How to perform an unattended installation of SQL Server 2005 Express". With the release of SQL Server 2008 it’s time to write another one about how to do the same but for SQL Server 2008 Express. So, let’s get started …

Unattended installations of SQL Server can be as involved as you want – pretty much every option can be specified in the configuration file. For this example I’m going to perform a relatively basic installation with minimal customisation so you can see the process at work. The installation will specify most of what I think are the critical options you’ll be interested in. Note that for this example I’m using the x86 (32-bit) version with advanced services.


Required Files

  • Run the executable you downloaded with the /x parameter (e.g. C:InstallSQL2008SQLEXPRADV_x86_ENU.exe
  • Choose a location to extract the installation files to.
  • Create a new text file that will become the unattended installation configuration file. Leave it empty for now.

Configuration Files

So, you can now create your own configuration file using Microsoft’s documentation or you can use the version I’ve included in this article.

Be careful with the Microsoft documentation as there is an error on the page called How to: Install SQL Server 2008 from the Command Prompt. It mentions a parameter called /BROWSERSVRACCOUNT but this should be /BROWSERSVCACCOUNT. If you get this wrong the installation WILL fail.

You can download the configuration file I’ve made below. The changes I’ve made are as follows (you may need to change these to match your settings).

  • Set the QUIETSIMPLE parameter to “True”.
  • Set the MEDIASOURCE parameter to the appropriate installation path.
  • Added a parameter called SAPWD and set it to the strong ‘sa’ password.
  • Set the INDICATEPROGRESS parameter to “True”.
  • Set the SQLSYSADMINACCOUNTS value to “MYPCAdministrator”.

Once you have your answer file all nicely setup and ready to use you’ll need to tell the setup program how to use it.

Run the script

From a command prompt (or Start > Run if you’re into that) run the following command. Remember to change the file and path names to the ones that match your system.

Run the install:

C:InstallSQL2008setup.exe /CONFIGURATIONFILE=C:Installsql-2008-express.ini

If you’ve done everything right this will start the installation process and you’ll end up with a SQL Server 2008 instance called SQLExpress running on your system. Easy!

Archived Databases Software Uncategorized

sqlcmd.exe on SQL 2008 fails – HResult 0x2, Level 16

I’ve built one of my test servers with SQL Server Express 2008 w/ Advanced Services. On a whole load of our servers I use SQL Express for local installations and SQLCMD.EXE works well as a good way to run scheduled backups. It’s done this way because SQL Express doesn’t support SSIS (SQL Server Integration Services), the component required for scheduled tasks. With SQL 2008, however, SQLCMD.EXE didn’t work for me when I tried to setup scheduled backups. Here’s how I fixed it …

The instance in question has the default name of SQLEXPRESS. Obviously this means that to connect to the server you need to use SERVERSQLEXPRESS – that works fine from Management Studio and from the Java application installed on this particular server.

When using SQLCMD.EXE from the command line the full error message looks like this:

HResult 0x2, Level 16, State 1
Named Pipes Provider: Could not open a connection to SQL Server [2].
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or instance-specific error has occurred while establishing
a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured
to allow remote connections. For more information see SQL Server Books Online.
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.

Some Googling suggested that this problem could be caused by one of 2 things. Firstly, that the SQL Browser service isn’t running – on my server it was running. Secondly, named pipes aren’t enabled in the SQL Server Configuration Manager … on mine they are. Hmmm.

I’ve had problems in the past with named instances of SQL Server so I had a look at the properties of the named pipes configuration and, sure enough, it said \.pipeMSSQL$SQLEXPRESSsqlquery. That *looks* ok, right? Yes but it’s the cause of the problem.

I changed the named pipe to the following.


Voila! SQLCMD.EXE now works from the command line meaning my scheduled backups now work too. Not being a full-time DBA I’d put this down to a bit of a fluke on my part although I then found an article by Jesse Johnston that confirmed the same steps worked in their situation too.

Problem solved!