Author Archive

[wget] downloading images

December 11, 2017 Leave a comment

Working with a Python script, I wanted to download images from various websites. I gave this job to wget that I called as an external program. However, downloading some images failed. I verified them, and they opened nicely in my browser. What da hell?

Some web servers verify the client and if it’s not a browser, they simply block it. Our job is to make wget pretend it’s a normal browser. Put the following content in your “~/.wgetrc“:

header = Accept-Language: en-us,en;q=0.5
header = Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
header = Connection: keep-alive
user_agent = Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0
referer = /
robots = off

Problem solved. I found this tip here.

Categories: bash, web Tags: ,

working with hex grids

December 11, 2017 Leave a comment

Solving Advent of Code 2017, today (Day 11) I ran into an interesting problem. We are on a (flat topped) hex grid, and we walk around. Question: how far did we get from the starting position? In short: what is the distance between two arbitrary hexagons in a hex grid?

I’ve never worked with a hex grid before so I had to do some research. I found an excellent blog post here: Hexagonal Grids. This post is interactive, so don’t forget to move your mouse over the figures.

I figured out that I needed cube coordinates; that gives the easiest way to calculate the distances. Here is a code snippet in Kotlin:

data class Point(val x: Int, val y: Int, val z: Int) {

    fun distance(b: Point): Int {
        return (abs(x - b.x) + abs(y - b.y) + abs(z - b.z)) / 2


var x = 0
var y = 0
var z = 0

val p1 = Point(x, y, z)    // starting position

val steps = "ne,ne,ne".split(",")    // go to North-East 3 times

for (direction in steps) {
    when(direction) {
        "n"  -> { ++y; --z }
        "ne" -> { ++x; --z }
        "se" -> { ++x; --y }
        "s"  -> { --y; ++z }
        "sw" -> { --x; ++z }
        "nw" -> { ++y; --x }

val p2 = Point(x, y, z)    // we arrived here
val dist = p1.distance(p2)    // the result is here (in this example: 3)
Categories: kotlin, programming Tags: ,

Linux Journal shuts down after 23 years

December 5, 2017 Leave a comment

It’s sad but Linux Journal shuts down :( Here is the announcement: .

LJ made all the issues available in various digital formats: .

Here is a simple script to produce individual wget commands to download the PDFs one by one:

#!/usr/bin/env python3

template = "{n}.pdf&tcode=pdf-{n}-1234&action=spit"

def main():
    for i in range(132, 283+1):
        url = template.format(n=i)
        cmd = 'wget "{url}" -O {n}.pdf'.format(url=url, n=i)

if __name__ == "__main__":


$ python3 >
$ sh
Categories: linux Tags: ,

[manjaro] i686 is dead but still alive

November 26, 2017 Leave a comment

I have an old 32-bit laptop that I use for one thing only: it’s connected to my TV with a VGA cable and that’s how I watch movies. I have Manjaro on this laptop and it worked well until about two weeks ago. Since then I couldn’t update it, the repos returned a 404 error.

Today I dived in the problem and it turned out that Manjaro dropped the 32-bit support in November 2017.

However, some people still want to keep the i686 support alive. Here is the announcement of this unofficial 32-bit support.

The project also has a webpage: .

Categories: manjaro Tags: ,

Install the Numix theme and icons for Ubuntu 16.04

November 24, 2017 Leave a comment

The look and feel of Ubuntu is quite boring. It looks the same with every release. If you want a fresh look, check out the Numix theme, it looks great.

Installation instructions are here.

Here is a screenshot of my desktop. I use the Numix Circle icons.

Update (20171126): I also updated my Manjaro box. You can customize the look and feel with the Xfce Theme Manager. Here is my current setting: Themes: Vertex; Windows Borders: Numix-Manjaro; Controls: Vertex; Icons: Numix Circle; Cursors: aero-drop. With “yaourt numix” and “yaourt numix circle” you can find easily what packages to install. I wanted to go full Numix, but then my Firefox looked ugly: the title of the tabs and the texts in the popups were unreadable, so I had to mix the themes Numix and Vertex to get a good result.

Categories: ubuntu Tags: , , ,

TLDR: simplified and community-driven man pages

November 24, 2017 Leave a comment

The TLDR pages are a community effort to simplify the beloved man pages with practical examples.


(I also have a similar project called PrimCom but it has never become popular.)

Categories: bash, python Tags: ,

Write your first Firefox extension

November 20, 2017 Leave a comment
Categories: firefox, web Tags: , ,