bublina

Love people, use things.

POSIX shell-only dirname replacement

For many years I have been using a snippet that worked well for all purposes I tried: a="/$0"; a=${a%/*}; a=${a#/}; a=${a:-.}; BINDIR=$(cd "$a"; pwd) But today I realized it does not play well with /, i.e. if the script is placed in /script.sh, the BINDIR will contain current directory (whatever it is) instead of /. TL;DR; the answer is a="/$0"; a="${a%/*}"; a="${a:-.}"; a="${a##/}/"; BINDIR=$(cd "$a"; pwd) UPDATE: Fixed also space handling reported at stackoverflow. Read more →

Busybox Init on Arch Linux

This is hard to believe. Arch Linux works well for me. For many years now (at least since 2007). But since 2012 I was very sad about systemd. But I did not really do anything about it. Until now. pacman -S busybox wget https://aur.archlinux.org/cgit/aur.git/snapshot/minirc-git.tar.gz tar xf minirc-git.tar.gz cd minirc-git makepkg -si ln -s /dev/null /etc/systemd/network/99-default.link systemctl reboot It is hard to believe it was so easy. Still using the systemd udev. Read more →

Mini Computers

There are many mini-computers on the market. I will name just a few here: Raspberry Pi OrangePi Pine64 JaguarBoard BananaPi Little Panda CHIP Computer Adapteva Parallella There are some related links I want to mention as well: Zigbee openHAB Read more →

London Quick Guide

London is a wonderfully diverse city. Here are some useful apps and hints: Citymapper is the app for public transport. 4G on Lycamobile works really great, just do not try to compile meta-raspberry Yocto layer through it as the limits are quite low for such experiments. Compiling Buildroot is OK though as it has much less dependencies to download… :-) Use public libraries! They are great! But even there it’s better to use internet over 4G. Read more →

Playing with hard links

Hard links can be very useful, but also nasty. I used them to my advantage when I was hosting the same files on multiple domains, but they bit me back because Git does not support them. First, how to make hard links if there are the same files with same names in the same directory structure? #!/bin/sh MDIR=${1:-"$HOME/some-default"} MDIR=${MDIR%%/} find $MDIR -type f \ | sed "s|^$MDIR/||" \ | while read f; do cmp $f $MDIR/$f 2>/dev/null \ && ln -vnf $MDIR/$f $f; done And in order to revert it, following script might be useful: Read more →