Skip to content

Instantly share code, notes, and snippets.

View zackfern's full-sized avatar
🌭

Zack Fernandes zackfern

🌭
View GitHub Profile
@zackfern
zackfern / join_playing_sonos.yaml
Created April 28, 2023 22:07
A Home Assistant script to make a Sonos speaker join whichever speaker is currently playing
# Add this to your scripts.yaml file
join_playing_sonos:
description: "Make a Sonos spaker join whichever speaker is current playing."
fields:
target:
description: "Entity ID of the Sonos which you'd like to make join the group"
example: "media_player.office"
variables:
group_owner: '{{ state_attr((integration_entities("sonos") | select("is_state", "playing") | first), "group_members") | first }}'
@zackfern
zackfern / time_formats.rb
Created April 1, 2024 00:39
Some date formats I regularly find myself using in my Rails projects
Time::DATE_FORMATS[:ymd] = "%F" # 2023-01-01
Time::DATE_FORMATS[:mdy] = "%D" # 01/01/23
Time::DATE_FORMATS[:human] = "%B %d, %Y" # January 01, 2023
Time::DATE_FORMATS[:time_12] = "%I:%M %p" # 01:30 PM