Skip to content

Instantly share code, notes, and snippets.

View beefchimi's full-sized avatar
🤠
yeeeeehaw!

Curtis Dulmage beefchimi

🤠
yeeeeehaw!
View GitHub Profile
@tannerlinsley
tannerlinsley / onWindowFocus.ts
Last active January 30, 2024 09:37
A utility function to detect window focusing without false positives from iframe focus events
type State = {
added: boolean;
interval: false | ReturnType<typeof setInterval>;
inFrame: boolean;
callbacks: Array<SetFocusedCallback>;
};
type EnrichedHTMLIFrameElement = HTMLIFrameElement & { ___onWindowFocusHandled: boolean };
type SetFocusedCallback = (focused?: boolean) => void;
@ChugunovRoman
ChugunovRoman / .bashrc
Last active January 6, 2024 10:04
Alias for npm run with auto completing a npm scripts from package.json from current directory.
alias nr="npm run"
_npm_scripts() {
# check package.json file in current directory
if [ ! -f ./package.json ]; then
return
fi
local scripts="$(node -e 'const { scripts } = require(`./package.json`); if (!scripts) process.exit(); let a = Object.entries(scripts); for (let s in scripts) { console.log(s); }' | grep -E ^$2)"
local -a toks