The new design

Just in case you’re wondering, this new design isn’t a homebrew. Moving content and other stuff from the old (movable type powered) site to this new platform was hard enough without me having to challenge myself to come up with a design and learn how to create a wordpress theme from scratch.

The core of the design is from gluedideas’ subtle theme. I’ve made it 200 pixels wider than the orgininal, but that’s about it on the theme side of this. I will probably switch the default header image (and colours) with images of my own at some point.

GMail filter/spam buglike feature

Gmail from Google is usually great, but it does have some bug-like features.

One of the most annoying is when your inbound mail is tagged with a label and should have been auto-archived, but is caught by their spam filter and placed in the spam folder. Discovering and finding the mail in the spam folder is easy, but when you tell Gmail, that the mail isn’t spam, it doesn’t pop in to the archive (where the filter-rule should have put it). It pops back into the inbox, and you can then archive from there.

Wordpress live...

Somethings changed. There’s a new look on the site and there’s a new engine under the hood. It’s seemed to be the time to switch from Movable Type to Wordpress – instead of the constant fighting with MovableType to keep things together a few years (after making too many hacks all around the MT-files), this new site hardly has a single hack – it’s just by the book and pieced together by standard components.

D-Link Wifi

The past few days I’ve been toying with Wifi equipment from D-Link – and access point (DWL-G700AP) and a wireless router (DI-524). These were pretty much the first to wifi-devices, which I’ve completely setup, and configured on my own, so it was an interesting experience. The first experience was in the weekend, when I tried to get a basic TDC Broadband (DSL) connection made avaiable wirelessly. Not knowing too much about Wifi, I though the Access Point was the thing to get, and the DWL-G700AP seemed to be a fair deal in the local IT-vendor. After spending a few hours trying to get it to work, I gave up and called a friend for some advice.

Basics on tables in Mysql

Navigating around in mysql is quite easy. You can see which databases by using the command “show databases”. There will always exist a database called “mysql” which is used by mysql itself.

If your user account has access to a database, you can access it by using the “use DATABASENAME” command. You can se which tables exist within a database by using the “show tables” command - and see details for each table by issuing the “desc TABLENAME” command.

Cracking Cryptex of the DaVinci code with PHP

In the book “the Davinci Code” there was a fun little device called a cryptex.. A Cryptex has 6 dials with 6 letters on each, and only one combination producing a word will open it. The most straight forward way to crack it would be to try every combination one by one, but there’s a substantial number of combinations and we know only those which a valid words is a candidate.

Date calc with SQL

Micro tip of the day: How many days has past since a date field in the database?

SELECT (TO\_DAYS(NOW()) - TO\_DAYS(date\_field)) AS days\_past FROM tablename

Fetching available newsgroups from a news server

This script fetches a list of available newsgroups (and descriptions) from a news server. The group list is returned as a hashref where the keys are the groupname and the value is a description of the group.

#!/usr/bin/perl -w
use strict;
use Net::NNTP;
use MIME::Base64 qw(decode\_base64);
use MIME::QuotedPrint qw(decode\_qp);

my  $server= "sunsite.auc.dk";
print STDERR "connecting to $server... ";
my $nntp= Net::NNTP->new($server);
unless($nntp) {
  print STDERR "failedn";
  exit 1;
}
print STDERR "okn";

print STDERR "getting messages... ";
my $newstuff= $nntp->newnews(time - 7\*24\*2600, "dk.edb.programmering.perl");
unless($newstuff) {
  print STDERR "failedn";
  exit 1;
}
print STDERR "okn";

my @messages;
foreach my $msgid (@$newstuff) {
  my $head= $nntp->head($msgid);
  next unless $head;

  my %msg;
  push @messages, %msg;
  foreach(@$head) {
    next unless /^(Newsgroups|Subject|From):s+(.+)$/i;
    $msg{lc $1}= $2;
  }
}

my $last= "";
foreach(sort { $a->{newsgroups} cmp $b->{newsgroups} } @messages) {
  if($\_->{newsgroups} ne $last) {
    print "n" if $last;
    $last= $\_->{newsgroups};
    print "$last:n";
  }
  print "t" . decode\_header($\_->{subject}) .
    " - " . decode\_header($\_->{from}) ."n";
}

sub decode\_header {
  my($text)= @\_;

  $text=~ s/=?(iso-?8859-.?|us-ascii|utf-8)?(q|b)?(\[^?\]\*)?=(s\*(?==?))?/&decode\_header\_block(lc $1,$2,$3);/gei;
  return $text;
}

sub decode\_header\_block {
  my ($input,$enc,$text) = @\_;
  if ($enc =~ /q/i) {
    $text=~ s/\_/ /g;
    $text= decode\_qp($text);
  } else {
    $text= decode\_base64($text);
  }
  return $text; # oh well  \[:-)\]
}

exit();

Fetching recent headlines from a news server

The followig piece connects to a news-server and fetches subjects from the last week in a specific newsgroup (the Danish perl-newsgroup) and prints these.

#!/usr/bin/perl -w
use strict;
use Net::NNTP;
use MIME::Base64 qw(decode\_base64);
use MIME::QuotedPrint qw(decode\_qp);

my  $server= "sunsite.auc.dk";
print STDERR "connecting to $server... ";
my $nntp= Net::NNTP->new($server);
unless($nntp) {
  print STDERR "failedn";
  exit 1;
}
print STDERR "okn";

print STDERR "getting messages... ";
my $newstuff= $nntp->newnews(time - 7\*24\*2600, "dk.edb.programmering.perl");
unless($newstuff) {
  print STDERR "failedn";
  exit 1;
}
print STDERR "okn";

my @messages;
foreach my $msgid (@$newstuff) {
  my $head= $nntp->head($msgid);
  next unless $head;

  my %msg;
  push @messages, %msg;
  foreach(@$head) {
    next unless /^(Newsgroups|Subject|From):s+(.+)$/i;
    $msg{lc $1}= $2;
  }
}

my $last= "";
foreach(sort { $a->{newsgroups} cmp $b->{newsgroups} } @messages) {
  if($\_->{newsgroups} ne $last) {
    print "n" if $last;
    $last= $\_->{newsgroups};
    print "$last:n";
  }
  print "t" . decode\_header($\_->{subject}) .
    " - " . decode\_header($\_->{from}) ."n";
}

sub decode\_header {
  my($text)= @\_;

  $text=~ s/=?(iso-?8859-.?|us-ascii|utf-8)?(q|b)?(\[^?\]\*)?=(s\*(?==?))?/&decode\_header\_block(lc $1,$2,$3);/gei;
  return $text;
}

sub decode\_header\_block {
  my ($input,$enc,$text) = @\_;
  if ($enc =~ /q/i) {
    $text=~ s/\_/ /g;
    $text= decode\_qp($text);
  } else {
    $text= decode\_base64($text);
  }
  return $text; # oh well  \[:-)\]
}

exit();