Skip to content

Instantly share code, notes, and snippets.

View Michal-Radomski's full-sized avatar

Michal Radomski Michal-Radomski

  • goEuropa
  • Gdansk (GMT+1), PL, EU, Earth, Solar System, Milky Way (Orion Arm), expanding finite? flat? (Ω = 1.00±0.02) Universe, (opposite my neighbors), ~13.8 billion years after the Big Bang
  • 17:56 (UTC +02:00)
View GitHub Profile
@Michal-Radomski
Michal-Radomski / useIdleTimerHook.tsx
Created May 23, 2024 21:34
Custom React hook of inactivity
//* Based on useIdleTimer (TC-Webapp)
import React from "react";
const useIdleTimerHook = (isActive: boolean, onIdle: Function, defaultTimeout_ms = 3600 * 1000): void => {
// console.log("isActive:", isActive);
const timerRef: React.MutableRefObject<number | null> = React.useRef<number | null>(null);
const resetTimer = React.useCallback(() => {
if (timerRef.current) {
@Michal-Radomski
Michal-Radomski / wheelColors.ts
Last active May 21, 2024 23:37
Calculate triadic, tetriadic, etc. colors based on the color wheel
//* Based on getTriadicColors (TC-Webapp)
//* https://en.wikipedia.org/wiki/Color_wheel
// How to use:
// Get 3 colors to red every 90deg (Square Colors)
const redHexColor = "#ff0000"; // red in hex
const threeNewColors = getWheelColors(redHexColor, 3);
console.log("threeNewColors:", threeNewColors); // threeNewColors: [ '#80ff00', '#00ffff', '#8000ff' ]
interface RGB {