So far, in the last 12 hours, I’ve discovered that my payslips from
this time last year bear no resemblence to reality, my pension company
has failed to recieve approximately 1900GBP of money that should have
been paid into it and O2 have managed to transfer my mobile number to
completely the wrong SIM. I’m still waiting for April so I can call the
Inland Revenue to find out what happened to all the student loan
repayments I made at my previous company (Approx 700GBP).

Have spoken with O2, who are going to transfer my number ot the right
SIM, hopefully in the next 2 hours. Need to speak to the guy that does
payroll in the office, when he comes in next.

Sucks to be me.

Update: Phone now works.

Which of these two fragments is more readable?

$self->{catalina_base} = $ENV{'CATALINA_BASE'};
if (!defined $self->{catalina_base}) {
    $self->{catalina_base} = $self->getTomcatHome() ;
}
if (!defined $self->{catalina_base}) {
    CCM::Util::error ("CATALINA_BASE unset and TOMCAT_HOME undefined", 3);
}

or

$self->{catalina_base} = $ENV{'CATALINA_BASE'} || $self->getTomcatHome()
   || CCM::Util::error ("CATALINA_BASE unset and TOMCAT_HOME undefined", 3);

Update: or

$self->{catalina_base} = (
   $ENV{'CATALINA_BASE'}
   or $self->getTomcatHome()
   or CCM::Util::error ("CATALINA_BASE unset and TOMCAT_HOME undefined", 3)
);

MJ
Ray
, I think you’re distorting what is going on. Google are,
rightly, protective of their search results and work actively against
people that try to manipulate the search results. This is what BMW.de
had done by giving a spam page to google and using javascript to
redirect users to the right page. As an aside, this would have broken
for text browsers or anyone without javascript. It’s not the pinicle of
accessibility is it? Google were protecting their index, not using it as
a vendetta against people it doesn’t like as you were suggesting. Stop
being so paranoid and stop distorting the story, or you’re no better
than the devil you’re trying to paint Google as.

Today, I discovered SQL::Translator,
which seems to have some very interesting use cases. Basically, it is a
perl module for translating a database schema from one of a number of
formats and turning it into another format. Parsers include:

  • Live querying of DB2, MySQL, DBI-PostgreSQL, SQLite and Sybase databases
  • Access
  • Excel
  • SQL for DB2, MySQL, Oracle, PostgreSQL, SQLite and Sybase
  • Storable
  • XML
  • YAML

Output formats include:

  • Class::DBI
  • SQL for MySQL, Oracle, PostgreSQL, SQLServer, SQLite and Sybase
  • Storable, XML and YAML
  • POD, Diagram, GraphViz and HTML

Several things spring to mind with this:

  1. Defining your Schema in XML and using SQL::Translator to convert it
    into SQL for several databases and a set of classes for Class::DBI,
    which would make your application immediately target any of the
    supported databases.
  2. Documenting an existing database for which you’ve lost existing
    documentation by pointing it at a running database instance and
    outputting HTML page and, thanks to the Diagram output module, visual
    representation of the structure.
  3. Convert one database from product to another. Point it at a MySQL
    database and generate SQL for postgresql. If you generated some
    Class::DBI stuff you could possibly quickly write a script to copy data
    too.
  4. Using the sqlt-diff script, compare you current SQL to what is
    running on the database and generate a SQL script to upgrade the
    database structure using ALTER TABLE etc. Presumably you’d need
    to convert any data yourself, but is still a time saver for large
    databases.

I’m sure other people could think of some interesting uses for this.
Having looked at the Class::DBI stuff, I think it could do with some
improvements. I can’t see a way to set the class names, although I
haven’t spent that much time looking and it insists on having all the
classes in one file. Also the XML and YAML formats
generated are rather verbose and I haven’t looked to see how much I
could cut them down to use as the source definition. I suspect that I
can make it a lot shorter and rely on sensible defaults.

My initial reason for wanting to use SQL::Translator is that
Class::DBI::Pg has a large start up time and isn’t really suitable for
CGI use if you have a complex database. This might be mitigated by using
mod_perl, but in the mean time I was hoping I could speed up startup by
telling Class::DBI my column names, rather than it querying the
database. SQL::Translator should allow me to save duplicating the
database structure, whilst allowing me to support multiple backend
databases. If I get this working, I’ll write up a short HOWTO.

I can’t believe in this day and age that OPSI (formerly HMSO) still don’t have
copies of UK acts of parliament before 1988 online. According to their
website:

Q. Why do you only display legislation back to
1988?

A. The website was launched in 1996. Initially, legislation was only
available from that year. In 2000 we took the decision to include older
legislation for which we had electronic files. These files only dated
back to 1988. Prior to this, legislation is only available in its
original print format.

I don’t think it’s acceptable to say “Oh it’s a bit of work to make them
available.” If Project Gutenberg
can make 17,000 out of copyright works available, I fail to see why the
government, who have resources at their disposal, can’t make the text of
approximately 3000 acts from the last 100 years available. This makes
several key acts which govern us today unavailable to the UK public,
including the Telecommunications Act 1984, Sale of Goods Act 1979,
Supply of Goods and Services Act 1982 and Unfair Contract Terms Act
1977.

On a similar note, they have only just started making PDF files
avilable for download (since October 2005). They don’t appear to be
planning on making existing documents available in PDF. Again, I don’t
think it would be too hard to make all their content availble in
alternative formats.

Found out that I’d been libelled by an old school friend
last night. Apparently I was mentioned as part of LugRadio’s highly amusing Look Queer for the
New Year
competition. Listen to the stream here (about 2
minutes in). I mean how insulting is it to be told you look
queer by a guy who looks like this:

I don’t know if I’m more insulted about only coming third or by the
fact that I don’t get a prize. Wish I’d slept with his girlfriend now
(or at least her sister).

You can run Jono, but you can’t hide.

One thing I forgot to mention is that I’ve been working on a new
layout for my website, which is mostly completed. Still need to do some
work on some of the styling, but I’m mostly happy with the layout of the
site. It’s not exactly an original design, but it’s a significant
improvement on the half style I used to have.

The next step is to improve the style so I don’t have to repeat the
style and html on every page and I’m hoping to do it without php. I have
some cunning plans involving python and xslt, but we’ll see how that
goes.

Also, after several months, I fixed my blog comments to not give a
500 Server Error, so people can now freely spam my comments. Turns out
that the comments plugin didn’t have write permission to the comments
directory, but pyblosxom kindly didn’t prove any hints beyond “Premature
end of script headers”. Cheers.

Yesterday I posted about some bad
shell
code I had found and posted an improved version. Part of the
reason for posting it was that I hoping someone could point out any
errors in the version I posted. Fortunately Neil Moore emailed me some
improvements.

  1. If the script returns more than one line they will be removed by the
    $(…) expansion when it is split into words. The solution there is to
    surround it in double quotes.
  2. The next problem Neil pointed out was that $@ should be
    surrounded by quotes in pretty much every case, otherwise parameters
    with spaces in will get split into separate parameters.
  3. The final problem is that if the script includes a return statement, it
    will stop the inner most function or sourced script, but not during
    eval.The solution is to enclose it in a function:

    
    dummy() { eval "$(perl "$CONF_DIR/project.pl" "$@")"; } dummy "$@"
    
    

Since making the post, I discovered that Solaris’ /bin/sh
doesn’t like $(...), so it’s probably better to use backticks
instead if you want to be portable. As I know the output from the script
I’m not worried about return statements, so I’ve ended up with:


eval "`perl "$CONF_DIR/project.pl" "$@"`"