How to install python-config on Alpine Linux

I recommend to use Python 3.x since Python 2.x is deprecated!

Installing python-config for Python 3.x

The python3-dev apk package provides /usr/bin/python3-config, so you’ll have to symlink that to /usr/bin/python-config:

apk update
apk add python3-dev
ln -sf /usr/bin/python3-config /usr/bin/python-config

Installing python-config for Python 2.x

Just install python2-dev, which installs /usr/bin/python-config

apk update
apk add python2-dev

 

 

Posted by Uli Köhler in Alpine Linux

What is DTMF playback?

DTMF – also called tone dialling – is when a phone number is being dialled by tones at a specific frequency. Each number key on the phone is assigned a combination of two specific tones that are played when the key is being pressed.
DTMF is a newer version of dialing over analog lines, compared to the older pulse dialing method.

DTMF playback controls, if your phone plays the characteristic tone for each.

If DTMF playback is enabled, every time you press a number key on your phone, you will hear the characteristic tone for that key.

If DTMF playback is disabled, you will not hear a DTMF tone while pressing the number keys on your phone.

Posted by Uli Köhler in Networking

How to change SIP port in FreePBX

In order to change the SIP port for chan_pjsip from the default port 5060 to a custom value first go to Settings => Asterisk SIP Settings

Then go to the SIP settings [chan_pjsip] tab:

Now scroll down to the bottom of the page and look for

Change it to the desired port, e.g. 15060

click Submit on the bottom right

After that, don’t forget to click Apply Config on the top right

You also need to Restart Asterisk after the change.

Posted by Uli Köhler in FreePBX

How to draw PCIe card edge connectors in KiCAD

You can download the Connector_PCBEdge library from the KiCad website and use the footprints from there for your PCI express card. You can use one of these footprints:

  • BUS_PCIexpress_x1
  • BUS_PCIexpress_x4
  • BUS_PCIexpress_x8
  • BUS_PCIexpress_x16
Posted by Uli Köhler in KiCAD

How to fix pfSense FreeRADIUS Login incorrect (eap_peap: TLS Alert read:fatal:access denied)

Problem:

When trying to login using WPA-EAP or 802.1X using the RADIUS protocol for authentication, you see an error message like

(235) Login incorrect (eap_peap: TLS Alert read:fatal:access denied): [uli/<via Auth-Type = eap>] (from client APs port 0 cli 98-55-2B-A9-76-B9)

Solution:

The issue in my case was that the CA certificate was not valid any more. Go to

Services => FreeRADIUS => EAP

and scroll down to Certificates for TLS

You need to choose correct, valid certificates for both the SSL CA Certificate and the SSL Server Certificate. The CA must be the CA that issued the server certificate: I recommend using a Let’s Encrypt certificate – if you do, be sure to select the correct Let’s Encrypt CA here!

My specific issue was that I had selected an old (expired) CA as SSL CA Certificate which caused some clients (mostly Windows) to fail certificate validation while other clients that ignored the CA certificate were able to connect properly.

Posted by Uli Köhler in Networking

How to fix FreePBX 15 The Module Named “manager” is required.

Problem:

When trying to install a FreePBX 15 module like Asterisk REST Interface Users you see the error message

The Module Named "manager" is required.

but you can’t find the manager module in the module list

Solution:

As you can see in module.xml in manager’s GitHub repository (which you can find easily by just googling FreePBX manager), the module is called

Asterisk API

Note that you can just click on the The Module Named "arimanager" is required. message if you disable your AdBlocker.

Posted by Uli Köhler in FreePBX

How to fix FreePBX 15 The Module Named “arimanager” is required.

Problem:

When trying to install a FreePBX 15 module like Asterisk Info you see the error message

The Module Named "arimanager" is required.

but you can’t find the arimanager module in the list of available modules.

Solution:

As you can see in module.xml in arimanager’s GitHub repository (which you can find easily by just googling arimanager), the module is called

Asterisk REST Interface Users

In order to install it, you also need the manager module which is called

Asterisk API

Note that you can just click on the The Module Named "arimanager" is required. message if you disable your AdBlocker.

Posted by Uli Köhler in FreePBX

How to fix Fedora CoreOS rpm-ostree error: Transaction in progress: deploy –lock-finalization revision=… –disallow-downgrade

Problem:

When trying to install a package using rpm-ostree, you see an error message like

error: Transaction in progress: deploy --lock-finalization revision=5040eaabed46962a07b1e918ba5afa1502e1f898bf958673519cd83e986c228f --disallow-downgrade 

Solution:

The error message means that currently there’s an rpm-ostree operating in progress and you need to wait for it to finish.

In order to see which process is running, use

ps aux | grep rpm

Example output:

[[email protected] uli]# ps aux | grep rpm
root         730 41.2  1.7 1218036 34568 ?       Ssl  18:41   0:30 /usr/bin/rpm-ostree start-daemon
zincati     1896  0.0  0.8 481172 17324 ?        Sl   18:41   0:00 rpm-ostree deploy --lock-finalization revision=5040eaabed46962a07b1e918ba5afa1502e1f898bf958673519cd83e986c228f --disallow-downgrade
root        3223  0.0  0.0 221452   832 pts/0    S+   18:42   0:00 grep --color=auto rpm

As you can see in the second line:

zincati 1896 0.0 0.8 481172 17324 ? Sl 18:41 0:00 rpm-ostree deploy --lock-finalization revision=5040eaabed46962a07b1e918ba5afa1502e1f898bf958673519cd83e986c228f --disallow-downgrade

the user zincati is currently running rpm-ostree on my system. zincati is the Fedora CoreOS auto-updater – in other words, an automatic system update is currently running on CoreOS.

Posted by Uli Köhler in CoreOS

ESP32 minimal Wifi access point example (PlatformIO / Arduino)

This minimal example shows how to create a wifi access point on the ESP32 using the Arduino framework on PlatformIO.

#include <Arduino.h>
#include <WiFi.h>

void setup() {
  WiFi.softAP("MyWifiName", "MyWifiPassword");
}

void loop() {
  // put your main code here, to run repeatedly:
}

As you can see, it’s really simple. Just call

WiFi.softAP("MyWifiName", "MyWifiPassword");

and the WiFi library will take care of the rest.

Posted by Uli Köhler in Electronics, ESP8266/ESP32, PlatformIO

How to ping gateway in ESP32

You can use the ESP32Ping library in order to easily ping the current gateway IP:

if(Ping.ping(WiFi.gatewayIP(), 1)) { // 1: Just one ping
  // TODO What to do on ping succes
  // Example: Print response time 
  Serial.print(Ping.averageTime()); // Unit: ms
  Serial.println(" ms");
} else {
  // TODO What to do if ping failed?
}

Full example:

#include <Arduino.h>
#include <WiFi.h>

#include <ESP32Ping.h>

void waitForWiFiConnectOrReboot(bool printOnSerial=true) {
  uint32_t notConnectedCounter = 0;
  while (WiFi.status() != WL_CONNECTED) {
      delay(100);
      if(printOnSerial) {
        Serial.println("Wifi connecting...");
      }
      notConnectedCounter++;
      if(notConnectedCounter > 50) { // Reset board if not connected after 5s
          if(printOnSerial) {
            Serial.println("Resetting due to Wifi not connecting...");
          }
          ESP.restart();
      }
  }
  if(printOnSerial) {
    // Print wifi IP addess
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());
  }
}

#define LED_BUILTIN 2

void setup() {
  Serial.begin(115200);
  WiFi.begin("MyWifiSSID", "MyWifiPassword");
  // Wait for wifi to be connected
  waitForWiFiConnectOrReboot();
  // Initialize LED
  pinMode(LED_BUILTIN,OUTPUT);
}

void loop() {
  if(Ping.ping(WiFi.gatewayIP())) {
    digitalWrite(LED_BUILTIN,HIGH);
    Serial.print(Ping.averageTime());
    Serial.println(" ms");
  } else {
    digitalWrite(LED_BUILTIN, LOW);
    Serial.println("Error :(");
  }

}

Example output

6.12 ms
5.12 ms
5.11 ms
5.16 ms
4.95 ms
4.88 ms
4.84 ms
7.67 ms
5.01 ms
4.87 ms
4.81 ms
4.80 ms
4.85 ms
5.08 ms
5.76 ms
4.54 ms
5.12 ms
2.77 ms
4.88 ms
4.84 ms
6.07 ms
5.08 ms
4.91 ms
6.04 ms
4.88 ms
4.98 ms
6.43 ms
8.18 ms
4.93 ms
5.17 ms
4.97 ms
5.46 ms
5.88 ms
4.78 ms
4.88 ms
6.03 ms
4.84 ms
5.70 ms
5.94 ms
7.25 ms
5.07 ms
4.78 ms
5.51 ms
4.99 ms
5.04 ms
4.79 ms
4.94 ms
4.81 ms
5.97 ms
5.85 ms
4.83 ms
4.80 ms
4.80 ms
6.29 ms
4.99 ms
5.04 ms
9.21 ms
5.20 ms
6.05 ms
6.14 ms
5.03 ms
4.90 ms
7.22 ms
5.06 ms
4.94 ms
9.03 ms
5.13 ms
11.97 ms
6.32 ms
6.12 ms
4.92 ms
4.92 ms
6.01 ms
4.96 ms
4.98 ms
4.94 ms
6.08 ms
6.11 ms
4.93 ms
5.05 ms
5.78 ms
4.47 ms
6.28 ms
5.02 ms
5.13 ms
5.11 ms
5.19 ms
8.89 ms
5.76 ms
5.18 ms
8.08 ms
4.97 ms
4.89 ms
4.70 ms
5.40 ms
7.46 ms
5.09 ms
4.95 ms
4.96 ms
5.01 ms
5.01 ms
4.89 ms
6.22 ms
6.76 ms
6.92 ms
6.10 ms
9.61 ms
5.29 ms
6.13 ms
5.15 ms
5.02 ms
5.03 ms
5.01 ms
6.13 ms
4.78 ms
3.90 ms
6.27 ms
8.07 ms
5.94 ms
4.50 ms
6.13 ms
4.99 ms
6.07 ms
4.80 ms
4.84 ms
4.95 ms
4.95 ms
6.78 ms
4.88 ms

 

Posted by Uli Köhler in C/C++, ESP8266/ESP32, Networking

How to fix Jupyter Hub Exception: Jupyter command `jupyter-hub` not found.

Problem:

When trying to start jupyter hub, you see this error message:

[email protected]:~$ jupyter hub
Traceback (most recent call last):
  File "/usr/local/bin/jupyter", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/dist-packages/jupyter_core/command.py", line 285, in main
    command = _jupyter_abspath(subcommand)
  File "/usr/local/lib/python3.8/dist-packages/jupyter_core/command.py", line 124, in _jupyter_abspath
    raise Exception(
Exception: Jupyter command `jupyter-hub` not found.

Solution:

Remove the space between jupyter and hub. Instead of

jupyter hub

run

jupyterhub

Example:

[email protected] $ jupyterhub                           
[I 2021-06-19 02:37:12.766 JupyterHub app:2463] Running JupyterHub version 1.4.1
[I 2021-06-19 02:37:12.766 JupyterHub app:2493] Using Authenticator: jupyterhub.auth.PAMAuthenticator-1.4.1
[I 2021-06-19 02:37:12.766 JupyterHub app:2493] Using Spawner: jupyterhub.spawner.LocalProcessSpawner-1.4.1
[I 2021-06-19 02:37:12.766 JupyterHub app:2493] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-1.4.1
[I 2021-06-19 02:37:12.773 JupyterHub app:1534] Loading cookie_secret from /home/uli/dev/jupyterhub_cookie_secret
[I 2021-06-19 02:37:12.788 JupyterHub proxy:497] Generating new CONFIGPROXY_AUTH_TOKEN
[W 2021-06-19 02:37:12.789 JupyterHub app:1808] No admin users, admin interface will be unavailable.
[W 2021-06-19 02:37:12.789 JupyterHub app:1809] Add any administrative users to `c.Authenticator.admin_users` in config.
[I 2021-06-19 02:37:12.789 JupyterHub app:1838] Not using allowed_users. Any authenticated user will be allowed.
[I 2021-06-19 02:37:12.823 JupyterHub app:2530] Initialized 0 spawners in 0.001 seconds
[W 2021-06-19 02:37:12.825 JupyterHub proxy:699] Running JupyterHub without SSL.  I hope there is SSL termination happening somewhere else...
[I 2021-06-19 02:37:12.825 JupyterHub proxy:703] Starting proxy @ http://:8000
02:37:12.946 [ConfigProxy] info: Proxying http://*:8000 to (no default)
02:37:12.948 [ConfigProxy] info: Proxy API at http://127.0.0.1:8001/api/routes
02:37:12.981 [ConfigProxy] info: 200 GET /api/routes 
[I 2021-06-19 02:37:12.981 JupyterHub app:2778] Hub API listening on http://127.0.0.1:8081/hub/
02:37:12.982 [ConfigProxy] info: 200 GET /api/routes 
[I 2021-06-19 02:37:12.983 JupyterHub proxy:347] Checking routes
[I 2021-06-19 02:37:12.983 JupyterHub proxy:432] Adding route for Hub: / => http://127.0.0.1:8081
02:37:12.984 [ConfigProxy] info: Adding route / -> http://127.0.0.1:8081
02:37:12.985 [ConfigProxy] info: Route added / -> http://127.0.0.1:8081
02:37:12.986 [ConfigProxy] info: 201 POST /api/routes/ 
[I 2021-06-19 02:37:12.986 JupyterHub app:2853] JupyterHub is now running at http://:8000

 

Posted by Uli Köhler in Python

How to run Jupyter Hub (multi-user mode) using systemd

The following script will install Jupyter Hub in single user mode (i.e. only a single Linux user can login to Jupyter Hub using the web interface).

Prerequisites

First install Python & PIP, then NodeJS, then Jupyter Hub, then configurable-http-proxy :

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs python3-pip
sudo pip3 install jupyterhub
sudo npm i -g configurable-http-proxy

Installing the Jupyter Hub systemd service

Run the following script using sudo!

#!/bin/bash
# This script installs and enables/starts the JupyterHub systemd service
export NAME=JupyterHub

# Create service file
cat >/etc/systemd/system/${NAME}.service <<EOF
[Unit]
Description=${NAME}

[Service]
Type=simple
ExecStart=/usr/bin/env jupyterhub --port=11569
User=root
Group=root

Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
EOF

# Enable and start service
systemctl enable --now ${NAME}

This script will install a systemd service named JupyterHub autostart it on boot. It is running on port 11569 by default.

Posted by Uli Köhler in Python, systemd

How to run Jupyter Hub (single user mode) using systemd for autostart

Note: This will only allow a single (preconfigured) user to login to Jupyter lab! See How to run Jupyter Hub (multi-user mode) using systemd on how to deploy Jupyter Hub in multi-user mode using systemd, which allows any Unix user to login!

The following script will install Jupyter Hub in single user mode (i.e. only a single Linux user can login to Jupyter Hub using the web interface).

Prerequisites

First install Python & PIP, then NodeJS, then Jupyter Hub, then configurable-http-proxy :

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs python3-pip
sudo pip3 install jupyterhub
sudo npm i -g configurable-http-proxy

Installing the Jupyter Hub systemd service

Run the following script as the user you want to be able to login! Do not run the script using sudo !

#!/bin/bash
# This script installs and enables/starts a systemd service
export NAME=JupyterHub-$USER
export GROUP=$(id -gn $USER)
# Create service file
sudo tee /etc/systemd/system/${NAME}.service <<EOF
[Unit]
Description=${NAME}

[Service]
Type=simple
ExecStart=/usr/bin/env jupyterhub

WorkingDirectory=$HOME
User=$USER
Group=$GROUP

Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
EOF

# Enable and start service
systemctl enable --now ${NAME}

This script will install a systemd service named JupyterHub-$USER (where $USER is the current user, e.g. uli) and autostart it on boot.

Running multiple services

If you run multiple services, you can run the script for each user and choose a unique port for each service by adding --port=7219 to the /usr/bin/env jupyter hub command, e.g.

ExecStart=/usr/bin/env jupyterhub --port=7192

Alternatively, you can run a single systemwide Jupyter Hub in multi-user mode where multiple users can log in.

Posted by Uli Köhler in Python, systemd

How to fix Jupyter Hub No such file or directory: ‘configurable-http-proxy’

Problem:

When trying to start Jupyter Hub, you see an error message like

[E 2021-06-18 13:07:48.462 JupyterHub proxy:711] Failed to find proxy ['configurable-http-proxy']
    The proxy can be installed with `npm install -g configurable-http-proxy`.To install `npm`, install nodejs which includes `npm`.If you see an `EACCES` error or permissions error, refer to the `npm` documentation on How To Prevent Permissions Errors.
[C 2021-06-18 13:07:48.462 JupyterHub app:2739] Failed to start proxy
    Traceback (most recent call last):
      File "/usr/local/lib/python3.8/dist-packages/jupyterhub/app.py", line 2737, in start
        await self.proxy.start()
      File "/usr/local/lib/python3.8/dist-packages/jupyterhub/proxy.py", line 707, in start
        self.proxy_process = Popen(
      File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'configurable-http-proxy'

Solution:

As outlined in the Jupyter Hub installation docs, you need to install the configurable-http-proxy npm package in order for Jupyter to work:

sudo npm install -g configurable-http-proxy

In case you haven’t installed npm, see our article on How to install NodeJS 14.x LTS on Ubuntu in 1 minute or find the appropriate distribution for your OS on the NodeJS download page.

Posted by Uli Köhler in Python

Resistor temperature coefficient calculator

Calculate the minimum and maximum value of a resistor based on its temperature coefficient.

TechOverflow calculators:
You can enter values with SI suffixes like 12.2m (equivalent to 0.012) or 14k (14000) or 32u (0.000032).
The results are calculated while you type and shown directly below the calculator, so there is no need to press return or click on a Calculate button. Just make sure that all inputs are green by entering valid values.

Ω

ppm

°C

°C

Posted by Uli Köhler in Calculators, Electronics

Sense resistor power dissipation calculator

TechOverflow calculators:
You can enter values with SI suffixes like 12.2m (equivalent to 0.012) or 14k (14000) or 32u (0.000032).
The results are calculated while you type and shown directly below the calculator, so there is no need to press return or click on a Calculate button. Just make sure that all inputs are green by entering valid values.

Too much power dissipation? You need to use a current sense amplifier ! See our Sense resistor / current shunt + current sense amplifier calculator !

Want to calculate the correct sense resistor value for your desired sense voltage? See Sense resistor / current shunt calculator

This calculator allows you to find out how much power your sense resistor will dissipate and how much voltage it will drop at a given current.

A

Ω

R_{text{sense}} = frac{U_{text{drop}}}{I_{text{sense}}} P_{text{sense}} = I_{text{sense}}² cdot R_{text{sense}}
Posted by Uli Köhler in Calculators, Electronics

How to fix CoreOS “WARNING: This system is using cgroups v1”

Problem:

When logging into your CoreOS instance, you see this warning message:

############################################################################
WARNING: This system is using cgroups v1. For increased reliability
it is strongly recommended to migrate this system and your workloads
to use cgroups v2. For instructions on how to adjust kernel arguments
to use cgroups v2, see:
https://docs.fedoraproject.org/en-US/fedora-coreos/kernel-args/

To disable this warning, use:
sudo systemctl disable coreos-check-cgroups.service
############################################################################

but when you look at https://docs.fedoraproject.org/en-US/fedora-coreos/kernel-args/ you only see an example of how to initialize a new CoreOS instance with Ignition files with cgroups v2.

Solution:

In order to migrate your system to cgroups v2, run

sudo rpm-ostree kargs --delete=systemd.unified_cgroup_hierarchy

After that, you need to reboot your system in order for the changes to take effect:

sudo systemctl reboot

After the system has rebooted, the error should disappear.

Posted by Uli Köhler in CoreOS