Skip to content

Instantly share code, notes, and snippets.

View DavesCodeMusings's full-sized avatar

Dave Horton DavesCodeMusings

  • Planet Earth
View GitHub Profile
@DavesCodeMusings
DavesCodeMusings / SQLiteTimeSeriesDB.txt
Last active July 14, 2023 02:37
SQLite Time Series Database for sensor data
Make a time series database using SQLite.
Time series DBs are useful for storing data taken from the environment. For example,
weather readings from a station at fifteen minute intervals throughout the day.
Rather than using a popular, but more resource intensive purpose built time series
database for your small scale project, you can just as easily use good old SQLite.
@DavesCodeMusings
DavesCodeMusings / rssinator.ini
Last active July 14, 2023 14:59
Scrape your website's article tags to create XML for an RSS feed
[site]
url = https://www.your-site.org/
[rss]
description = News and Updates
default_author = [email protected] (Hot Shot Author)
@DavesCodeMusings
DavesCodeMusings / sha256aes.py
Last active November 27, 2023 03:36
Password Hashing for MicroPython
# Password hashing class that works with MicroPython v1.21
# There's no SHA512 or bcrypt in MicroPython, so use SHA256 and AES.
# Close to a Unix-like system password, but not compatible.
from random import choice, seed
from cryptolib import aes
from hashlib import sha256
from binascii import b2a_base64
@DavesCodeMusings
DavesCodeMusings / apk-upgrade-check.sh
Created December 17, 2023 13:42
Alpine periodic package upgrade check
#!/bin/ash
# Put in /etc/periodic/weekly to be reminded of package upgrades.
# The -s option tells apk to check, but not install. Installing needs to
# be done manually.
apk update && apk -s upgrade | mail -s 'Available Package Upgrades' root
@DavesCodeMusings
DavesCodeMusings / update-dep-pkgs.bat
Created December 17, 2023 13:54
Update dependent packages for VS Code extensions you've created
REM Shamelessly lifted from StackOverflow.
REM https://stackoverflow.com/questions/16073603/how-can-i-update-each-dependency-in-package-json-to-the-latest-version
REM Change directory to your extention's code directory and run the commands below.
REM `npm install -g npm-check-updates` installs the ncu utility and only needs to be run once per system.
REM Repeat ncu -u and npm install as needed for each extension's code directory.
npm install -g npm-check-updates
ncu -u
npm install
@DavesCodeMusings
DavesCodeMusings / Dockerfile
Last active June 1, 2024 21:24
Cooperative Python on code-server Docker Container
FROM lscr.io/linuxserver/code-server:latest
# Add Python support
RUN apt-get update \
&& apt-get install -y \
python3 \
pylint \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
@DavesCodeMusings
DavesCodeMusings / configuration.yaml
Created September 25, 2024 12:59
Stupid simple highlight theme for Home Assistant dashboard
# Add this to configuration.yaml and you can select a theme for navigation buttons,
# and possibly other cards, that will show the text and icon in the accent color
# for the overall theme. For example, in dark mode the accent color is orange, so
# any card having this theme will show in orange.
frontend:
themes:
accent:
primary-text-color: "var(--accent-color)"
paper-item-icon-color: "var(--accent-color)"
@DavesCodeMusings
DavesCodeMusings / s31.yaml
Last active October 7, 2024 03:26
Configuration for Sonoff S31 flashed with ESPHome
esphome:
name: s31-1
friendly_name: s31-1
esp8266:
board: esp01_1m
early_pin_init: False # Mitigate relay flipping on reboot.
# Disable logging (UART is used by cse7766 power sensor.)
logger:
@DavesCodeMusings
DavesCodeMusings / VirtualBox_Ventoy_USB_Boot.md
Last active December 31, 2024 20:05
Ventoy VirtualBox Boot

Ventoy Flash Drive as VirtualBox Boot Device

This document shows how to use a Ventoy formatted USB device (instead of an optical disk) to boot an ISO image in VirtualBox. There are other HowTo documents on the internet that explain this procedure (one is mentioned in the References section below), but most use a deprecated VBoxManage sub-command to create the raw device. This document uses the preferred createmedium sub-command. It also uses PowerShell rather than cmd.exe.

The generic form of the command that makes the Ventoy USB drive available to VirtualBox is as follows:

.\VBoxManage createmedium disk --filename=PATH --format=VMDK --variant=RawDisk --property RawDrive=DEVICE_NAME

But, there are some prerequisites...

@DavesCodeMusings
DavesCodeMusings / random_complex_password.sh
Created November 24, 2024 05:49
Random Complex Password
#!/bin/sh
# Generate a random complex password on a Linux system.
tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' </dev/urandom | head -c 32; echo
# Reference:
# https://owasp.org/www-community/password-special-characters
# https://www.gnu.org/software/coreutils/manual/html_node/tr-invocation.html