Skip to main content


disorder file awk

Randomize a file lines with AWKThe goal here is simple:

I have a file (music playlist, user list,...)I want to disorder it, just like I woul beat the cardsI asked this a long time ago on Usenet (fr.comp.os.unix), and I got this anwser from St├ęphane CHAZELAS.

If the file is not too big:
awk < fichier '{a[n++]=$0} END{for(srand();n--;a[i]=b) {b=a[n];a[n]=a[i=int(rand()*NR)]}; while(++n<NR)print a[n]}'

awk < fichier 'BEGIN{srand()}{print rand(),$0}'  | sort -k1,1 | cut -d -f2-
I write it down here just for the archives
Recent posts

mediadrop direct publishing

Make uploaded videos directly published At ESTI I needed a special feature:

Students need to upload videos as anonymousAs soon as uploaded, videos need to be in the published state

Mediadrop default workflow is to have videos go through a precise workflow, as stated in the documentation.
Of course this is not what I want.
I looked for a way to hack it in order to get what I want.

I achieved this with these too commits:
Drawbacks This is a dirty hack. To make it clean, I need make it configurable through the administration interface, which is not the case as is.
That will be the next step, but let's go live for the moment.

centos kickstart gdm

Starting GDM after a Kickstart installation When installing CentOS7 from Kickstart, GDM is not starting at boot.
This is because the default target is "multi-user":

ls -l /etc/systemd/system/ lrwxrwxrwx. 1 root root 41 Mar 24 01:53 /etc/systemd/system/ -> /usr/lib/systemd/system/
To solve this, I put these lines in the "%post" section:

%post rm /etc/systemd/system/display-manager.service rm /etc/systemd/system/ ln -sf /usr/lib/systemd/system/ /etc/systemd/system/ ln -sf /usr/lib/systemd/system/gdm.service /etc/systemd/system/display-manager.service %end

HAProxy HTTPS SSH Bitbucket

Atlassian Bitbucket Bitbucket is a software developped by Atlassian and I define it like an interface to Git, in order to make it more friendly.
There is a bunch of software in Bitbucket, acting as layers in order to facilitate collaboration on code.
Last but not least, Bitbucket has a good integration with Jira, which is one of the main reasons I choosed it to be our tool at ESTI.
I thank Atlassian very much for metting ESTI use community licence of both Jira and Bitbucket.

The goal: HTTPS and SSH on regular ports Default HTTP and SSH port for Bitbucket is neither 443 nor 22. Their are configurable and it would be possible to directly make Bitbucket face those ports, but we dont like that, we'd rather setup a HAProxy instance that will forward the ports for us.
Prerequisite for that is to have a HTTPS certificate. It might be self signed or not. The one I use is not self-signed, and I bought it to Gandi, which provides an intermediate SHA2 certificate.

To sum it up, I have in my…

new google calendar week number

Display week number in the new Google Calendar For several Google accounts, Google has enabled the new calendar interface.
They are globally nice, but they do not enable the week number display.
This is not trivial to enable, but here we are:
Go to the "Settings"Go to "Browse Calendars of interest"At the very bottom, check "Week numbers"

The week number will be displayed in the
"Month view": at each start of the month"Week view": under "Monday" It wont be displayed for
"Day view""Year view"

ArchLinux Installation EFI

Installing ArchLinux with UEFI

The official ArchLinux installation page is very good, but obviously cannot cover all installation scenario.

I had to install with EFI and steps are not straight copy/paste of that page.

I will make the log story short but just pasting the commands and indicate what is needed and not in the guide.

ping timedatectl set-ntp trueUse parted instead of fdisk
parted /dev/sdaPrint existing partitions and clear them all:
(parted) print (parted) rm 1 (parted) rm 2 (parted) rm ...Create the EFI partition and fill the remaining
(parted) mklabel gpt (parted) mkpart ESP fat32 1MiB 513MiB (parted) set 1 boot on (parted) mkpart primary btrfs 513MiB 100% (parted) print (parted) quitNote that in "parted", "quit" also saves (in "fdisk", "quit" does not)

Format and mount created partitions
mkfs.fat -F32 /dev/sda1 mkfs.btrfs /dev/sda2 mount /dev/sda2 /mnt mkdir -pv /mnt/boot/efi mount /dev/sda1 /mnt/boot/efiHere is just a smal…

tc classid range

TC minimum and maximum "classid" and "flowid"
Playing a lot with TC on Linux, I one time wondered what is the min and max value of the "classid" and "flowid".

Looking to the man page, I found:
IDs consist of a major number and a minor number, separated by a
colon - major:minor. Both major and minor are hexadecimal numbersand are limited to 16 bits. There are two special values: root is
signified by major and minor of all ones, and unspecified is all
Well, to get more precise, I also put here what is the relationship between hexadecimal and bits:
Hexadecimal numerals are widely used by computer system designers and programmers. As each hexadecimal digit represents four binary digits (bits), it allows a more human-friendly representation of binary-coded values. One hexadecimal digit represents a nibble (4 bits), which is half of an octet or byte (8 bits) I hope this helped to understand several details we sometimes skip when in a rush.