Skip to content

Instantly share code, notes, and snippets.

View cmsj's full-sized avatar
🏠
Working from home

Chris Jones cmsj

🏠
Working from home
View GitHub Profile
//
// hs.application.js
// Hammerspoon 2
//
// Created by Chris Jones on 23/10/2025.
//
"use strict";
// JS class to handle multiple watchers for hs.application events.
@cmsj
cmsj / foo.swift
Last active October 22, 2025 11:56
func mightFail() -> Bool? { // Return type of this is actually Optional(Bool) because of the ?
return nil
}
func main() {
guard let result = mightFail() else { // This unwraps the Optional(Bool)
print("lol get rekt")
return
}
@cmsj
cmsj / tts.yaml
Last active August 13, 2025 07:55
alias: Universal TTS Announcement 2
description: Sends a TTS message, routing to Alexa or Cloud TTS based on the target entity.
icon: mdi:bullhorn-variant-outline
fields:
message:
name: Message
description: The text you want to announce.
required: true
selector:
text:
@cmsj
cmsj / worker-proxy.patch
Created June 27, 2025 00:29
Not proud of this, but needs must.
diff --git Worker/AppState.swift Worker/AppState.swift
index 06515fc..f09e3c7 100644
--- Worker/AppState.swift
+++ Worker/AppState.swift
@@ -33,14 +33,14 @@ final class AppState {
// Approach 2:
//
// Trying to "un-own" the products array also doesn't work:
- let localProducts = self.products
+// let localProducts = self.products
@cmsj
cmsj / build.sh
Created May 30, 2024 19:58
Sometimes you just need to build some damn unix libraries
#!/bin/bash
set -eu
if [ $(basename ${PWD}) != "vendor" ]; then
echo "ERROR: You're not in the vendor directory."
exit 1
fi
export MAKE="make -j12"
#!/bin/bash
# This script will:
# * Download DJ Electric Samurai's Progressive Psytrance mixes from youtube
# * split them into individual MP3s
# * tag them with a reasonable amount of metadata
# * import them into Music.app (née iTunes)
#
# Dependencies:
# * yt-dlp
# * mid3v2 (from the mutagen project)
@cmsj
cmsj / eink_bins.py
Last active December 31, 2023 01:15
Home Assistant python_scripts script to render info from the Waste Collection Schedule HACS integration
# eInk Waste Collection Renderer
# v1.0 Copyright Chris Jones <[email protected]>
# Licensed under the MIT License
# This can be called as a Home Assistant service if you follow: https://www.home-assistant.io/integrations/python_script/
# Calendar is expected to be populated by the Waste Collection Schedule integration from HACS
# (although I only tested with my home region, it's likely the data is formatted differently for other regions)
# eInk tag to render to
tag_entity = "open_epaper_link.000002838f103b16"
@cmsj
cmsj / config.yaml
Created October 5, 2023 23:02
docker compose stack for octodns and bind to sync a zone from Route53 to a local Bind
---
providers:
config:
class: octodns.provider.yaml.YamlProvider
directory: /config/
default_ttl: 3600
enforce_order: True
route53:
class: octodns_route53.Route53Provider
access_key_id: env/AWS_ACCESS_KEY_ID
@cmsj
cmsj / hue_nicely.yaml
Created September 26, 2023 10:08
A Home Assistant custom script for turning on zigbee lightbulbs in a less awful way than default.
hue_nicely:
alias: A Hue Nicely
mode: queued
fields:
bulbs:
name: Bulbs
description: Turn zigbee-connected Hue bulbs on smoothly
required: true
selector:
entity:
@cmsj
cmsj / Code.gs
Created August 25, 2023 09:30
Google Script thread muter
// Enforce thread muting
// When you mute a thread in Gmail, it adds a "Muted" label
// Unfortunately, it doesn't really completely mute the thread - e.g. emails added to the thread will still be marked as unread and show up against folder counts
//
// This script will ensure that all emails appearing on muted threads, will be marked read, and archived.
//
// By default it will only look for emails that are less than 3 days old, to limit the size of the query results. You can adjust that if you want to
var age_max="3d"
function enforceMutes() {