## Seine flooding

On this mounth, the Seine decided to flood Paris and its neighborouds, so I took my camera to take pictures. I realised:

### people live on boats

Even when it is barely reachable

## UTF8, base64 and other encoding conversion

A common way to represent binary files in ascii-only diplay is to use base64. This is also done a piece of software does not handle unicode: it manipulate its base64 representation.

Let’s take as example this 2 binary sequence represented in base64:
6YCZ5YCL57ay56uZ5piv576O6bqX55qECg== and dGhpcyB3ZWJzaXRlIGlzIGJlYXV0aWZ1bAo=

• to text/unicode:
 echo '6YCZ5YCL57ay56uZ5piv576O6bqX55qECg==' | base64 -d
 echo 'dGhpcyB3ZWJzaXRlIGlzIGJlYXV0aWZ1bAo=' | base64 -d
• to text/unicode:
 echo '6YCZ5YCL57ay56uZ5piv576O6bqX55qECg==' | base64 -d | xxd -p -i | sed -e's/, //g'
 echo 'dGhpcyB3ZWJzaXRlIGlzIGJlYXV0aWZ1bAo=' | base64 -d | xxd -p -i | sed -e's/, //g'
• from hex:
echo 'e98099e5808be7b6b2e7ab99e698afe7be8ee9ba97e79a840a' | xxd -p -r
• mix hex and ascii to ascii:
echo -e 'this\x20website\x20is\x20bueatiful'

## GPG key renewal

What happen when a PGP key expire? Obvious answer: you can no longer securely use it. Nevertheless, you may not delete it as you must be able to read your encrypted files.

Basics step that should be done are:

1. generate a new (sub)key
3. test your newly generated key

## generate a new key

### first setup

For the first key generation, you should have used
The common way using pgp is:

gpg --gen-key


On some installation, you may have used gpg --full-gen-key  to a obtain a dialog for each option

### key rotation

You must generate a new subkey:

gpg --edit-key
> save


Then you add two keys: one to sign and one to encrypt. Do not forget to save your changes.
I recommand to use the default choice when creating a new key (RSA and RSA for my current installation)

quite simple:

gpg --keyserver pool.sks-keyservers.net --send-keys


you may use any keyserver of your choice. A short list include pgp.mit.edu, keys.gnupg.net, subkeys.pgp.net, keyserver.ubuntu.com.

## loop devices

Loop devices are used to acces any file as if it were a block device such as a disk. On GNU/linux, the canonical command to interact with loop devices is losetup. To list the next usable loop device: losetup -f

## disk image loop mount

The most spread usage of loop devices is mounting a file such as an iso or a img file as if it were a disk.

newloop = $( losetup -f ) losetup$newloop /path/to/iso
mount -t cd9660 /dev/$unit /mnt # -t mandatory  ## swap file over any filesystem swap can be either into a dedicated partition or into a file. In the second case, the file cannot reside anywhere. I understand (but I may be mistaken) that the kernel will try to access the swap file without using VFS. Thus, the number of filesystem a swap can reside on is limited and does not include network filesystem. One way to avoid this limitation is to create a loop device. The kernel will access a block device (the loop device). You may expect a dramatic fall in performance (due to number of abstraction layers). Donnot forget that swap can host cached information in an unencrypted way (such as RAM, but in a more persistent way). ### create file First of all, you may create a file. The most obvious way is to use dd: dd if=/dev/zero of=/path/to/file bs=1M count=512  But one can also use truncate: truncate -s 512M /path/to/file  Do not forget to format it as a swap partition (man mkswap) if you use it a partition or to check permissions if you use it as a swapfile; and to activate this swap (man swapon). ### mount file This section is greatly inspired by this post. swapfile=$(losetup -f)
truncate -s 8G /path/to/file       # create 8G sparse swap file
losetup $swapfile /path/to/file # mount file to loop mkswap$swapfile
swapon $swapfile  ## awesome global shortcut The awesome window manager does not provide GUI configuration tool. Here is a litte how to to provide a feature using global shortcut, illustrated with wolume control. ## Defining and identifying the feature and the shortcut The wanted feature is usually accessible via the CLI. For example, to modify the sound, the alsa provides the amixer command (via the alsa-utils package in archlinux): amixer set Master 40% # put Master level to 40% amixer set Master 9%+ # increase Master level by 9% amixer set Master 9%- # decrease Master level by 9% amixer sset Master toggle # toggle Mute on Master  The shortcut can be a combination of keys including the modkey. You may also use some of the Xfree86 key binding[1. here is a list] if your keyboard provides use some multimedia keys. For sound control, the symbols of interest are XF86AudioRaiseVolume, XF86AudioLowerVolume and XF86AudioMute. ## Modifying configuration files I don’t fully understand the functionning of the awful.key function. It allows to execute a command when pressing some keys. Those keys are sepcified in the first two parameters, and the lua function executed in the last parameter. Several example can be found on the awesome wiki. To enable a global keybinding, this awful.key() function must be placed inside the global.keys() function. The configuration file to modify is the rc.lua whose default location is inside the $XDG_CONFIG_HOME/awesome/ directory (~/.config/awesome/ in my case).

For the sound configuration, modify the globalkeys adding the three wanted features:

globalkeys = awful.util.table.join(
...
awful.key({ }, "XF86AudioRaiseVolume", function () awful.util.spawn("amixer set Master 2%+") end),
awful.key({ }, "XF86AudioLowerVolume", function () awful.util.spawn("amixer set Master 2%-") end),
awful.key({ }, "XF86AudioMute", function () awful.util.spawn("amixer sset Master toggle") end),
...
)


## random unix notes (part II)

Few weeks ago, I wrote down about some unix tools. Here are some other multiple process using the same stdout/stdin file desricptor.

## file descriptor

The 3 most used file descriptors are stdin, stdout and stderr. A command’s stdout can easily be redirected to another command’s sdtin using pipe mechanism.

More about file descriptor can be found in this stackoverflow answer and this tiny tutorial. In short, file descriptors are located under /dev/fd/ (e.g. stdin is /dev/fd/0) and an unnamed pipe can be created using NN>&1 (redirecting stdout to /dev/fd/NN).

## piping from multiple processes

The problem is the following: I have multiple command and I want to concatenate all the outputs. An obvious and easy way is to pipe all the outputs as input to the cat command. To do so, one must group all this commands together:

bin
include
info
lib
lib64
libexec
local
lost+found
sbin
share
src
var
November 2015         December 2015         January 2016
Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su  Mo Tu We Th Fr Sa Su
1      1  2  3  4  5  6               1  2  3
2  3  4  5  6  7  8   7  8  9 10 11 12 13   4  5  6  7  8  9 10
9 10 11 12 13 14 15  14 15 16 17 18 19 20  11 12 13 14 15 16 17
16 17 18 19 20 21 22  21 22 23 24 25 26 27  18 19 20 21 22 23 24
23 24 25 26 27 28 29  28 29 30 31           25 26 27 28 29 30 31
30


UPDATE: Moreover, one can use calendar [1. available on debian in the bsdmainutils package] along with its own shell script(s) to periodically check upcoming events and possibly mail reminders.

## this morning thought

Pour toi qui est touché, par ces rafales d’horreur
Pour toi qui  est tombé, et pour toi qui a peur
Pour toi je vais danser, la rage de vivre au ventre
Pour toi je vais lutter contre cette épouvante

Le poing plein de colère, et les yeux plein de larmes
Pour toi je lève mon verre, car c’est là ma seule arme
Contre cette lâche force, qui se cache, qui attends
Et qui tire sa force de notre enfermement

Oui pour toi je vais vivre, pour toi je vais jouer
Faire comme dans les livres, me permettre de rêver,
Et le faire pour toi

Celà ne m’empèche pas, d’aider dans la douleur
Tout ces proches qui sans toi, on perdu toute candeur
Et le faire pour toi

## random shell notes

Few month ago, I wrote some notes about Unix. Now is the conterpart about shell scripts. Note that many forum will give bash-specific help, and I’m not curently using bash (I use zsh).

## wait until enter is pressed

the more portable I found until now:

while read answer; do
done < "myfile"