A rather dull worKLOG. This is just a scratchpad for solutions to IT problems that might be useful to someone else. Expect no opinions, no brilliant insights and definitely no pictures of pets or children. Expect stack traces, code snippets and other hints for the Google Indexer.

Wednesday, January 31, 2007

Moving mail to gmail

I've decided to move completely over to gmail so that I don't have to configure my mail clients to deal with umpteen different accounts. I also want to store all my legacy mail so it's all searchable in the one place. How do I upload my Thunderbird mail files to gmail?
This: http://www.marklyon.org/gmail/download.htm seems to do the job. It's a small python app that goes through your Thunderbird mbox files and forwards them all. It's slow, and it's going to mess up your emails' timestamps, but it does the job.

Friday, January 19, 2007

Weekly summary

* Helping Isa debug PLASTIC functionality in VOSpec

http://esavo02.esac.esa.int:8080/vospec/
* Prep for MSc
* Installed latest STILTS
* Looking into an example for VisIVO paper
* New Plastic group in Apps WG
* Uni of Queensland Connection


--
------------------------------------------------------------------------
AstroGrid/VOTech
&
WFAU, Institute for Astronomy, Edinburgh
Skype:johndavidtaylor <skype:johndavidtaylor?chat>

------------------------------------------------------------------------
*Gratuitous advertising:*
Plastic - http://plastic.sourceforge.net | AstroRuntime -

http://www2.astrogrid.org/desktop
AstroGrid - http://www.astrogrid.org | WFAU -

http://www.roe.ac.uk/ifa/wfau/

Thursday, January 11, 2007

How can a bash or shell script find its own directory?

It's often desirable to write a small bash script to launch an
application. However, you want the application to be portable, so you
don't want to hard-wire absolute file locations into the script.
Unfortunately, this means that if you execute the script from somewhere
other than the directory which holds the script, then it won't locate
the files. A bit of googling suggests that the general problem of
making a script aware of the directory in which it resides is quite
hard. However, the following works for me:
cwd=`dirname $0`
old=$pwd
cd $cwd
#launch your application here, for example
nohup python main.py &
#where main.py is in the same directory as the script
cd $old

Subclipse, Eclipse plugin does not work on Ubuntu

You've installed Eclipse, the subclipse subversion plugin, set up your
repository locations and are ready to go. Left click on your favourite
subversion repository to see the contents. Uh-oh:
'
Folder " does not exist remotely.
'

This is because the JVM that ships with Ubuntu (GNU gij) doesn't even
remotely work.
OK that's very unfair. It does seem to screw up Eclipse and Subclipse
though.
To fix this problem, you need to download the latest Sun JDK install it
somewhere convenient, and (importantly) make sure that this JDK's bin
folder is on the front of your path. If you've got it set correctly
then executing java -version at the command line should give you the
reassuring
"
java version "1.6.0"
....
java HotSpot(TM) Client VM.....

"

Thursday, January 04, 2007

"Multiproject" site generation in Maven 2.0.4

Yet again Maven has shat upon me from on high by randomly updating a
plugin and changing its behaviour. Previously, if you had a project
configured as a "multiproject" build of modules, the way to include a
link in your parent project's docs to the child documentation was to add
${modules} into the parent's site.xml. No longer! Try this now, and
your mvn will spit out some garbage about your site.xml being malformed
xml, when it plainly isn't. No, now the secret incantation is to put a
menu item in thus: <menu ref="modules"/>. The same goes for ${reports}
and ${parent} presumably. The new syntax is certainly nicer, if you
don't mind the extra wear and tear on your fingers, but I wish they
had just deprecated the old syntax, rather than secretly removing it.

Problems with Image loading in Java


I'm trying to load images in Java for use in icons with the following:
new ImageIconr(url)

Mostly, this works fine. But just once in a while it fails with:

Uncaught error fetching image:
java.lang.SecurityException
at java.lang.SecurityManager.checkPermission(SecurityManager.java:562)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1078)
at sun.awt.image.URLImageSource.checkSecurity(URLImageSource.java:81)
at sun.awt.image.ImageRepresentation.imageComplete(ImageRepresentation.j
ava:597)
at sun.awt.image.InputStreamImageSource.errorConsumer(InputStreamImageSo
urce.java:131)
at sun.awt.image.InputStreamImageSource.setDecoder(InputStreamImageSourc
e.java:331)
at sun.awt.image.InputStreamImageSource.doFetch(InputStreamImageSource.j
ava:252)
at sun.awt.image.ImageFetcher.fetchloop(ImageFetcher.java:172)
at sun.awt.image.ImageFetcher.run(ImageFetcher.java:136)

What's worse, surrounding the code with a try-catch block doesn't save you - the application simply locks up. Note that this
only happens when running under a SecurityManager such as under WebStart. It seems there's a bug in the JDK
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4881229
which means that if the URL gets redirected with an http 302, then an internal thread in the JDK will fail. This
is pretty hopeless - can't fix it, can't trap it.

The workaround is to use a different part of the API. Instead of constructing an Icon from a URL, you first get an Image using
Image im = ImageIO.read(url);
then construct an icon from that:
new Icon(im);