Skip to content

Instantly share code, notes, and snippets.

View ocariocawebdesign's full-sized avatar

Carlos Abreu ocariocawebdesign

View GitHub Profile
@ocariocawebdesign
ocariocawebdesign / profile.jsx
Created March 19, 2024 14:29
Tradução da página de perfil
import React, { useState } from "react";
import { DivProfile } from "./styles/styles";
import "./styles/styles.css";
//import "./styles.css";
export function CarlosAbreu() {
const [textCarlos, setTextCarlos] = useState({
pt: "Eu sou um desenvolvedor de frontend e moro no Rio de Janeiro, Brasil. Eu sou um usuário da distribuição linux Ubuntu e sou apaixonado por ela.",
@ocariocawebdesign
ocariocawebdesign / cronometro.jsx
Last active December 27, 2023 12:13
Componente React crônometro
/*CÓDIGO MELHORADO CHATGPT*/
import React, { useState, useEffect, useRef } from "react";
import Calendar from "../../images/calendar.png";
const CronometroDecrescente = () => {
const dataFinal = new Date("2023-12-28T23:59:59");
const [tempoRestante, setTempoRestante] = useState(calcularTempoRestante());
const intervaloRef = useRef(null);
function calcularTempoRestante() {
@ocariocawebdesign
ocariocawebdesign / gravar.php
Created October 10, 2023 10:37
Pega os dados do formulário e cria um json com os dados
<?php
// Verifica se o formulário foi submetido
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Pega os dados do formulário POST
$nome = $_POST["nome"];
$email = $_POST["email"];
$telefone = $_POST["telefone"];
// Cria um array associativo com os dados
$dados = [
@ocariocawebdesign
ocariocawebdesign / cronometro.js
Last active November 22, 2023 20:47
Cronômeto decrescente
//Javascript cronômetro LP
//Funcionando
function updateCountdown() {
/*Array diasDaSemana = [
"Domingo", = 0
"Segunda-feira", 1
"Terça-feira", = 2
"Quarta-feira", = 3
"Quinta-feira", = 4
"Sexta-feira", = 5
@ocariocawebdesign
ocariocawebdesign / cpf-databr.js
Created September 11, 2023 18:09
Validação para CPF Brasil em Jquery
jQuery.validator.addMethod("cpf", function(value, element) {
value = jQuery.trim(value);
value = value.replace('.','');
value = value.replace('.','');
cpf = value.replace('-','');
while(cpf.length < 11) cpf = "0"+ cpf;
var expReg = /^0+$|^1+$|^2+$|^3+$|^4+$|^5+$|^6+$|^7+$|^8+$|^9+$/;
var a = [];
@ocariocawebdesign
ocariocawebdesign / scroolSuave.js
Last active September 18, 2022 21:49
scrool-suave
function scrollSmooth() {
// href^=''#' a que termive com #
const linksInternos = document.querySelectorAll('.nav-main a[href^="#"');
console.log(linksInternos);
function scrollToSecion(event) {
event.preventDefault();
const href = event.currentTarget.getAttribute("href");
const section = document.querySelector(href);
<style>
.boxs {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 20px;
}
#box-1 {
background: red;
}
const result2 = document.querySelector("#result2");
async function fetchPposts(url) {
const productsResponse = await fetch(url);
const jsonBody = await productsResponse.json();
return jsonBody;
}
const requisicaoProd = fetchPposts(
"https://meusite.com.br/wp-json/wc/store/products"
//CÓDIGO REFATORADO PELO CHATGPT
const result = document.querySelector("#result");
async function fetchPosts(url) {
try {
const response = await fetch(url);
const jsonData = await response.json();
return jsonData;
} catch (error) {
@ocariocawebdesign
ocariocawebdesign / dados.js
Last active April 23, 2022 12:15
async / await
//async / await
const result = document.querySelector("#result");
async function fetchPposts(url) {
const response = await fetch(url);
const jsonBody = await response.json();
return jsonBody;
}