Chris Foote's blog

Getting rid of those pesky quotes

If you've ever written a stack of SQL inserts using Perl and wondered if there was a better way to do it, and that gets around these issues:

  1. Doesn't need a multi-line string with quoted variables,
  2. Isn't a page long handling the query with transactions, and
  3. Checks that the Perl variable contains data that matches the database column's field type,

then this piece of code will help:

use strict;
use DBI qw(:sql_types);

my $dbname = "christest";

my $dbh = DBI->connect("dbi:Pg:dbname=$dbname", "", "",
                       { RaiseError => 1, AutoCommit => 0 });

# using the DBI statement handler's bind_param() feature, bind the
# given SQL parameters to the prepared query.
#
# To be eval'ed from sql_insert()
#
# Args:
#       - reference to statement handler (i.e. \$sth)
#       - remaining args are arrary references representing
#         value and type pairs - e.g. ["fred", SQL_VARCHAR]
#
# Returns:
#       nothing
#
sub bind_query {
  

Getting St George bank's WebPay library working under FreeBSD

St George supply a shared library for RedHat Linux 9 at https://www.ipg.stgeorge.com.au We want it to run it using FreeBSD for various reasons, the least of which is that RH9 hasn't been supported for more than a year. (Actually, the real reason is that we have a client using FreeBSD that doesn't want to use the Java API.)

The current version (released Jan 2004) will work under FreeBSD 4 with a few steps:

  1. Install the linux emulation ports:

    emulators/linux_base-rh-9
    devel/linux_devtools
    devel/linux-glib2

  2. Install the kerberos5 and openssl libaries using RPMs.

    RPMFLAGS="--root /compat/linux --dbpath /var/lib/rpm --nodeps --replacepkgs --ignoreos --ignorearch"
    rpm -U $RPMFLAGS krb5-libs-1.2.7-10.i386.rpm
    rpm -U $RPMFLAGS openssl-0.9.7a-20.2.i386.rpm

  3. Copy the webpay library to both usr/lib directories:

3G Internet Access from Linux

A couple of months ago I was able to get the 3 network's PCMCIA card working for Internet access from my Ubuntu (Debian based) Linux laptop. I received a question about it, so I thought I'd make some notes here in case they're of use to someone else as well.

The logs on my laptop have all rotated, so I don't have details on the PCMCIA (CardBus) device anymore ;-(

From memory, apart from the slightly strange PPP config, I needed to install just one package:
apt-get install pcmcia-cs

I suggest that you install that package, then go along to a shop and see if info appears in /var/log/daemon.log or /var/log/messages You should end up with a virtual /dev/ttyS1 serial device. A friend of mine runs OneClickAway (222 Grote St, Adelaide) who sells cards and the 3 service, so you could ask for him as I'm sure he'd let you try it in the shop. Ask for Richard Kaye 8413 9100, and mention my name.

As for the PPP config, it's pretty standard, but the chatscript is quite wierd (I had to snoop the serial port on the windows box to get some details, and merge them with another config on the net I found for the Orange 3 network in the UK). Here's what I have for config files:

Drupal Installed

I've got Drupal up and running for HostExpress blogs and news postings. If you haven't heard of Drupal before, it's a GPL licensed content management system suitable for a wide range of purposes (including blogging) - more info available at the Drupal website.

So far I'm extremely impressed with the quality of the admin interface and features. I was tempted by WordPress and Nucleus, which were also very polished and met most needs during testing, but in the end, Drupal's support of general CMS features and add-in modules got me hooked.

I've turned on anonymous comment posting, so I'm waiting to see how well it blocks spammers.

Syndicate content