Skip to content

Instantly share code, notes, and snippets.

"""sync_webui_docs.py
compares a local directory of files with an Open WebUI Knowledge base
Files that exist in both directories are updated, if changed
Files deleted from local source are removed from Open WebUI
New local files are uploaded
After file updates are complete the Knowledgebase is re-indexed.
@robweber
robweber / attempt1.py
Created April 20, 2024 17:42
Different examples of parsing Nagios performance data output with Python
output = "HTTP OK: HTTP/1.1 200 OK - 16499 bytes in 0.019 second response time |time=0.019284s;;;0.000000;10.000000 size=16499B;;;0"
# first split on the pipe
perf_data = output.split("|")
# each data point separated by a space
for p in perf_data[1].split(" "):
result = {}
p_values = p.split(";")
"""
Takes in a set of files calculates the value sum from time periods designated in a YAML file
Install library requirements first (pandas generally installed via OS, on Linux sudo apt install python3-pandas)
"""
import argparse
import datetime
import os
import os.path
import pandas
import sys
@robweber
robweber / low_battery_blueprint.yaml
Last active November 6, 2022 16:28
Home Assistant Blueprints
blueprint:
name: Low battery level detection & notification for all battery sensors
description: Regularly test all sensors with 'battery' device-class for crossing
a certain battery level threshold and if so execute an action. Marck/home-assistant-automation-blueprints/blob/main/low-battery-level-detection-notification-for-all-battery-sensors
domain: automation
input:
threshold:
name: Battery warning level threshold
description: Battery sensors below threshold are assumed to be low-battery (as
well as binary battery sensors with value 'on').
@robweber
robweber / update_godaddy_dns.py
Last active May 19, 2025 12:26
Use the GoDaddy API to update a DNS record when external IP changes
"""update_godaddy_dns.py
Updates a GoDaddy DNS record with a new external IP address using the GoDaddy API
Run in debug mode (-D) to check the IP but not update DNS records
https://developer.godaddy.com/doc/endpoint/domains
Requires:
configargparse
requests
"""
@robweber
robweber / backup.py
Last active July 1, 2022 19:42
Command Line Backups Solution
"""Backup utility
Performs a backup of files and directories given in a YAML configuration file. This is done by first putting them all in a tar archive
and then using the smbclient package to copy the file to the destination.
Run with: python3 backup.py -c /path/to/config.yaml
requires jinja2 and pyyaml """
import argparse
import os
@robweber
robweber / calc_energy.py
Created February 28, 2022 16:42
Calculate energy based on load percent
"""calc_energy.py
calculate the energy usage based on a load percentage and max power rating
"""
def calc_energy(current_load, max_load, min=5, unit='W'):
# load percent * max load
current_power = (current_load/100) * max_load
# multiply the power by the time increment
# time increment should be in hours
@robweber
robweber / filter_color.py
Last active February 28, 2022 17:52
Filter an Image based on an array of colors
import argparse
import os.path
from PIL import Image
def create_palette(colors):
result = []
for c in colors:
rgb_values = c.split(',')
# there must be 3
@robweber
robweber / pullrequest.sh
Last active August 22, 2019 22:48
Kodi Addon Checker Pull Request Script
#!/bin/bash
#will either check your addon (same as PR will do) or send a pull request on up to the repo
#cultivated from instructions at https://kodi.wiki/view/HOW-TO:Create_add-on_PRs_using_Git_Subtree_Merging and modified
## ARGS pass in file to source other args as -f or --filename ##
ADDON_CHECKER_VERSION=0.0.14
KODI_FORK=https://github.com/robweber/repo-scripts.git
KODI_REPO_BRANCH=jarvis
ADDON_URL=https://github.com/robweber/xbmcbackup.git
ADDON_BRANCH=master