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.

 

Advertisements

Entropy of /dev/random in function of time

With a simple bash script, I’ve monitored the entropy in /dev/random, the entropy of the Linux kernel entropy pool. Note however that the way I’ve done it, it lowers the entropy’s pool level by a few bits at every entropy’s level check. So that I’ve limited the entropy checking at a frequency of 1 measurement every 2 seconds, during 6000 seconds (1 h 40 mins).

Here’s a quick summary of the data obtained:

Min.   : 728.0
1st Qu.: 929.0
Median : 986.0
Mean   : 982.3
3rd Qu.:1040.0
Max.   :1202.0

sd:78.52207

Here’s a histogram and a plot of the entropy pool level in function of time:

entropy-vs-timehistogram-entropy

 

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)

Average number of stones randomly placed on a 19×19 goban so that 2 are adjacent

This time what caught my attention was the average number of stones ramdomly placed on a 19×19 goban required such that 2 stones are adjacent.

So I’ve written a python program (https://github.com/arbolis/pythonstuff/blob/master/goproblem_random/gorandom_1.py) and a R script for the plotting part (https://github.com/arbolis/personalscripts/blob/master/goban_random.R) to solve the problem numerically. It turns out that the number is around 13.1 which, in my opinion, is counter intuitive in the sense that most go players expect that number to be much higher (scarce are the go players who predicted a number below 30).

Anyway here is a summary of the data after 1,000,000 simulations of placing stones on a 19×19 goban until 2 stones are adjacent:

Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
2.00    8.00   12.00   12.97   17.00   49.00

And there comes a bar plot:bar-plot-go-19x19

I find that plot interesting and the summary of the data interesting.

Now I could get similar data for the 8×8 chessboard. Out of my memory the number of pieces randomly placed on a chessboard until 2 are adjacent is around 6.1. I expect a similar histogram than the one for the game of go somehow, except that the width of the distribution should be much smaller.