September 18, 2007 at 9:04 am
· Filed under Debian
Working with subversion I’ve had a bit trouble making project wide search and replaces. find -name '*.pm' | xargs perl 's/foo/bar/g' breaks a subversion working copy in not so subtle ways and grep’ing returns duplicate results. I gave up making the correct find statement in five minutes and installed ack. What a useful utility.
Marc-André Lureau has ITP’ed it and it’s dependencies but hasn’t got anything uploaded yet. I offered to sponsor but havn’t recieved a respons yet and I’m impatient so I’ve rolled out my own packages, renaming ack to ack-grep to avoid name clashes with the existing ack package.
Either download ack-grep_1.66-1_all.deb and libfile-next-perl_1.00-1_all.deb or use the following in you sources.list:
deb http://hacking.dk/debs sid main
deb-src http://hacking.dk/debs sid main
Still willing to either sponsor or maintaining the package myself.
Permalink
September 14, 2007 at 3:50 pm
· Filed under Open source (english)
Ok, just going to do something scary:
$_=pack"C*",33..86;$o='NRCRIMGZLLLCXZBCVUIOR';$o=~s/./chr((ord($&)-13-&f)%26+97)
/eg;$_=$o;s/r/r /;s/l/l /;sub v{$v=ord(substr($_,pop))-32;$v>53?53:$v}s/p/P/;sub
f{s/U$/U$`/;s/U(.)/$1U/;s/V$/V$`/;s/V(.)/$1V/;s/(.*)V$/V$1/;s/V(.)/$1V/;s/(.*)([
UV].*[UV])(.*)/$3$2$1/x;$c=v 53;s/(.{$c})(.*)(.)/$2$1$3/;(v v)>52?&f:v v}s/t/t /
;print”\\u$_,\\n”;[substr qr/(.*)([UV].*[UV])(.*)/i,qw(Just another Perl hacker,)]
and now back to the regular schedule….
Permalink
August 29, 2007 at 11:27 am
· Filed under Open source (english)
While SPF seems to be among the currently used technologies for spam protection, SRS looks rather dead. But forwarding mail breaks SPF without workarounds. So what is the best current practice?
- Completly ignore the existence of SPF
- Implement SPF but just implement forwarding “the old way”
- Inform you users that forwarding breaks SPF and they have to whitelist you mail server
- Implement SRS (but keep it a secret)
The forwarding part of SRS is rather simple, but I havn’t found any clear way to implement the actual handling of bounces. It wouldn’t be hard to hack some usage of Mail::SRS onto postfix but there doesn’t seem to be an off the shelves solution?
Permalink
August 23, 2007 at 8:52 am
· Filed under Debian
A good read eval print loop for perl has been on my Wanted list for a long time. Matt S Trout’s Devel::REPL has been looking promissing but I didn’t want to fiddle with installing the dependencies. Thanks to Alexis Sukrieh and the Debian Perl Group Devel::REPL will enter unstable. Yeahhh…
Another thing on my wanted list was Debian packages of Perl::Critic. Couldn’t find a ITP, but looking around at the Debian Perl Group’s website to find out how to package it I discovered that Joey Hess allready did the work.
I’ve been using the morning installing the above from the subversion repository on pkg-perl.alioth.debian.org. Only problem was that I needed a newer package of libppi-perl which wasn’t maintained in subversion.
What’s next? Looking at my ~/.perl Perl::Tidy seems to be a candidate.
Permalink
August 21, 2007 at 7:47 pm
· Filed under Open source (english)
Watching the popular Inbox Zero video would probally improve my email handling skills better. But this took less time and I wanted to play around with Net::XMPP;
#!/usr/bin/perl -l
use warnings;
use strict;
use Config::Simple;
use Linux::Inotify2;
use Email::Abstract;
use Net::XMPP; # aka Jabber and Gtalk
use POSIX;
my $DEBUG = 0;
our %config;
Config::Simple->import_from("$ENV{HOME}/.mailnotifyrc", \%config);
deamonize() unless $DEBUG;
my $inotify = new Linux::Inotify2
or die "Unable to create new inotify object: $!";
# Different Maildir implementations triggers different events"
# IN_MOVED_TO: rename("tmp/file","new/file")
# IN_CREATE: link("tmp/file", "new/file") && unlink("tmp/file")
#
# At this point the file should be written and closed.
$inotify->watch("$config{Maildir}/new", IN_MOVED_TO|IN_CREATE, sub {
my $e = shift;
my ($fh, $xmpp, $email, $message);
debug('Got event for ' . $e->fullname);
open $fh, "<", $e->fullname;
$email = new Email::Abstract join("", <$fh>);
close $fh;
$message = 'Mail from ' . $email->get_header('From') .
' concerning "' . $email->get_header('Subject') .'"';
debug("Getting ready to send [$message]“);
my $sender = new Net::XMPP::JID ($config{Sender});
my $receiver = new Net::XMPP::JID ($config{Receiver});
$xmpp = new Net::XMPP::Client();
$xmpp->Connect( hostname => $sender->GetServer,
port => $config{port} || 5222,
tls => $config{usetls} || 0,
);
$xmpp->AuthSend( username => $sender->GetUserID,
password => $config{password},
resource => $sender->GetResource || ‘mailnotify’,
);
$xmpp->MessageSend( to => $receiver,
type => $config{MessageType} || ‘chat’,
body => $message,
);
$xmpp->Process(1);
$xmpp->Disconnect;
debug(”Event done”);
});
1 while $inotify->poll;
sub deamonize {
my $pid = fork();
if ($pid) {
exit 0;
}
### close all input/output and separate
### from the parent process group
open STDIN, ‘</dev/null’ or die “Can’t open STDIN from /dev/null: [$!]\n”;
open STDOUT, ‘>/dev/null’ or die “Can’t open STDOUT to /dev/null: [$!]\n”;
open STDERR, ‘>&STDOUT’ or die “Can’t open STDERR to STDOUT: [$!]\n”;
### Change to root dir to avoid locking a mounted file system
### does this mean to be chroot ?
chdir ‘/’ or die “Can’t chdir to \”/\”: [$!]“;
### Turn process into session leader, and ensure no controlling terminal
POSIX::setsid();
}
sub debug { return unless $DEBUG; print STDERR for @_; }
__END__
Permalink
August 18, 2007 at 9:04 pm
· Filed under Open source (english)
While testing Debian Live I suddenly discovered that something had installed a library in my home directory: ~/cbt/lib/libcbtsysinfo_0.so.
Google gives two hints: Some discussion on the danish usenet group dk.edb.mac and some discussion on debian-user.
It looks like it get installed when I log into my internet bank. By lookin at the symbols extracted by objdump (a couple of symbols stating with Java_com_ibm_cbt_slight_CbtSysInfo) it seems to be IBM’s Crypto-base Transaction system.
Evil to install such thing without asking. (Well, it’s a Linux/x86 library even though I’m using Linux/PPC)
Permalink
August 8, 2007 at 11:08 am
· Filed under Open source (english)
Russel Cooker asks two questions to free software Contributors. Here is my answers:
The most important advice I can give to someone who wants to contribute to the free software community is “Take it easy, it’s only software”. If you’re not able to take criticism or to be drawn into tough discussions without taking it personal, you should consider if it it worth it to contribute. Most free software project have their part of to big egos, regular kooks and people with less than good communication skills. And worst of all, nor really good way of coercing people to behave or work together.
My own advantage of participationg in open source projects is the famous itch. For me the most convincing argument for working with open source is “Scratching you own itch while being lazy and not reinvent everything else.” If you dn’t have that itch, then you shouldn’t care about joining a project.
Permalink
July 9, 2007 at 10:31 am
· Filed under Open source (english), Syre
Some random perl code I threw together:
use Data::Dumper;
use List::Util (reduce);
@p = (580, 420, 355, 335, 275, 215);
$target = 1505;
$A[0] = [0, [], 0];
foreach $i (1 .. $target) {
my @tmp;
foreach $a (@A) {
next unless defined($a);
push @tmp, [$a->[0], $a->[1], $i];
push @tmp, [$a->[0] + $_, [@{$a->[1]}, $_], $i] foreach (@p);
}
@tmp = grep({$_->[0] == $i;} @tmp);
# ok, prefer the shortes solution for no other reason
# than 7 times mixed fruit is so boring.
$A[$i] = reduce { if ($a->[0] == $b->[0]) {
@{$a->[1]} < @{$b->[1]} ? $a : $b
} else {
$a->[0] > $b->[0] ? $a : $b
}
} @tmp;
}
print Dumper($A[$target]);
Mixed fruit? You probally have to read this xkcd strip
Update: Changing the grep statement from testing for less than or equal to strict equality seems to be about 30 times faster with the same result.
Permalink
July 5, 2007 at 6:30 pm
· Filed under Open source (english), Syre
Principia Mathematica 320 years, Spam 70 years and Debian Social Contract 10 years. Things that changed the world?
Permalink
July 3, 2007 at 9:34 am
· Filed under Debian, Open source (english)
- Our priorities are pancakes and beer
We will be guidede by our need for pancakes and (preferable free) beer. We will place this interest first in our priorities. We wil support the needs of our users for knowledge of where to get many different kinds of pancakes and beers. We will not object to other kind of food and drinks, but pancakes and beer are our main common interesst and priorities. In furtherance of this need, we will provide guidance to beer and pancakes all over the world near and far away from Denmark.
For some reason the celebration of the Debian Social Contract was centered on Denmark. So I thought we might as well organize something in Denmark for real (some of us had talked about it some days ago).
We have yet to decide if our main priority is beer or pancake so the plans aren’t quite final yet. Ølbaren has been mentioned. If you are interested in joining contact me. (Update: Ølbaren is closed for the month)
Permalink