Saturday, November 18, 2006

Making the GCN More Useful with GreaseMonkey

For people who do research on gamma-ray bursts, one of the central clearing houses is the GCN. This service provides hot new results about the most recent GRBs. Unfortunately the presentation is a little spartan: most of the pages are plain text and there is no cross-linking between circulars and to GRBs. Here is an example circular:

Mozilla Firefox
TITLE:   GCN CIRCULAR
NUMBER: 5818
SUBJECT: GRB061110A: Correction to GCN5817
DATE: 06/11/12 19:45:13 GMT
FROM: Johan U. Fynbo at U.Copenhagen <jf

Johan P. U. Fynbo (DARK) report:

Unfortunately I made an error in the gain-co
reported in GCN #5817. Here are the correct
photometry. In the NOT images taken about 8

As you can see, it's just plain text. Because of that, the page title is "Mozilla Firefox" and there are no hot links on the page.

I've created some GreaseMonkey scripts which tweak the contents of GCN notice and circular pages. The first one, GCN GRB Linker, adds links to each GCN circular and notice for every reference to a GCN or GRB that it can find. It correctly handles multiple GRBs on one day (i.e. it points to the single repository on the GCN for all bursts from that day). Let's see
how that looks:

Title: GCN #5818: GRB061110A: Correction to...
TITLE:   GCN CIRCULAR
NUMBER: 5818
SUBJECT: GRB061110A: Correction to GCN5817
DATE: 06/11/12 19:45:13 GMT
FROM: Johan U. Fynbo at U.Copenhagen <jf

Johan P. U. Fynbo (DARK) report:

Unfortunately I made an error in the gain-co
reported in GCN #5817. Here are the correct
photometry. In the NOT images taken about 8

Much better. Now there are links to take you to useful places like the web was intended to do.

The second script is called GCN Coordinate Query, and it inserts a set of queries to three common astronomical databases wherever a set of GCN GRB coordinates appears. This makes it easy to do simple searches around GRB positions without doing complicated gymnastics with the mouse.

See below for the script download information.

Prerequisites:

Downloads:

Cutting and Pasting with X Windows on the Mac

If you are a hardcore X windows person like me, working on a Mac presents certain issues. Mac OSX applications hosted by X windows are more or less second class citizens. Most X windows people are used to copying directly to the clipboard by selecting, and pasting with the middle mouse button. However, on the Mac, the behavior not really consistent.
  • For clipboard contents created by non-X applications, pasting into X with the middle button works fine.
  • After selecting something within X, pasting back into X with the middle button works fine as well.
  • However, when you want to copy from X to a non-X application, then you need to go through the extra step of invoking "Copy" from the "Edit" menu. This is especially frustrating when you want to copy a URL from an Xterm to Firefox.
What I really wanted was "just" a way to automatically copy the X selection to the Mac clipboard. I puzzled over complicated descriptions such as these, until I finally just did some experimentation. It turns out it can be done!

Just edit the .Xresources file in your home directory (or create a file with that name), and add the following to it.
XTerm*VT100.Translations: #override \
<btn1up>: select-end(SELECT, CLIPBOARD, PRIMARY, CUT_BUFFER0)\n\
Ctrl <keypress> Insert:insert-selection(PRIMARY, CUT_BUFFER0)
Then you should restart X (or at least "xrdb -merge ~/.Xresources"). For emacs, you should add the following to your .emacs file,

(setq x-select-enable-clipboard t)
I've been very happy ever since.