Skip to content

Instantly share code, notes, and snippets.

View lilyball's full-sized avatar

Lily Ballard lilyball

View GitHub Profile
public enum TruncateMode {
case Head, Middle, Tail
}
public extension String {
/// Truncates a string to a maximum length in grapheme clusters using the
/// specified mode. If `addEllipsis` is `true`, the resulting string
/// including the ellipsis will be no longer than `maxLength`.
func truncateToLength(maxLength: Int, mode: TruncateMode = .Tail, addEllipsis: Bool = false) -> String {
if maxLength <= 0 {
@lilyball
lilyball / 4button-pico-bp.yaml
Last active March 21, 2023 05:10 — forked from crkochan/4button-pico-bp.yaml
Home Assistant Blueprint
blueprint:
name: Lutron Caseta Four-Button Zone Pico Actions
description: Short and long press automations for the Pico four-button remote.
domain: automation
input:
pico_remote:
name: Pico Four-Button Zone Remote
description: Select the Pico four-button zone remote to configure.
selector:
device: