Truncating strings with bash

This is particularly handy if you’re building up a comma separated list through concatenation and need to remove the final comma. The following snippet removes the final character from $test.

test="Hello world"
echo ${test:0:`expr length "$test" - 1`}

(Cribbed from the Advanced Bash-Scripting Guide.)

Convert Bank of Scotland statements to QIF

I made a little tool to convert the Bank of Scotland’s CSV statements to QIF format for import into your accounting software. It does the conversion in Javascript, so your information never leaves your computer. You can find it at http://www.joehalliwell.com/converter.html.

Restoring the Earth one tweet at a time

A recent project:

Environmental charity, Restore the Earth, today launched a new breed of web service encouraging people to take simple, positive actions for the environment. The campaign builds on Twitter using software developed by Edinburgh-based Artificial Intelligence consultancy, Winterwell. The campaign is being launched at the Live Nation concert with a video appeal voiced by Joanna Lumley.

Restore the Earth encourages people to take positive steps. The cumulative effect of these “handprints” will help to reverse ecological damage happening around the world. “The Handprint symbolizes our positive and proactive relationship to the Earth, as opposed to the negative “footprint” concept frequently referred to in the media,” said Andreas Kornevall of Restore the Earth. . The new system builds on Twitter, the popular micro-blogging service. The service has garnered media attention thanks to high-profile users like Stephen Fry. Twitter users, known as twitterati, exchange text-message sized descriptions of their current activities. This makes it a perfect fit for Restore the Earth’s handprint campaign.

But with Twitter’s popularity comes a problem: the campaign aims to generate thousands of handprints – far more than the Restore the Earth team can handle. So they asked Winterwell to build custom “chatbot” software to lighten the load. Founded by Dr Joe Halliwell and Dr Daniel Winterstein, Winterwell specializes in innovative intelligent software.

“Our twitterbot engages with the public and tries to respond intelligently to the greetings, questions and handprints it receiveѕ,” said Halliwell. “We can’t anticipate everything that people might say so our software is designed to learn as it goes. Artificial intelligence can’t yet handle a real conversation. But we think it can do just enough to be useful.”

You can get involved with the handprint campaign by following @rtearth on Twitter.

Switch off underlining for hyperlinks in OpenOffice

Our current document pipeline goes from Markdown (for content) through HTML (for structural transformations) to OpenOffice (for pagination etc.)

This is dandy but by default OpenOffice underlines hyperlinks and anything that looks like it could be converted into one (email addresses, URLs). It also colours them blue.

This is extremely annoying a problem, as our “structural transformations” include indexing, TOC, footnotes and other processes that produce useful hyperlinks that absolutely should not be underlined. Or blue.

Unless of course you want that Particle Physics Lab circa ’95 feel for your document.

Here’s the slightly non-obvious way to fix it.

  1. Bring up the styles and formatting dialog using Format > Styles and Formatting
  2. Choose the Character Styles section (second button from the left)
  3. Right click on Internet Link and choose Modify
  4. Go to the Font Effects tab
  5. Switch Underlining to (Without) and Font colour to Automatic

Ada Lovelace Day

Yesterday was Ada Lovelace Day and I pledged that I’d blog about women in computing. Epic fail.

But I did think about what to write. This involved a pleasant hour or so reading through the Women in Computing category at wikipedia. It reminded me how awesome Grace Hopper was — I’m a sucker for a uniform — but also sent me off on a dozen other fascinating trails. Programming language design, in particular, seems to attract many pioneering women. There are also significant contributions to the cryptography, internetworking and library studies ontology. But it seems kinda ridiculous to lionize these women who are already widely and justly celebrated.

So I’m taking a more personal tack. First, I want to salute all the brilliant women in computing it’s been my pleasure to study with, work alongside and befriend over the years. They know who they are. (Oddly, it seems I’ve avoided being taught by women…)

And I want to tip the propeller beanie to Dr Sheena Flower, who was the computer science teacher at the school where my mum used to work. It being a single-sex school, Dr Flower must have introduced many thousands of women to computing over the years. Score. But here are three gifts she gave me:

  1. With her PhD-fu she made me aware of Edinburgh as a centre of excellence for computer science.
  2. She explained “delta analysis” aka the method of differences to me at some point in the late 80s. This was the first time I saw an algorithm discover something.
  3. She lent me school computers — first BBC Bs, then PCs — over the summer holidays. This was my first opportunity to stay up late programming.

Thanks, Sheena!

Winterwell gets SMART award for pervasive gaming tech

PR blipvert follows. Normal programming will resume shortly.

Edinburgh-based firm Winterwell Associates has been awarded a SMART award to design artificial intelligence (AI) tools for the creative industries. SMART Scotland gives grants to small and medium sized enterprises to support R&D projects representing a significant technological advance for UK industry.

Founded by computer experts, Dr Joe Halliwell and Dr Daniel Winterstein, Winterwell provides research, development and consultancy on new media, web services, mathematical modelling and data mining. The SMART award will enable the company to develop intelligent technology for a new type of media: pervasive games – also known as alternate reality games (ARG), interactive drama, or more simply: adventures.

Like video games, pervasive games are highly interactive and story driven. But there’s a key difference. “In a computer game or a TV show, you visit another world. In a pervasive game, another world comes to you!” says Winterstein who like Halliwell holds a PhD degree from the University of Edinburgh. “New technology allows us to take the real world as the arena. Our characters will have Facebook pages, they’ll text and email players – even meet with some of them.” The result is to bring a drama or advertising campaign very much to life.

Though thrilling for players, game creators have to work round-the-clock to breathe life into their characters. “Time costs and scalability are key problems, and that’s where software can help,” explains Halliwell. “Our systems will understand plot devices and characters. And they’ll take the drudgery out of talking with players across different media platforms. Scotland is a world leader in video games. We believe it can become an international centre for pervasive gaming too.”

The creative and digital content industrіes are worth £5 billion to the Scottish economy and seen by many as crucial to the nation’s future development. In a report published last week, innovation quango Nesta estimates they could create 150,000 jobs across the UK and deliver a £85 billion boost to the economy by 2013.

Relocating git-svn checkouts

I use git-svn to maintain backups of our entire SVN repository. It’s fast, secure and easy; and the git clone of the whole repository history, branches and all uses about the same space as a subversion needs for a single revision, single branch checkout. No brainer.

Originally we used svn+ssh:// to provide remote SVN access. But as we’ve begun to collaborate with more and more people, we’ve needed to open up subtrees of our repository. And rather than creating user accounts for all these folk we’ve been giving them https:// access. This means that www-data needs to own the repository, so everyone needs to switch over to the new access scheme.

For regular svn checkouts that’s easy enough:

OLD_URL = `svn info; grep URL; cut -d" " -f2`
svn switch --relocate $OLD_URL $NEW_URL

Unfortunately git-svn has no equivalent sub command. Fear not. You could just clone from the new repository location, but that would be horribly wasteful. The following procedure (mainly cribbed from GitWiki) will see you right:

  1. Using svn checkout HEAD from the https:// repository. Cache your authentication credentials so git-svn can use them if necessary. This is important.
  2. If there haven’t been any commits since your last git-svn rebase make one now e.g. touch kick; svn add kick; svn commit -m "Kicking git-svn". This is important.
  3. Now, in your git-svn checkout edit .git/config. In the svn section, comment out the old url entry (hash or semicolon are valid) and add a new one.
  4. git-svn fetch to fetch a new revision from the new repository
  5. In .git/config comment out the new url entry and restore the old one.
  6. git-svn rebase -l to perform a local rebase
  7. In .git/config comment out the old url entry and restore the new one.
  8. Enjoy the fresh minty taste.

Managing your identity across social networks

AnonymousOne of the best sessions at yesterday’s BarCamp Scotland: Kate Ho led a high-traffic discussion about the pain and perils of managing your profile across Facebook, LinkedIn et al.

The key problem is that people have one name and one face but want to present different versions of themselves (aspects? personae?) to different groups. Friends get one picture; family another. Potential employers or investors a third. Now Facebook et al. offer rather detailed privacy settings which can achieve this objective or an approximate version of it. But — the complaint runs — it’s not obvious, not easy.

Tough.

My advice, my pragmatic advice, is that you stop trying to be two different people with the same name and the same face. No matter how many personae you think you have, there’s only one identity that counts. (Hint: it’s the one with the passport.) You only have one reputation. So, try not to do things that you’re ashamed of. Or come out of the closet. Problem solved.

And if you want to have more than one persona — which, I must stress, is a reasonable thing to want — bite the bullet and create one. Give it a different name and wear a fake nose for the photoshoots.

Eclipse crashing in 64-bit Ubuntu?

There are, it seems, crashers in recent Ubuntu 8.10 amd64 sun-java6-jre packages. Eclipse seems especially adept at finding them. Here’s the fix that worked for us. Add the following to your $ECLIPSE_INSTALL/eclipse.ini:

-XX:CompileCommand=exclude,org/eclipse/core/internal/dtree/DataTreeNode,forwardDeltaWith

And some background: