Skip to content

Instantly share code, notes, and snippets.

View HNJAMeindersma's full-sized avatar

Rick HNJAMeindersma

View GitHub Profile
@HNJAMeindersma
HNJAMeindersma / changedetection_price_notifications.md
Last active July 24, 2024 10:04
Pretty Gotify notifications from ChangeDetection.io's Price-mode

This is a very, very dirty way of turning ChangeDetection.io's price-mode output, which is JSON, into a more friendly markdown format. Using Jinja2, which is currently lacking a from_json function, we replace parts of the JSON output to form a markdown message. This will only work correctly as long as ChangeDetection.io's price-mode override JSON format stays EXACTLY the same. Any non HTTP 200 response might trigger such a change in which case a malformed message might be produced and send. Not something that could (should) "break" your ChangeDetection.io or notification service. Which is Gotify in this example gist. Tested with Tweakers.net Pricewatch product pages.

Example output

Some Product has changed!

  • Lowest: 235.67 → 235.65
  • Highest: 482.57
  • Sellers: 33
  • Currency: EUR

https://tracking-and-comparing-web.site/some-product.html

@HNJAMeindersma
HNJAMeindersma / install_frontail.sh
Last active March 14, 2024 10:56
This script installs openHAB on a Debian Linux system anno 2024
#!/bin/bash
# Install frontail
sudo apt install -y nodejs npm &&
sudo npm install frontail -g &&
echo "[Unit]
Description=Frontail openHAB instance
Documentation=https://github.com/mthenw/frontail
After=openhab.service
PartOf=openhab.service
@HNJAMeindersma
HNJAMeindersma / dsmr_to_mqtt.py
Created February 20, 2024 13:34
Script that reads serial data from a DSMR P1 port with a FTDI USB cable and post it via MQTT
#!/usr/bin/env python2
# Import required libraries
import datetime
import collections
import re
import sys
import serial
import crcmod.predefined
import json
@HNJAMeindersma
HNJAMeindersma / LibreELEC-11.0_HDMI-CEC_HTTP_bridge.py
Last active February 16, 2024 21:21
Goal is to control switching HDMI sources on my TV, unfortunately my TV's API is hardly working so I'll need HDMI-CEC. Since LibreELEC-11.0 has no default package manager, thus PIP packages cannot easily be installed (like paho.mqtt). And considering cec-client is not functioning properly on my system, thus the more difficult cec-ctl had to be u…
from http.server import BaseHTTPRequestHandler, HTTPServer
import re
import subprocess
import json
# Function: add value to dictionary
def nested_set(dic, keys, value):
for key in keys[:-1]:
dic = dic.setdefault(key, {})
dic[keys[-1]] = value
@HNJAMeindersma
HNJAMeindersma / host_setup.sh
Last active July 10, 2023 18:22
TVheadend pipe creator from .m3u
#!/bin/sh
# Install TVheadend
curl -1sLf 'https://dl.cloudsmith.io/public/tvheadend/tvheadend/setup.deb.sh' | sudo -E bash
sudo apt update && sudo apt install -y tvheadend
# Install ffmpeg piper
sudo apt install -y curl ffmpeg
sudo mkdir /etc/tvheadend && sudo chmod a=rwx /etc/tvheadend
echo "#!/bin/sh
@HNJAMeindersma
HNJAMeindersma / X-USB PulseAudio.md
Created March 22, 2020 14:38
[Behringer X32 / Midas M32] Split a multi-channel X-USB into virtual outputs with PulseAudio on Linux/Ubuntu

X32/M32 with X-USB on Linux/Ubuntu

This guide is written for all owners of a Behringer X32 or Midas M32 with a X-USB 32x32 channel expansion card. It is directed towards splitting the X-USB channels up in virtual outputs on Ubuntu 18.04 with PulseAudio. The guide may also work for other versions or distro's of Linux with PulseAudio.

It is assumed that the X-USB is installed and connected to a computer. And automatically recognized as a multi-channel soundcard by the operating system. Also note that on Ubuntu 18.04, PulseAudio runs on top of ALSA. ALSA picks up the soundcard and PulseAudio then uses the full soundcard through ALSA to create virtual channels.

Table of contents

  1. Find X-USB device name
  2. Create virtual outputs in PulseAudio
  3. Restart PulseAudio
  4. Control application channel
@HNJAMeindersma
HNJAMeindersma / Debian Clean Update.sh
Last active March 21, 2020 23:38
A simple script for Debian/Ubuntu which will check for updates and act accordingly
#!/bin/sh
# A simple Debian/Ubuntu script which will check for updates and act accordingly
# Version 1.2
# Source: https://superuser.com/questions/199869/check-number-of-pending-security-updates-in-ubuntu
# Status levels
STATUS_OK=0
STATUS_WARNING=1
STATUS_CRITICAL=2
STATUS_UNKNOWN=3