This file contains hidden or 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 convertToHex = (color) => { | |
const colors = { | |
red: '#A31419', | |
green: '#10A337', | |
blue: '#4C91F0', | |
yellow: '#F0EA6F', | |
purple: '#8132A3', | |
}; | |
return colors[color] || 'Not found color' ; | |
}; |
This file contains hidden or 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
// Fonte - https://www.youtube.com/watch?v=sCk8DHeGQfo | |
// expressões regulares | |
// 5 padrões que você | |
// precisa conhecer | |
// padrao 1 : | or | |
const reg1 = new RegExp("franciscochaves.com.br|franciscojsc.github.io"); | |
const str1 = "franciscochaves.com.br"; | |
const match1 = str1.match(reg1); |
This file contains hidden or 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 startTime = "07/26/2021 02:48:56" | |
var endTime = "07/27/2021 02:48:56" | |
function run(start, end) { | |
return Math.abs(new Date(start).getTime() - new Date(end).getTime()) | |
} | |
var milliseconds = run(startTime, endTime) | |
var second = run(startTime, endTime) / 1000 | |
var minute = run(startTime, endTime) / (1000 * 60) |
This file contains hidden or 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 run(name, users) { | |
if (typeof users == "string") users = JSON.parse(users); | |
return !!verifyUser(name, users); | |
} | |
function verifyUser(name, users) { | |
return Object.values(users).filter(function(user) { | |
return user.name == name; | |
})[0]; | |
} |
This file contains hidden or 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
/** | |
* @description Identificar a ocorrência do texto por meio de Regex | |
* | |
* @param {String} text Texto informado pelo usuário | |
* @param {Object} options Objeto com os pares de chave e valor | |
* | |
* @return {String} Retorna a opção selecionada pelo usuário ou o valor padrão | |
**/ | |
function run(text, options) { | |
if (typeof options == "string") options = JSON.parse(options); |
This file contains hidden or 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
#!/usr/bin/env bash | |
# Author: Francisco Chaves <https://franciscochaves.com.br> | |
# Description: Clone site with software wget. | |
URL=$1 | |
if [ -z $(which wget) ]; then | |
echo -e "Please install wget\nsudo apt install wget" | |
fi |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>WebCam Web</title> | |
</head> | |
<body> | |
<video id="video" autoplay muted></video> | |
This file contains hidden or 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 URL = 'https://api.github.com/users/franciscojsc' | |
fetch(URL) | |
.then((data) => data.json()) | |
.then((result) => console.log(result)) |
This file contains hidden or 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
let valor = 1686; | |
const nota100 = parseInt(valor / 100); | |
valor %= 100; | |
const nota50 = parseInt(valor / 50); | |
valor %= 50; | |
const nota20 = parseInt(valor / 20); | |
valor %= 20; |
This file contains hidden or 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 distanciaTotal = 650; | |
const combustivelGasto = 40.0; | |
const resultado = parseFloat(distanciaTotal / combustivelGasto).toFixed(3); | |
console.log(`Consumo médio: ${resultado} km/l`); |