Skip to content

Instantly share code, notes, and snippets.

@ahue
ahue / motion.conf
Last active March 26, 2021 06:57
Configure raspberry pi zero for motion with gif creation and mqtt
# Rename this distribution example file to motion.conf
#
# This config file was generated by motion 4.1.1
# Documentation: /usr/share/doc/motion/motion_guide.html
############################################################
# Daemon
############################################################
# Start in daemon (background) mode and release terminal (default: off)
@ahue
ahue / cyclical_feature.py
Created February 15, 2021 21:09
Because I tend to forget... building cyclical features
import numpy as np
from typing import Union
def cyclical_feature(x: Union(float|np.array), max_x: float):
"""
Transforms a linear scale feature to a feature pair that represent a cyclical one.
Assumes that the feature is in interval [0, max_x]
See also https://towardsdatascience.com/cyclical-features-encoding-its-about-time-ce23581845ca
from typing import Union
def scale(x: Union[int|float],
min_x: Union[int|float], max_x: Union[int|float],
a: Union[int|float], b: Union[int|float]) -> float:
"""
Scale a number x relative to domain [min_x, max_x] to a domain [a,b]
Parameters:
x (int|float): The value to scale
@ahue
ahue / groceries_bring
Created February 14, 2021 07:43
A slot-program for retrieve German grocery terms for Rhasspy
#!/usr/bin/env bash
set -e
url="https://web.getbring.com/locale/articles.de-DE.json"
echo "GET ${url}" >&2
curl -X GET \
-H 'Content-Type: application/json' \
"${url}" | \
jq --raw-output 'to_entries[] as $e | "\($e.value)"' | \
@ahue
ahue / groceries_wiktionary
Last active July 19, 2021 14:57
rhasspy slot program to get german groceries from wiktionary into rhasspy
#! /usr/bin/python3
try:
# For Python 3.0 and later
from urllib.request import urlopen
from urllib.parse import quote
except ImportError:
# Fall back to Python 2's urllib2
from urllib2 import urlopen
from urllib2 import quote
@ahue
ahue / openhab2backup.sh
Created February 5, 2021 20:01
Openhab2 Backup Script
#!/bin/bash
# create new folder for the day
DATE=`date +%Y-%m-%d_%H-%M-%S`
BACKUP_PATH=~/openhab2-backup
# backup metadata in ./meta
mkdir -p $BACKUP_PATH
sh /usr/share/openhab2/runtime/bin/backup $BACKUP_PATH/openhab2-backup-$DATE.zip
@ahue
ahue / install-influxdb-grafana.sh
Created February 5, 2021 19:59
Grafana and Influx-DB Install for Raspberry Pi 3
#!/bin/bash
# Create InfluxDB and Grafana 4.4.3 (latest)
source /etc/os-release
OPSYS=${ID^^}
curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
test $VERSION_ID = "8" && echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
test $VERSION_ID = "9" && echo "deb https://repos.influxdata.com/debian jessie stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
curl https://bintray.com/user/downloadSubjectPublicKey?username=bintray | sudo apt-key add -