Archiv des Autors: hamster

compile a cuda program with gcc-6

If one experiences this example message while compiling:

/usr/local/cuda/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
 #error -- unsupported GNU version! gcc versions later than 6 are not supported!

Try the flag CUDA_NVCC_FLAGS and set the gcc compiler to version 6:
cmake -D CUDA_NVCC_FLAGS="-ccbin gcc-6" .. && make

awk script to remove objects from a pdf

First uncompress the pdf if it is compressed with pdftk:
pdftk myfile.pdf output unc.pdf uncompress

Then remove all objects that contain the keywords PDF-XChange||PDFXCViewer20|Click to buy NOW:

awk '
    BEGIN {
    if ( $0 ~ /^[0-9 ]+obj/ ) {
    } else if (objectFound == 1) {
        if ( $0 ~ /PDF-XChange||PDFXCViewer20|Click to buy NOW/ ) {
        if ( ( $0 ~ /endobj/ ) && ( found == 0 ) ) {
            for (i=0; i<length(objektZeilen); i++) {
                print objektZeilen[i];
            delete objektZeilen;
        if ( ( $0 ~ /endobj/ ) && ( found == 1 ) ) {
            delete objektZeilen;
    } else {
        print $0
' unc.pdf > test.pdf

Recompress and repair pdf with pdftk:
pdftk test.pdf output comp.pdf compress

Too bad it also removed the OCR layer. I couldn’t find out which layer is responsible for the OCR.

extract all rars in all subdirectories with find

Findet alle multipart rars in allen subdirectories von . außer dir1 und dir2 und entpackt in dem Ordner die Dateien.

find . \( -path "./dir1" -o -path "./dir2" \) -prune -o -name '*.r00' -execdir unrar x {} \;

Wenn schon Dateien vorhanden sind, die nicht überschrieben werden sollen:

find . \( -path "./_GameRetroPacks" -o -path "./_Konsol" \) -prune -o -name '*.r00' -execdir bash -c "echo E | unrar x {}" \;

Löschen aller Rardateien in allen Unterordnern:

find . -regextype posix-extended -iregex ".+\.r[0-9ar]{2}" -exec rm {} \;

Create a guest WLAN with OpenWrt

It’s enough to do it like this tutorial says:

If you want a log of the surfing history for maybe avoid being held responsibly for the things your guest does (Störerhaftung) you can log the DNS queries:

Now you need a rsyslog server that collects those logs:

Ubuntu and a custom build zfs and spl from git

I wanted to try the 0.7.0-rc3 from git. So I cloned from git and changed to the zfs and spl version 0.7.0-rc3 tag.

Since ubuntu ships with a prebuilt zfs and spl my custom packages didn’t work.
It always loaded the prebuilt zfs and spl from the kernel modules directory but not the one I built.
I figured out a way to make it work nonetheless.

– check your currently running zfs module:

# modinfo zfs
filename:       /lib/modules/4.8.0-41-generic/kernel/zfs/zfs/zfs.ko

– remove kernel mods (make sure to have all zfs pools unmounted, otherwise it will fail):

rmmod zfs zunicode zcommon znvpair spl zavl

– remove kernel module from your current running kernel:

rm -r /lib/modules/$(uname -r)/kernel/zfs

– build deb packages for your currently running ubuntu (see their wiki):

cd $where_your_spl_from_git_resides
make clean; ./
cd $where_your_zfs_from_git_resides
make clean; ./
cd $where_your_spl_from_git_resides
./configure; make deb
for file in *.deb; do gdebi -q --non-interactive $file; done
cd $where_your_zfs_from_git_resides
./configure; make deb
for file in *.deb; do gdebi -q --non-interactive $file; done

– do a modprobe:

modprobe zfs

– check again the running zfs module:

# modinfo zfs | head -2
filename:       /lib/modules/4.8.0-41-generic/extra/zfs/zfs/zfs.ko
version:        0.7.0-rc3

After that it worked just well. I guess it has to be done for every new kernel release. If there is another better way instead of deleting modules from the kernel modules directory to make it work, please share.

PulseAudio erlaubt es nicht das Audio Ausgabegerät zu wechseln

Vielleicht liegt es am pavucontrol, dass nicht umgeschaltet werden kann. Nach ein wenig googeln findet man Kommandos, wie man die Audioausgabe über Konsole abändern kann.
pacmd move-sink-input 2 1 ging nicht. Fehler ist „Moved failed.“
Weiterer Details verrät:

hamster@hamsterkaefig:~$ pacmd list-sink-inputs
1 sink input(s) available.
    index: 2
  driver: <protocol-native.c>
  state: RUNNING
  sink: 2 <alsa_output.pci-0000_00_14.2.analog-stereo>
  volume: front-left: 65536 / 100% / 0,00 dB,   front-right: 65536 / 100% / 0,00 dB
          balance 0,00
  muted: no
  current latency: 50,91 ms
  requested latency: 23,22 ms
  sample spec: float32le 2ch 44100Hz
  channel map: front-left,front-right
  resample method: copy
  module: 14
  client: 14 <Tropico5>
    media.role = hex:
    phonon.streamid = hex: = "Playback Stream" = "Tropico5"
    native-protocol.peer = "UNIX socket client"
    native-protocol.version = "31" = "30530"
    application.process.user = "hamster" = "hamsterkaefig"
    application.process.binary = "Tropico5"
    window.x11.display = ":0.0"
    application.language = "de_DE.UTF-8"
    application.process.machine_id = "96177112fcaef6926d04e5b80000002e"
    application.process.session_id = "c2" = "sink-input-by-application-name:Tropico5"

Dort steht bei flags: "DONT_MOVE"
Danach gegoogelt findet man die Lösung z.B. hier und hier

Man erstellt eine Datei im eigenen Home namens .alsoftrc mit Inhalt:


Raspberry Pi reset wireless lan to solve problems with no connection

I found a script on which tried to reset the wlan interface in various ways. I modified that script a little with and installed in on cron and let it execute each minute (*/1 * * * * /root/bin/

# program to check wifi and reset if not running
if [[ ! -z "$(ps waux | grep $0)" ]]; then exit 0; fi
exec 2>&1 1> >(tee -a $HOME/wificheck.log)
IWCONFIG_BIN=$(which iwconfig)
RFKILL_BIN=$(which rfkill)
PING_BIN=$(which ping)
DEVICE=$(iwconfig 2>/dev/null | grep 802 | awk '{print $1}')
function isPingWorking {
        if ${PING_BIN} -c 1 ${GATEWAY} >/dev/null 2>&1 ; then
                exit 0
                echo "didn't work :("
while true; do
        # Failed, try to reset wifi - sometimes works ok
        ifdown ${DEVICE}
        sleep 1
        ifup ${DEVICE}
        sleep 10
        echo "turn wlan stick power off... "
        ${IWCONFIG_BIN} ${DEVICE} txpower off
        sleep 3
        ${IWCONFIG_BIN} ${DEVICE} txpower auto
        echo "use rfkill to reenable wlan stick... "
        ${RFKILL_BIN} list
        ${RFKILL_BIN} block wifi
        sleep 3
        ${RFKILL_BIN} unblock wifi
exit 0

Test if you have rfkill installed. The other bins should be available on most default installations.

download from vitalsource

login and save session cookie:

wget --keep-session-cookies --user-agent=Mozilla/5.0 --save-cookies cookies.txt --post-data ';user%5Bpassword%5D=asdf&amp;;;jigsaw_brand=evantage'

„print“ the whole page and look for the page with „print“ in it:;to=chapter-end

This will give you a html with all picture links in it. I saved it as links.txt
LINKS=$(sed -re '/src/!d' -e '/.js/d' -e '/.css/d' -e 's#.*src="(.*?)".*#\1#' -e 's#800#2048#' -e 's#%20# #' links.txt)
for i in $(echo $LINKS); do
wget --load-cookies cookies.txt ${i} -O "$(printf "%03d" ${counter}).jpg"

If printing isn’t available, it is possible to iterate through the pages and get the image source out of the html. Open the first page and look at the frame source code for something like „“. The number 348102883 can be iterated.
You get the image source link with:

wget --header="Accept-Encoding: compress, gzip" --header="Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" --user-agent='Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/53.0.2785.143 Chrome/53.0.2785.143 Safari/537.36' --ignore-length --keep-session-cookies --save-cookies cookies.txt --load-cookies cookies.txt '' -O - | gunzip | sed -re '/src/!d' -e '/.js/d' -e 's#.*src="(.*?)".*".*?".*#\1#' -e 's#800#2000#' -e 's#%20# #'

If there are some numbers missing there is a 302 status code. Run in a loop and first check with

wget --keep-session-cookies --save-cookies cookies.txt --load-cookies cookies.txt -S "" 2&gt;&amp;1 | grep "HTTP/" | awk '{print $2}' | head -n1

if it is 200 or 302. If 200 you can get the correct image source link.

Film aus einzelne Filmsegmente runterladen und zusammenführen von Arte

  • .m3u8 Datei finden und herunterladen
  • überflüssige Informationen entfernen
    sed -i -e '/^#/d' -e '/^$/d' index_1_av.m3u8
  • parallel die Dateien herunterladen
    cat index_1_av.m3u8 | parallel --gnu "wget -c {}"
  • Dateien umbenennen, damit in der richtigen Reihenfolge zusammengefügt wird
    for i in *.ts; do extracted_number=$(sed -re 's/segment([0-9]*)_.*/\1/' <<<"$i"); mv "$i" "segment_$(printf "%04d" ${extracted_number}).ts"; done
  • zu einem Film zusammenfügen
    cat segment_* > film.ts