Groesbeek, view of the 'National Liberation Museum 1944-1945' in Groesbeek. © Ton Kersten tonkersten.com | Tue Aug 17, 2010 | © Ton Kersten - PA1TON
Most of this template stuff is borrowed ("stolen") from Miek Gieben
stopsoftwarepatents.eu petition banner

April 2009 Archives - Thoughts of a geek

April 2009 Archives

That bloody Shift-Backspace

Ton Kersten / 2009-04-24 09:15:04 CEST / Permanent link / news, Linux

On my laptop I'm running Ubuntu Linux 8.04 with XFCE 4.6 and it works great. But (Isn't there always a 'but'?) every once in a while I killed my Xsession with some type of key combination. The standard combination for this is Ctrl-Alt-Backspace so I switched that off in the file /etc/X11/xorg.conf'. I added theServerFlags` section, like this.

Section "ServerFlags"
    Option "DontZap"    "on"
EndSection

After restarting I tried the dreadful Ctrl-Alt-Backspace and I thought that 'Bob's your uncle'.

How disappointed I would be. I started work again and suddenly my X session was killed again, and again and again. And then I saw it, I was not pushing the Ctrl-Alt-Backspace combo, but I tried to insert text with Shift-Insert and accidentally hit Shift-Backspace. Now I had a point to start my search.

Googling and file digging revealed that my keyboard was set to PC-101 and that it should be PC-105. Strange, but solvable. I switched the keyboard in the XFCE settings panel and my problem was solved. It can also be solved by adding

setxkbmap -model pc105 -layout us -variant basic

to the startup script for your window manager.

But, of course, I could not just accept the solution and leave it to that. The problem turned out to be Compiz, the fantastic OpenGL accelerated desktop. This has a feature that the Shift-Backspace turns out to be for debugging purposes.
Yeah, right! We already had Ctrl-Alt-Backspace for that, right!



Hilbert's paradox of the Grand Hotel

Ton Kersten / 2009-04-22 12:40:39 CEST / Permanent link / news

Last week I saw a documentary about the German mathematician David Hilbert. This very interesting documentary had some nice mathematical problems that seem impossible to solve, but when thought through there always was a little loophole.

A very nice one is The paradox of the Grand Hotel

If you are a bit into maths, this really is stuff to read.

The prove of The Last Theorem of Fermat is my next goal... :-)



Patches for IceWM online

Ton Kersten / 2009-04-15 13:58:30 CEST / Permanent link / news

I've been using IceWM on and off for many years now. And because we used it in our UNIX/Linux education environment I did create some patches for IceWM. Some of these patches are now part of the mainstream version and (of course) some are not.

My patch files can be found here.

These patches are mostly focused on window management such as (This list is not complete):

  • win_allowRestore
  • win_allowMove
  • win_allowSize
  • win_allowMaximize
  • win_allowMinimize
  • win_allowHide
  • win_allowRollup
  • win_allowRaise
  • win_allowLower
  • win_allowLayer
  • win_allowMoveto

and some are focused on system control (reboot and family)
All these options can be controlled through the preferences file.



Markdown patched

Ton Kersten / 2009-04-14 16:13:35 CEST / Permanent link / nice_tools

As you might know, this site is created with Nanoblogger and Markdown. This setup works nice and almost completely as I want it.

What I didn't like was the fact that every link opens in the current page. I think (and you may disagree, yes really, you may) that an external link can be opened in a different tab or window.

So I patched the Markdown Perl script and added an extra option for links.

Now I can define two sorts of links:
The internal (opens in the same window or tab):

[Link text](the URL to the link)

The external (opens in a new window or tab):

[Link text]{the URL to the link}

Note the subtle difference between the two. The internal uses () and the external {}.

Just take a look at the patched Markdown.pl

Update 1

When I was generating my complete site I noticed that something broke the W3C compliance. Looking into it I found that it had to do with the patched Markdown.pl. It introduced a underscore and further in the process it is translated into some HTML-code.

I've corrected the problem and a new Markdown.pl is now available.



W3C Compliant

Ton Kersten / 2009-04-14 15:57:43 CEST / Permanent link / news

I did take a lot of care to make this site W3C compliant, but a little bug entered the code. This spoiled it and W3C give me 48 errors. Of course that's too much. A little debugging session showed the problem and now I'm W3C again.

Have a look at the W3C Validation Service



Nanoblogger code plugin

Ton Kersten / 2009-04-10 12:47:46 CEST / Permanent link / nice_tools

Miek pointed me to a nice plugin for Nanoblogger called the Code Plugin

Some nice examples:

CODE(c){

include

int main( int argc, char* argv[] ) { /* A Hello world example */ (void) printf( "Hello, World!\n" );

return 0;

} }CODE

and

CODE(sh){

!/bin/bash

A Hello world example

echo "Hello world" }CODE

If you want to cut and paste code examples, just go into vi and give it a

CODE(vim){ :%s/^[0-9]* // }CODE



Editing files and posting to git

Ton Kersten / 2009-04-09 12:02:24 CEST / Permanent link / nice_tools

A couple of days ago I posted that I was converting to git. Well, that was not the completely truth. I already had switched to git.

But what I didn't like was the fact that git doesn't support keyword-expansion and therefore there's no way of knowing what version of the file you are editing. I do like this in CVS and SVN, so I implemented it in a script called vigit.

What vigit does is let you edit a file and when you quit it (after saving of course) it commits the file to git, get's the git-hash and replaces this in the file (if it's already there).

The only drawback is that the files in git are not identical to the ones on disk. I have to find a solution for this.

When you use the header script, this will give you a box with all the supported keywords. This box looks similar to:

#------------------------------------------------------------------------------#
#                    V e r s i o n   i n f o r m a t i o n                     #
#------------------------------------------------------------------------------#
# $Id:: vigit 14 2009-02-26 12:53:11Z tonk                                  $: #
# $Revision:: 14                                                            $: #
# $Author:: Ton Kersten <Ton.Kersten@ATComputing.nl>                        $: #
# $Date:: 2009-02-26 13:53:11 +0100 (Thu, 26 Feb 2009)                      $: #
# $Hash:: vigit e2963ac 2009-02-26 13:37:17 +0100 tonk                      $: #
#------------------------------------------------------------------------------#
#             E n d   o f   v e r s i o n   i n f o r m a t i o n              #
#------------------------------------------------------------------------------#

Get vigit here.



Version control with git

Ton Kersten / 2009-04-08 14:26:34 CEST / Permanent link / shell_tips

Some time ago I decided it was time to change from subversion to git for my version control system. The advantages where obvious. git is distributed and so I can code on my laptop without being connected to my home server. When I do get home I just sync the repositories and everything's OK.

But, how to do this. I took the easy road and created an user on my home server and made sure I could login with SSH key authentication. After that I did:

ssh git@server
mkdir ~/repos
cd ~/repos
mkdir <new repo>
cd <new repo>
git --bare init
git config gitweb.owner "Ton Kersten"
git config gitweb.description "Description of this repo"

Edit the file ~/repos/<new repo>/description and add a descriptive text for this repository.

On the develop client the next mantra is used:

mkdir <new repo>
cd <new repo>
git init
git remote add server ssh://git@server/home/git/repos/<new repo>
git config gitweb.owner "Ton Kersten"
git config gitweb.description "Description of this repo"

Place a nice description in the file .git/description.

Also create a global git configuration file with the commands

git config --global user.name "Ton Kersten"
git config --global user.email "Weblog_at_TonKersten.com"

Now it's time to code your fingers to the bone.

After testing, recoding and testing it's time to commit all changes:

git commit -a

and after getting home:

git push server master


MySQL Backup

Ton Kersten / 2009-04-06 11:11:41 CEST / Permanent link / nice_tools

When using a MySQL database, it's often very useful to create backups of the databases. This can be done with the MySQL dump command, but this does not allow for separate week, month and year backups. On the web I found the tool automysqlbackup and that did almost what I wanted. I changed it a lot and my version can be found here or here.



HP/UX LVM migration

Ton Kersten / 2009-04-02 21:47:13 CEST / Permanent link / nice_tools

For a customer of us we needed to migrate the complete SAN data on HP/UX 11.x machines to a new SAN. This can be done by creating a complete backup, connecting the new SAN and doing a complete restore. Not only does this take a lot of time, it also means a lot of down time. And, as you can guess, this was not an option.

Well, we had to think of something else. After giving it some thought we decided that we could solve this problem with LVM mirroring.

It goes like this:

Make sure the new SAN devices are visible

ioscan -Cdisk

Create the device files

 insf -Cdisk

Find out what the current device of a volume group is

 vgdisplay -v <volume group>

Give the next command sequence

pvcreate /dev/rdsk/<new SAN device>
vgextend /dev/<volume group> /dev/dsk/<new SAN device>
for f in $(vgdisplay -v <volume group> | awk '/LV Name/ { print $3 }')
do
    lvextend -m 1 ${f} /dev/dsk/<current SAN device> /dev/dsk/<new SAN device>
done

Now it's time for some coffee and a long wait. The system mirrors all logical volumes in the volume group

After the mirroring is done

for f in $(vgdisplay -v <volume group> | awk '/LV Name/ { print $3 }')
do
    lvreduce -m 0 ${f} /dev/dsk/<current SAN device>
done

After some testing time, when the system is considered fully functional, the old SAN can be disconnected. This can leave stale devices, but that can be solved easily with a reboot.

 pvreduce <volume group> /dev/dsk/<current SAN device>


The Header Script

Ton Kersten / 2009-04-02 21:20:06 CEST / Permanent link / nice_tools

In my daily working routine I do create a lot of shell scripts, LaTeX source and whatever. I always try to keep things simple and consistent. This not always being easy, so I wrote a Perl program that generates a standard template for a lot of standard code. This could be e.g. Bash shell, Perl, RPM spec file, LaTeX source, C source, etc.

The only thing this program needs is Perl and a file in your home directory called .name.info. This file should contain a tag and the value on a single line. An example:

name Ton Kersten
firm Ton Kersten
adr1 Address line 1
adr2 Address line 2
adr3 Address line 3
zipc Your zip or postal code
cntr The Netherlands
tele Tel: Telephone number
tfax Fax: Faximile number
mail Email adress
cpri Copyright string

Header output

The output of the header --help command

header 4.9 by Ton Kersten
Syntax: header [options]

Options:
    --nameinfo=filename Use an alternative name.info file <~/.name.info>
    --language=language Programming language <bash>
    --file=filename     Output filename
    --copyright=cpy     Copyright message (<short>|yes|gnu|none)
    --short         Use a short header
    --stdout        Print the output to stdout
    --headlang=nl|en    Which header language to use <en>
    --tabstop=n|--ts=n  What tabstop size to use <4>
    --width=n       What headerwidth to use <80>
    --vcs=cvs|svn|none  What version control system to use <svn>
    --help          Print this help

Options can be abbriviated, as long as they can be uniquely identified

Supported program languages:
    atroff bash c config html init js ksh latex nagios pascal
    perl php rexx spec tic vim

The header script

...can be downloaded here