Skip to content

Instantly share code, notes, and snippets.

View jahir's full-sized avatar

Jakob Hirsch jahir

  • Offenburg, Germany
View GitHub Profile
@jahir
jahir / meter.pl
Created December 17, 2020 20:39
yearly meter summary for volkszaehler.org
#!/usr/bin/perl
# vim: ts=4
use strict;
use warnings;
use DBI;
use Text::Table;
my $chid = shift;
my $dbh = DBI->connect("DBI:mysql:database=vz;host=localhost", "vz", "Geheim", { RaiseError => 1, AutoCommit => 1 });
#!/bin/bash
#
# dehydrated hook script for verification by dns
#
# args (see https://github.com/lukas2511/dehydrated/blob/master/docs/dns-verification.md)
# $1 an operation name (clean_challenge, deploy_challenge, deploy_cert, invalid_challenge or request_failure) and some operands for that. For deploy_challenge
# $2 is the domain name for which the certificate is required,
# $3 is a "challenge token" (which is not needed for dns-01), and
# $4 is a token which needs to be inserted in a TXT record for the domain.
#
@jahir
jahir / tasmota rules
Last active March 9, 2020 11:38
power off after %mem1% minutes with less than %mem2% W
# first turn all rules off
backlog rule1 0; rule2 0; rule3 0
# PC, laptop
backlog mem1 5; mem2 60
# laser printer
backlog mem1 30; mem2 600
# set/reset ruletimer for power off depending on power usage
#!/usr/bin/env bash
CIPHERS='ALL:eNULL'
DELAY=${2:-0.1}
SERVER=${1:?usage: $0 <host:port> [delay, default is ${DELAY}s] [ciphers, default is ${CIPHERS}]}
MAXLEN=$(openssl ciphers "$CIPHERS" | sed -e 's/:/\n/g' | awk '{ if ( length > L ) { L=length} }END{ print L}')
echo Using $(openssl version).
declare -A TLSMAP=( [tls1_1]=cipher [tls1_2]=cipher [tls1_3]=ciphersuites )
#!/usr/bin/python3
import sys
(darlehen, zinssatz, monatlich) = (float(x) for x in sys.argv[1:])
monate = 0
zinsen = 0.0
while darlehen > 0:
monate += 1
zins = darlehen * zinssatz / 100 / 12
zinsen += zins
@jahir
jahir / fritzbox_reconnect.sh
Created June 15, 2019 23:40
fritzbox reconnect
#!/bin/sh
#wget -qO- "http://fritz.box:49000/igdupnp/control/WANIPConn1" --header "Content-Type: text/xml; charset="utf-8"" --header "SoapAction:urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress" --post-data="<?xml version='1.0' encoding='utf-8'?> <s:Envelope s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/' xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'> <s:Body> <u:GetExternalIPAddress xmlns:u='urn:schemas-upnp-org:service:WANIPConnection:1' /> </s:Body> </s:Envelope>" | grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'
#wget -q "http://fritz.box:49000/upnp/control/wanipconnection1" --header='Content-Type: text/xml; charset="utf-8"' --header='SoapAction: urn:dslforum-org:service:WANIPConnection:1#ForceTermination' --post-data='<?xml version="1.0" encoding="utf-8"?> <s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <u:ForceTermination xmlns:u="urn:dslforum-org:service:WANIPConnection:1"
#!/usr/bin/python3
# vim: ts=2
# -*- coding: utf-8 -*-
#
from time import strftime, sleep
from urllib.request import urlopen,Request,URLopener
# install with `pip3 install adafruit-circuitpython-bme280`
import busio
import board
@jahir
jahir / speedtest.c
Last active September 12, 2021 22:48
speedtest-cgi
/*
* speedtext fcgi writev v2 2018-08-13
* (C) [email protected]
* Licensed under GPL v3.0
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
@jahir
jahir / mouse.c
Created April 14, 2017 20:48
read (midde) mouse button state every 5ms
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <linux/input.h>
#include <stdint.h>
#define test_bit(p, n) !!(p[n>>3] & (1u << (n&7)))
int isButtonPressed(int fd, unsigned short code) {
@jahir
jahir / s0event.c
Last active April 13, 2017 08:17
Read S0 impulses from mouse events
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <time.h>
#include <linux/input.h>
#include <stdint.h>