Archive for July, 2008

Jul 16 2008

River in Egypt for sale, must act quickly

Published by Dougal under Computing

It’s strange to think there are people who still see the majority of adverts online. AdBlock will revolutionise your life, make you five pounds thinner, get rid of unwanted facial hair, get rid of embarrassing age spots, and make browsing the web considerably nicer.

Something which is still difficult to do is block text adverts — though it’s not impossible. The “rule” for AdBlock Plus, if the text advert is in a labelled <div> element, is:

#div(classname)

This does mean delving into the HTML for a page to find a good candidate element to remove, but it’s not a terrible hardship and only need be done once. And I’ve done the hard work for Facebook as an example. To block the text adverts on Facebook, use

#div(ad_story)

But then Facebook adverts are so hilariously bad it’s almost a shame to block them. You’d think data mining would be at its most sophisticated for automated marketing… but no. All I get are adverts for gay bars and chiropracters. Clearly I fit the demographic for being doubly in denial!

5 responses so far

Jul 15 2008

Political fearmongering

Published by Dougal under Politics

New Yorker cover Apparently the cartoon on the front of The New Yorker depicting Barack and Michelle Obama as Islamic terrorists burning the Stars and Stripes in the Oval Office isn’t good satire because

satire needs to be completely over-the-top, and this isn’t.

Just roll that one around inside your head for a while.

As one commenter on the Guardian blog says:

In any country there are sophisticated people capable of seeing through several layers of irony and there are those whose humour and comprehension is limited to custard-pie-in-the-face.

…and then there are those who claim sophistication but would censure others for fear of the reaction.

Comments Off

Jul 12 2008

Flatwarming panic

Published by Dougal under Food, Home, Work

So we foolishly decided that we’d get the place redd up if we arranged for a whole bunch of people to come over all at once. Well, they’re coming over this week but there doesn’t look to be much happening on the cleaning-and-tidying front.

I built the final kitchen chair today, so that’s one fewer thing taking up space in the living room. But there’s still loads of boxes full of CDs, DVDs and books which don’t have a home because we have no shelving.

Among today’s minor successes are having a proper set of bathroom towels, and plugging my desktop computer back in. Still no internet connection, but I did put on some photos of my parents’ trip to China, so there’s more variety on the screensaver. I like watching photos as screensavers. (I’ve been teasing my colleagues at work lately by using some of Helen’s food photos as my screensaver. I got back to my desk the other day and they’d turned off my monitor to avoid seeing further tantalising food shots!)

Just now I’ve got some baguettes in the oven, but they’re too slim and are rather too much like breadsticks. But it’s all about the practice…

Comments Off

Jul 12 2008

Simplifying arrival times in the BusTracker library

Published by Dougal under Programming

A few days ago I posted a brief walk through my Haskell library for querying the realtime bus data in Edinburgh. I’ve since made a couple of minor alterations to that library to make later operations easier.

The change was probably always going to happen because of the way data is supplied by the remote service. If a bus is due imminently (I don’t know the exact details, maybe “within the next minute”?) the information returned is "DUE". Up to on hour into the future the result is the number of minutes, again as a string: "13". But anything more than an hour is reported as the actual time, in 24-hour format with a colon to separate hours and minutes: "15:36".

This is exactly the format used on the LCD stands in the street, which is quite easy to read (especially as they never seem to show anything more than an hour away). But for parsing by machine it’s a real mess. Last time around I just left these strings as they were, passing them on to the human at the end in the hope they would still make sense.

That approach is certainly easier but means the library is less flexible to use. So I made the String type a parameter for the Result datatype, rather than built-in (ie, it’s now Result a instead of Result). So I can choose what type I want to represent the arrival time.

data Result a
  = R {resultBusNumber   :: String,
       resultDestination :: String,
       resultDisabled    :: Bool,
       resultArrivalTime :: a,
       resultEstimated   :: Bool}

The bonus is that not only can I choose my type, but I can fairly easily convert between types when I want a different representation. Result is an instance of Functor so I can quickly convert any Result String to Result TimeDiff, which is what I actually do by default.

The original types (though written as strings) can be easily classed as time differences (due, 3 minutes from now, etc.) and exact times (6.15pm). This could be simply represented as Either TimeDiff CalendarTime though this didn’t occur to me at the time. But more importantly, this would just put more strain on the library user, since whatever calculations they do must cope with both types. So I opted to convert them to a common one.

Comments Off

Jul 11 2008

Highlighting current diffs in the VIM editor

Published by Dougal under Programming

Some of you might regard all these technical posts as verging on noise, but that’s your loss.

If there are any VIM users out there (declare yourselves! you have nothing to lose but your RSI!) I’d like to highlight the existence of this plugin, called SCMDiff. It’s pure genius, so it is but. (If someone knows what the Emacs equivalent is, be sure to comment!)

With a deft Ctrl-D it diffs the version you’re working on in the buffer with whatever was stored in the repository. But it doesn’t show you the diff file: it actually uses that information to highlight the lines you’ve changed in your current buffer. So you know exactly what changes you’ve made to the file before you save, and can remove unneeded changes before saving.

The best part is that is seems to work with most version control systems. It’s been tested with Subversion, Mercurial and I can confirm it works out of the box with Darcs too! Magic.

The big challenge is whether it works with ClearCase, the software that must do things differently. (Where by differently I of course mean wrong.) With a bit of fiddling it does, though it breaks the script for everything else. This isn’t a problem if you only ever use ClearCase though.

--- scmdiff.vim Fri Jul 11 11:52:04 2008
+++ ccdiff.vim  Thu Jul 10 16:39:37 2008
@@ -1,5 +1,5 @@
 if !exists("g:SCMDiffCommand")
-let g:SCMDiffCommand = 'svn'
+let g:SCMDiffCommand = 'cleartool'
 endif
 
 if exists("loaded_scmdiff") || &cp
@@ -28,7 +28,7 @@
 let cmd = 'cat ' . bufname('%') . ' > ' . tmpfile
 let cmd_output = system(cmd)
 let tmpdiff = tempname()
-let cmd = g:SCMDiffCommand . ' diff ' . g:scmdiff_rev . ' ' . bufname('%') . ' > ' . tmpdiff
+let cmd = g:SCMDiffCommand . ' diff -diff_format -predecessor ' . g:scmdiff_rev . ' ' . bufname('%') . ' > ' . tmpdiff
 let cmd_output = system(cmd)
 if v:shell_error && cmd_output != ''
 echohl WarningMsg | echon cmd_output

If you’re not using ClearCase then you just change the SCMDiffCommand argument to whatever your system’s tool is called — darcs, hg, … Happy coding!

2 responses so far

Jul 10 2008

How many angels can dance on the head of a pin?

Published by Dougal under Bad Science, Politics

This must be what it feels like to fall into a bottomless pit of inanity, also known as a parliamentary discussion about “alternative” medicine. I think the defining point of the discussion is this short note by Oliver Heald (Cons):

My hon. Friend must not forget aromatherapists. The Aromatherapy Organisations Council has done a great deal of work to move towards regulation of the profession, and would be interested to hear the Minister’s remarks on that.

And so on with other contradictory approaches to health. The important thing is not whether these approaches are effective or worth the money — but whether there is a council of idiots to represent it. In short, whether they are vocal enough.

3 responses so far

Jul 09 2008

A simple and delightful cocktail for you

Published by Dougal under Food, Home

I popped out the office today to pick up some martini glasses — you know the standard shallow-cone cocktail glasses with stem. They also have a silver rim, like all those silvered test tube experiments from Standard Grade Chemistry that I never did. You can see the glasses here.

I got home and pulled out my cocktail-fu. Made up a couple of White Ladies when Helen arrived.

How to make a White Lady

You will need:

  • 1 lemon
  • Cointreau
  • Gin
  • Ice

I got a little over 50ml of juice out of my lemon, enough for two glasses, but I guess they’re all different. You will need to:

  1. Squeeze your lemon.
  2. Half-fill your shaker (or a sturdy pint glass) with ice cubes.
  3. Add 50ml (two shots) of gin.
  4. Add 25ml (one shot) of Cointreau.
  5. Add 25ml of lemon juice.
  6. Put a lid on and shake vigorously until the outside of your shaker frosts up.
  7. Strain into a martini glass.

It will probably look fabulous, like ours, and taste it too.

Cocktail against the sun

If you’re a real pro (or have too much time on your hands) you can pop in a measure of egg white too, which makes a froth on top. This strikes me as being a hell of a faff and not worth it, kids.

After we ate — last night’s remake of Rapid Ragu, with a bit of rice to bulk it out — Helen decided to make some more with a slightly different recipe. Which explains any typos in this post, I think.

One response so far

Jul 09 2008

Gnome screensaver and Clearcase revert

Published by Dougal under Computing

Little snippets of information that I’ve been meaning to write up…

Screensaver images in Ubuntu

The XScreensaver configuration application was always a bit ugly and not sensibly laid out — but one thing it definitely did was provide easy access to all the options you’d need to fiddle with.

Now that GNOME supply their own GUI for screensavers they have decided that simple configuration of your screensaver is not allowed.

If you’re using some of the XScreensaver hacks you can put this in a file called .xscreensaver in your home directory.

imageDirectory: /path/to/screensaver/images/

Otherwise you have to make a “theme” (ugh), most easily by copying one that already exists. For example, to make your own slideshow:

$ cp /usr/share/applications/screensavers/cosmos-slideshow.desktop ~/.local/share/applications/screensavers/my-slideshow.desktop
$ $EDITOR ~/.local/share/applications/screensavers/my-slideshow.desktop

and change the --location= to point to your preferred image directory. It’s all quite pitifully backward compared to how it used to be.

Clearcase revert command

This has driven me nuts for ages, and it’s only recently dawned on me what a doofus I have been.

Clearcase is a centralised version control system which requires you to “check out” a file before you can edit it. If you edit the file you’ve checked out, it seemed there was no way of reverting it to the unchecked state. There is no cleartool revert command.

Of course, the unique thing about Clearcase is that all work is done in a DB-backed “view” which provides full access to the version history using special path syntax. If you append @@version to a filename then the filesystem will delve into the versioned history and pull out the right one. So you can use standard diff tools to compare different versions like so:

$ diff foo.c@@/mainline/branch/twig/3 foo.c@@/experimental/LATEST

Quite clever (though notoriously flaky and unwieldy to use). And you have to learn to think differently. If you create a task branch off /main/branch that’s called /main/branch/task_branch and so on down the version tree. Each individual revision in a branch is numbered (where LATEST is a synonym for the highest number).

So, after all that explanation, one can revert a file by just copying!

$ cp foo.c@@/mainline/branch/task_branch/0 .

If you want to automate this a bit, it’s easy to find the version of a particular component by running:

$ cleartool describe -predecessor foo.c

You can pull out the right value from that easily enough and make your own cleartool revert!

6 responses so far

Jul 07 2008

Bespoke suit from travelling tailors

Published by Dougal under Life

A man got on the bus in front of ours yesterday wearing an amazing scarlet zoot suit and absurdly long crocodile-leather shoes. The only thing he was really missing was the hat. This cat had style… and he helped an old lady onto the bus. Style and class.

On Thursday I’ll be going to get measured up for some kind of suit, though I don’t know what. I think a Thirties-style jazzy red number would be somewhere outside my comfort zone — not to mention, I would find even fewer occasions to wear it than I normally do with a suit.

I don’t wear suits often, but it’s not because I don’t like suits. Half the fun of watching the Ocean’s Eleven remake was the really nice suits. Nice suits are nice. And nice suits are expensive…

So on Thursday after work I’ll be heading along to some hotel (I can’t remember the details) where Raja Fashions will have hired a suite for the day. And I will be measured and photographed and I’ll choose a suit, of some kind. The idea is that the company’s army of slave labour willing workers make a fine bespoke suit for you at less-than-Savile Row prices, which arrives in the post a few weeks later. We shall see!

Despite some good intentions to go into some of the nicer stores in Edinburgh at the weekend and look at suits, I did not. So I have little idea of what suits (!) me or what I want. As mentioned, I don’t wear suits often and I don’t see suit-wearing becoming a regular part of my day job, so I think I will aim for something I can feel stylish in. (And get invited to more cocktail parties.) What that means in terms of cut and cloth and colour I have no idea. This will be an adventure, and I’ll let you know what happens!

One response so far

Jul 05 2008

Internet access: easy in bars, difficult at home

Published by Dougal under Home, Networking

We’ve been fighting with Virgin Media for about 6 weeks now to get our net access transferred over to the new flat. The entire time we’ve been paying for a service we do not have. This will definitely require remuneration when we finally get a service.

We’ve been surviving thus far with a couple of open WiFi connections that we could pick up. Neither were very close to us — this requires careful positioning of laptops to maintain signal levels — but they were still usable.

Were usable. Past tense. On Thursday night both of the networks we used disappeared. One of them hasn’t come back and the other has but appears broken. I can occasionally get an IP address but it doesn’t forward packets past the router. :-( We are bereft, cast loose in a sea of microwaves, all encrypted… we’ve been really suffering!

We’re currently in Montpeliers, downing cocktails and jealously guarding access to the power socket that is powering my laptop. I can highly recommend their Whisky Sour, which is really delightful, and the Espresso Cocktail, which was apparently made with the wrong ingredients but tasted grand anyway. It’s pouring with rain outside and I feel no motivation to get wet.

Email and blogging may be rather light this weekend because we’ll be snatching whatever access is available in cafés and bars (carrying an Eee around is awesome). Please bear with us!

One response so far

« Prev - Next »