Update: Hugo, FA Cup Semi, Analysing Sleep

April 25, 2017

Categories: Personal Tags: update


So guess it’s that time of the year when I check out if I can find any interest in writing without having anything in particular in mind. Probably won’t, though part of the problem used to be the insanely egregious technology stack involved in doing anything web related easily, but it has gotten better I think. Static site generators have become much simpler for example. Although I don’t touch Golang if I can help it, but statically linked native executables are always nice and I don’t really have any problem with using anything written in it. I use the fuzzy finder fzf a lot in my scripts for example.

Anyway, the static blog generator Hugo seems to be good. It’s fast, has a vibrant community (important for, at least, themes) and recently started supporting Org-mode natively so pretty featureful as far as I am concerned. Only problem is that somehow I couldn’t stand practically every theme there is when the reason I am trying to use it in the first place is that I don’t fancy rolling one on my own. So still going with the one that I found to be the most reasonable, called nofancy. Kind of approve the philosophy of it.

FA Cup Semi

Such was the season that despite the stature of the game, I thing I wasn’t the only one feeling remarkably dispassionate. But to be fair, naivete in defence let us down big time this season (duh), otherwise the squad was quality. So the three in the back with two wingbacks is not what I would have guessed Wengerball would devolve into, but Wengerball is practically dead and you have to do what you must to shore up. So credits to Wenger and Gabriel-Holdini in particular for a mature showing. Funnily enough, Ox was amazing and Monreal scored the vital equalizer from his cross. Was a gritty display overall.

Analysing Sleep

I will admit, I don’t have the best sleep hygiene these days. It would have been nice to have some data on these sort of things. I see people use fitbit or apps like sleep cycle and it’s pretty cool. But I don’t have that, what I have here is a poor proxy. Usually the last thing I do before hitting the bed is logging off from the computer and vice versa.

Apparently I have been using this distro called Void Linux for a bit more than 6 months now. I only ever really used Lubuntu before, despite the occasional distro hopping. This was my first foray into rolling releases and the somewhat obscure reputation notwithstanding, it could hardly have been better. But that’s a post for another day. What’s of relevance here is that in Linux systems the login data of all users in your machine is kept in /var/log/wtmp file. It’s a DBase III database format, whatever that means. The command last extracts information from it and prints it in a readable manner. Well the readability of these high level utilities doesn’t always imply the output can be easily parsed, but it’s not bad here.

The annoying part is that usually when I go to bed, it’s technically the next day on the log. Sometimes I even do reboot deep into the night. I just had to keep track of the last log on up to a cut-off time, say 8 in the morning of the next day. In the grand tradition of completely unreadable Perl one-liners, this was my write-only attempt:

last | head -n -2 | tac | head -n -1 | perl6 -e 'my $c=0; my $b=(0,0); for lines() {my $a=$_.split(/\s+/); my ($d,$h1,$m1,$h2,$m2)=($a[4],$a[5],$a[7])>>.comb(/\d+/).flat; if $c != $d and $h1 >= 8 { say $b[0]+$b[1]/60 if $b[0] < 13; $c=$d; }; $b=($h2,$m2);}' > data

The hour and minute was collapsed into decimal format because I wanted to feed this into something general purpose. A brief search led me to this repo called data-hacks which contains a histogram tool. Afterwards I reverted that into normal time and hour with another regex pass. Had to be careful and do a bit of post-edit to not mess up the percentage data.

cat data | python2 histogram.py -m 0.0 -x 12.0 -b 12 -p | perl6 -pe '$_ ~~ s:g/(\.\d\d+) <!before "%">/{sprintf ":%02d", ($0 * 60).floor}/;'

Erm, yeah it’s tempting to all day simply talk about how crazy Perl is. Anyway, that gave us:

# NumSamples = 183; Min = 0:00; Max = 12:00
# Mean = 4:25; Variance = 3:04; SD = 1:45; Median 4:18
# each ∎ represents a count of 1
    0:00 -     1:00 [     5]: ∎∎∎∎∎ (2.73%)
    1:00 -     2:00 [     5]: ∎∎∎∎∎ (2.73%)
    2:00 -     3:00 [    12]: ∎∎∎∎∎∎∎∎∎∎∎∎ (6.56%)
    3:00 -     4:00 [    44]: ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ (24.04%)
    4:00 -     5:00 [    81]: ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ (44.26%)
    5:00 -     6:00 [    21]: ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎ (11.48%)
    6:00 -     7:00 [     1]: ∎ (0.55%)
    7:00 -     8:00 [     4]: ∎∎∎∎ (2.19%)
    8:00 -     9:00 [     1]: ∎ (0.55%)
    9:00 -    10:00 [     5]: ∎∎∎∎∎ (2.73%)
   10:00 -    11:00 [     2]: ∎∎ (1.09%)
   11:00 -    12:00 [     2]: ∎∎ (1.09%)

Aaaaand, that’s just woeful. Not to mention, there were phases (early November and then late December) when I practically forgot how to sleep. Obsessing (TV Tropes warning) over it certainly didn’t help.

Interestingly, the file /var/log/btmp holds all records of failed login attempts. Naturally you need root access to view this. I found my password a few times in it ;)

Likewise I can also see the first login time in every morning. But that would be less revealing without finer analysis because of greater variation in it. Also, I really should learn some gnuplot.