Skip to content

Instantly share code, notes, and snippets.

View ohthehugemanatee's full-sized avatar
💭
I may be slow to respond.

Campbell Vertesi ohthehugemanatee

💭
I may be slow to respond.
View GitHub Profile
@ohthehugemanatee
ohthehugemanatee / .Shelly high-availability for home assistant.md
Last active February 20, 2024 09:54
Shelly HA script: when homeassistant is unavailable, gracefully fail over to local operation

Shelly / Home Assistant High Availability Scripts

Great home automation is invisible to the user, and should never cause catastrophic failure (ie inability to turn on the light). Which means that when your HomeAssistant server is down for whatever reason, the lights should continue to work "as expected".

These are scripts you can insert in the web interface of your Shelly device to achieve this effect. For normal operation, set the shelly to "detatched" mode, and create a HomeAssistant automation to actually respond to switch on/off events. Then add this script in the Shelly's web interface. Make sure to adjust the URI for your homeassistant appropriately.

The script checks the availability your homeassistant URI every 30 seconds to make sure it's up. If it's down, it changes the mode to local "flip" mode, where it cuts power on a switch event. When, on a future check, homeassistant is once again responding, it will automatically return to detached mode.

Variants of this script are floating around the h

@ohthehugemanatee
ohthehugemanatee / drm.log
Created December 6, 2022 17:06
drm debug log
This file has been truncated, but you can view the full file.
[Di Dez 6 15:23:31 2022] [drm:drm_ioctl [drm]] comm="sway" pid=55803, dev=0xe280, auth=0, I915_GEM_EXECBUFFER2_WR
[Di Dez 6 15:23:31 2022] [drm:drm_ioctl [drm]] comm="sway" pid=55803, dev=0xe280, auth=0, I915_GEM_MADVISE
[Di Dez 6 15:23:31 2022] [drm:drm_ioctl [drm]] comm="sway" pid=55803, dev=0xe280, auth=0, I915_GEM_MADVISE
[Di Dez 6 15:23:31 2022] [drm:drm_ioctl [drm]] comm="sway" pid=55803, dev=0xe280, auth=0, DRM_IOCTL_SYNCOBJ_WAIT
[Di Dez 6 15:23:31 2022] [drm:drm_ioctl [drm]] comm="sway" pid=55803, dev=0xe280, auth=0, DRM_IOCTL_SYNCOBJ_DESTROY
[Di Dez 6 15:23:31 2022] [drm:drm_ioctl [drm]] comm="sway" pid=55803, dev=0xe280, auth=0, I915_GEM_MADVISE
[Di Dez 6 15:23:31 2022] [drm:drm_ioctl [drm]] comm="sway" pid=55803, dev=0xe280, auth=0, DRM_IOCTL_SYNCOBJ_CREATE
[Di Dez 6 15:23:31 2022] [drm:drm_ioctl [drm]] comm="sway" pid=55803, dev=0xe280, auth=0, I915_GEM_EXECBUFFER2_WR
[Di Dez 6 15:23:31 2022] [drm:drm_ioctl [drm]] comm="sway" pid=55803, dev=0xe280, auth=0, I915_GEM_MADVISE
[Di Dez 6 15:2
@ohthehugemanatee
ohthehugemanatee / split-zoom.sh
Created March 11, 2021 11:52
Split zoom meeting recordings into two sides
#!/bin/sh
set -eu
### Splits a zoom side-by-side recording into separate left and right video files.
# Usage: ./split-zoom.sh /path/to/my-zoom-file.mp4
# Outputs ./my-zoom-file_right.mp4 and ./my-zoom-file_left.mp4
# Ensure we have ffmpeg in the PATH:
which ffmpeg
@ohthehugemanatee
ohthehugemanatee / sway.log
Created July 9, 2020 09:24
sway debug log for output issue
00:00:00.225 [sway/input/seat.c:930] Cannot load xcursor theme for output 'eDP-1' with scale 2.000000
00:00:00.279 [sway/input/seat.c:930] Cannot load xcursor theme for output 'eDP-1' with scale 2.000000
00:00:00.286 [sway/input/seat.c:930] Cannot load xcursor theme for output 'DP-5' with scale 1.000000
00:00:00.334 [sway/input/seat.c:930] Cannot load xcursor theme for output 'eDP-1' with scale 2.000000
00:00:00.334 [sway/input/seat.c:930] Cannot load xcursor theme for output 'DP-5' with scale 1.000000
00:00:00.334 [sway/input/seat.c:930] Cannot load xcursor theme for output 'DP-9' with scale 1.000000
/bin/sh: ff-theme-util: command not found
Got sleep lock: 11
Unknown option -b
Traceback (most recent call last):
2020-02-18 12:20:05 - [sway/main.c:152] Linux Wotan 5.4.18-1-MANJARO #1 SMP PREEMPT Thu Feb 6 11:41:30 UTC 2020 x86_64 GNU/Linux
2020-02-18 12:20:05 - [sway/main.c:168] Contents of /etc/lsb-release:
2020-02-18 12:20:05 - [sway/main.c:152] DISTRIB_ID=ManjaroLinux
2020-02-18 12:20:05 - [sway/main.c:152] DISTRIB_RELEASE=19.0.0
2020-02-18 12:20:05 - [sway/main.c:152] DISTRIB_CODENAME=Kyria
2020-02-18 12:20:05 - [sway/main.c:152] DISTRIB_DESCRIPTION="Manjaro Linux"
2020-02-18 12:20:05 - [sway/main.c:168] Contents of /etc/os-release:
2020-02-18 12:20:05 - [sway/main.c:152] NAME="Manjaro Linux"
2020-02-18 12:20:05 - [sway/main.c:152] ID=manjaro
2020-02-18 12:20:05 - [sway/main.c:152] ID_LIKE=arch
@ohthehugemanatee
ohthehugemanatee / gist:87291f1e77a9b5f920fcb5c74a7805cf
Created June 18, 2019 14:02
track outbound links in google analytics
<script>
//Track Outbound Link Clicks
(function trackOutbounds() {
var hitCallbackHandler = function(url,win) {
if (win) {
window.open(url, win);
} else {
window.location.href = url;
@ohthehugemanatee
ohthehugemanatee / winvm
Created March 6, 2018 11:01
Bash script to start/stop an Azure remote workstation, and connect to it via RDP
#!/bin/bash
# Simple script to start/stop my Azure remote workstation.
# Requires:
# - Azure CLI configured
# - Remmina RDP client
# - Zenity
#
# Change these values to match your VM.
@ohthehugemanatee
ohthehugemanatee / RestaurantEntity.php.diff
Created September 18, 2017 11:10
Add revisions to an existing entity. In a project for RAS I had to add revisions to an existing entity. There are some small modifications necessary to the entity class itself, and two update hooks to apply the schema changes (core's normal process won't allow you to modify the schema of an entity type with existing data). Note that entity_ui=TR…
use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\Entity\RevisionableContentEntityBase;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityChangedTrait;
@@ -19,6 +20,7 @@
* @ContentEntityType(
* id = "restaurant",
* label = @Translation("Restaurant"),
+ * show_revision_ui = TRUE,
[ 0.000000] Linux version 4.12.5-041205-generic (kernel@tangerine) (gcc version 6.3.0 20170618 (Ubuntu 6.3.0-19ubuntu1) ) #201708061334 SMP Sun Aug 6 17:35:26 UTC 2017
[ 0.000000] Command line: BOOT_IMAGE=/@/boot/vmlinuz-4.12.5-041205-generic root=UUID=c0d21ade-5570-41a3-b0cf-a5ce219e7a8e ro rootflags=subvol=@ quiet splash video.use_native_backlight=1 vt.handoff=7 drm.debug=0xe
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Centaur CentaurHauls
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x008: 'MPX bounds registers'
@ohthehugemanatee
ohthehugemanatee / keycdn.php
Last active May 14, 2017 13:47
how I invalidated keycdn
<?php
// Invalidate and update the item state.
$hashes = KeycdnCacheTagHeaderGenerator::cacheTagsToHashes($tags);
// Break the list of tags into multiple requests.
$hash_sets = array_chunk($hashes, 1000);
foreach ($hash_sets as $hash_set) {
$invalidation_state = $this->invalidateItems('tags', $hash_set);
}