Mike's Musings

Do you want code with that mongoose?

0

Ch-ch-changes

It appears that it is a time of change for me at the moment so I thought I’d take a moment and let you all know what’s going on. The first and perhaps the most obvious is the theme for the site has been updated, after close to two years I felt the old design needed a bit of a refresh. The new site is using a lot of HTML 5 and is all semantically marked up with sections, articles and such, I’ve got to say HTML 5 is makes a lot of sense for a site like mine allowing a lot more meaning to generated from the code itself. I’ve also increased my ‘social presence’ in the sidebar adding in links to my github, Google+ and Stackoverflow profiles.

Now I’ve mentioned github I think that it’s worth noting that from now on I’m primarily going to be using that for hosting my source control, I’m by no means an expert with git but I’m learning and enjoying using it so far. The only legacy codebase of mine that I’ve migrated to github currently is gIDE which can be found here. Thinking about projects going forward I have two projects which I haven’t mentioned on this blog, I’ll briefly mention them here and later provide a more indepth post about each of them.

CRAPI – One of the projects I have worked on in the past was a REST API for Coldfusion, during which I found CF to be a bit lacking in what I wanted it to do. So to remedy this I have started CRAPI which stands for a Coldfusion REST API. This framework is inspired by the various MVC frameworks that I have toyed with (though it supplies no ORM functionality) and I like to think that it is reasonably easy to use. The name is only a placeholder at the moment and I will most likely be changing it to CFRest before I make a post about it.

MarkPDF – I like markdown, I think it is fantastic for a quickly written document to get some formatting. Recently I have been playing around with taking a document formatted with markdown and transforming it into a PDF, MarkPDF is my progress so far it’s a small commandline app written in C#. I’m working on adding more functionality to it at the moment (mostly around metadata) before I make ‘proper’ post about it.

Finally I’m going to end this post on a bit of a downer. February the 10th marked my last day working for LayerX, unfortunately I was made redundant. I started at LayerX on the 6th of July in 2009 and I enjoyed my time with the company, I’m looking forward to what the future has instore for me and I’ll update this blog when I find as things progress.

0

Generic Makefile

Earlier today I decided to start working on yet another side project, this time written in C++. Before I get into the meat of this post I thought I’d mention that I reinstalled my dev environment for C++, I use the MinGW port of the GCC for my compilier and would like to mention that the work they have done on their package manager mingw-get is really awesome it allowed me to get MinGW and MSYS up and running in no time with very little effort.

Once my dev environment was all setup again I went to set up my project only to find that somewhere along the way I had lost my generic all purpose Makefile, so after taking a little bit of time out to re-teach myself how to write a Makefile – from the best source that I know of – I recreated a makefile very similar to my original generic makefile. In an effort to not lose it again I thought I would share it with the world:

APPNAME = test
SRCDIR = src
OBJDIR = obj
BINDIR = bin

SRC = $(shell find $(SRCDIR) | grep .cc)
OBJ = $(patsubst $(SRCDIR)/%.cc, $(OBJDIR)/%.o, $(SRC))

.PHONEY: all clean init

all: clean $(APPNAME)

clean:
	rm -rfd $(OBJDIR) $(BINDIR)

init:
	mkdir $(OBJDIR) $(BINDIR)
	$(foreach DIR, $(patsubst $(SRCDIR)/%, $(OBJDIR)/%, $(shell find $(SRCDIR)/* -type d)), mkdir $(DIR))

$(APPNAME): init $(OBJ)
	$(CXX) -o $(BINDIR)/$(APPNAME).exe $(OBJ)

$(OBJDIR)/%.o: $(SRCDIR)/%.cc
	$(CXX) -c $< -o $@

To use this makefile you will need to run it from a POSIX like environment so it should work fine on Mac OSX and Linux but on Windows you will need something like MSYS or Cygwin, personally I use MSYS but that’s just a preference thing.

This makefile is intended to be a drop in start point for any C++ project, though it isn’t had to modify it for other languages. The following is the project structure that the makefile is designed to work with:

  • Project Root/
    • makefile
    • src/
      • source_file1.cc
      • source_file2.cc
      • subfolder1/
        • source_file3.cc
      • subfolder2/
        • source_file4.cc
        • source_file5.cc

It will pickup all of the source files in the subdirectories eliminating the need for a recursive makefile. I have never tested this makefile on a large project so I don’t know how well it would hold up, but I’m guessing if your project is getting big you would most likely be better off using something like Autotools or CMake.

0

Fun with strings and hashes in ColdFusion

At work we do a bit of web development using ColdFusion and earlier this week I got stumped by a problem which I thought I would share.  We are currently working on a RESTful API which requires an API signature similar to how flickr does. When it came to writing my unit tests I created a signature grabbing a private key out of the database to test against. I ran the test and BAM! it failed, now this was half expected it was the first time I’d run the test. So it turned out that the code was syntactically fine, then I thought  maybe I had made a mistake in the process of creating a signature.

With that ins mind the next step I took was comparing the raw pre-hashed version of both signatures, to my surprise I found that the test passed.  This was beginning to not make sense, it wasn’t until I altered the test to fail that I saw what the issue was: when I retrieved the key from the database all of the characters were uppercase however when coldfusion retrieved the key all of the characters were lower case. After updating the test to use a lower case version of the key it passed successfully.

So it turns out that ColdFusion is not case sensitive when it does string comparisons, but the hash function does care what case the characters are, as you can lead to a frustrating situation.  Now I’m not expecting you to take my word for it so I have quickly coded up some example code showing the issue.

<cfset original = "secret-key" />
<cfset upperCase = "SECRET-KEY" />
<cfset match = "secret-key" />
<cfset random = "5q2up0awet530" />

<cfset originalHash = Hash(original) />
<cfset upperCaseHash = Hash(upperCase) />
<cfset matchHash = Hash(match) />
<cfset randomHash = Hash(random) />

<cfoutput>
	<h1>String Matching</h1>
	<table border="1" style="width: 30%">
		<tr><th></th><th>Upper case</th><th>Match</th><th>Random</th></tr>
		<tr>
			<th style="text-align: left">Original</th>
			<td style="text-align: center">#original eq upperCase#</td>
			<td style="text-align: center">#original eq match#</td>
			<td style="text-align: center">#original eq random#</td>
		</tr>
	</table>

	<h1>Hash Matching</h1>
	<table border="1" style="width: 30%">
		<tr><th></th><th>Upper case</th><th>Match</th><th>Random</th></tr>
		<tr>
			<th style="text-align: left">Original</th>
			<td style="text-align: center">#originalHash eq upperCaseHash#</td>
			<td style="text-align: center">#originalHash eq matchHash#</td>
			<td style="text-align: center">#originalHash eq randomHash#</td>
		</tr>
	</table>
</cfoutput>

When you run the code this is the output you should get.

As I found the hard way when ColdFusion says two strings are the same it may not necessarily be true.

2

Weekend of Code

I found that for me this weekend is going to be a bit of a quiet affair so rather than sitting around all day doing not very much I decided that I’d try to be productive.  It’s been a while since I sat down and done any meaningful amount of coding for myself so I thought that is where I’d start, my next question was what do I want to write? I then remembered that I’m not overly fond of most of the music players that I’ve tried on Windows, the closest so far to something I find acceptable is iTunes.  With that I had it: my goal for this weekend would be to write (or at least make a dent in writing) a music player that I would like.

Alright, that’s all fine and dandy to say but what does that actually mean? Brainstorming it I came up with seven key features that I want in my media player:

  • Only plays music, doesn’t try to do anything else.
  • Watch folders.
  • Filter on album, artist, title.
  • Filter a filter.
  • Ability to queue songs while on shuffle.
  • Playlists.
  • A similar interface to iTunes.

While watching Justice League: The New Frontier tonight I made a bit of start by making some rough UI mock-ups in Balsamiq.

To implement this I’m planning on using C# and WPF, I haven’t had a good chance to play around with WPF or some of the new Windows 7 features that are available so I figured this would be as good a time as any.  Finally my other goal with this project is an attempt to get me back into blogging, to that end I will hopefully be making a post at the end of each day summarizing what I’ve done – possibly with some screenshots.  Until then I should be posting some updates to my twitter feed.

0

theCloud Blog

So it would seem that I might be starting to go a little theme happy. Not one week after releasing the new theme to my own blog I’ve tried my hand at another theme. At work we are gearing up for the release of theCloud our hosted services platform and I had the pleasure of designing the blog theme that we are using for theCloud blog which was launched yesterday there over the next little while you will be able to find posts related to hosted services, cloud computing and other related topics. I’m hopefully going to try and squeeze in some posts about customising the software we have available through coding.

2

New Theme

If you have actually browsed to the site to read this post you will have noticed that Mike’s Musings has had a fresh coat of paint, also if you’ve read my previous entry you will have noticed that it is not the theme that I mocked up. In the end I thought that the first theme was not a good fit for the site, though one day I might turn it into a real theme.

The motivation for changing the theme in the end came down to a mixture of the following factors:

  • Fluid Blue the old theme had been in service on this site for getting close to four years now and it was time for a change.
  • I wanted to try my hand at a bit of design, I knew it was not going to be any hugely fantastic but I’m happy with the result.
  • Finally I wanted to integrate some of the various social networking sites that I belong to into the site, I found that fluid blue didn’t really lend itself to how I wanted it all displayed.

As I noted above I wanted to integrate some of my social site activity into the site to that end I have also integrated my twitter stream into the left sidebar.  As with any new piece of code I will not be surprised if there are bugs, I have tested it in IE 8, Firefox and Chrome and it appears to work fine but these are not the only browsers in the world.  If you do happen to find anything wrong with the site don’t hesitate to report a bug over at the mlowen.com bug tracker.

0

Development Utilities

In June of 2009 I left my first programming job to move to LayerX, it’s been roughly six months since the switch and I haven’t looked back. One of the biggest changes in the switch over that I wasn’t expecting to be so big was moving from Linux to Windows as my primary development environment I had not realised how many of the small apps that shipped with Ubuntu that I relied for my day to day work. It’s only been just recently that I felt that I’ve settled into windows development enough that I am no longer swapping and trying out new tools. As my first post for the year I thought that I would share the list of tools that I currently use often.

In this list I am trying to avoid major tools (like an IDE) and rather focus on the small language agnostic tools which makes my day to day life just that little easier.

Notepad2 – This is just a simple text editor, what puts it above the notepad that ships with windows is the syntax highlighting that it provides for many

Putty – While my primary development environment is no longer Linux I do still need to access various Linux servers and putty is still the simplist and most light weight tool for the job.

WinSCP – This is yet another tool for dealing with linux servers, getting files off of a linux server (lacking samba) onto a windows box can be a PITA and that is where this tool comes in to save the day it makes retreival of files from linux machines a breeze.

WinMerge – An awesome visual diff tool.

7-zip – I can not stress how much I love 7-zip or how lost I’d be without it. Able to uncompress every compression format I have come across so far, you no longer have to fear others sending you files compressed in formats which are not zip.

Balsamiq Mockups – I think this is damn near the perfect tool to create mockups to show to clients, the sketched feel to them seems to strike the right balance between looking somewhat professional and not looking like a real application.

Filezilla – An ftp client that just works.

TortoiseSVN – This seems to be the svn client for windows, with it’s integration into explorer it is easy to see why.

IcoFX – A simple easy to use Icon editor, it can be used to create Icons from scratch or transform existing images to icons.

InnoSetup – Distributing an application and want an easy to use installer? Then InnoSetup is the tool for you.

Console2 – I do not like the standard windows command prompt window at all. I have my reasons and half of them can probably be solved quite trivially, the point is the shouldn’t have to be. The ability to have multiple tabs of different types of consoles in one window is great.

Sqliteman – If you deal with SQLite databases then you need this tool, it lets you get into the database and examine and manipulate the data contained within.

MSBuildShellextension – This is a neat little tool I only discovered recently courtesy of the 2009 Hanselman tool list. My life is a little bit brighter now I can build VS projects from explorer without having to launch Visual Studio.

Is there anything you feel that I might of left out? Or do you know or better alternitives to some of tools listed above? If so leave a comment so I can look into them.

0

REST API Test Utility

One of the things I enjoy most about being a programmer is the fact that when you can’t find a tool to do what you want you can write it yourself. Generally I’ve found that these applications tend to be quite simple and stick to the unix philosophy of ‘do one thing and do it well’ which as a software developer I think is a good philosophy to live by. The most recent occurrence of this happening to me was at work not to long ago where we are currently writing a REST API I needed an application to make a HTTP call to a URL. After about 5 minutes of looking around the web I couldn’t find anything, at that point I had the choice of either continuing to search for an appropriate tool or I could write my own. As you might have guessed I wrote my own, it took about 10 minutes to implement the basics of what was needed.

Over the next couple of weeks the tool continued to evolve to better fit the specifics of the project we we’re working on, but in the back of my mind I kept going back to how other people must have this problem as well. Eventually I decided to re-implement the core of my tool. Having finished the re-implementation a couple of weeks ago I’m finally getting around to releasing it to the public under the GPL, below are the links to download the 0.1 release.

  • [download id="1"]
  • [download id="2"]

For those of you who would like to grab the latest source and stay current with any updates (which may be buggy broken code) you can check out the subversion repository which is available at the following URL:

In other news I have signed on to be a contributor to lounge media a blog about digital media in the home, hopefully I should have a post up there soon – once I figure out a good subject to start on.

1

New Theme Design

With moving to the new server I thought I would take a leaf out of Paul’s book and change the theme for the site.  I have been using the current theme fluid blue since I started this blog in October 2006 so it probably long overdue for a change.  When making this decision there is one factor I did not count on – I am a very picky person.  After spending about an hour going through themes on the wordpress themes site I got sick of it and decided that I would be able to come up with something.

Now I don’t claim to be a designer, my hopes with this theme is to create something that I like and won’t make your eyes bleed if you stare at it too long.  The goals I had in mind when working on this was a clean, minimal design that incorporated curves, I wanted curves because the current theme is all straight lines and right angles.

Currently I have completed a mock-up which can be found at mlowen.com/mockup and is currently filled with dummy data from this site, if you have any feedback it would be appreciated.

0

New Server Transition Complete

So a quick post to let those who might’ve wondered that yes this site is still semi-active, I haven’t posted as much as I would’ve liked to due to being busy at work.

Enough of that though and onto the purpose of this post this site and the collection of other sites who share the same server as I do have just finished transitioning to our new server at xlhost we decided to leave layeredtech after spending a couple of years there due to layeredtech shutting down the data center our server was hosted in and xlhost offering a better deal.

I was able to export all of the content from my old wordpress installation to import here. However it appears that I was not able to get all of the images which is a little disappointing, I might go looking through the google cache and hope I stumble upon something. Due to importing all of my posts from my old wordpress installation into this new one I’m not sure if people who subscribe to my rss feed got swamped with entries or not, if you did I apologise.