This is how you can create a package of Python code so that you can use the module in various projects. Let’s assume this is the code your module has: STUFF_VERSION = “1.1-dev” def get_stuff(): return “This is stuff. Use it wisely.” Of course the module can be much more complicated with various functions and […]
Oneshot Service in Linux Systemd
My trusty old VDR box started behaving erratically: sometimes the IR remote didn’t do anything. Rebooting the whole box usually helped, but not always. Eventually I was able to narrow the problem down: for some reason the LIRC serial driver did not correctly detect the IR receiver in the serial port at the boot. I […]
Configuration File Parsing in Python
Example of configuration file parsing in Python: With the configuration file configtest.cfg: Example output: More information: https://docs.python.org/3/library/configparser.html Also available in GitHub: https://github.com/markkuleinio/python-config-parsing
Logging in Python
Example of configuring logging in Python: Output: More information: https://docs.python.org/3/library/logging.html
Argument Parsing in Python
Example of command line argument parsing in Python: Output: More information: https://docs.python.org/3/library/argparse.html Also available in GitHub: https://github.com/markkuleinio/python-argument-parsing
Linux Routing Memos
These are just small hints and memos what to do on a Debian Linux setup. This is not a complete guide on doing a secured routing environment with Linux. /etc/sysctl.conf: net.ipv4.ip_forward=1 Configure /etc/network/interfaces iptables -t nat -A POSTROUTING -o <upstream_interface> -j MASQUERADE apt-get install iptables-persistent apt-get install iftop apt-get install conntrack conntrack -L -s 10.11.1.10 […]
Identifying Raspberry Pi
How to identify your Raspberry Pi, maybe built in a nice and sealed box? Here is how: $ cat /sys/firmware/devicetree/base/model;echo Raspberry Pi Model B Rev 2 $ $ cat /sys/firmware/devicetree/base/model;echo Raspberry Pi 3 Model B Rev 1.2 $ $ cat /sys/firmware/devicetree/base/model;echo Raspberry Pi 3 Model B Plus Rev 1.3 $ $ cat /sys/firmware/devicetree/base/model;echo Raspberry Pi […]
The Issues with Lenovo ThinkPad X1 Carbon 6th Gen
I have been a ThinkPad user since 2007. The first one was Z61p I think, and after that I’ve had (either my own or employer-provided) T61, T420, T430s, T540p, X1 Carbon 4th gen and now X1 Carbon 6th gen (or X1C6, as they call it in some forums). In T540p the big disappointment was the […]
NetBox Install on Debian 9
When installing NetBox on Debian 9 and Apache, the instructions in http://netbox.readthedocs.io/en/latest/ are fine, just some small additional operations are needed. The libapache2-mod-wsgi-py3 package needs to be installed as well, otherwise you will get errors about the “WSGIPassAuthorization on” command when starting Apache [this has later been addressed in commit b917e8d] Disable the “000-default” site […]
TLS Certificates in Debian and Apache
Adding TLS configurations in Apache: cat > /etc/ssl/private/myserver.key chmod 0640 /etc/ssl/private/myserver.key chgrp ssl-cert /etc/ssl/private/myserver.key cat > /etc/ssl/certs/myserver.crt cd /etc/apache2/sites-available cp default-ssl.conf myserver-ssl.conf vi myserver-ssl.conf – add ServerName if needed – RedirectMatch ^/$ https://myserver.mydomain.com/appname (if needed) – edit SSLCertificateFile and SSLCertificateKeyFile a2ensite myserver-ssl a2enmod ssl vi 000-default.conf – add ServerName if needed – Redirect / https://myserver.mydomain.com/ […]