Skip to content

Instantly share code, notes, and snippets.

View manix84's full-sized avatar
🧸
Being a parent

Rob Taylor manix84

🧸
Being a parent
View GitHub Profile
@manix84
manix84 / useClipboard.ts
Last active June 28, 2024 11:13
A front end clipboard tool for multi type copying. It has fallback for FireFox and older browsers.
/**
This code is licensed under the terms of the MIT license
*/
import { useCallback } from 'react';
type ClipboardItemData = {
type: string;
data: string;
};
@manix84
manix84 / fan-temperature.yaml
Last active June 10, 2024 14:38
Speed up and slow down ceiling fans, as it get's hotter and colder.
blueprint:
name: Fan Temperature
description: |
Speed up and slow down ceiling fans, as it gets hotter and colder.
domain: automation
source_url: https://gist.github.com/manix84/c16a8e46d10423e4354b5e862facc907
author: Manix84
input:
fan_entity_ids:
name: Fans
@manix84
manix84 / zha-hue-remote-lights-with-automation.yaml
Last active May 14, 2024 14:55
An automation for Hue removes, which has brightness buttons (100%, 66%, 33%, 0%), and long presses turns off the automations.
blueprint:
name: Hue Remote Lights with Automation (ZHA Integration)
description: |
An automation for Hue removes, which has brightness buttons (100%, 66%, 33%, 0%), and long presses turns off the automations.
domain: automation
source_url: https://gist.github.com/manix84/8c94b97285e82c594aac3c1372f40660
author: Manix84
input:
dimmer_device_id:
name: Dimmer Remote
@manix84
manix84 / philips-hue-remote-lights.yaml
Last active May 14, 2024 14:55
An automation for Hue remotes, which has brightness buttons (100%, 66%, 33%, 0%).
blueprint:
name: Hue Remote Lights (Philips Hue Integration)
description: |
An automation for Hue remotes, which has brightness buttons (100%, 66%, 33%, 0%).
domain: automation
source_url: https://gist.github.com/manix84/be2b758caa6fa518fa895ce7265dc85c
author: Manix84
input:
dimmer_device_id:
name: Dimmer Remote Device
@manix84
manix84 / smart-button.yaml
Created October 29, 2023 23:31
A Home Assistant Automation Blueprint for detecting Single, Double, and Long presses of ZHA attached Smart Buttons (EG: Hue Smart Button). Allowing you to attach your own custom actions to the events.
blueprint:
name: Smart Button
description: |
Short, Long, and Double press actions for Smart Buttons.
Variables:
* <strong>last_triggered</strong> - the time the script was triggered.
* <strong>last_triggered_seconds</strong> - number of seconds since the last trigger.
* <strong>action</strong> - parsed actions list (<em>short_press</em>, <em>double_press</em>, <em>long_press</em>).
domain: automation
blueprint:
name: Tablet Themes (Lumins)
description: |
Use Browser Mod to change the theme used on tablets around the house, based on the brightness of the local sensor.
domain: automation
source_url: https://gist.github.com/manix84/761a2633fb555041e51a5bea53778fc7
author: Manix84
input:
browser_device_id:
name: Browser Device
blueprint:
name: Blinds automation
description: |
Open blinds at sunrise or specified time, which-ever comes later.
Close blinds at sunset or specified time, which-ever comes earlier.
domain: automation
source_url: https://gist.github.com/manix84/c1b39dfb62d5052664c8fee0d29b3bd3
author: Manix84
input:
blinds_entity_ids:
@manix84
manix84 / isLeftHanded.ts
Last active June 28, 2024 11:13
A React Hook for guessing if you're left or not. This is useful for navigation menus appearing near your thumb on mobile devices.
/**
This code is licensed under the terms of the MIT license
*/
import { useEffect, useState } from "react";
const MINIMUM_VERTICAL_MOVEMENT_PX = 100;
const MINIMUM_HORIZONTAL_MOVEMENT_PX = 10;
const STORED_GUESSES = 11; // More than half in one direction will cause a switch
@manix84
manix84 / resizeText.ts
Last active June 28, 2024 11:14
A React+Typescript hook for resizing a line of text, so it fits on X lines.
/**
This code is licensed under the terms of the MIT license
*/
import { useCallback, useState } from "react";
export const useTextResize = () => {
const [originalFontSize, setOriginalFontSize] = useState<number>(null);
const [originalLineHeight, setOriginalLineHeight] = useState<number>(null);
@manix84
manix84 / timeout.ts
Last active June 28, 2024 11:16
A React+Typescript hook for setTimeout requests. Includes pause, restart, resume, start, stop, and current state.
/**
This code is licensed under the terms of the MIT license
*/
import { useCallback, useEffect, useRef, useState } from "react";
export const useTimeout = (
callback: Function,
delay: number /** milliseconds */
) => {
const timeoutRef = useRef(null);