biotext.org.uk

Echoes of the past

by Andrew on Dec.31, 2009, under Microposts

In reflective mood, because it’s the end of the year, and prompted by some biographical reminiscences on Charlie Stross’s blog, I just found the contact details for my FidoNet BBS in an old nodelist from 1995.

Happy new year, everyone.

Leave a Comment : more...

How to make sure your media disk is mounted before starting iTunes

by Andrew on Dec.30, 2009, under Tips

This is an Apple Annoyance that’s been bugging me for a while — if your iTunes library is on an external HD, and you start iTunes without it mounted, the bloody thing can seriously mangle its own library index (under Tiger at least).

So I’ve replaced my iTunes Dock icon with a little AppleScript that checks whether said disk is mounted first:

1
2
3
4
5
6
7
tell application "Finder"
	if exists (disk "LaCie") then
		tell application "iTunes" to activate
	else
		display dialog "Don't start iTunes without LaCie external disk mounted." buttons {"OK"} default button 1 with title "Cannot start iTunes" with icon stop
	end if
end tell

Compile, save as script, add to dock, bingo. (Obviously, replace LaCie with the name of your external HD, as it appears in /Volumes when mounted.)

For extra points, you can give it iTunes’ icon too. Just get Info on iTunes and select the little icon in the top left (not the big one under Preview). Then just cmd-c, select the same icon in the script’s info window, and cmd-v.

Leave a Comment : more...

Help! Eclipse won’t believe I have Maven 2.2.1

by Andrew on Nov.26, 2009, under Questions

I have a project (built from an AppFuse template) that requires Maven 2.2.1. So I upgraded to this (from 2.1.0) and set my path and my M2_HOME and MAVEN_HOME env variables.

Then I ran mvn eclipse:eclipse and imported the project into Eclipse (Galileo).

However, in the problems list for the project (and at the top of the pom.xml GUI editor) it says:

Unable to build project ‘/export/people/clegg/data/GanymedeWorkspace/funcserve/pom.xml; it requires Maven version 2.2.1

This persists whether I set Eclipse to use its Embedded Maven implementation, or the external 2.2.1 installation, in the Preferences -> Maven -> Installations dialog.

I’ve tried closing and reopening the project, reindexing the repository, cleaning the project, restarting the IDE, logging out and back in again, everything I can think of! But Eclipse still won’t believe I have Maven 2.2.1.

I just did a plugin update so I have the latest version of Maven Integration for Eclipse — 0.9.8.200905041414.

Does anyone know how to convince Eclipse I really do have the right version of Maven? It’s like it’s recorded the previous version somewhere else and won’t pay any attention to my changes :-(

If you have any clue whatsoever — please drop an answer here

Thanks!

Leave a Comment :, , more...

MacBook keyboard hacks for # (hash/pound/numbersign)

by Andrew on Nov.07, 2009, under Tips

One of the few annoying things about my oldish MacBook Pro is its keyboard, for example a few unresponsive keys, but particularly the lack of a # key. It’s a UK keyboard, and has £ for shift-3, and # is hidden in alt-3 (not labelled).

This is fine in native desktop apps, but less fine in some text-mode programs (e.g. vim), when for some reason this often produces a superscript 3 instead.

So I’ve set up a custom keyboard mapping in iTerm to map F3 to #, which works nicely. However!

If I’m SSHed in to a remote Linux machine (or even my local Ubuntu VirtualBox) neither of these keys work in X apps. But, xmodmap (via the config file ~/.Xmodmap) can help. For some reason, Macs all have a dedicated key for these characters — § and ± — which no-one ever uses. But with this line in ~/.Xmodmap we can remap it to produce #:

keycode 18=numbersign

UPDATE: I’ve found a better way which works pretty much globally…

Using Ukelele you can copy the British keyboard layout and then remap keys to your heart’s content. I’ve moved the § character to the alt-§ key combination, in case I ever need it, and moved the # character to the raw § key. This seems to be respected almost everywhere so I don’t need to mess around with alt-3 or F3 any more. Joy. It also works over JollysFastVNC to a remote RealVNC server, which none of the other methods did.

Unfortunately, things still aren’t perfect. If I actually open a VirtualBox console session into GNOME on the local Ubuntu VM, the pointless § and ± key actually produces < and > so neither of these tricks work. In fact, I can’t get anything to generate a # even though I have the MacBook Pro Intl keyboard layout selected in GNOME. Any ideas?

UPDATE 2: YES!! I’ve finally cracked it for VirtualBox. With the help of the xkeycaps command, I discovered that X the keycodes coming into Ubuntu weren’t what I thought they were — somewhere the Mac-ness of the keyboard layout was getting lost. It turned out that the § key was generating keycode 94 instead. So I set up this in .Xmodmap on the Ubuntu VM:

keycode 94=numbersign

Now it works in VirtualBox too. Leave gifts of thanks below :-)

Leave a Comment :, , , , more...

Penhayl Cottage website — design notes

by Andrew on Oct.17, 2009, under Tips

The website is now live for Penhayl Cottage, a self-catering holiday cottage in Cornwall, run by my family. I’m not much of a web designer, but thankfully there’s a lot of free tools around these days that make it easy for an amateur to do a decent-looking job.

The layout was based on a free stylesheet from Free CSS which a great resource for the design-impaired like me. The image gallery on the right side uses a neat Javascript library called Lightbox2.

The Google Map doesn’t use any fancy techniques like their Javascript API or anything. It’s just embedded in an iframe. This page was very useful in getting the URL parameters right for the marker and the zoom level.

The Flash video player is a very flexible open-source app called Flowplayer, and I used ffmpeg to convert the original MPEGs into FLVs to play in it.

I used the oldish version of iMovie that came with my Mac to compose the video clips into a single long movie for the downloadable versions, and to export the H.264 m4v version for the iPhone, although apparently there’s other tools like iSquint that can also do this. Incidentally, iMovie is a bit weird about file formats — it wouldn’t open the mpeg files which came from the original DV camera but arrived on a CD-ROM. It will happily open the same format if you plug the camera in directly, but the camera was in Cornwall and I’m in London. Thanks Apple. Fortunately, this thread explains how you can fool it into thinking a disk image containing the files is actually a plugged-in device.

I also used ffmpeg to transcode the m4v back into an mpeg-1. The results aren’t especially pretty but it will play on most players out there, and anyway, this is just a backup plan for non-Flash-users.

Andrew.

Leave a Comment :, more...

How to pull fields from MEDLINE the easy way

by Andrew on Oct.08, 2009, under Tips

In response to this thread on FriendFeed

curl -s 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=19614587&retmode=text&rettype=medline'|egrep '^(MH |DP )'

This will pull all the MeSH keywords and the date of publication from the article with PubMed ID 19614587. Stripping the field codes from the response is left as an exercise to the reader (but can be done trivially with a Unix command line utility).

Or for multiple documents, just use comma-separated IDs:

curl -s 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id=11877539,11822933,11871444&retmode=text&rettype=medline'|egrep '^(PMID-|MH |DP )'

In this case it’s good to include the PubMed ID in the results so you know which values come from which doc.

There’s a full list of the MEDLINE field codes here, and the docs for efetch are here.

If you want to actually search by content, try esearch, which will return a list of IDs you can send to efetch.

For simple queries like this, XML is totally overkill.

Leave a Comment :, more...

Finding the dimensions of a PostScript image

by Andrew on Sep.08, 2009, under Tips

If I have images in .ps or .eps format, how can I tell how big they are? i.e. how big would they print out at ‘natural’ size without any scaling?

If they have a correct bounding box defined — more likely with EPS than PS files — this bit of Perl will show you the width and height in cm:

#!/usr/bin/env perl
 
use strict;
use warnings;
 
# Usage: measure.pl <postscript-file>
# Or send it some data on stdin.
# Assuming the BBox is correct, it'll tell you the 
# dimensions in cm.
 
while( defined ( my $line = &lt;&gt; ) )
{
    if( $line =~ /^%%BoundingBox:\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/ )
    {
        my( $llx, $lly, $urx, $ury ) = ( $1, $2, $3, $4 );
        my $x_pts = $urx - $llx;
        my $y_pts = $ury - $lly;
        my $x_in = $x_pts / 72;
        my $y_in = $y_pts / 72;
        my $x_cm = $x_in * 2.54;
        my $y_cm = $y_in * 2.54;
        printf "%.1f %.1f\n", $x_cm, $y_cm;
        last;
    }
}

Dead handy when preparing images for a paper.

PS if you are hazy about the difference between PS and EPS — like me — have a look at this article.

3 Comments :, , more...

Awesome ways to save audio streams for future listening

by Andrew on Aug.25, 2009, under Tips

For a start, you can use mplayer to save the stream to a local disk:

mplayer -bandwidth 10000000000 -cache 32 -dumpstream -dumpfile output_file.ra 'rtsp://some.server/some_stream'

The huge bandwidth parameter will make sure that no throttling happens (at the client side anyway) — i.e. you can download hours of audio in a few seconds.

The dumpstream parameter writes the stream out byte-for-byte in the format it arrives in, e.g. RealAudio in the example above. But you can use ffmpeg to decode a RealAudio stream into a wav, and lame to re-encode it as an mp3, on-the-fly:

ffmpeg -i output_file.ra -f wav - | lame - output_file.mp3

N.B. That can be quite processor-intensive, but hey, what’s dual-core for??

ffmpeg will tell you what the bitrate of the stream is, so you can use lame’s -b switch to make sure you’re not re-encoding it at a vastly higher quality than it’s actually capable of.

e.g. for spoken word:

ffmpeg -i output_file.ra -f wav - | lame -b 64 -f - output_file.mp3

(-f = fast mode, slightly quicker encoding for less quality per bit)

Or if you’re feeling especially boffiny, use a named pipe so you don’t have to save the original stream to the hard disk:

… which is apparently possible but I haven’t got it to work yet. If you know how, leave a comment before I figure it out :-)

Andrew.

Leave a Comment : more...

London bio people — pub tonight

by Andrew on Jul.30, 2009, under Uncategorized

The biogeeks are getting together again at The Miller from 6ish tonight. All are welcome.

Leave a Comment more...

More live gigs!

by Andrew on Jun.26, 2009, under Announcements, Events

I’ll also be running an interactive workshop on FuncNet at:

The EMBRACE-ENFIN workshop on Expression, Interactions, and System Level Modeling

Helsinki, 5th-6th October 2009

Leave a Comment :, , more...

Search

Use the form below to search the site:

Leave a comment if you can't find what you need.