Skip to content

Instantly share code, notes, and snippets.

View geraldotech's full-sized avatar
🎯
Focusing

Geraldo Costa Filho geraldotech

🎯
Focusing
View GitHub Profile
@geraldotech
geraldotech / MenuDropDown.jsx
Created February 24, 2024 13:15
Handler isArrayWithObjects
import React from 'react'
import { MenuContext } from './Menu'
import isArrayWithObjects from '../Hooks/isArrayWithObjects'
export default function MenuDropDown({ items, keyName }) {
const { on } = React.useContext(MenuContext)
let data = items
if (on && Array.isArray(data) && data.length > 0) {
@geraldotech
geraldotech / getYoutubeVideoID.js
Created January 20, 2024 18:54
getYoutubeVideoID.js
function getparams(url){
let regex = /[^=\]]+(?=&)/g;
// void broken code add a & final url
let str = url + '&';
let match = regex.exec(str)[0];
return match
}
console.log(getparams('https://www.youtube.com/watch?v=z_DNPipPdUA&t=1900s'))
console.log(getparams('https://www.youtube.com/watch?v=uzUoGD1G6LU&list=RDuzUoGD1G6LU&start_radio=1&rv=z_DNPipPdUA'))
@geraldotech
geraldotech / cartshopping.js
Created January 14, 2024 12:28
Cart Shopping purchase.js
// evita adicionar o mesmo item no carrinho, apenas increment quantidade
const cart = []
function addToCart(product){
// get index se o item tem no carrinho
const checkCartItem = cart.findIndex(pro => pro.id === product.id)
if(checkCartItem > -1){
// item existe apenas increment quant
@geraldotech
geraldotech / checkAgeNumber.html
Created December 18, 2022 16:15
Check Age template literal
<!DOCTYPE html>
<html lang="en" style="color-scheme: dark">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Chek Age Number</title>
</head>
<body>
<input type="number" />
<p></p>
@geraldotech
geraldotech / LoadTime.js
Created August 27, 2022 21:47
LoadTime
var loadTime = function(){
setTimeout(function(){
var perfData = window.performance.timing;
var EstimatedTime = (perfData.loadEventEnd - perfData.navigationStart);
console.clear();
console.log(EstimatedTime);
console.log(EstimatedTime+" milliseconds");
@geraldotech
geraldotech / calculadora-notas.js
Last active October 9, 2022 19:18
Calculadora notas laço while - JavaScript - Video
let [cont,sum,qt] = [1,0,2]; //contador, soma e quantidade de notas
while(cont <= qt){
const notas = +prompt(`Digite a nota ${cont}`);
if(notas > 10) { alert('nota invalida!'); break; } // verifica se a nota for maior que 10 cancela a operacao
sum += (notas) //faz a soma
document.write(`Nota ${cont} => ${notas}`);
document.write('<br>');
cont++;
}
// get all questions || or gararito answers
const title = document.querySelectorAll("[data-testid='question-typography']:first-child")
for(const i of title){
console.log(i.textContent)
console.log("=============")
}
// get all answers
const resp = document.querySelectorAll("[data-element='link_resposta'] [data-testid='question-typography']")
@geraldotech
geraldotech / Special.js
Last active December 17, 2022 14:56
exercicios special
//first class function
const ano = [1992,1995,2000,2006,2008];
function idade(age){
let d = new Date();
return d.getFullYear() - age;
}
function Calc(ano,fun){ // declarando dois parâmetros, os anos e a função que calcula a idade baseado nos anos
let gets = []; // array vazio vai armazerar os resultados
@geraldotech
geraldotech / fetch_repo_map.js
Created June 26, 2022 01:47
fetch_repo_map
const api = "https://gh-pinned-repos.egoist.sh/?username=geraldotech";
loadE = document.querySelector("#loading");
container = document.querySelector("#container");
async function get(url){
response = await fetch(url)
console.log(response)
data = await response.json();
console.log(data)
@geraldotech
geraldotech / search.js
Last active August 7, 2022 17:22
Listener Search
//html
<input type="text" />
<div id="esu">
<span id="res"></span>
</div>
//css
#esu{
display: none;