Build Python 3.11 From Source With TLS/SSL on CentOS 7

Building Python 3.11 from source on CentOS 7 is straightforward but it is tricky when we want to build with TLS/SSL support. The reason is that OpenSSL version (1.0.2k) in CentOS 7 is older than the minimum required by Python 3.11 i.e. 1.1.1k. This is not an unsurmountable problem because the newer version is available in the EPEL repository.

Read more …

Ansible runs task in role even when condition is false

I ran into a perplexing problem where Ansible was running a task in a role even if the role had a when condition which was resolving to false. Plus the task was failing.

To visualize it better, one task (not all) was running in the role symptom in the example playbook below,

- hosts: all
    - role: symptom
        - false

Read more …

nginx Magic Variables

Let's say an upstream, proxied by nginx, sets a cookie foo=bar in its HTTP response. To use this cookie name as a variable in nginx configuration, use the magic prefix $cookie_ and the variable becomes $cookie_foo. But how did a cookie become a variable? I call it a magic variable. It could also be called an arbitrary variable.

Read more …

Configure Wifi on Ubuntu Server with Netplan

Add a file, 1-wlan0.yaml, to /etc/netplan/ with the following contents,

$ sudo cat << EOF >> /etc/netplan/1-wlan0.yaml
    version: 2
            optional: true
                    password: "YOUR_SECRET_WPA_PSK_HERE"
            dhcp4: true
            dhcp6: true

Then apply the plan,

$ sudo netplan apply

A Case Study of Go Channels and Goroutines

Let's talk about Go channels and Goroutines and how we can get started with them using a semi-practical example.

In our case we will calculate all prime numbers from 2 to 500,000. The reason for picking this example is that determining a number is prime takes CPU time and it's an independent enough task that we can use threads to concurrently process multiple numbers. By using channels to distribute the work to Goroutines we get a well rounded way to learn about these concepts.

At the end, we will implement the same thing in Python. We will compare the implementation differences between Go and Python and how long it takes to run equivalent programs. Spoiler alert: Go is much better suited for this task.

Read more …