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
check_commands() { | |
local ok=0 | |
for command in "$@";do | |
if ! command -v "${command}" >/dev/null 2>&1;then | |
echo "'${command}' is not installed!" | |
ok=1 | |
fi | |
done | |
return "${ok}" | |
} |
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
cr_wf () { | |
user="$(echo $1 | sed 's|https://github.com/\([^/]*\)/\([^/]*\)/pull.*$|\1|')" | |
repo="$(echo $1 | sed 's|https://github.com/\([^/]*\)/\([^/]*\)/pull.*$|\2|')" | |
pull="$(echo $1 | sed 's|https://github.com/.*/pull/\([0-9]\+\).*$|\1|')" | |
workspace="/tmp/mv-tse-cr-${user}/${repo}" | |
api_pr="https://api.github.com/repos/${user}/${repo}/pulls/${pull}')" | |
branch="$(curl -s -H 'Accept: application/vnd.github.v3+json' "${api_pr}" | jq --raw-output '.head.ref')" | |
echo "USER=${user}" | |
echo "REPO=${repo}" | |
echo "PULL=${pull}" |
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
{"max_id_str":"1382726260682489858","datetime":"2021-04-15T16:03:25.399Z","retweets":0,"likes":0} |
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
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh | |
[ -s "$HOME/.git-prompt.sh" ] && . "$HOME/.git-prompt.sh" | |
[ -s "$HOME/.git-completion.bash" ] && . "$HOME/.git-completion.bash" | |
GIT_PS1_SHOWDIRTYSTATE=1 | |
GIT_PS1_SHOWSTASHSTATE=1 | |
GIT_PS1_SHOWUNTRACKEDFILES=1 | |
GIT_PS1_SHOWCOLORHINTS=1 | |
GIT_PS1_SHOWUPSTREAM="auto" | |
GIT_PS1_DESCRIBE_STYLE="default" | |
exitstatus() { |
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 debounce = (func, delay) => { | |
let timeout = null; | |
return (...args) => { | |
clearTimeout(timeout); | |
timeout = setTimeout(() => { | |
func.apply(this, args); | |
}, delay); | |
}; | |
}; |
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 sleepMs = (delayMs) => new Promise((resolve) => setTimeout(resolve, delayMs)); |
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
import { useState, useEffect } from "react"; | |
function useDebounce<T>(value: T, delay: number): T { | |
const [debouncedValue, setDebouncedValue] = useState<T>(value); | |
useEffect(() => { | |
const handler = setTimeout(() => { | |
setDebouncedValue(value); | |
}, delay); | |
return () => { | |
clearTimeout(handler); |
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 randomArrayElement = (array) => array[Math.floor(Math.random() * array.length)]; |
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
function shuffle(array) { | |
for (let i = array.length - 1; i > 0; i--) { | |
const j = Math.floor(Math.random() * (i + 1)); | |
[array[i], array[j]] = [array[j], array[i]]; | |
} | |
return array; | |
} |
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
function inOrder(node) { | |
node.left && this.inOrder(node.left); | |
console.log(node.val); | |
node.right && this.inOrder(node.right); | |
} |
OlderNewer