This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('click', '#MyDoubleClickElement', function () { | |
var t = $(this), doubleClickInterval = 500; //set up base vars | |
var lastTouch = t.data('lastTouch') || 0, time = new Date().getTime(); //check when this element has been clicked last | |
t.data('lastTouch', time); //store this click time | |
if (time - lastTouch < doubleClickInterval && lastTouch !== 0) { //check if time between this and previous click exceeds the threshhold. If there is no last click registered, don't handle the callback | |
//do your stuff here (execute a callback) | |
alert("Double click!"); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* JavaScript function prototype debouncer 4.3 - 2010-2022 hnldesign.nl - Klaas Leussink | |
* Demo: https://code.hnldesign.nl/demo/hnl.debounce.html | |
* | |
* Based on code by Paul Irish and the original debouncing function from John Hann | |
* http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/ | |
* Register deBouncer as a function prototype. | |
* | |
* All debounced variants of the function (depending on the supplied debouncing parameters (see below) | |
* are stored inside a 'dbObj' Object inside the debounced function. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* CSP Generator v0.2 (C) 2020-10-12 hnldesign.nl / Klaas Leussink | |
* @param array $rules | |
* Rules, specified as an array with rulesets (array) or rules (string). Note that 'hosts' are specified as an array inside the ruleset: | |
* note: it's easier to define hosts in the $domains array (see second param) | |
* array( | |
* 'default-src' => array ( | |
* 'self', | |
* 'data', | |
* 'unsafe-eval', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** This script adds the current breakpoint-name (as specified in the 'breakpoints' const) | |
* to the body class and notifies anyone listening of the change via the 'breakPointChanged' event. | |
* | |
* Default breakpoint names and cutoff pixel values taken from Bootstrap 5's default responsive breakpoints: | |
* https://getbootstrap.com/docs/5.0/layout/breakpoints/ | |
* | |
* Usage: | |
* - include the script into your page and the class is updated, and will continue to update whenever | |
* the width of the window changes enough to trigger another breakpoint. | |
* - optionally listen for the event via: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const stickes = document.body.querySelectorAll('.position-sticky'); | |
window.addEventListener('scroll', function(){ | |
stickes.forEach(function(el){ | |
let stuck = false; | |
const rect = el.getBoundingClientRect(); | |
if (window.getComputedStyle(el).bottom == 'auto') { | |
stuck = rect.top === parseInt(window.getComputedStyle(el).top, 10); | |
} else if (window.getComputedStyle(el).top == 'auto') { | |
stuck = rect.height + rect.top < window.innerHeight; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
/* | |
ARC-VT: Audio-stream Reorganizer, Converter & Video Transcoder by Klaas Leussink / hnldesign (C) 2022-2023 | |
This nodejs script is originally aimed at non-DTS LG OLED owners running Plex on a Synology Diskstation. | |
The problem being that Plex will stubbornly offer the DTS track for playback, producing no sound. And when | |
asked to convert, playback is choppy/hangs every x seconds. The most solid solution is to make sure the | |
first available audio stream is a non-DTS (e.g. AC3) codec. This script automates that process: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Blueprint by Klaas Leussink / hnldesign.nl (c) 2022 | |
blueprint: | |
name: Motion Light with override | |
source_url: https://gist.github.com/c-kick/32234ea474f6b854a861853b17b881ce | |
description: >- | |
This blueprint can be used to have a motion sensor switch on (a) device(s), but allow the turning off procedure (after no motion is detected anymore) to be overridden by a (ZHA) switch/button. Useful if you need to activate a light upon entry, and turn off after no motion (most cases), but keep the option to make the light stay on if you're planning on spending more time in the area (e.g. a shed). | |
Note: if you need to know what is happening, uncomment the debug message lines. | |
domain: automation | |
input: | |
motion_sensor: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Blueprint by Klaas Leussink / hnldesign.nl (c) 2022 | |
blueprint: | |
name: Set schedule-related booleans | |
source_url: https://gist.github.com/c-kick/b4dcdae9d9fa85ca8c51cdedd7293bf5 | |
description: >- | |
This automation uses schedules to set two indicators (booleans): a morning schedule (useful for short morning routines on working days) and a home indicator (useful for indicating people are home, until they go to bed). It also includes an option to use a holiday calendar, which sets the home indicator on the specified start and end times if the current day is a holiday. Another option is a vacation override, which - when set to active - ignores *all* schedules/calendars and uses the specified 'vacation schedule' instead. | |
domain: automation | |
input: | |
morning_routine_schedules: | |
name: Morning schedule(s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* debounceThis ES6 module v1.4 (10-2023) | |
* Debounces/rate-limits the provided function (callback) | |
* | |
* Provides a way to debounce or rate-limit a function, which can be useful in scenarios where events may be | |
* triggered frequently and rapidly, such as scrolling or resizing the window. | |
* | |
* Example usage: | |
* |