Skip to content

Instantly share code, notes, and snippets.

View MauricioRobayo's full-sized avatar
🧰
Refactoring

Mauricio Robayo MauricioRobayo

🧰
Refactoring
View GitHub Profile
@MauricioRobayo
MauricioRobayo / speedmp3.sh
Last active March 18, 2020 16:09
YouTube to mp3 command line script
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}"
}
@MauricioRobayo
MauricioRobayo / crwf.sh
Last active May 9, 2020 03:46
Microverse code review workflow on steroids
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}"
@MauricioRobayo
MauricioRobayo / git_ps1.sh
Last active November 22, 2020 11:35
Git PS1 using git-prompt.sh
# 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() {
@MauricioRobayo
MauricioRobayo / microvot.json
Last active May 20, 2021 13:09
Tracks microvot state
{"max_id_str":"1382726260682489858","datetime":"2021-04-15T16:03:25.399Z","retweets":0,"likes":0}
const randomArrayElement = (array) => array[Math.floor(Math.random() * array.length)];
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);
@MauricioRobayo
MauricioRobayo / debounce.js
Last active May 20, 2021 15:40
#gogofast
const debounce = (func, delay) => {
let timeout = null;
return (...args) => {
clearTimeout(timeout);
timeout = setTimeout(() => {
func.apply(this, args);
}, delay);
};
};
@MauricioRobayo
MauricioRobayo / quote.txt
Last active May 21, 2021 01:13
Donald E. Knuth, Selected Papers on Computer Science #gogofast
The best programs are written so that computing machines can perform them quickly and so that human beings can understand them clearly. A programmer is ideally an essayist who works with traditional aesthetic and literary forms as well as mathematical concepts, to communicate the way that an algorithm works and to convince a reader that the results will be correct.
@MauricioRobayo
MauricioRobayo / quote.txt
Last active May 21, 2021 01:15
The Humble Programmer by Edsger W. Dijkstra #gogofast
The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague.
@MauricioRobayo
MauricioRobayo / quote.txt
Last active May 21, 2021 01:25
by Kent Beck #gogofast
I'm not a great programmer; I'm just a good programmer with great habits.