elliot's blog

REST - get 'em started young

I was fiddling around with some designs for Spring REST applications this weekend, writing in a notebook. While I was writing, my daughter, Madeleine, came over to see what I was doing. She returned to the table, wrote on a piece of paper, then brought it back, proudly emblazoned with the word "PUT". Then she went backwards and forwards to the table, copying bits of what I was writing. This was the end result:

In case you can't read it, it says:

REST VERBS
PUT
POST
DELETE
GET

If I ever do a presentation on REST, I will definitely include this picture. Cute.

Koha - open source library management system

I spent a couple of hours last night and this installing Koha, an open source library management system. Unlike systems such as VuFind and Scriblio which are just OPACs (i.e. a web-based front-end for bibliographic catalogue data), Koha is a full-fledged LMS (or ILS, as they are called in the US). It's written in Perl, and runs as two sets of Perl CGI scripts under a web server like Apache, with MySQL as the back-end.

Installation was, how shall I say it diplomatically, not straightforward. The points that tripped me up were:

  1. I recommend creating all the directories you need before you start. I installed everything into /opt/koha, creating an opac, intranet and log directory underneath. You'll be prompted to enter these locations during installation.
  2. The permissions on the installation directory have to be set so that Apache can write into them. Without this, you get cryptic HTTP 500 errors when you try to access the web interfaces.
  3. It requires a load of Perl CPAN libraries to be installed. I don't know much about Perl, so this was fairly new to me. CPAN doesn't have the simplest interface, and it took me quite a while to work out whether the modules were properly installed or not. Plus Koha needs a version of one Perl library (ZOOM, which implements the ZOOM API for information retrieval) which wouldn't install on my machine, as my Perl installation is too old (I think). I had to manually visit CPAN, download an older version of the module as a tarball, and install it manually, which was a pain. The old version still seems to work fine with all the other Perl modules used by Koha.
  4. As I use XAMPP, I have a non-standard MySQL socket location, which meant that the installation crashed out at the point where the database gets set up. I tried to work out how to fix this, twiddling with SQL code inside the Perl scripts, but I couldn't get it to work. In the end I gave up and made a symlink (/opt/lampp/var/mysql/mysql.sock) from my XAMPP MySQL socket to the one Koha expects (/var/run/mysql/mysql.sock). This did the trick.
  5. You have to remember to include the generated koha-httpd.conf file in your main Apache config.. In my case, I also needed to uncomment the two Listen directives to make Apache listen on the ports I had configured Koha to run on.

The end result: a running LMS, with separate OPAC and admin. front ends. Rather confusingly, the admin. front end asks you for a card number to login, when what you need is the MySQL username to access the database.

I have to say that I thought the installation process was over-complicated. Ironically, by creating an installer which generates the database and copies the files for you, they make it harder to fix errors when one step in the process fails. For example, I had to try to do the whole installation about 8 times, rolling back all the changes to directories and the MySQL database each time it failed (near the end). I'd much rather the steps an installation process are discrete: create directories, copy the files, create the database and user, pipe in the SQL commands to setup the database, generate the httpd config., etc.. That way, if step 6 out of 6 steps goes wrong, I don't need to roll back the previous 5 steps.

I haven't got time to play with it now, but will post my thoughts when I do. So far, I'd say the admin. area is pretty slick:

And the OPAC simple but functional:

I need to do some config. to make it do interesting things, but at least I finally got it running.

Magic tricks revealed

I feel cheated. I was using StumbleUpon to find stuff and came across this article on aerogel. It's virtually transparent, and can support a fair bit of weight. It occurred to me that maybe David Blaine uses it in his performances to do his levitation, which has always befuddled me. I then started looking around for evidence of this, and discovered this PDF which explains his performances. As is always the case, reading about how mundane some of the tricks he performs really are is quite depressing.

Even more depressing was the explanation for how he does his levitation. A clue: have a look at Balducci levitation; here's a video of it being performed. When I looked again at David Blaine's levitation, it was obvious that he was doing a different trick, not the Balducci levitation; but the PDF explains exactly what was going on. I'll leave it up to you to read it if you want the illusion utterly shattered.

Drupal wins the Packt overall open source CMS award

Read about it here.

You knows it.

(I was on the judging panel, by the way.)

Post-scarcity economics

I came across the concept of agalmics the other day, while reading the rather good zenbullets. Agalmics is an approach to (or more properly, perhaps, an alternative to) economics which acknowledges that non-scarce goods will always be copied, whether legally or illegally: "With our information technologies copying data is the easiest thing in the world, so it would be fool-hardy to try to fight it." The answer, according to agalmics, is to acknowledge that rather than paying for and protecting data, we form a new economics based on "reputations, kudos, and respect, all of which are earned in a variety of non-Capitalist ways." We're already seeing this on the web, with blogs forming reputations and earning money. I have personally benefitted from this, as this blog has definitely enabled me to present myself effectively when looking for work, and exposed me to more opportunities than would otherwise have come my way. The end result of agalmics? "Information will be abundant and free."

In particular, I liked this analysis of recent trends in music, such as Radiohead offering up their album for what the listener thinks it's worth, and Prince giving his album away with a newspaper. Elsewhere he talks about Madonna signing a deal with a concert promotion company.

The corporate approach to this [the ease of digital copying] seems to be DRM (Digital Rights Management) which is perhaps the stupidest thing I have ever heard of. The idea is that the mp3s they sell are locked to a certain player. For example anything bought through the iTunes store is locked to only play through iTunes, limiting what a consumer can do with their purchase. What they are effectively doing is making sure that the mp3s they are charging money for are actually of less value to the consumer than the illegally downloaded, free equivalent. This can only encourage file sharing, rather than combat it.

(My emphasis). Hear, hear.

As an aside, this entry intrigued me (I've had a passing interest in the Situationist International and Guy DeBord), and led me to Kriegspiel, and then onto an online Kriegspiel. That was a happy hour or so.

Need a builder? A Drupal site might help!

My brother-in-law (Jason) is a builder, based in Caterham, Surrey He asked me if I'd put together a site for him to advertise his company (he's self-employed), Alljays Building Services. The main things he wanted were somewhere to host a list of services, address and contact form, and a portfolio of work.

I decided to put him a site together with Drupal 5. The static pages and contact form were easy. But I wanted to add in a portfolio which he could edit himself. So I used the following Drupal modules to add the functionality I wanted:

  • CCK, to create a custom content type to represent portfolio entries. This meant I could create an "Example of work" page type.
  • The Image field for CCK, which gives you a simple image upload field.
  • The Views module, which enables you to produce custom summary and detail views for nodes.

With these in place, I created a taxonomy of types of work Jason does (e.g. Conservatory, Garden), and specified that each Example of work page has to be added to at least one of these categories. I then created some taxonomy-based views, to first show the types of work in the portfolio as links; each link then becomes a link to the nodes in that category, again shown in a custom view (see the site for more details). Most of this can be done through the Drupal GUI; but I wrote some custom templates to do the rendering.

The idea is that Jason should be able to login, create a new portfolio item (using Textile markup if he wants), upload a picture (and have it automatically resized), and categorise it. It will then find its way into the appropriate part of the site with no further work. On my own site (this one) I use these great, flexible Drupal features to build the navigation: create a category and/or node type, add items to it, then link it to the navigation. It makes adding new content to the right section trivial: you just set a category and Drupal does the rest.

The end result is basic but functional, and took me maybe a day to do (most of which time was spent toying with CCK and Views, which I hadn't used before). I think Drupal is a great little CMS for this type of small dynamic site, or for pretty much any kind of site; but I'd add that I think CCK and Views should be more readily available as part of the core; I'd also like to see more comprehensive documentation and examples to make it easier for people to pick up. I know I could write some, but I think it would need a good slab of time I don't have at the moment.

Holiday at Pontin's

We've just got back from a long weekend at Pontin's Camber Sands resort. We got it for about 40 quid for 4 days, through a newspaper offer. It's not really the kind of holiday I'd go for as an adult; but for Madeleine, it is bliss. She particularly loves the character shows, where they have people dressed in fluffy outfits, dancing and singing; the playgrounds and soft play areas; and activities for children, like painting and drawing. We stayed in a chalet which was freezing cold with a terrible bed (I ended up sleeping on a single in Madeleine's room to avoid it last night), but it was enjoyable nonetheless.

We had a great time, and I particularly enjoyed the family entertainment provided by the Blue Coats. We went to their cabaret show, and I have to admit to being very impressed by their performances: these people spend the whole day doing children's activities, running quizzes, performing on stage, working on the rides etc.; then spend the evening doing song and dance routines. The dance routines and singing were frankly very good, given that they were given by all-rounders. Although pretty cheesy, I had a sneaking admiration for the professional approach taken by the staff.

The highlight for me was Amethyst, a magic and illusion act that came on before the "Blues". They were hired in, not Blue Coats, and had a classic intro where a deep booming voice said stuff like:

Please do not attempt any of the magic and illusions you will see on stage. The tricks you will see are being performed by professionals.

And now, ladies and gentlemen, we present: Amethyst.

If you've ever seen Jonathon Creek, or that episode of Knowing Me, Knowing You With Alan Partridge, where they parody the overblown magic act, it was just like that.

However, once they got started, I was sucked in and enjoyed it. They ended with a particularly fine illusion where they made the illusionist bloke made it look like he'd cut off the lady's head. No idea how he did it. Madeleine loved it, too.

I don't think I'd stay in a chalet again (given a choice), but I enjoyed the holiday camp experience.

You've got to love open source

A while ago, I did some work on s33r, a Ruby library for Amazon S3. It was good fun to work on, and I used it to mess around with S3 when I was looking for a backup solution. However, I then started using Dreamhost for my backups, lost my use for S3, and stopped actively developing the project. At the same time, Marcel Molina (the Rails core fella) released his own S3 library, which, of course, outstripped the popularity of mine by a long way and became the de facto standard. All these factors combined meant that I decided to scrap my library and just refer people to Marcel's.

But it turns out some folk were still using s33r for projects, and obviously found bugs as they continued using it with newer Ruby software. I got a few bugs and patches submitted, but had little time or need for the fixes myself. I decided to suggest that the submitters take over the project as the new admins.

Tiago Macedo graciously agreed to take over the project, and has already released a new minor version and been folding submitted patches into the code base. I feel a bit like a proud father watching his child (the s33r code, not Tiago, of course) walk through the school gates on their own for the first time. The s33r code belongs to the world, not just me. I feel proud to let go of it, handing it over to someone who thinks it's worth continuing.

Java - better than you think?

I've been at Talis for a week now, and so far it's been great: the people there are top notch, extremely welcoming and very technically-competent. I'm also finding the culture invigorating and interesting, as I'm dealing with many techniques and technologies first hand which I've only been able to dabble with previously. I've also realised that I love programming. I really do. So: so far, so good.

The first project I've been attached to involves a lot of Java coding. I can't give too much away, but suffice to say we are using Spring and Hibernate (nothing too startling there, then), and approaching the project with test-driven, agile techniques, using Ant to build and Subversion for source control. This is exciting (slightly daunting, too, but mainly exciting).

And I have to admit, I am growing to really like Java, especially when written using Eclipse (the code completion, spell checking, refactoring tools etc. are first rate); and Spring is making me reassess my whole approach to coding (more and better use of design patterns).

It's also made me realise that there are definite advantages to static, manifestly-typed languages (like Java), over dynamic languages (like Ruby and PHP): a lot of errors get caught early on while coding, rather than at runtime, as the compiler is constantly checking types of variables, and making sure the type casts you do will give the results you expect. Eclipse is superb in this respect, pointing out where you're going wrong as the mistakes occur. Non-dynamic languages like Java are painful if you're coding the old-fashioned way (with a text editor); but I'm finding them much less error-prone than dynamic ones if you're coding with modern tools. For example, I refactored a section of someone else's code, and Eclipse pointed out to me where this had an impact on other parts of the code. I could just go through and make my changes wherever they were necessary. All this was made easier because of Java's manifest typing: the IDE can detect exactly where changes in one part of the code will impact elsewhere. I'm sure this is possible with Ruby and PHP (as examples of dynamic languages), but I've yet to find an IDE that does this really well.

One down-side I've found with Java is package management: pulling dependencies together to form a coherent buildable software system. I've been investigating Maven as a possible solution for this issue. My other issue is source code organisation: Rails has spoiled me by telling me where to put everything, while Java is laissez faire. More flexible, but I seem to have spent loads of time just deciding how to divide up my applications. I also find that Java is more verbose and awkward than something like Ruby, but I think there are other benefits which counter that. Let's see how I feel about it in a month or so...

More exciting developments are on the way, so stay tuned.

The nerd test

I've done these before, but even I was surprised at quite how nerdy I turned out to be when I took one today:

I am nerdier than 96% of all people. Are you a nerd? Click here to find out!

Nicola found the summary amusing:

All hail the monstrous nerd. You are by far the SUPREME NERD GOD!!!

I didn't think I was quite as nerdy as that. I suppose putting it on my blog makes me even nerdier.

Then I took version 2.0, and got this result:

See, I am really only a computer nerd.

Syndicate content