Dreams in Code Snippet
A quick overview of my development of the code snippet used in the blog byline.
Looking for a simple graphic to add to the site byline I elected to use some C-type code, being my most familiar dialect, and being a Mac user, the Monaco typeface in an appropriately anti-aliased size.
Now I’d set out some basic requirements, the question remained, what should it do? With the line “dreams in code” it certainly had to epitomise sleep and naturally I wanted to show some Zs. Thus the concept was born: sleep makes more Z! Latching onto the universally recognised ++ notation for incrementing a variable my first iteration looked like so:
int sleep(int z) {
return z++;
}
The first thing you might notice is that my use of braces is different. The above snippet being my preferred style of layout. The reason for the change? I had limited myself to a fixed sized graphic and the alternative code-block style allowed me to use a slightly larger font size. Lets clean that up so it’ll fit better in my Photoshop template:
int sleep(int z)
{
return z++;
}
However, that keen eyed among you are more likely to point out that my function, though perfectly legal in C, C++, Java, Objective-C and probably a number of other languages, does not in fact do as it appears. As ++ is a post-increment the increase in z would happen after the function or method returns — therefore the value of z is returned before it is changed.
Now, I debated whether to keep this as it, after all you might say that when sleeping the goal is to do nothing; however, my goal had been to increase the number of z, so the solution? Pre-increment.
int sleep(int z)
{
return ++z;
}
While this notation is not nearly as commonly seen in code, it does allow the function to return an increased value for z without using another line or a hard coded value. It was a shame to drop the original concept of z++, and you might consider the whole thing rather over-engineered, but as this tiny code-snippet sits proud atop every page on a blog about development I certainly believe this was an excellent occasion to favour a correct solution over a visually appealing one.
To WordPress… and Beyond!
Blogging on-and-off again for more years than you should know my blog has been relocated; from Blogger to WordPress… and beyond.
I’ve been blogging on-and-off again for more years than I can count. My latest ‘official’ blog, and by latest I mean 2008, was on Blogger. I’ve been looking to skin up my blog for some time, preserving my ‘brand’, but it just never happened. It’s not that it can’t be done over on blogger, but I do like to tinker so the edit/refresh/observer-bug/find-your-position-in-file cycle in the browser just wasn’t conducive to the way I work, so I grabbed a standard template and that was it.
Looking for a ‘professional’ blogging platform I took a look at Moveable Type but I’d actually done a fair bit of work with WordPress before as it’s the engine used for my brother’s art blog over at jacquesy.co.uk, that coupled with my ‘leet PHP skillz and it was settled. I’d also seen a theme that with a few tweaks would integrate well with the existing styling used on my portfolio called Dropshadow. Unfortunately, the download link is a dud, fortunately the good folks at Archive.org have everything in stock.
Now, I was debating whether to copy the four published posts on Blogger over, by hand, when I find that you can import into WordPress right from Blogger. I must admit I was pretty damn impressed by the functionality. Old comments, posts, images and even drafts have been pulled over, no effort. Just had to choose to, automatically, convert all categories to tags to finish off the import. I popped right over to Blogger and added some quick-n-dirty re-direct code to forward any lost souls to the new URL, like so:
<meta HTTP-EQUIV='REFRESH' content='0; url=http://blog.homedsl.co.uk/'/> <script type='text/javascript'> <!-- window.location = "http://blog.homedsl.co.uk/"; //--> </script>
Four hours of copy-n-pasting CSS from my portfolio’s stylesheet and a few image-tweaks in Photoshop and everything is looking pretty good. I hop along and grab a few plugins: Page Links To, to allow me to easily integrate links into the tab/page bar at the top of the page; StatPress, to keep an eye on you all and Visual Code Editor, to clean up the rendering of <code> and <pre> blocks, before going on to syntax highlight them. For this I’m using Google Code Prettify in combination to some pre-processing on the relevant tags (to set the class) as modifications to the Visual Code Editor plugin.
So, I’m pretty much ‘done’, though I’m sure they’ll be a few more tweaks required – there was, just to publish this post – but, I’m ready to have yet another bash at this blogging m’larkey.