Ever wanted to know who was logged into your oracle server and where
from? This SQL will show you the username connected, which machine they
are connected from and what time they connected.

SELECT s.username, s.program, s.logon_time
   FROM v$session s, v$process p, sys.v_$sess_io si
   WHERE s.paddr = p.addr(+) AND si.sid(+) = s.sid
   AND s.type='USER';

Since upgrading to GNOME 2.14, I have been revisited by an annoying
problem with gnome-terminal. Gnome-terminal sets your character encoding
to being the same as your locale by default, which unfortunately was
being detected as ANSI_X3.4-1968, while I had my $LANG set to
en_GB.UTF-8 in my ~/.bash_profile. The reason it wasn’t being
detected was because nothing between logging in and starting
gnome-terminal looked at that file, so gnome-terminal thought the locale
was C.

The result was corrupt
display when programs attempted to display unicode characters. I could
fix it by changing the character encoding using the menu, but I’d have
to do this for every tab, which quickly becomes annoying. Time to find a
fix.

Turns out that you need to tell gdm to set the right locale, which
you can do by configuring ~/.dmrc. Mine now looks like:

[Desktop]
Session=gnome
Language=en_GB.UTF-8

Obviously, the important section is the Language line. You
need to set it to a locale that exists on your system, which you can
find using locale -a. Once
you’ve set that and logged in again, everything should be working
correctly.

Julien,
the majority of comment spam can be dealt with very simply by including
a turing test. On my blog, when I first started getting comment spam, I
added a check box asking if the poster was a human. For a human, it’s
not a massive inconvience to tick a box, but for an automated tool, it’s
a major problem. Was implemented in 3 lines of html and one line of
python. Since I added it, I haven’t recieved a single piece of
spam.

I don’t believe it’s had a major effect on people commenting,
although I currently can’t tell. I could change it to hide posts that claim to be non-human
until I’ve checked them. If spam tools work out this simple problem, I
could change the nature of the test to randomly change between “I am a
human” and “I am not a human”. After that I could include a simple sum
or some other simple question. It also has an advantage over captchas
that it is accessible.

It is a simple change which massively reduces spam by increasing the
cost of spamming and I’m surprised that most people don’t do something
similar.

I’ve spent the weekend playing around with the new Oracle XE Debian
packages in preparation of having to use them at work in the near
future. I’ve written up my experiences of setting the server and
connecting remote clients in my latest
article
.

Talking of work, we have a position for a junior support role open. If
you live in or around Brighton, England and know a little bit about
Linux, Debian, Tomcat, Java, PostgreSQL and Oracle and willing to learn
more, have a look at the job
description
and get in contact.

I recently wanted to deal with docbook <ulink> elements that
didn’t have any contents by displaying the url as the link text. I
wanted to convert:

<ulink url="http://www.example.com">Example.com<ulink>
<ulink url="http://www.example.com"/>

to

<a href="http://www.example.com">Example.com<a>
<a href="http://www.example.com">http://www.example.com<a>

I originally had:

<xsl:template match="ulink">
   <xsl:element name="a">
      <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
      <xsl:apply-templates/>
   </xsl:element>
</xsl:template>

This sucessfully dealt with the first form of <ulink> that had
content, but not with the second example with an empty element.
The solution is the use an <xsl:choose> element with a test to see
if the current node has any child nodes. Using child::node() we
can get any child nodes. We can then test if the node has any children using the
count() function. The resulting xslt is:

<xsl:template match="ulink">
   <xsl:element name="a">
      <xsl:attribute name="href"><xsl:value-of select="@url"/></xsl:attribute>
      <xsl:choose>
         <xsl:when test="count(child::node())">
            <xsl:apply-templates/>
         </xsl:when>
         <xsl:otherwise>
            <xsl:value-of select="@url"/>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:element>
</xsl:template>

Sometimes you need to generate several SSL certificates, but don’t want to pay money to a Trusted Root, and self-signed certificates just won’t cut it. If you’ve ever had this dilemma, just for you, here’s an article describing how to set up your own trusted root certificate and how to import it into several common applications. If you want me to add your favourite application, feel free to email me with instructions and screenshots if appropriate.

Over the weekend, I managed to revive my main desktop machine, which
as spent the last 15 months turned off under a desk because it was
showing some odd behaviour and didn’t have time to fix it. I’ve upgraded
it to the latest sid and given it to my girlfriend to use instead of the
Windows machine she had been using. She appears to have fallen in love
with tuxpaint. 🙂

In the process of setting it up I discovered printconf, which
automatically sets up parallel and USB printers under cups. Plugged in
my printer, went to print in firefox and there was the printer. These
things just get easier and easier. Gone are the days when you spent
hours writing a printcap entry for your printer. One thing I would like
is for DBus support in CUPS so I know when the print job has finished.

Just finished writing an article on PostgreSQL
user administration
. Go read it.

Been stuck at home ill all day, so I took the opportunity to type up an
article on LDAP
basics
, which is hopefully an easy to understand introduction to
LDAP. Given the complicated subject matter, I probably failed in a
couple of places. If you find something you don’t understand, I’d love
to know so I can rewrite that section to make it clearer.

I also updated my robust
shell scripting
article to include a small section on (almost)
race-free locking in bash, using IO redirection and bash’s noclobber
option. Thanks to Ralf Wildenhues for the suggestion.