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' | |
export const useCountdown = (time: number) => { | |
const [count, setCount] = useState(time) | |
useEffect(() => { | |
setTimeout(() => { | |
if (count) { | |
setCount((prevCount: number) => prevCount - 1) | |
} |
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 song = (...[mp3File, name, thumbnail, duration]) => ({ mp3File, name, thumbnail, duration }) | |
const mockedResponse = [ | |
song('./songs/despacito.mp3', 'Despacito by clonalejandro', './songs/images/despacito_thumbnail.jpg', 3 * 60 * 1000 + (30 * 1000)), | |
song('./songs/despacito.mp3', 'Despacito by clonalejandro', './songs/images/despacito_thumbnail.jpg', 3 * 60 * 1000 + (30 * 1000)), | |
song('./songs/despacito.mp3', 'Despacito by clonalejandro', './songs/images/despacito_thumbnail.jpg', 3 * 60 * 1000 + (30 * 1000)), | |
] | |
const objectAdapter = (obj, adapter) => { | |
const modifiedObj = {} |
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
{ | |
"sync.gist": "eb02eed61109a157732ed61312983ba1" | |
} |
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 paginate(array, pages) { | |
const arr = [...array]; | |
const paginated = []; | |
while (arr.length){ | |
paginated.push(arr.splice(0, pages)); | |
} | |
return paginated; | |
} |
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
new RegExp(/\d{1,3}(\.\d{1,3}){3}|[a-zA-z]+\.[a-zA-Z]{2,3}, 'g') |
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
var isEnded = false | |
const board = { | |
rows: 3, | |
columns: 3, | |
map: [], | |
isEmpty: () => !board.map.length, | |
isFull: () => !board.map.some(row => row.includes(0)) | |
} | |
const players = { |
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
var OFF = 0, WARN = 1, ERROR = 2; | |
module.exports = exports = { | |
"env": { | |
"es6": true, | |
"amd": true, | |
"node": true, | |
"browser": true | |
}, |
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
setcolor(){ | |
printf $1 | |
} | |
resetcolors(){ | |
printf "\e[39m" | |
} | |
startserver(){ | |
setcolor "\e[95m" |
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
# Removes the oldest backup | |
files=$(ls -1 | wc -l) | |
if [ $files -gt 3 ] || [ $files -eq 3 ]; then | |
rm "$(ls -t | tail -1)" | |
fi | |
# Gen the name of the backup | |
name=home$(date +%d%m%Y) |
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
#!/bin/bash | |
checkroot(){ | |
if [ $(id -u) -ne 0 ]; then | |
setcolor "\e[31m" | |
echo "Please run as root user!" | |
resetcolors | |
exit | |
fi | |
} |
NewerOlder