Skip to content

Instantly share code, notes, and snippets.

View adlerweb's full-sized avatar

Florian Knodt adlerweb

View GitHub Profile
@adlerweb
adlerweb / res-change.py
Last active July 13, 2024 00:11 — forked from sohailshaukat/res-change.sh
Linux Screen Resolution Change script
#!/usr/bin/env python3
import argparse
import subprocess
def set_resolution(output, mode, refresh, apply):
modeline = False
width, height = mode.split('x')
gtf_cmd = f"gtf {width} {height} {refresh}"
gtf_output = subprocess.check_output(gtf_cmd, shell=True, text=True)
/*
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleNotify.cpp
Ported to Arduino ESP32 by Evandro Copercini
Create a BLE server that, once we receive a connection, will send periodic notifications.
The service advertises itself as: 6E400001-B5A3-F393-E0A9-E50E24DCCA9E
Has a characteristic of: 6E400002-B5A3-F393-E0A9-E50E24DCCA9E - used for receiving data with "WRITE"
Has a characteristic of: 6E400003-B5A3-F393-E0A9-E50E24DCCA9E - used to send data with "NOTIFY"
The design of creating the BLE server is:
@adlerweb
adlerweb / fritzlog.py
Last active March 14, 2024 13:06
FRITZ!Box Graylog Gateway
#!/usr/bin/env python3
# Free Open Source Software released under GPLv2
# see http://www.gnu.org/licenses/gpl-2.0
# Author: Florian Knodt <git@adlerweb.info>
# Original Author: Tilman Schmidt <tilman@imap.cc>
# Contributor: Peter Pawn @ IP Phone Forum
# inspired by http://www.administrator.de/contentid/214598
# Requirements (for example via pip): graypy, requests
@adlerweb
adlerweb / vz.md
Last active December 30, 2023 17:25
Grafana MySQL query to visualize Volkszähler-Data

Using Channel-IDs (that's not UUID)

SELECT
  timestamp/1000 as time_sec, 
  data.value as value, 
  properties.value as metric
FROM data
  LEFT JOIN properties ON (properties.entity_id = data.channel_id)
  LEFT JOIN entities ON (entities.id = data.channel_id)
#include <ESP8266WiFi.h>
#include <ESP8266mDNS.h>
#include <PubSubClient.h>
const char* cfg_wifi_ssid = "freifunk-myk.de";
const char* cfg_wifi_pwd = "";
const char* mqtt_server = "deinserver.local";
const unsigned int mqtt_port = 1883;
@adlerweb
adlerweb / mandrill_extract.py
Created September 30, 2023 11:18
Extract target URL from a mandrill tracking link. Based on https://gist.github.com/medmunds/1b696ee88ccb0480d71f
import sys
import json
import base64
import argparse
from binascii import Error as BinasciiError
from urllib.parse import urlparse, parse_qs, urlencode, urlunparse, parse_qsl
version = "0.1"
def urlsafe_base64_decode(s):
@adlerweb
adlerweb / PKGBUILD
Last active August 28, 2023 23:53
s25rttr 0.9.5 GCC13 aur
#Maintainer: Matthias Mailänder <matthias at mailaender dot name>
#Contributor NiNjA <heinep at gmail dot com>
#Contributor float <flo.at at gmx dot de>
#Contributor adlerweb <aur at adlerweb dot info>
pkgname=s25rttr
pkgver=0.9.5
pkgrel=3
pkgdesc="Return to the Roots is a reimplementation of Settlers II (Die Siedler II) by BlueByte Software GmbH. Put the files from the original game in the folder (/usr/share/s25rttr/S2/)"
arch=('i686' 'x86_64')
@adlerweb
adlerweb / README.md
Created August 20, 2023 18:16
pip upgrade helper

When updating a venv to a newer python version you need to reinstall all locally install pip packages. This script can be pointed at the previous versions site-packages directory and output a string containing all previously installed packages, suitable to pass to pip install.

(Search-foo: Might help if you are running HomeAssistant inside a venv and, after upgrading python, integrations are not loaded)

@adlerweb
adlerweb / cli_convert.py
Created August 20, 2023 18:11
HomeAssistant: Convert command_line sensors to new (2023) format
#!/usr/bin/env python3
# pip install pyyaml pyyaml-include
import yaml
from yamlinclude import YamlIncludeConstructor
import os
import sys
base_dir = os.path.expanduser('~') + '/.homeassistant/'
@adlerweb
adlerweb / .SRCINFO
Created August 3, 2023 10:40
zfs-linux-rc-2.2.0_rc3-1
pkgbase = zfs-linux-rc
pkgver = 2.2.0_rc3_6.4.7.arch1.2
pkgrel = 1
url = https://zfsonlinux.org/
arch = x86_64
license = CDDL
makedepends = linux-headers=6.4.7.arch1-2
depends = kmod
depends = zfs-utils-rc=2.2.0_rc3
depends = linux=6.4.7.arch1-2