Number of times each package was installed + upgraded in Arch Linux

I’ve made a Python script that (for now at least) plots the number of times each package on my system was installed + upgraded. That is, if the y-axis reads “2”, it means the package was installed and upgraded once. If the y-axis reads “1” it means the package was installed once and never upgraded.

As my system is rather new (about 2 months old), most packages were not upgraded. The package that was most upgraded was Linux (10 times), followed by youtube-dl and python-setuptools. I decided to only show the name of these 3 packages as they were the most upgraded and the x-axis would contain 531 package’s names if I were to show them all.

I seek to post the code soon on github so you can use it and modify it as you wish.

 

A very simple FICS bot in Python

Below is a Python code for a very simple bot that logs in into FICS, ask for a username and password that one must manually enter and then the bot will chat in channel 53, a channel for general discussion where guests can participate.

The code assume that you have a file called “random-words.txt” in /path-to/ directory. You can edit those according to your needs. The bot will randomly pick lines in the text file and send them in the 53th channel. It will do so at a rate of 1 line every 30 seconds by default, but this is adjustable.

Have fun editing and using this bot!


import getpass
import sys
import telnetlib
import string
import time
import random

HOST = "freechess.org"
# user = raw_input("Enter your user name account: ")
user = input("Enter your user name account: ")
password = input("Enter your password: ")
user_bytes = user.encode('utf-8')
password_bytes = password.encode('utf-8')

tn = telnetlib.Telnet(HOST)

tn.read_until(b"login: ")
tn.write(user_bytes + b"\n")
tn.write(password_bytes + b"\n")
tn.read_until(b":")
tn.write(b"\n")
tn.write(b"set tell 1\n")
tn.write(b"set pin 1\n")
tn.write(b"tell 53 Hello, I am a robot!\n")

word_file = "/path-to/random-words.txt"
WORDS = open(word_file).read().splitlines()

while 1:
    word = random.choice(WORDS)
    word_bytes = word.encode('utf-8')
    tn.write(b"t 53 " + word_bytes + b"\n")
    time.sleep(30)

HP pavilion x360 and Linux, dual boot with Windows 8.1 (part 2)

The other problem I faced was reboot/shutdown not working and booting would get stuck approximately once out of three times. The fix is simple and involves disabling two kernel modules: “echo “blacklist dw_dmac” | sudo tee -a /etc/modprobe.d/blacklist.conf” and “echo “blacklist dw_dmac_core | sudo tee -a /etc/modprobe.d/blacklist.conf“. These problems should be gone. Source: https://askubuntu.com/questions/580666/ubuntu-14-10-startup-shutdown-issues-w-hp-pavilion-x360.

Hope it helps.

Gentoo Linux, compilation of packages’s time

I had heard some complaints that in Gentoo Linux it takes way too much time to compile the packages that one would install in a “normal system”. I got curious and so I gathered this data on my own Gentoo system.

Note that :

  1. My cpu is an Intel Core i3-3217U CPU @ 1.80GHz. (laptop)
  2. As MAKEOPTS value, I have set to use 2 threads for compilation, having HT enabled and so 4 threads in total.
  3. I have 708 packages in total but only 608 of them have been compiled on my machine and so will be used in the data.

Visually the result can be summarized in the following histogram:

gentoo-data Some numbers about time of compilation in seconds (s):

Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
4.0    10.0    20.0   116.9    45.0 20580.0

So in average it took slightly less than 2 minutes to build a package on my system. Most packages take less than 50 s to build and only 3 took more than 1 hour to build (firefox/thunderbird and libreoffice).

Other numbers, about how many times I updated the packages:

Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
1.000   1.000   1.000   1.314   1.000   5.000

In other words most packages were built only once, the average number of times I’ve built a package is 1.314 and the most time I’ve built a package is 5 times.

Considering that I’ve a rather slow processor and “only” 4 GB of RAM, most people could achieve times of building packages up to 5 times lesser easily, I suppose.

Thus overall I’d say that keeping a system up to date in Gentoo doesn’t take too much time, especially on a modern hardware.

P.S.: The bash and R scripts I’ve used to gather and plot the data can be found at https://github.com/arbolis/personalscripts/blob/master/script-gentoo-time-compilation.sh and https://github.com/arbolis/personalscripts/blob/master/gentoo-results.R respectively.

HP pavilion x360 and Linux, dual boot with Windows 8.1 (part 1)

I have an HP Pavilion 11-n030ar x360 Notebook (see http://support.hp.com/us-en/document/c04439109 for the specs) and I faced two major problems when trying to use Linux (any distribution, but let’s say Arch in particular). Thanks to duckduckgo/google I know that other laptop users have faced and will face the same problems so I hope that I can help them.

The first difficulty, assuming you want to install Linux alongside Windows 8.1 in uefi mode, is that the machine will boot Windows 8.1 before anything else, so no way to access Grub or Gummiboot, etc. Well there’s a way that’s cumbersome, it’s to go into the uefi settings from Windows and then pick an option (F9 on my machine) to choose grub, to boot into Linux. But to really install it like it should be, you must go through a hack.

It seems like HP firmware wants to boot Windows no matter what, so the hack consists in renaming a linux.efi file into bootmgfw.efi and move it where the windows efi file is (and replace it) so that HP will boot Grub first, thinking it’s Windows.

I’ll assume from now and on that you have disabled secure boot and fast boot in Windows and that you have installed Linux on your hard drive. Install efibootmgr and grub.

Using the command “efibootmgr -v“, check the path of bootmgfw.efi (that’s the Windows efi file that HP uses to boot the machine) and check the grubx64.efi file from Linux. Now rename bootmgfw.efi into for instance bootmgfw.efiold. With the comandline, to do so you can do: “# mv /path_to_bootmgfw/bootmgfw.efi /path_to_/bootmgfw.efiold“. Now rename the grubx64.efi into bootmgfw.efi and move it to the path where bootmgfw.efiold is. You can do for example “cp path_togrubx64/grubx64.efi path_to_bootmgfw/bootmgfw.efi“. Now a reboot should bring Grub instead of Windows. The problem is that choosing Windows won’t boot it. For it to boot properly you’ll need to create the file /etc/grub.d/40_custom and place in it the part in the file /boot/grub/grub.cfg that refers to Windows (that is, the part that beings with “menuentry ‘Windows …’ which is situated between ### BEGIN (path) ### and ### END (path) ###. Once done, regenerate the grub.cfg file with “# grub-mkconfig -o /boot/grub/grub.cfg“. Now the whole problem should be fixed and you should be able to dual boot with Windows 8.1 normally.

Sources: https://askubuntu.com/questions/235567/windows-8-removes-grub-as-default-boot-manager, https://xpressubuntu.wordpress.com/2014/04/14/how-to-reinstall-grub-after-windows-8-1-upgrade-on-a-hp-pavilion/.

See part 2 to see the other problem I faced.

My processors temperature in function of time when running a 2 threaded program

I wanted to check out whether the processors temperature of my computer would follow a capacitor charging voltage’s like curve (see for instance http://www.learningaboutelectronics.com/images/Capacitor-charging-graph.png) when running a program that runs on my 2 threads/processors.

So I’ve written a python script that register the cores temperature every second for 2 minutes and I started Stockfish chess engine (uci, go infinite) at about second 16 or so.

The result is that yes, somehow the temperature does follow a capacitor charging-like curve:

cpus_temp_sf