Skip to content

Instantly share code, notes, and snippets.

View u12206050's full-sized avatar

Gerard Lamusse u12206050

View GitHub Profile
@u12206050
u12206050 / scroller.css
Last active July 25, 2023 07:27
Horizontal scroll snap container
.scroll-snap-x-container {
display:flex;
overflow-x: scroll;
-ms-overflow-style: none;
scrollbar-width: none;
-ms-scroll-snap-type: x mandatory;
scroll-snap-type: x mandatory
}
.scroll-snap-x-child {
@u12206050
u12206050 / safeDebounce.ts
Last active March 5, 2023 21:23
Debounces the execution of a function being called across containers utilising a shared cache
// eslint-disable-next-line node/no-extraneous-import
import Keyv from 'keyv';
/**
* Debounces the execution of a function that takes an ID parameter, ensuring that it only runs once per second
* for each ID across all containers/threads. Uses a combination of shared cache and a locking mechanism to achieve this.
*
* @param id - The ID parameter for the function being debounced
* @param cache - The Redis cache instance used for locking and storing timestamps
* @param fn - The function being debounced, which takes the ID parameter and returns a Promise