Shell

Alpine, tmux and UTF-8

A quicky in case anybody has the same issue. I use pine / alpine as a mail client since my firsts steps on the UNIX/Linux world, it always served me well.
Nevertheless, since a couple of weeks, I had this weird behavior where the mail content pager would not display accents (éàü…) while the mail list would! Worse, this inconsistent behavior only happened in tmux.
I suspected something involving locales but no, everything was fine on this side.
So it turns out alpine’s mail content pager doesn’t know how to cope with a value of screen-256color in the TERM variable. Changing it to xterm-256color fixed accents display.

Push Motion Image Capture to Telegram

I use the fantastic motion project to monitor my apartment activity when I’m not home (not happening until God knows when these days…). I wanted it to warn me when there’s movement more interactively than with a basic email. Telegram and its very well documented bot API is really perfect for this task, so I came up with the following motion configuration:

on_picture_save /bin/sh /home/imil/bin/on_picture_save.sh %f

and more importantly, the following script:

#!/bin/sh

. ${HOME}/.tg

ffile=${HOME}/tmp/motion_capture

f=${1%?????????}

mplayer ${HOME}/Music/42899__freqman__canon-dos-d30-no-focus.wav

[ -e ${ffile} ] && [ "$(cat $ffile)" = "$f" ] && exit 0

curl -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendPhoto" \
 -F chat_id=${CHATID} -F photo="@$1"

echo $f > $ffile

the ~/.tg file has the following content:

Migrating from Hexo to Hugo

Brand new iMil.net!

I’ve wanted to switch from hexo to hugo for quite a long time for various reasons, one of them being I love golang and, well, let’s just say I don’t like javascript / node much. Also, hugo documentation is pretty well done, its author is a well known figure in the golang community, and last but not least, I find the overall workflow more simple and consistent.

I delayed the migration because I wrongly thought articles front-matter modifications would be painful, but it turns out it was pretty much straightforward:

Monitor network health with somebar

I knew about a MacOS task bar plugin called Anybar, which basically draws an icon on the task bar to which you can send behaviors with a simple nc command. Naturally, someone cloned it for our beloved Free Unices environments, and it’s called somebar.

I am sometimes in places with weak network, and I like to see at a glance how is my connection doing, somebar seemed the perfect tool for the task.

Tricking bash HISTTIMEFORMAT

While trying to find a clean method to remove line numbers from the history command, I found an interesting trick by using the HISTTIMEFORMAT environment variable. Here’s what bash’s man says:

       HISTTIMEFORMAT
              If  this  variable  is  set and not null, its value is used as a
              format string for strftime(3) to print the time stamp associated
              with  each  history  entry displayed by the history builtin.  If
              this variable is set, time stamps are  written  to  the  history
              file  so they may be preserved across shell sessions.  This uses
              the history comment character  to  distinguish  timestamps  from
              other history lines.

But it turns out you can actually put pretty much anything in there, and for example, an ANSI escape sequence that does a line feed and erases the current line:

Extract data-bits from your Jenkins jobs

Another quicky.

I read here that cool trick to convert HTML entities to plain text:

alias htmldecode="perl -MHTML::Entities -pe 'decode_entities(\$_)'"

In a Debian based system, this suppose to apt-get install libhtml-parser-perl. Why bother you may ask? Well because the (awful) Jenkins-cli outputs text areas content in encoded HTML entities, and for example I like the idea of being able to test a standalone packer template that’s failing.

Finally, here’s the full usecase:

sysutils/shelldap dans les bacs

Connaissez-vous shelldap ? Cet outil absolument indispendable est L’Outil que j’attendais depuis des années. Saoulé que j’étais de la machine-à-coredumps gq et de l’usine à gaz lat, j’implorais les Dieux du code de faire apparaître quelque part sur l’internet convivial un outil pratique pour éditer des bases LDAP, possiblement en console, fou optimiste que je suis.

Et bien cet outil existe. Et il est énorme. Comme son nom l’indique, il s’agit effectivement d’un shell-like destiné à la consultation et l’administration de bases LDAP, avec la completion s’il vous plait.

Regexp du soir, espoir

Dans ma tentative de conquete du monde, je suis confronté à un problème auquel je n’avais pas immédiatement pensé. En effet, une foule d’outils partagent sans vergogne certains noms de fonction (usage(), help(), error()…) et de variables globales. Cet ennuyeux constat aboutit evidemment à des problèmes de linkage et faisait lamentablement foirer la compilation de mon BeastieBox cheri.

Une solution evidente était de renommer ces fonctions et leurs appels. mais…

Flemme quoi.

merde, j'ai pas de backup...

Combien de fois cette phrase a retenti dans vos esprits imprudents ? dans mon esprit imprudent à moi, plein. Alors, comme je viens de toper un kimloli sur les conseils de mon bouquetin favori, je me suis dit que, pour une fois, j’y collerais bien une procedure de backup propre.

J’ai déjà parlé et probablement pasté ici même un petit script gentil qui, grâce au couple rsync / rsyncd, permettait de rendre cette opération relativement rapide assez simplement. J’y ai apporté quelques modifs et enrobé le tout d’un chouillat de sécu. Un chouillat j’ai dit, trépigne pas spoty.