Grave Gravatars make comments seem sarcastic

Like many other blogs, this one uses so-called “globally recognised avatars”. or “gravatars” to provide each commenter with their own unique image which will match from site to site, and from visit to visit, so long as they use the same email address when commenting. It’s a clever idea – the supplied address is encrypted using a one-way hash (so there’s no easy way to get the email address from the hash), and that unique hash is used to return an image associated with the user.

If they’re so inclined, users can create an account at www.gravatar.com and set their own custom image. If they don’t then the site will algorithmically create an image for them, based on their email hash, ensuring that they get the same image every time they use that email address. There are a few types of algorithmically generated images – a geometric pattern, a monster, or a generated face (which they refer to as a “wavatar”). It is the latter that I use on this site, and it is the latter than is the source of the apparently sarcastic comments.

Wavatars are made up of several pieces that canchange with each hash: a background, a “face” shape, eyebrows, eyes and mouth. The problem is the mouth in particular, though the eyebrows can also be an issue: several of the mouth variations look unhappy, and the eyebrows can appear as a frown. An unhappy, frowny wavatar can give a completely different feel to even the nicest of comments. In fact the nicer the comment, the more sarcastic it seems to become.

Let’s look at some examples. The images below are all genuine gravatars for real comments that have been left on this blog, or on my webcomic. I’ve posted just the image and the opening or closing words of the comments, but omitted the full text and the posters’ details. See what your sarcasm detectors think about this lot:

When seeing wavatars like these, I can’t help but feel that there’s an implicit “…NOT!” that should be added, regardless of how complimentary the comment is.

The only real solution to this would be for the gravatar developers to change their palette of mouths to replace the miserable, downturned, grimaced variants with happier versions. Alternatively, if you do decide to leave a comment on my blog or comic, you might want to set your own gravatar image just in case. Or at the very least, choose your words to sound less sarcastic if they do get paired with a grumpy visage.

Posted in Miscellaneous, Tech, Web. No Comments »

Using Calibre with a Kindle 3 on Ubuntu 10.04

I’ve been waiting and watching the eReader world for some time now, waiting for the price (for a half decent product) to drop below about £100. The Kindle 3, starting at £109, was close enough for me to preorder one – although I actually ended up being swayed by the allure of the 3G version at £149.

While waiting for it to arrive I installed the Calibre eBook manager on my Ubuntu 10.04 (Lucid Lynx) system from the repositories and went trotting off to download a bunch of out-of-copyright classics. The new Kindle arrived yesterday, so I plugged it into my machine, fired up Calibre, told it to send the eBooks to the reader… and got an error message.

The problem is that the Kindle 3 is supported on the latest version of Calibre (0.7.16) but of course the version in the Ubuntu repositories is far older than that (0.6.42). Even the version in the Maverick repository is too old (0.7.13). One obvious answer would be to download the source of the newest version from the Calibre site and build it myself, but where possible I prefer to stick to software from the official repositories so that I get automatic updates.

A bit of googling resulted in the answer in this forum thread: the changes to support a Kindle 3 are fairly trivial and only occur in one Python file, so it’s very easy to modify an installed 0.6.42 version. When Ubuntu pushes updates I’ll simply tell it to keep my modified file until they push a version >0.7.16, and which point I’ll let it get replaced with the official repository version.

So for anyone in a similar situation, here’s the step-by-step guide to getting the version of Calibre in the Ubuntu Lucid repositories to support a Kindle 3:

  1. Install Calibre from the Universe repository using your package manager of choice. You can click on this link and open with “apturl” to achieve the same effect: apt://calibre
  2. Press ALT-F2 to bring up a “Run Application” dialogue.
  3. Copy and paste the following line into that dialogue:
    gksudo gedit /usr/lib/calibre/calibre/devices/kindle/driver.py
  4. Enter your password when prompted and you should see “gedit” (text editor) open with the file ready for editing.
  5. Scroll to the bottom of the file.
  6. Copy and paste the following code at the end of the file:
    class KINDLE2(KINDLE):
    
        name           = 'Kindle 3 Device Interface'
        description    = _('Communicate with the Kindle 3 eBook reader.')
    
        FORMATS        = KINDLE.FORMATS + ['pdf']
        PRODUCT_ID = [0x0004]
        BCD        = [0x0100]
  7. Save the file and quit “gedit”.
  8. Launch Calibre from the Applications=>Office menu and start managing your eBook collection for your Kindle 3.

Note that I’m no Python programmer, but my reading of the code suggests that this change might stop Calibre working with a Kindle 2 as it appears to override the existing KINDLE2 class. So if you’ve got both a Kindle 2 and a Kindle 3 and want to use Calibre with both you’re probably better off downloading the latest version and building from the source.

Solved: Ubuntu Missing Numpad Issue

If you just want the quick fix: try pressing SHIFT+NUM_LOCK. For the full gory story, as it affected me, read on…

A few weeks ago the numeric keypad on my work PC stopped responding. The Enter key still worked, but most of the other keys didn’t seem to do much. I wasn’t really surprised that it had finally given up the ghost: it was supplied with the machine seven years ago, and wasn’t the most deluxe keyboard in the world even when new. The silver painted coating had long since worn off of the well travelled parts of the device, and it had probably collected enough particles of my lunch over seven years to furnish a full banquet if anyone were foolish enough to shake it out.

It wasn’t until I was devoid of a numeric keypad that I realised how much I use one. Dotted quads for IP addresses trip lightly off the fingers of the right-hand rather than being laboriously thumped out of the row of digits at the top of the typewriter section. When programming my muscle memory flitted /* and */ comment delimiters into existence almost subconsciously. And when working with Inkscape the +,-,* and / of the keypad are my preferred route into the world of boolean operations on paths. I quickly resolved that a replacement keyboard needed to be found, pronto.

I could have asked work to buy me a new keyboard, but that would have got me another cheap model. Now I don’t mind the cheap HP model that had just died: it was quite a comfy keyboard to type on, and I hadn’t felt a desperate need to replace it in the past 7 years. But I’ve used other cheap (and some expensive) keyboards that were just horrible – one of my colleagues has a Dell monstrosity that nearly breaks your fingers to type on. But I knew that I had an old buckling spring keyboard kicking around at home that would be a delight to use every day.

An AT-to-PS/2 adaptor into a PS/2-to-USB adaptor later and I was typing away, number pad and all, with two side-effects. Firstly the clicky-clacky sounds emanating from my cubicle were enough to keep them awake – Hah! Secondly they made it a lot more obvious when I wasn’t writing code – D’oh!

Everything was rosy, I was a happy, clicky-clacky man. And then it happened: my number pad stopped working again. This was too much of a coincidence, so I went off a-googling and quickly found this to be a common issue, with the culprit being one of the keyboard accessibility options. From the search results I found it would appear that this has been an issue at least since Hardy Heron (8.04); the machine I’m using has the latest release, Lucid Lynx (10.04) so presumably this has been an issue for all the versions in-between as well.

Go to the System menu, select Preferences, then Keyboard, then the Mouse Keys tab. The issue was that this option had become enabled, meaning that my numpad no longer acted as a pad for entering numbers, but as a pad for controlling the mouse:

How had this happened? I wasn’t aware of ever going into that window and enabling that option – let alone having done it twice. It seems that there’s a keyboard shortcut to enable that mode – SHIFT+NUM_LOCK – which immediately toggles Mouse Keys whatever you’re doing at the time. With my frequent use of CTRL+NUMPAD for various Inkscape options, an accidental brushing of SHIFT+NUM_LOCK is a likely candidate for the cause of this confusion.

I can understand that having a keyboard shortcut for toggling this is invaluable for anyone who needs to use Mouse Keys regularly. However I’m not the only person to have been caught out by this, so I would suggest making it a little harder to enable by mistake. Specifically, there is an application called Assistive Technologies Preferences in which I specifically have “Enable assistive technologies” unchecked. Perhaps the state this checkbox should be honoured when a SHIFT+NUM_LOCK is detected.

There’s also a section for Accessibility in the Keyboard Shortcuts control panel. Why isn’t SHIFT+NUM_LOCK exposed there? That would perhaps be the best solution of all, as it would allow the toggle to be set to Disabled for users like me, who don’t want to trigger it by accident, but it would also allow an even more convenient shortcut to be defined by anyone who does want to access this feature regularly.

So if you’ve stumbled across this post because you’ve been affected by this issue, and a web search has sent you this way, try SHIFT+NUM_LOCK first. Unless you want to use your “broken” keyboard as an excuse to invest in a nice clicky-clacky affair.

Oh, and for what it’s worth the 7 year-old keyboard turns out to be fine. But I think I’ll stick with the buckling spring monster, if only for the sadistic pleasure of keeping my colleagues awake.

DIY Foxkeh SVG Wallpapers

I’ve long argued that there should be more SVG-based wallpapers available, so that users can modify or tweak them to suit their own requirements.

A step in the right direction is Foxkeh’s Wallpaper Creator – a web page which lets you combine an image of Foxkeh (Mozilla Japan’s cute mascot) with a background, calendar and Firefox logo to create your own desktop image (or mobile phone wallpaper, or Firefox Persona). The source images are SVG, letting you scale Foxkeh to a size that suits you.

Foxkeh's Wallpaper Creator

Unfortunately there doesn’t seem to be a way to save the finished SVG file, you can only export a bitmap image in PNG format. Although that’s fine for simple desktop wallpaper creation, it prevents any significant post-production editing. Perhaps that was intentional, as they don’t let you produce a wallpaper without a Firefox logo, either.

It’s currently in Beta, so maybe such an option will get added. In any case, if you’re after a cute, Firefox-promoting wallpaper with an optional calendar, it’s well worth trying.

Source: Mozilla Hacks

Posted in Miscellaneous, Web. No Comments »

R4 Cards Now Illegal in the UK

*Sigh*

R4 (and similar) cards have now been declared illegal in the UK. Personally I think this is a significant injustice, as it further erodes individuals’ ability to use their purchased hardware for non-approved (but legal) uses, under the flag of preventing piracy.

Don’t get me wrong, I’m generally against piracy and have purchased all my DS games legally. But I do own and use an R4 card. There are two reasons for this: firstly I do play the occasional homebrew game; secondly I use it as a means to conveniently carry all my games with me without the need to keep swapping cartridges. If there was a legitimate way to achieve this then I wouldn’t have any need of this “piracy device”.

The most worrying part of the article is this quote:

“The mere fact that the device can be used for a non-infringing purpose is not a defence,” read the ruling by Justice Floyd.

By that argument we’d better all get rid of our cameras, CD writers, PVRs, video capture cards and any other technology that may be used for copyright violations as well as legal uses.

I use an iPod as a means to aggregate hundreds of CDs into one device: my R4 is a means to aggregate dozens of games into one cartridge. I could put illegally downloaded music onto my iPod just as easily as I could put illegally downloaded games onto my R4. Yet one device is seen as a successful stalwart of consumer electronics, whilst the other is a scurrilous device used by pirates and ne’er-do-wells. The main difference I can see is that Apple are a big, rich company whereas the defendants in this case were small independent suppliers.

Yet again it would seem that money talks – or at least buys expensive lawyers to do the talking for you.

sudo? sudon’t! Stupid “sudoers.d”

If you don’t know what “sudo” is, then this isn’t the post for you… it’s going to get technical and Linuxy. Let’s start with the summary, as it’s the most important part of this post:

If you use /etc/sudoers.d/ don’t create files in the directory – create them elsewhere, ‘chmod’ them, and only then copy them in

Now for the story about how I came to this discovery…

For reasons that I’ll describe in a future post, I have a need to be able to trigger the “chvt” command from a keyboard shortcut. More specifically I want to run “gksudo chvt 1″, as using chvt to switch from a graphical screen to a console requires superuser privileges on my Ubuntu box. This prompts for my password, which seems a little redundant as I can use CTRL-ALT-F1 to the same effect without having to enter a password. So I decided to add an entry to the sudoers file in order to grant myself passwordless access to the chvt command.

I went wandering over to /etc and found not only the expected “sudoers” file, but also a “sudoers.d” directory. This directory contained a single README file, as follows:

#
# As of Debian version 1.7.2p1-1, the default /etc/sudoers file created on
# installation of the package now includes the directive:
#
# #includedir /etc/sudoers.d
#
# This will cause sudo to read and parse any files in the /etc/sudoers.d
# directory that do not end in ‘~’ or contain a ‘.’ character.
#
# Note that there must be at least one file in the sudoers.d directory (this
# one will do), and all files in this directory should be mode 0440.
#
# Note also, that because the sudoers file is not a ‘conffile’ in the Debian
# sense, and sudoers contents can vary widely, no attempt is made to add this
# directive to existing sudoers files on upgrade. Feel free to add the above
# directive to the end of your /etc/sudoers file to enable this functionality
# for existing installations if you wish!
#

That seemed like just what I wanted. I could create my sudoers command in a file of its own, safe in the knowledge that it wouldn’t get trampled by any future upgrades that affect the sudoers file itself. I copied and pasted the #includedir line into my sudoers file (using “sudo visudo”), then set about adding my sudoers directive in a file I named “chvt”:


> cd /etc/sudoers.d/
> sudo touch chvt
> sudo chmod 0440 chvt

BANG!

My terminal was filled with a lengthy backtrace, but scrolling back up to the top, I found this little nugget:

sudo: /etc/sudoers.d/chvt is mode 0644, should be 0440

Well thanks for that marvellous insight – I was just trying to set it to 0440 when you stopped me, you stupid machine.

Because I committed the heinous crime of creating an empty file in /etc/sudoers.d/ “sudo” won’t work at all. I can’t correct the permissions, I can’t delete or move the file: in short, I’ve lost administrator access to my machine. All for the sake of an empty file.

Now I can understand sudo throwing a wobbly and quitting if it can’t parse the sudoers file – blindly proceeding to read a malformed file could be a quick route to a buffer overflow attack or similar. But dying completely because an empty file has the wrong permissions seems a little draconian. Yes, that README did say “…and all files in this directory should be mode 0440″ – but “should be” isn’t quite the same as “…MUST be 0440, or I’ll DIE!!!”. Here’s an idea: if you don’t like the permissions, just don’t read the file – there’s no need to get all suicidal about it.

It seems that the only way to recover from this situation is to reboot the machine: either booting from a Live CD, or selecting the recovery console during the GRUB boot sequence. You can then remove or change the permissions of the offending file and everything will be back to normal after you restart the machine. It does seem like a lot of hassle caused by a zero length file though – thank goodness I didn’t do this on a production server!

All of which leads back to the summary at the top of this post: Don’t create files directly in /etc/sudoers.d/ If you do use the #includedir directive in your sudoers file, make sure you create your files elsewhere, set the permissions to 0440, and only then copy them into place.

A bettr Flattr dashboard

I’ve mentioned Flattr on this blog before, and now that I’ve been using it for a while I’d like to suggest some changes to the Flattr “Dashboard” which might make more effective use of the screen.

I would imagine that many Flattr users treat the Dashboard as their “Home” page on the site. It provides a quick overview of any recent flattery you may have received, shows you how dilute your own flattery is, and provides a few links to help you discover things to flatter. Here’s how it looks (click for the full sized version):

The site is fresh and modern, with a familiarly blog-like design which partitions it into the four commonly used sections of a Header, Footer, Main Content Area and Sidebar:

I’m specifically not going to talk about the Header or Footer areas. I’m just interested in the real meat of the page: the Main Content and the Sidebar. I’m also not going to suggest any radical changes to the content of these areas. I’m just going to suggest some ways in which they could be made more beneficial to a Flattr user without having to go so far as a radical redesign.

Main Content Area

Let’s get started with the Content Area – specifically the panel at the top:

There are three particularly useful sections in this panel: your Means, your Revenue, and the Current Click Value section. Keeping the Means and Revenue large and obvious is a good idea as it lets you immediately see whether you need to top your account up, and whether you’ve received some money to withdraw or transfer in the past month. The Current Click Value shows your Monthly Flattr Amount, the number of things you’ve flattered and as a result the value of each of those clicks.

What about the rest of the panel? The Monthly Flattr Amount section is completely redundant as a source of information as you can see the figure in the Current Click Value area. Yes, it also acts as a control to let you change your monthly Flattr amount, but do people really change this value often enough to warrant giving it so much space every time they visit the Dashboard? Better to turn the Current Click Value into a button or link which will reveal this control when clicked.

As for the Transactions sections, I would wager that most people only have a few transactions each month so don’t need to see the details on every visit. How about making this show just the date and value of the most recent transaction and the next upcoming one – the “View all transactions” link is still there if you want more details.

A bit of work in The GIMP to apply these suggestions results in the image below. It’s still got the same basic layout as the current version, but with less redundancy and just the relevant details shown. All the other information and controls from the original panel are still available via links or slide-out controls. You’ll notice that I’ve also filled up the space in the bottom right with a “Your user info” section, taken from the sidebar to free up a little more space there.

This version of the top panel only takes up about half the vertical space of the original design, but still offers the same functionality. That extra space can then be used to show more items in the tabbed lists at the bottom of the content area. On the subject of those lists, while I can understand showing two lines of the description for items in the “Things I have Flattred” tab, it seems a little excessive in the “My latest things” and “My top things” tabs. They’re listing my things – I don’t really need much description to remind myself about them. Cut that down to a single line and you can fit more items in.

So we’ve reduced the size of the top panel, resulting in more space for the bottom panel. And we’ve reduced the size of each item in the bottom list. Together these changes will free up the space to show a few more items in those bottom lists… but where are the “Show all” links? It would be nice to be able to open to an extended view of each of these lists rather than just losing things off the bottom as new entries appear at the top.

Sidebar

There are five panels in the sidebar, so let’s just deal with them one at a time, starting from the top…

Did you know?
Did I know that I could invite friends to join Flattr? Why yes I did, because you tell me that every single time I access my Dashboard. If you must have a box like this, at least vary the tips from time to time. Better still lose the box altogether, or just show it occasionally as a reminder.

Your user info
I’ve already dealt with this one by moving it to the Main Content Area. Even without any of the other changes I’m suggesting here, there’s plenty of space in the existing design to move this information across. It doesn’t serve any real purpose living in the sidebar, so move it or get rid of it to free up some space.

Newest things on Flattr
Undiscovered things
I’ll deal with both these as one entry as they’re similar. “Undiscovered things” shows Flattr users’ submissions that haven’t yet been flattered at all. It can be a great way to discover interesting and underrated sites… but it can also reveal that there’s a reason why some things never get flattered ;)

I’m not quite sure what “Newest things” shows. All the entries here usually have just a few flattrs, so I don’t think it’s as simple as “most recently flattered” (otherwise more popular things would show up too). However they populate this list, it’s another good way to discover items that you might not otherwise have stumbled across.

Both these lists are great when you’re in a random browsing mood – except for the fact that they’re too short. These should both be doubled to show 10 items.

All time top 5
At the time of writing, the list looks like this:

This is actually quite a shocking image because, for the first time in weeks, the number 4 and number 5 spot have swapped position! Other than that, this list has been pretty much the same for as long as I’ve been a Flattr member. There’s a positive feedback mechanism at work here: the top rated get additional visibility from appearing in this list, so are more likely to get flattered, so are more likely to stay on the list…

What’s most depressing is that only two of the entries here are for “real” content. The other things are all to do with Flattr itself. If it’s to flourish, Flattr needs to be a way to find (and fund) exciting and interesting content – not just a self-referencing collection of closed loops back to Flattr itself, or the few other things that manage to reach the top 5.

Personally I would lose this panel completely, replacing it with a “Random things” panel which shows entries selected at random, regardless of their existing popularity.

The sidebar has now been reduced to three panels (“Latest”, “Undiscovered”, “Random”), each showing ten items. I would also have a “More…” link on each of these to open a page full of items – ideal for those rudderless browsing sessions we all sometimes have.

Conclusion

I’ve deliberately steered clear of suggesting any radical changes, but instead focused on incremental changes that I feel could make the Dashboard a more functional and useful part of the Flattr site. Of course this is just my opinion – perhaps you do change your monthly Flattr amount regularly, or you love the Top 5 panel. Feel free to leave a comment with your own ideas for the Dashboard – and if you like my suggestions… well, there’s a little orange button just a short mouse move away that would appreciate your click ;)

Posted in Miscellaneous, Tech, Web. No Comments »

Mozilla Add-ons workshop, London 2010

Last night I went to the free Add-ons workshop that Mozilla hosted in London. It was an informative and interesting evening – well worth the trek down to London, even if it did then lead to a late-night trek back again.

Particular highlights of the evening were:

  • Myk Melez demonstrating that he’s a braver man that I am as he coded a small Jetpack extension as we watched – and it worked first time!
  • Tobias Leingruber’s wonderful presentation about his artzilla.org website and the creation of Firefox extensions as artistic works. Easily the funniest presentation of the evening.
  • Paul Rouget’s amazing demos. His French accent was a little thick at times – especially when he got excited. But the fact that he did get excited is telling in itself. Keep an eye on hacks.mozilla.org, especially as we get closer to the release of Firefox 4, as I’m sure most of his demos will appear there at some point.

There was also a stand with some free Firefox merchandise – mostly badges, pens and lanyards – but I did pick up a sheet of Foxkeh stickers for my girlfriend who is a big fan of the cute character, and uses the Foxkeh monthly desktop backgrounds on her computer (you might want to read this if you’re an English rather than Japanese speaker):

I’ve often wondered why the EU and US arms of Mozilla don’t make more use of Foxkeh in their marketing. He gets commented on by a lot of people that see my girlfriend’s desktop, which inevitably leads to conversations about what Firefox is, and how it differs from Internet Explorer. A mascot that leads to spontaneous discussions like this is surely something that should be used more widely.

Update: Chris Heilmann’s blog covers this event in more detail, and includes some videos of Paul Rouget’s demos.

Although many aspects of these demos will only become available in Firefox 4 (or nighties and pre-release versions thereof), it’s worth noting that SVG clipping, masking and filtering of HTML (including Ogg Theora video) works right now in Firefox 3.5, as demonstrated by my own post on using Inkscape filters in Firefox.

Posted in Tech, Web, XUL. No Comments »

Project Canvas

Posted in Miscellaneous, Tech. No Comments »

Focus in XBL handlers in Firefox 3.6

Most people can safely ignore this post for fear of melting your brains. It’s only here to help people who stumble across the same problem I did, and go googling for the terms I’ve put in the post title.

For a while now Gecko has supported a non-standard CSS extension called “-moz-user-focus“. The main use of this (at least in my code) seemed to be to prevent particular XUL elements from being focusable by setting it to “ignore”.

When I recently upgraded to Firefox 3.6 I found that the focus handler in my XBL widgets was no longer getting called – with the result that I couldn’t even focus them using $(“objectName”).focus() in Firebug. It would appear that the default state for XBL-bound elements has changed from focusable to non-focusable.

The fix for this is simply to add “-moz-user-focus: normal” to the CSS styling of your XBL-bound element. It works whether added directly to a style attribute or in a referenced CSS file. With this in place my focus handler now fires as it used to, and the software works as expected once again.

Posted in Tech, XUL. No Comments »