elliot's blog

Presentation on dynamic languages and Ruby on Rails

I was recently asked by the Coventry branch of the British Computer Society to give a presentation on dynamic languages, with special reference to Ruby on Rails. I'm not really a computer scientist (despite my Ph.D. being in that subject, I'm really academically a cognitive scientist), so I had to learn quite a bit about the topic first (dynamic vs. static, manifest vs. implicit, strong vs. weak typing). I think I did a reasonable job, though some may disagree with my definitions. I also did some live programming, and built a simple application during the presentation, showing some Ruby meta-programming features that Rails makes use of. Again, I did my best to work out what the hell was going on in Rails when you use dynamic finders etc., but in a couple of cases I made some inferences based on minimal evidence! It's tricky stuff, and involved a fair bit of forensics and consultation of Ruby for Rails.

The presentation went well (the chairman said it was one of the most detailed and technical sessions they'd had for a while, which reassured me that I did kind of know what I was talking about). The audience had quite a few old skool FORTRAN programmers who seemed initially skeptical of dynamic languages: I think I placated some of this skepticism by comparing ActiveRecord and Hibernate, and demonstrating that they have different purposes/environments/sweet spots. I also did my best to explain why/when/how you might use a static language vs. a dynamic language.

I've attached the presentation and my script for building the application live for anyone interested. Any comments or corrections are welcomed.

Drupal Last.fm module - now works with Drupal 5!

Another update: I noticed today that this module had disabled my site. I'm not sure why, but I think it may be because Last.fm wasn't responding. I'm still using it, but if you have it on your site and everything goes bad, it might be because Last.fm isn't available. I manually disabled it in the system table for my Drupal install and my site came back to life, so I know it was this module that caused the problem. I need to do some more debugging before it's suitable for production, so use at your own risk, or exclude the block from the admin page so at least you can disable the module if it causes problems.

Update: I've just updated this slightly, so that the cached track listing is used if your recent tracks from Last.fm is blank. This avoids you getting an empty listing if you haven't been listening to music for a while. I also updated it a second time to prevent errors occurring if you get broken XML back from Last.fm (which happened to me once, and caused my whole site to crash).

I've had a couple of requests for my Last.fm Drupal module, in response to a previous blog post. This was also a good opportunity to learn how to write modules for Drupal 5 and learn the new forms API, which I've now done.

The new version is attached to the bottom of this post. It requires Drupal 5 and PHP 5 with the DOM extension enabled (this is used for parsing the XML feed from Last.fm). It won't check whether the DOM extension is enabled (it's not that clever yet), so it could cause issues (like your site breaking) if you try to install it on a system without PHP 5 and/or the DOM extension.

Install it as a standard module (drop into the modules directory, enable in Administer > Site building > Modules). I've integrated it with the admin. system (under Administer > Site configuration > Last.fm module settings), so you'll need to configure it there before it works. The settings required are:

  • Your Last.fm username.
  • The number of tracks you want to show (1-10).
  • The period for which you want to cache the list (5 minutes to 1 hour), or no caching. The listing is cached in your Drupal root directory (under the filename lastfm_cached.html) for efficiency. In cases where Last.fm doesn't respond quickly enough, you will get an error message (rather than it just leaving your site hanging).

Then turn on the block with the title Recent tracks in the block admin. pages. And away you go! As proof it actually works, see the left-hand side of this site, where it's in action.

Another perspective on DRM

I've recently started watching Mobuzz, which is a kind of MTV-presenter-fronted ITV show. It's kind of light and frothy but cute, and has an interesting, popularist slant on IT/tech. issues. I like to keep up with the kids: consider it light relief.

My point: a recent episode noted that issues with DRM on tracks downloaded from Deutsche Telecom's musicload music download service are responsible for about 75% of the calls to their customer service call centre. I hadn't though of this before, but now someone's mentioned it, it's obvious. I bought a couple of tracks from somewhere recently that were DRM-encumbered (as I couldn't get them elsewhere), and discovered that I had to enter a password into the Windows Media Player to play each frigging track. I can imagine this can fox a lot of people. Some people probably stupidly think they can download a track to their PC, then put it on their mp3 player and their brother's, only to find it can only be used on two bloody devices. Or someone buys a track, plays it 5 times, and finds it won't play any more. Or upgrades their computer to find they can no longer access all the music they've been paying for over the last few years. I bet there are a lot of frustrated customers out there and equally frustrated call centre operators.

Hold on there a few minutes Grandmaster Flash, stop reinventing popular music and contact customer service to get your password reset.

Linux desktops - a real life example

Here's an interesting, real example of a normal (power, but not especially technical) user trying to make a switch from Windows to Linux. It's a good article, and should be required reading for all Linux on the desktop evangelists. I agree with the author (Sharon Machlis) that large parts of the problem with adopting Linux are down to lack of vendor support. I still think this is the big sea change required to make Linux acceptable on the desktop: decent hardware support, applications ported to Linux, support for consumer software (games) and devices. We have to be realistic if we expect people to use Linux in their day-to-day lives.

I use Linux on my laptop all the time, but I'm quite a techie, and can install stuff from source or obscure repositories if I need to. Also, I deliberately avoid hardware I know won't work with it (e.g. iPods) or will probably not work straight away (e.g. webcams). What's the first thing I do when I do a fresh install of Linux? Put the Windows fonts on it, install mp3 support, install Realplayer, install the Flash plugin for Firefox, install the Quicktime codecs for mplayer and the mplayer Firefox plugin, install Java (should be easier soon), and install support for DVD decryption (naughty!). So I can actually use the system in my daily life.

I'd willingly pay someone a decent amount of money if they'd provide me with a legal Ubuntu repository which does all of this for me. Even better would be if DRM were abolished and everyone used Ogg Vorbis to encode their music: but it just isn't going to happen any time soon. While I am (deep down) a free software person, lots of people who provide content or provide services aren't, and I often need to be able to use their stuff. I stop short of using anything which requires Internet Explorer, but apart from that, needs must.

New ecommerce module for Drupal

Yesterday a new ecommerce module for Drupal, Ubercart, was announced. This is pretty exciting. I'd looked at the existing Drupal ecommerce module before, but it's a bit of a mess, cobbled together from what seemed to be endless disparate modules that half work together. (Not to belittle the achievements of the team which produced the ecommerce module: it has masses of functionality, and integration with all sorts of stuff; but it's too complex for normal people who just want to sell books or something.)

What marks out Ubercart?

  • Nice documentation. It looks like the development company behind it has actually written a professional, clear, comprehensive set of manuals for it. This makes the world of difference to how easy a product is to use.
  • Support for anonymous checkout. Users new to the site can be gently guided through checkout without having to create an account before they can do anything. The explanation of scenarios this encompasses is thorough and well thought through.
  • The system looks modular and well designed. You can just load up the parts of the framework you need, and the dependencies and features of each are properly explained.
  • The developer's guide is clear, concise and gives you a decent number of examples of the API (hooks), variables available to templates, etc.. They've even gone to the trouble of providing a coding standards guide, and a list of useful open source applications you can employ to start doing your own development.
  • Because it's based on Drupal, and Drupal has a whole slew of modules (including CRM), Ubercart increases the potential of Drupal as a simple, extensible, general-purpose business framework. Imagine if your online shop and your CRM could easily share customer data...

The only issue I'm not clear on (probably somewhere in the documentation) is whether you could use it to build a electronic downloads site (e.g. to sell images or PDFs). I'm sure other stuff will crop up too (like currency handling).

This is a really exciting project, and is the kind of thing that could give Drupal a big boost as a general purpose web framework. It definitely looks like it could give osCommerce a kick up the arse. It's actually a joy to read the well-written, clear documentation (there are a few areas where it's incomplete, but generally it's pretty comprehensive). I've added it to my todo list of products to have a look at within the next month, and hopefully I'll end up using it myself (eventually).

Congratulations to the team, and I wish them the best of luck in getting it off the ground.

The perils of testing dating agency software

I get to install a lot of software at OpenAdvantage, but a recent request about dating agency software is also one of the wierdest I've received. I started testing Friends & Love this morning, which is one of the most popular SourceForge dating agency software projects. It kind of works, though the English translations of some of the text strings are a bit odd (once you've signed up, you get a message which congratulates you "Now your are such a new member" and invites you to "Now let search your match"), the forms are a bit clunky, and the really important bit (finding people) doesn't work at all. The last one is a bit of a negative, I'd say. Plus the whole "storing personal data" thing is probably fraught with danger, which I'll be advising my client about.

Anyway, what is amusing is that this is the first time I have received a sexually-explicit PHP error message (WARNING: adult content follows):

Warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the 
right syntax to use near 'out, dick_size, circumcision, body_hair, orientation, role, safe_sex, smoke, dri' at line 1 in 
/opt/lampp_axlegrease_0.6.4/htdocs/friendnlove/includes/ez_sql_mysql.php on line 206

"dick_size" and "circumcision"?! I actually feel embarassed testing this stuff. What kind of people use dating sites that want this information? Oh dear, it's bringing out the Puritan in me.

Once it's up and running, the "Edit Adult Profile" for members allows you to select from every fetish ("Frottage", "Kilts", "Waders", "Chaps"), inclination ("Bears", "Chubbies"), and sexual activity ("Electro" and "Verbal" are two I can actually list, as I don't know what they mean) known to man or beast. It is hilarious.

I have to take a scientific standpoint on this kind of stuff, I feel: test dispassionately and not worry about how it's going to be used. I'm not really in a position to take the moral high ground. It would be like a builders' merchant refusing to sell bricks to someone who's planning to build a brothel.

By the way, if you're looking for slightly less tawdry and more professional-looking dating software, osDate is a much better bet. It has more functionality, looks slicker, is coded more cleanly, and appears to have a small team behind it, doing regular updates. Still open source (LGPL), too.

Reggae Reggae Sauce

My sister recently blogged about Reggae Reggae Sauce (as featured on Dragon's Den) on her blog. In return the Reggae Reggae Sauce Blog responded to her recipe. Go Clo! as they say in the RRS Blog (as I'm going to call it from now on).

Ever wanted a Roland TB303?

I love acid house. I think I've made that perfectly clear over the years. I discovered today that LadyAda has kits for making a clone of the Roland TB303 (the acid bassline generation synth/sequencer) called the x0xb0x (pronounced "zocksbox"). There's also a selection of great acid music written using it, available for free download. It sounds exactly like the real thing ("because it is the real thing", as they say on the website).

I've toyed with electronics in the past, but never got beyond making a circuit with a piezo buzzer and potentiometer that made an adjustable-pitch whine. For some reason, I just never got electricity. But the possibility of owning a 303 may be too much to resist. When's the 808 kit coming out, I wonder? Perhaps I'll get round to it when I retire.

Another "Rails - what the hell?!" moment

I took a look at Flickrlilli today and noticed that the tmp/sessions directory was absolutely full, chock full in fact, of ruby_sess (Rails session) files. So many in fact that when I tried to clear them out with the rm command, I got this:

[bart]$ rm *
-bash: /bin/rm: Argument list too long

Yikes! Just how many files were in there? In 13 years of using Unix, I've never seen rm refuse to process a set of files! I suppose this demonstrates the issues with storing sessions on the filesystem. I'm sure Flickrlilli isn't used that much, so I'm not sure where all these session files are coming from. Do AJAX calls generate Set-Cookie headers in the response or something?

I ended up clearing them out a few at a time with:

rm ruby_sess.a*
rm ruby_sess.b*
... etc. ...

Scary. Maybe Rails is trying to take over my hosting company's hard disk. Maybe DHH is secretly a Borg or something.

Open Source Showcase at OpenAdvantage

At OpenAdvantage, we keep running across West Midlands organisations using open source all the time. There are probably hundreds, maybe 5% (or less) of which we've had any interaction with. I'd like to uncover these hidden open source users, as it's great to hear about organisations successfully using open source.

So I suggested we host a "showcase" event, where those companies get to do lightning (10 minute) talks about what they've done with open source. I've just put up a flyer describing the showcase, which includes instructions about how speakers (we're looking for 10) can get involved. Unfortunately, we can't pay anyone for attending, but hopefully it will be great fun and a good opportunity for networking.

If you're interested, and you're based in the West Midlands, please get in touch, as we'd love to hear from you.

Syndicate content