The Godfather of Lomography

Posted: August 27th, 2004 | Filed under: Uncategorized | No Comments »

Last night I encountered the first program on BBC Four that I was actually interested in watching: The Lomo Camera: Shoot from the hip. As you’d expect it was packed full of fantastic photos taken on the classic Lomo Kompakt Automat and the newer multi-shot cameras produced by the Lomographic Society, but the really interesting stuff was about the history of the Lomo. Way back in the early 90’s the Lomographic Society was beginning to take off, and needing a reliable supply of Kompakts, made a deal for its exclusive worldwide distribution. Unfortunately shortly thereafter, the Lomo PLC (now in the world of capitalism) worked out its per-unit production costs and discovered they were higher than the per-unit sale price, thus deciding to cease all production. The Lomo Society tried many tactics to convince them to continue production, in the end involing then Mayor of St. Petersburg, Vladamir Putin. Putin, realising the importance of the Lomo Kompakt to both St. Petersburg & Russian history, as well as to the Lomo Society, managed to convince (pressure ?) the factory to continue production. Truly he is the Godfather of Lomography

The one who got away…

Posted: August 23rd, 2004 | Filed under: Uncategorized | No Comments »

But what if you got a second chance? That’s the premise of Richard Linklater‘s film Before Sunset, a 9 year later followup to Before Sunrise. I won’t repeat the plot here, since that’s readily available on the IMDB pages I just linked to. Before Sunset has a mere handful of sets, with most of the film taking place on the streets of Paris as Jesse & amp; Celine wander around catching on their lives. What’s more the entire film takes place almost in real-time – a mere hour and 20 minutes & shows you don’t need to span a whole 24 hours to build a really entrancing story.

Open source streaming media

Posted: August 13th, 2004 | Filed under: Uncategorized | No Comments »

Its nice to see the BBC taking a stand against the extortionist licensing model of RealMedia (and other commercial media streaming companies) by pushing ahead with development of its own Open Source standard. Its also interesting to note that since the design & implementation can be based on technical merit rather than potential commercial benefits, Dirac could feasibly turn out to be faster than existing codecs.

Borer believes Dirac could turn out to be more efficient than standards based on commercial patents, even though it has to use technology more than 20 years old to avoid breaking patents.

Many of the techniques were published by academics long before they were used commercially, and some are relatively new in being applied to video compression. ‘Wavelets [exotic waveforms used to map changes] have been around for 20 years now
…snip…

Efficiency depends on how techniques are used as much as on the techniques themselves. Commercial organisations trying to agree a standard currently fight to get their own intellectual property included, which makes for complexity and does not necessarily lead to the adoption of the best of breed. ‘We have tried to make our codec as simple as we can so it is easy to understand and easy to implement efficiently,’ said Borer.

30 second guide to Perl DBI

Posted: August 5th, 2004 | Filed under: Coding Tips | No Comments »

The Perl DBI module provides a uniform API to access relational databases. Thanks to Perl’s data type model using it is considerably easier than, say JDBC in the Java world. In common with most database access APIs, the code is split into two bits, the generic infrastructure is in the DBI module, while backends for each database are in the various DBD modules:

The first task in any program is to connect to the server. This is done with the DBI->connect method. To simplify error handling, its good practice to turn on ‘RaiseError’ option, and turn off ‘PrintError’ and ‘AutoCommit’. Then by wrapping the entire unit of work in an eval we get safe transaction commit/rollback without the need to check method return status on each DBI call.

  use DBI;

  my $db;

  eval {
    $db = DBI->connect("DBI:Pg:dbname=mydb;host=myhost",
                       $username, $password, {
			  RaiseError => 1,
			  PrintError => 0,
			  AutoCommit => 0
                       });

      ...do some work with the db...
  };
  if ($@) {
     if ($db) {
       $db->rollback;
     }
     die $@;
  }
  $db->commit;
  $db->disconnect;

The next task is issue statements to the DB. Following common practice DBI allows placeholders to be used in SQL, which are substituted with real values at execution time. If the underlying DB doesn’t support placeholders, DBI will emulate them. For maximum performance its advisable to use prepared statement handles, and again DBI will emulate this feature if the underlying driver does not support it.

    my $sth1 = $db->prepare_cached("INSERT INTO foo (bar) values (?)");
    $sth1->execute($bar);

    my $sth2 = $db->prepare_cached("UPDATE foo SET bar = ? WHERE wizz = ?");
    $sth2->execute($bar, $wizz);

    my $sth3 = $db->prepare_cached("DELETE foo WHERE bar LIKE ?");
    $sth3->execute($bar);

The final common task is retrieving data from the DB. There are a number of ways to get data back, but the simplest to code is to bind variables to each return parameter and then call ‘fetchrow’.

    my $sth4 = $db->prepare_cached("SELECT bar, wizz FROM foo where bar > ?");
    $sth4->execute(20);

    my ($bar, $wizz);
    $sth4->bind_columns(\$bar, \$wizz);
    while ($sth4>fetchrow) {
        print "Got $bar $wizz\n";
    }

Putting this together a complete example looks like

  use DBI;

  my $db;

  eval {
    $db = DBI->connect("DBI:Pg:dbname=mydb;host=myhost",
                       $username, $password, {
			  RaiseError => 1,
			  PrintError => 0,
			  AutoCommit => 0
                       });

    my $sth1 = $db->prepare_cached("INSERT INTO foo (bar) values (?)");
    $sth1->execute($bar);

    my $sth2 = $db->prepare_cached("UPDATE foo SET bar = ? WHERE wizz = ?");
    $sth2->execute($bar, $wizz);

    my $sth3 = $db->prepare_cached("DELETE foo WHERE bar LIKE ?");
    $sth3->execute($bar);

    my $sth4 = $db->prepare_cached("SELECT bar, wizz FROM foo where bar > ?");
    $sth4->execute(20);

    my ($bar, $wizz);
    $sth4->bind_columns(\$bar, \$wizz);
    while ($sth4->fetchrow) {
        print "Got $bar $wizz\n";
    }
  };
  if ($@) {
     if ($db) {
       $db->rollback;
     }
     die $@;
  }
  $db->commit;
  $db->disconnect;

Most Heinous Government Organization

Posted: August 4th, 2004 | Filed under: Uncategorized | No Comments »

Its that time of year again when Privacy International hands out the UK Big Brother Awards. Amongst the categories are
Worst Public Servant, Most Invasive Company, Most Appalling Project, Most Heinous Government Organization and Lifetime Menace. This being the UK there is strong competition and the winners don’t disappoint

Most Appalling Project was awarded to Britain’s National Health Service electronic medical records program, which aims to computerize patient records in a way that some have protested is insecure and will compromise patient privacy.

Most Heinous Government Organization was won by The Office of National Statistics for its development of the Citizen Information Project, which will collect, collate and share U.K. citizens’ data with other government agencies.

Its all summed up nicely by the quote

“We are seeing a race to the bottom, where government and private sector alike compete to provide the most intrusive services in the most unstable environment for privacy,” said Davies. “The proclaimed need for protection of children and the fight against terrorism is often shamelessly used as the pretext for privacy invasion.”