Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View tomlobato's full-sized avatar
🎯
Focusing

Tom Lobato tomlobato

🎯
Focusing
View GitHub Profile
@tomlobato
tomlobato / throttle-and-debounce.sh
Created February 2, 2018 17:38 — forked from niieani/throttle-and-debounce.sh
throttle and debounce commands in bash
#!/usr/bin/env bash
declare -i last_called=0
declare -i throttle_by=2
@throttle() {
local -i now=$(date +%s)
if (($now - $last_called >= $throttle_by))
then
"$@"