domenica 21 agosto 2011

The many paths to disk UUIDs

In protest against Google censorship of Blogger blogs in some countries, this post has been moved to Wordpress.

Questo post è stato spostato su Wordpress in protesta contro la censura applicata da Google su richiesta dei governi di alcuni paesi.

giovedì 18 agosto 2011

Are Gnome and KDE giving up the desktop battle?

In protest against Google censorship of Blogger blogs in some countries, this post has been moved to Wordpress.

Questo post è stato spostato su Wordpress in protesta contro la censura applicata da Google su richiesta dei governi di alcuni paesi.

lunedì 8 agosto 2011

Logging for HAProxy on CentOS 5.x

In protest against Google censorship of Blogger blogs in some countries, this post has been moved to Wordpress.

Questo post è stato spostato su Wordpress in protesta contro la censura applicata da Google su richiesta dei governi di alcuni paesi.

sabato 6 agosto 2011

Installing Android SDK on Eclipse (Fedora 15)

In protest against Google censorship of Blogger blogs in some countries, this post has been moved to Wordpress.

Questo post è stato spostato su Wordpress in protesta contro la censura applicata da Google su richiesta dei governi di alcuni paesi.

giovedì 4 agosto 2011

Rewriting addresses in Postfix with regular expressions

Today my employer asked me to look into Postfix. We should take an address like root@some.obscure.host.local.lan and make it into root.some.obscure.host@domain.tld.

Looking at the (good) documentation from Postfix, I managed to get a solution. You should change in /etc/postfix/main.cf:

canonical_maps = regexp:/etc/postfix/rewrite

and the /etc/postfix/rewrite file will contain:

/^(.*)@(.*)\.local\.lan$/     ${1}.${2}@domain.tld

sabato 23 luglio 2011

Ignore a word in a regular expression

Today a friend of mine asked me a tricky regexp related question: he wanted to match against a set of strings like:

WORD_FOO
WORD_BAR
WORD_FOOBAR
WORD_QUUX
WORD_FAR

He did want to match and store any string starting with WORD_ and followed by a valid word, unless it was FOO. So it should match all the aforementioned lines but WORD_FOO.

Tricky.

He was using something like /^(WORD_[^\s]+)$/, so I suggested using [^\s|VERSION] (I did wake up only a few moments before), but of course that doesn't work, since it would exclude all strings containing the characters V, E, R, S, I, O, N.

It took me some digging, but finally I found this answer on StackOverflow that documents the use of negative look-arounds.

Using these constructs I managed to get this regex: WORD_((?!FOO\W)\S+) that satisfies the requirements (you can check it on Rubular).

How does it work?


(?!FOO\W) checks the next characters of the string. If they DON'T (!) contain the word FOO followed by a non-word (whitespace, etc) character (\W), then the matching will be made against \S+ (one or more non whitespace characters). So you'll get the second part of the word in your \1, $1, etc.

If you want to ignore all sub-strings starting with FOO, you can get rid of that \W.

mercoledì 20 luglio 2011

Good tip on better font rendering in Fedora

I just finished reading this good tip on how to obtain better font rendering on Fedora.

Results are good, so I just wanted to share the link :)