Skip to content

Instantly share code, notes, and snippets.

Setting up an Eaton UPS on TrueNAS Core

To see if the UPS USB shows up:

$ sudo usbconfig
ugen1.1: <AMD XHCI root HUB> at usbus1, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen0.1: <AMD XHCI root HUB> at usbus0, cfg=0 md=HOST spd=SUPER (5.0Gbps) pwr=SAVE (0mA)
ugen1.2: <vendor 0x09da USB Keyboard> at usbus1, cfg=0 md=HOST spd=LOW (1.5Mbps) pwr=ON (100mA)
ugen1.3: <EATON 5E> at usbus1, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON (20mA)
@enosh
enosh / synced-play.html
Last active November 24, 2024 18:33
Synced video playback with drag-and-drop
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Synced Video Playback</title>
<style>
body {
font-family: SF Pro, Arial, sans-serif;
margin: 0;
@enosh
enosh / pdf-splitter.html
Created November 12, 2024 17:49
PDF Splitter applet in-browser locally using pdf-lib
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PDF Splitter</title>
<script src="https://unpkg.com/pdf-lib@1.17.1/dist/pdf-lib.min.js"></script>
</head>
<body>
<h2>PDF Splitter</h2>
@enosh
enosh / Tasmota long press dimmer toggle.md
Created August 22, 2021 06:55
Tasmota long press dimmer toggle how-too

I've been using an LED strip with a Magichome controller running Tasmota for more than a year now. A while back I set up a long press to trigger a stateless programmable button in my HomeKit setup. What I ended up actually using the long press for was a kind of nightlight toggle: If the lights were set to more than 50% I'd set them to 5% and vice versa. But this setup has a ton of moving parts so from time to time it'd stop working. I knew of Tasmota's rules functionality, so I wanted to switch to it thinking this really should done be on device.

Since figuring how to do this took me a bit of time. I thought I'd write up a small explainer.

Keywords: Tasmota long-press dimmer toggle, Tasmota rules conditional, Tasmota dimmer high-low toggle, Tasmota rules long press action, Tasmota long-press trigger.

Some background settings:

Backlog SwitchMode 5; ButtonTopic 0; SetOption73 1; SetOption32 12
@enosh
enosh / change-tts-voice.applescript
Last active November 21, 2020 16:33
A small AppleScript to change the system voice that works with Siri voices. As opposed to options based on the `say` command which only work with older voices. (Also `defaults write` as far as I could tell.) I use it through Alfred.
tell application "System Preferences"
reveal anchor "TextToSpeech" of pane id "com.apple.preference.universalaccess"
activate
end tell
tell application "System Events"
tell application process "System Preferences"
set theGroup to group 1 of window "Accessibility"
set thePopUp to pop up button 1 of theGroup
"""Acronym Finder, rearranges letters to find words then ranks them based on a frequency list.
Usage:
acrofinder [-of --language=<lc> --format=<fmt> --save=<file>] <letters>
acrofinder --list-supported
acrofinder -h | --help
Options:
-h --help Show this screen.
-l --language=<lc> Language code of the database to run against [defualt: he].
@enosh
enosh / gen_audiobook_chapters.py
Last active March 17, 2018 23:53
Generate a chapters file for `mp4chaps` from `.mp3` files in the current directory or the one passed as its first argument.
# -*- coding: utf-8 -*-
import sys, re
from datetime import timedelta
from os import listdir, getcwd
from os.path import isfile, join
from mutagen.mp3 import MP3
EXTENSION = ".mp3"
# RE to extract chapter names (name being the first capture group.)
@enosh
enosh / graph_podcast_duration.py
Created June 12, 2016 08:36
A script to create a graph of podcast length vs episode number, from an RSS feed.
"""
Create a graph of podcast length (in minutes) vs number, from an RSS feed.
Usage:
python(3) <script> <the RSS feed (local or a URL)> <regex expression to split episode title and name; optional but
useful when the feed doesn't include all the episodes>
Examples:
python3 graph_podcast_duration.py "http://atp.fm/episodes?format=rss" "^(\d{1,4}): (.+)"
python3 graph_podcast_duration.py "https://www.relay.fm/rd/feed"
@enosh
enosh / gen_podcast_wiki_episode_table.py
Last active June 12, 2016 08:33
A script to generate a wikitable of podcast episodes (with columns: episode number, title, release date, and running time) from a given RSS feed.
"""
Generates a wikitable of podcast episodes (with columns: episode number, title, release date, and running time) from a given RSS feed.
Usage:
python <script> <the RSS feed (local or a URL)> <regex expression to clean up episode titles> <host of files>
Examples:
python script.py "http://www.hellointernet.fm/podcast?format=rss" "H\.I\. \#\d{1,2}\: " > list.txt
python script.py "https://www.relay.fm/rd/feed" "Reconcilable Differences \d{1,2}\: " > list.txt
"""