slippens's blog

In-place string changing in files from the command line with "perl pie"

18 April, 2007 - 13:22

The standard unix/linux tools for filtering/changing strings (or patterns) in files from the commandline are sed and awk. But what if you want to change strings in-place in the files without the burden of creating new files and replacing the old ones afterwards?

The "perl pie" is a handy one-liner for these occasions:

perl -p -i -e 's/Jesus/Elvis/g' bible.txt

This will replace in file bible.txt all occurences of 'Jesus' with 'Elvis' in-place.

More info:

VRT internetradio beluisteren zonder dat flashgedoe

13 March, 2007 - 16:50

Het heeft me wat tijd gekost, maar eindelijk vond ik een lijst van rechtstreekse links naar de VRT internetradio streams. Nu kan ik eindelijk (vanuit Linux) naar de VRT-radio luisteren zonder dat dat flashgedoe in als zijn "trendyness" zinloos cpu staat te verbruiken en eigenlijk niets doet behalve foutmeldingen spuwen.

Awaken the post-lunch PhD that lives inside you.

2 March, 2007 - 12:13

Awaken the post-lunch PhD that lives inside you.

now back to work

Accessing a svn server behind a firewall

5 February, 2007 - 17:37

Disclaimer: this entry is mainly a reminder to myself (the stuff you would write on a post-it), but maybe it's useful to someone else.

The subversion server at my work is (currently) only accessible from within the LAN, which is, of course, separated with a firewall from the evil internet. This makes it a bit difficult to access the subversion server when working from home. SSH Tunneling to the rescue!

To setup an SSH tunnel (on computer home):

ssh -l username -L 8910:svnserver:80 gateway cat -

This creates an SSH connection from computer home to computer gateway and opens a listening TCP-port 8910 on the the computer home. Connections to this port will be forwarded through the SSH tunnel to TCP-port 80 from computer svnserver (as seen from computer gateway).

Now we can access the svnserver as follows (on computer home):

svn co http://localhost:8910/svn/repository/path

In a nice diagram:

Graphics used in diagram from Tango icon gallery.

Had je 10 miljoen, wat zou jij dan doen?

18 January, 2007 - 17:03

Had je tien miljoen wat zou jij dan doen
een feestje bouwen en je geld op doen?
Ik kocht liters limonade, honderd kilo chocolade
om aan iedereen uit te delen!
Had je tien miljoen wat zou jij dan doen
een feestje bouwen en je geld op doen?
'k Zou een kermis laten maken,
en ik schreeuwde van de daken,
kom maar allemaal met me spelen!

Gert Verhulst, die al een veelvoud van 10 miljoen verdiend heeft, mag zijn belofte wel eens nakomen. Gelukkig zijn er mensen die hem daaraan helpen herinneren:

Niets vergeten, Gert Verhulst?

Get name of current function and caller with Python

11 January, 2007 - 15:22

With the python module inspect, one can inspect (no kidding) the run-time python stack. Among other things, this makes it possible to get the name of the current function or callers. Handy for logging or debugging purposes. A simple script to illustrate:

import inspect
# functions
def whoami():
    return inspect.stack()[1][3]
def whosdaddy():
    return inspect.stack()[2][3]
def foo():
    print "hello, I'm %s, daddy is %s" % (whoami(), whosdaddy())
def bar():
    print "hello, I'm %s, daddy is %s" % (whoami(), whosdaddy())
johny = bar
# call them!


hello, I'm foo, daddy is ?
hello, I'm bar, daddy is foo
hello, I'm bar, daddy is ?
hello, I'm bar, daddy is ?

Links are so uncool

24 November, 2006 - 11:23

Why use a super standard, easy, one-click-compliant hyperlink when you can use some stupid, ugly widget loaded, two-clicks-needing annoyance instead?

Fortis choose language UI

Even the world famous good-UI-design-superstar does a weird thing for its Belgian front page:

Apple choose language UI

Look, it's not so difficult: choose language UI

Download offline version of dynamic pages with Wget

24 November, 2006 - 10:43

Remainder mainly to myself: short list of useful options of wget for recursive downloading of dynamic (PHP, ASP, ...) webpages (because wget's man page is too long):

  • --no-clobber: do not redownload pages that already exist locally.
  • --html-extension: append extension .html to webpages of which the URL does not end on .html or .htm but with things like .php or .php?q=boo&bar=4.
  • --recursive: turn on recursive downloading.
  • --level=3: set the recursion depth.
  • --convert-links: make the links in downloaded documents point to local files if possible.
  • --page-requisites: download embedded images and stylesheets for each downloaded html document.
  • --relative: only follow relative links, not absolute links (even if in the same domain).
  • --no-parent: do not ascend to parent directory of the given URL while recursively retrieving.

Rising spam level on my UGent email account

17 November, 2006 - 11:45

Almost two years ago, UGent implemented anti spam measures that reduced the amount of spam messages in my UGent email account considerably from 20 something each day to zero. But recently the daily amount of spam that reaches my inbox is growing again in an unfavorable way:

graph of spam messages per day and weekly average