Skip to content

{ Category Archives } Tips

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

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 [...]

Tagged , , , ,

Penhayl Cottage website — design notes

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 [...]

Tagged ,

How to pull fields from MEDLINE the easy way

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 [...]

Tagged ,

Finding the dimensions of a PostScript image

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 [...]

Tagged , ,

Awesome ways to save audio streams for future listening

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 [...]

Tagged

RetriableTask — a generic wrapper for retrying operations in Java

A couple of times recently I’ve needed to write methods that retry up to n times if an error occurs, and surprisingly, couldn’t find any standard patterns to accomplish this on the web. So I wrote my own. All comments appreciated (there may well be massive holes in my logic but it works so far).

Tagged , ,

Running RasMol from Firefox and Finder in OS X

A colleague asked me today, how can we set up someone’s Mac to open .pdb files in RasMol when clicking a .pdb link in Firefox. This turned out to be a non-trivial operation. Here’s how I did it, with RasMol 2.7.2 and Firefox 3.0.7 on OS X 10.4.

Tagged , , ,

Execute SQL outside of a transaction in Hibernate

I hit upon a snag today — while PostgreSQL requires that certain maintenance commands (e.g. vacuum analyze) are executed outside of a transactional context, it’s actually quite hard to get at Hibernate’s underlying database connection directly. Each Session object has a connection() method which returns a JDBC connection object, but this actually turns out to [...]

Tagged , ,

Finding out last VACUUM/ANALYZE times in PostgreSQL

When was my database last vacuumed or analyzed? This took me a while to figure out from googling around so I’ll put it here for posterity, short and sweet. select relname, last_vacuum, last_analyze from pg_stat_all_tables where schemaname = 'public' Add the columns last_autovacuum or last_autoanalyze if you use those features. Andrew.

Tagged

Connecting Apache to Tomcat: mod_jk

I spent yesterday afternoon trying to get Tomcat web apps served via Apache, since that decouples the public interfaces of our web services from their implementation — people don’t need to know when they hit a service that it’s running on a Tomcat server on port 8080. There’s a connector to allow this, mod_jk, but [...]

Tagged ,