Xpath expression ignoring the namespace

July 10, 2018

If you need to search an xml document specifying a default namespace, the libraries such as libxml2 etc. have problems to search for xpath expressions.

The following xpath expressions will ignore any namespace, just checking for the local name of the element:

In XPath 1.0


Selects any element with “name” as local-name.

In XPath 2.0 you can use:


bash-script spinner

March 14, 2018

The following bash-function is displaying a spinner as long as data can be read from stdin, for example reading from pipe. In the moment the stdin stream is closed, the spinner will terminate.

Credits: It is a modification of the spinner of http://fitnr.com/showing-a-bash-spinner.html


  ## hide the cursor
  tput civis

  local spinstr='|/-\'
  printf " [%c] " "$spinstr"
  while read -N 30 chunk; do
     printf "\b\b\b\b\b\b"
     local temp=${spinstr#?}
     local spinstr=$temp${spinstr%"$temp"}
     printf " [%c] " "$spinstr"
  ## overwrite the spinner
  printf "\b\b\b\b\b\b "
  ## return to original cursor position
  printf "\b\b\b\b\b\b"
  ## unhide the cursor
  tput cnorm


This spinner can be used to display a progress when performing an untar or  to show activity in syslog file:

tail -f /var/log/syslog | spinner

Synaptic on Ubuntu 17.10

February 17, 2018

Synaptic tool is not starting on my Ubuntu 17.10, the window does not appear. It seems that root-user lacks privileges to access the window manager.
The following command will grant access to root to open an X-window on Ubuntu 17.10 for this session only.

xhost +si:localuser:root

Afterwards execute synaptic as super-user (root)

sudo synaptic

Lösung Känguru Stufe 5/6 (2016) Aufgabe C3

February 7, 2018

Die Lösung lautet 13, berechnet mit folgendem Python Programm:

for A in range(16):
  for B in range(16):
    C = 7;
    D = 3;
    for E in range(16):
      F = 1;
      for G in range(16):
        H = 6
        for I in range(16):
        J = 2
        if A+B+C == C+D+E and C+D+E == E+F+G and E+F+G== G+H+I and G+H+I == I+J+A:
          print (A)


Samsung CLX 3185FN LAN access with Ubuntu 17.10

February 5, 2018

The official Samsung driver (universal linux driver ULD) does not support access to the printer/scanner functionality via LAN. Seems, this driver supporting  devices attached via USB.

For LAN access, just the Open Source Samsung Universal Linux Driver (SULD) is working for me (project page at http://www.bchemnet.com/suldr/index.html).

If you intend to install the SULD,  you will need to perform the following steps (sudo-permissions are required on your host):

Install the packages libsane-extras, and xsane

sudo apt-get intall libsane-extras
sudo apt-get intall xsane

Install the SULD driver following the instructions from project http://www.bchemnet.com/suldr/index.html

The following steps must be performed, namely adding the SULD repository to your resource list, add the signature-key to your truststore, update the local database, and finally the installation of the  suld-driver.

sudo bash -c 'echo "deb http://www.bchemnet.com/suldr/ debian extra" >> /etc/apt/sources.list'
wget http://www.bchemnet.com/suldr/pool/debian/extra/su/suldr-keyring_2_all.deb
sudo dpkg -i suldr-keyring_2_all.deb
rm -f suldr-keyring_2_all.deb
sudo apt-get update
sudo apt-get install suld-driver-4.01.17

Now add your user $USER to both groups “scanner” and “lp” (will require logout or reboot)

sudo usermod -a -G scanner $USER
sudo usermod -a -G lp $USER

After reboot and login, the tool “xsane” should discover the scanner, and you should be able to choose the printer in setup-tool.

Converting sequence of images to video

January 20, 2018


First rename all images, starting with counter 0000, then use ffmpeg to create the video

# Rename all images in local folder to format IMG_0000.JPG, etc.
for datei in `ls` ; do 
   neuname=$(printf "IMG_%04d.JPG\n" $zaehler); 
   echo "$neuname"; 
   mv $datei $neuname; 
   zaehler=`expr $zaehler + 1`; 

# Convert images to video-stream, using framerate 4
ffmpeg -framerate 4 -i IMG_%04d.JPG -c:v libx264 \
    -profile:v high -crf 20 -pix_fmt yuv420p output.mp4


Flow Chart Editor on Linux

January 10, 2018

Recent years I really missed a _good_ flow chart editor for Linux, I am glad I found one yEd of https://www.yworks.com

Creating uninitialized socket-recv-buffer with Rust

October 4, 2017

Programming Rust: Assuming one wants to recv data from socket,  storing the data into an byte buffer. Either you create a byte-array, initializing each element with well defined value, such as the following  code zero-ing the memory chunk completely.

fn recv_handler() 
  let mut recvbuf : [u8; 2048] = [0; 2048];

Or, as zero-ing of large byte-buffers may be time-consuming and as the net-socket recv-function does not read from supplied buffer anyway, creating an uninitialized byte-buffer to recv the data from socket.

use std::mem;

fn recv_handler() 
  let mut recvbuf : [u8; 2048] = unsafe { mem::uninitialized() };

The memory of recvbuf will be located on stack, no dynamic memory allocation will be involved, and the corresponding memory section is not zero-ed out.

Samsung CLX-3185FN with Ubuntu-17.04

August 27, 2017

With Ubuntu 17.04 network-printer support for Samsung CLX-3185FN multi-functional-device works out of the box, except its  scanner is not discovered by tools like Simple-Scan.

To get the scanner discovery working, install the driver from “Samsung Unified Linux Driver Repository” (SULDR) http://www.bchemnet.com/suldr/

Configure package source as documented at: http://www.bchemnet.com/suldr/

Finally install the driver package suld-driver2-1.00.36.

Afterwards starting the GUI tool “Simple Scan” the scanner-device should be discovered in the network.

Howto virt-builder debian-9 using serial console

July 25, 2017

I am using the Virtual Machine Manager (virt-manager) on the Ubuntu distro. The documentation is sparse regarding the setup with debian-9 guest systems (systemd based) using the virt-builder but with ‘none’ graphics support. Most blogs refer to ‘adding kernel parameters to /etc/inittab’ but this SYSV-config-file does not exist any longer since transition to systemd. It is required to set kernel parameter  that redirect  console IO  to  ttyS0.  With systemd this can be  achieved defining grub-default-parameters in file /etc/default/grub and re-creating the grub-menu-config.

Building the image:

sudo virt-builder debian-9 -v -x -o my-image.qcow2 --hostname dnssv.intern --root-password password:root --install "bind9,bind9-doc,dnsutils" --edit '/etc/default/keyboard: s/^XKBLAYOUT=.*/XKBLAYOUT="de"/' --edit '/etc/default/grub: s/^GRUB_CMDLINE_LINUX_DEFAULT=.*/GRUB_CMDLINE_LINUX_DEFAULT="console=ttyS0"/' --run-command '/usr/sbin/update-grub2'

Installing into virtual machine manager:

virt-install --name dnssrv --ram 256 --disk path=my-image.qcow2,format=qcow2 --import --graphics none

Instead of graphical windows with scaled fonts, on startup you should see a simple text console.

The tooling is available installing the following debian packages
sudo apt-get install libguestfs-tools
sudo apt-get install virt-manager