Jeb Wilkins

Coding and climbing in Cumbria.

Sage Line 50 and Rails

I’ve done a fair amount of integration work between Sage Line 50 and various websites, e-commerce and others, and I’m writing a plugin for Rails to make this process a bit easier.

Integration is achieved with a great product from Internetware called connect which lets us talk with Sage via Connects own XML format. This makes integration pretty easy in any language with good XML support providing you know the schema. My plugin will hopefully remove the need to understand the inner details of the schema.

I’ve already written the part for handling uploading data from Sage, thats nice and simple - you handover the xml, and the call either Products, Categories/Tax Codes or Customers methods with nice rubyesque code blocks to do something with that Product/Category/Tax Code/Customer.

I’m now trying to decide on a clean API for downloading data back to Sage Line 50. This needs quite a lot of data to generate either a Sales Order or Invoice, the question is how make doing this easy without knowledge of the schema. Options I’ve thought of so far

  1. Some way to extend the users models to generate SalesOrders or Invoices - will need to spec how to map fields, then we have an equivalent to the current to_json, to_xml methods - this ties the knowledge of sage quite tightly to the users models though.

  2. a generator which creates a nicely commented builder template - the user can then play fill in the blanks, this does expose the schema directly but makes it quite easy for the user - doesn’t feel very clean though

  3. a intermediate object, much like the upload - this will either need to be handed a way to map fields though, and I’m not sure how to hand the nesting of data within the schema, or will just need a stack load of methods - which is extremely messy

  4. some kind of DSL, AtomBuilder is a bit like this but ends up still requiring the user to know the Atom schema - this wont fly for us since our schema is a lot more complicated. In principle this feels the right way but I don’t want the user to need to know the ins and outs of the schema

Will have to see where this leads - the intention is a plugin with the logic well hidden, and a generator to create a sample controller which the Connect package can talk to and the user can butcher/tweak/learn from.

Code is at

As an aside I’ve been using Git for this - seems to have come on a long way but is still not as pleasant to use as bzr. Easygit makes it bearable though and its certainly a lot faster.

Dell Rant

I’ve got a nice Dell Laptop which I got a few months back, and XPS M1330 - and at the time I was able to reclaim the unneeded Windows licence and was singing Dells praises.

What I’ve now discovered (well, my girlfriend discovered) is it actually has a destroy the hard drive button - I kid you not! I’m still not 100% sure what happened but it looks it happens when you press the key with a house symbol (left of the power button) whilst going through the BIOS part of the boot process. At which point the laptop tries to start some helpful media player, finds its not on the hard drive (I reformatted the whole machine with linux) so restores itself. No warning, No confirmation, just happily writes a 2gig blob onto the disk destroying what ever was there, then rewrites the first entry in the partition table to point to this blob. The blob turns out to be an NTFS filesystem containing what looked like some WinXP varient. I was busy and it was a week before I could look at this, all the time thinking I’d lost the data on the laptop since my backup machine died a month before.

Turns out it writes the blob to the end of the disk (in fact 1 cylinder past the end of the disk according to the partition table), which thankfully was filled with a large swap partition. Once I got Testdisk to fixup the partion table and recreated my swap partition the laptops was back in working order.

That doesn’t change the fact Dell are shipping laptops which intentionally overwrite the hard drive with no confirmation, it blows my mind how stupid the engineers at Dell must be to let something like this through their QA process.

Scribes TextMate-style Plugin

I use TextMate all day in work and its about the only reason I’d consider buying a Mac, unfortunately its not a good enough reason for the price premium so I’m trying to find good work-a-likes on Linux.

A friend had recommended Scribes to me and whilst I’ve not played with it much it looks to have potential. Currently it has no ‘Project’ support, so I’ve hacked up a plugin to open files relative to the currently open file - this is built upon (butchered from :) ) the SnapOpen plugin for Gedit, itself modelled off TextMates ‘Meta T’ function. The significant difference is that since we have no project root to search below, we automatically search the folder, and subfolders of the current file. Each time you press the Up arrow it automatically moves the search root up a level. This works great for the rails apps I’ve been working on recently and should hopefully work fine for most medium sized software projects.

Caveats -: Its currently quite slow when working with subversion checkouts, since its finds all the .svn files, then excludes them with grep - this is a problem with Gedits SnapOpen plugin as well and I’m looking to replace the search logic with something smarter.

You can download it here. Just untar the file, and drop the contents into ~/.gnome2/scribes/plugins.

Alternatively grab the bzr branch from

TM-Bazaar Works Again

I’ve fixed a couple of bugs in the CocoaUI factory (progress bars) which were preventing several of the commands from working. The logic for the progress bars still not quite right but should at least work, hence push, pull, branch all work again now. I’ve also fixed another bug in commit which was preventing that from working. Once I’ve got cocoaUi properly sorted I create a new tarball but in the mean time all the changes are in bzr at

TM-Bazaar’s Not Dead

I’ve been pretty lax with TM-Bazaar lately, after a good start I’ve been pretty busy with a rails app in work and its fallen by the wayside, I’ve also not had a working bzr install to test it against. It turns out something’s changed in bzr’s api, which has broken my CocoaUIFactory, which in turn has broken every command that uses it (most) - not sure how long this has been broken for but oops! I’ve now started trying to update TM-Bazaar, hopefully I’ll have a fixed version out in the next week or so.

Rails, Mod_fcgid and 503 Errors

Whilst setting up a Rails app for one of our clients I’ve been getting 503 errors occasionally when browsing the site. It seems to occur whenever the fastcgi process has been dormant for a while, and presumably killed of by mod_fcgid, and very occasionally at other times. A bit of googling showed that this seems to be a known issue with older copies of fcgid - unfortunately the server in question is running Ubuntu Dapper Drake, and so v1.07 of fcgid with no backport available.

We’re running other rails apps on a Debian Etch box with a marginally newer fcgid v1.10 with no problems so I decided build my own backport of fcgid. My first attempt was with the copy that comes with Hardy (v2.2 I think) since that’s what my laptops running, this didn’t work though because of dependencies that couldn’t be satisfied by Dapper. In then end I backported the copy from Edgy Eft since thats 1.10, same as debian, and so far that seems to be working fine. So if your getting the same error it might be worth installing my backported libapache2-mod-fcgid deb.

Fun With Servers

A couple of weeks back the hard disk in our office server died, like many offices this is an old computer in the corner with just a single disk running debian. At the time I got it back up quite quickly, and just pulled all data from the previous nights backup. At the time I vowed to get it running with a proper RAID 1 setup, but instead had to rebuild it quickly with the single working spare disk we had lying round the office. So yesterday I set about migrating from an old PATA disk to a pair of shiny 500Gb SATA drives plus new controller, since I’ve not setup RAID by hand before this was a good challenge.

Well Planned Ice Climbing Trip - Not!

Every once in a while I head up to scotland to go ice climbing. These are always quite major trips, lots of effort and in theory there should be lots of planning. I’ve yet to manage that on any trip in the last couple of years, this weekend will be no exception since as of an hour ago I’ve decided I’m off on one such trip straight from work tomorrow. It should be a lot of fun but since I need to head out in 10 mins my prep has been minimal, fingers crossed it all works out. We’re heading to glen coe so there should be lots of opportunity for good climbing together with a good pub at the end of the day.

Refund on Windows Tax

Wow - it actually worked. I got a new shiny new Dell laptop a month ago, which I’d had to buy a copy of Windows with, no option to not purchase, so I’d figured it’d be worth at least trying to reclaim the value of the unnecessary license. At the time I opened the box I dutifully took lots of photos of me booting from the ubuntu cd and reformatting the entire drive. Its taken me most of the last month to get round to writing the letter to Dell and putting the photos on a cd but I finally did that and put the letter in the post on Sunday. Low and behold I got a phone call of them today saying they’d be refunding me the costs of windows, £105 I think - no questions, no hassle.

Hats off to Dell UK, I didn’t think they’d refund the value and certainly didn’t think it would be this easy. I’ve included the wording of the letter below for anyone else wanting to claim the money back on an unused windows license.

Fixing RedBox Bugs

We use RedBox, a lightbox plugin, for a couple of Rails sites in work. It works great most of the time but today I’d got a bug with its overlay not hiding absolutely positioned elements in the page, only under IE. A lot of searching and a much better understanding of how RedBox works later and it turns out to be a simple z-index issue. That got me started though so I then fixed another couple of bugs, one with the overlay not occupying the whole viewport when the content was shorter, and one with the embeded div not taking where the page is scrolled to into account. In both cases I read the source to the original lightbox for ideas - got to love open source :) I’ve sent the patches to the author, hopefully they’ll be a new release, if not i’ll look into posting the bug fixed code up here.