How to backup to an external disk once it is plugged in

How it should work:

  • insert a disk with a partition labelled as backup
  • wait until the beep
  • remove the disk

To label an ext3/ext4 disk, use

e2label device [newlabel]

Then, create an udev rule that runs your script when you insert a disk with a partition named backup:

echo 'KERNEL=="sd*", ENV{ID_FS_LABEL}=="backup", RUN+="/usr/local/bin/backup.sh"' 
   >> /etc/udev/rules.d/99-backup.rules

your backup script can be as simple as this:

#!/bin/sh
/bin/mount /dev/disk/by-label/backup /media/backup && \
  /usr/bin/rsync -r /home/* /media/backup && \
  /bin/umount /media/backup && \
  /usr/bin/beep

Watch out, $PATH is not set, you shoud use absolute paths everywhere.

To make it all work, reload udev rules with

udevadm control --reload-rules

Convert a git repository from submodules to subtrees

Git submodules and git subrees are well explained in the git-scm book. Here's a small script that automatically converts the former to the later:
cat .gitmodules |while read i
do
  if [[ $i == \[submodule* ]]; then
    mpath=$(echo $i | cut -d\" -f2)
    read i; read i;
    murl=$(echo $i|cut -d\  -f3)
    mcommit=`eval "git submodule status ${mpath} |cut -d\  -f2"`
    mname=$(basename $mpath)
    echo -e "$name\t$mpath\t$murl\t$mcommit"
    git submodule deinit $mpath
    git rm -r --cached $mpath
    rm -rf $mpath
    git remote add $mname $murl
    git fetch $mname
    git branch _$mname $mcommit
    git read-tree --prefix=$mpath/ -u _$mname
fi
done
git rm .gitmodules

OK… Here's another way to add random signatures to Gmail. Now using Google Apps Script.

It almost works. It will update signatures that you store in a Google Sheet at regular intervals. The only problem is… You have to be a Google Apps for Business administrator to run this thing, because the only way to update a Gmail signature programmatically is via the Google Apps for Business Admin SDK. Ha-ha. Another problem is tha the signature only gets updated when you refresh the page. But that's a minor thing ;-)

Check it out and make a copy to have access to the script.. And here's the code:

On the usefulness of Akoma Ntoso

There's been very few laws that I followed closely, but all of them had a direct impact on my life, so I took this seriously. I didn't actually follow laws, but rather legislative processes because I either wanted a change or I was averse to it. In both cases, the object of interest was not a law itself, but its evolution.

You should already know that most laws are hand-crafted patches applied to previous laws. There are virtually no laws that are written from scratch, one notable exception is the constitution. Other laws refer to past laws.

For example, today's law that extends the powers of the Belgian intelligence service is a patch applied to the law that created the service in 1996, and it says literally this:

  • Go the the article 3 of the past law and append this extra paragraph
  • commit your changes in the legislative branch
  • push to the executive branch

If you go and search for the original law, you won't find it that easily, because laws were digitized back to 1998, while the original law dates from 1996. If you are lucky, you'll have free online access to the so-called 'consolidated' version of the law. That is, a version with all the patches applied. However:

3 disruptive technologies that will change policymaking

Version-controlled laws

Here's a EurActiv article that gives a bird's eye view of the subject of version control systems applied to legislation.

End-to-end verifiable anonymous voting

This one is better explained by Wikipedia. Here's the description of the simplest of such voting systems.

Inline comments

Here's the best implementation of inline comments until now.

 

Tags: 

Pages