Skip to content

Instantly share code, notes, and snippets.

View luisvinicius09's full-sized avatar
๐Ÿš€

Luis Vinicius luisvinicius09

๐Ÿš€
View GitHub Profile
@luisvinicius09
luisvinicius09 / gist:6df8517df6a2e01ced166d118f0de289
Created December 17, 2020 16:40
Address autocomplete for Brazil
This is a code for autocomplete the address in forms using ViaCEP endpoint.
<script>
function clean_forms() {
document.getElementById('street').value = ('');
document.getElementById('district').value = ('');
document.getElementById('city').value = ('');
document.getElementById('uf').value = ('');
}
function my_cb(content) {
require_relative 'enumerables'
=begin test variables
array_test = [1, 2, 3, 4, 5, 6]
obj_test = { one: 1, two: 2, three: 3 }
# Method call for tests each
puts '------------Original each--------------'
array_test.each { |e| p e**2 }
obj_test.each { |e| p e }
@luisvinicius09
luisvinicius09 / projectCreation.js
Created April 7, 2021 18:40
This is a snippet for creating 'projects' and storing it in on localStorage.
const projectBtn = document.querySelector('#project-btn');
const projectName = document.querySelector('#new-project');
window.addEventListener('load', () => {
if(JSON.parse(localStorage.getItem('projects')) === null) {
localStorage.setItem('projects', JSON.stringify(new Array));
}
displayProjects();
@luisvinicius09
luisvinicius09 / activeItem.js
Created July 4, 2021 02:40
Active item on list
const list = document.querySelectorAll('.list');
for (let i = 0; i < list.length; i += 1) {
list[i].onclick = () => {
let j = 0;
while (j < list.length) {
list[j++].className = '.list';
}
list[i].className = '.list active';
}
@luisvinicius09
luisvinicius09 / leibnizPi.c
Last active April 13, 2022 21:21
leibnizPi-C
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main() {
int i, c;
double pi, x, dn;
dn = 1.00;
pi = 4.00;
@luisvinicius09
luisvinicius09 / floydTriangule.c
Created April 28, 2022 05:13
Floyd's triangle
#include <stdio.h>
#include <stdlib.h>
int main(){
int x, lineFinalNumber, previousLineFinalNumber;
lineFinalNumber = 0;
previousLineFinalNumber = 1;
import { Box, Flex, Text } from "@chakra-ui/react";
type StepProps = {
activeColor?: string;
defaultColor?: string;
title: string;
isFirst?: boolean;
index: number;
isActive?: boolean;
isLast?: boolean;
@luisvinicius09
luisvinicius09 / useWindow.tsx
Last active December 22, 2022 22:31
useWindow react hook
import { useState, useEffect, useRef } from 'react';
/**
* Generated by
* @link - https://chat.openai.com
*
* React hook to access the window object.
* Make sure to check if window is defined before using it.
*
*/
@luisvinicius09
luisvinicius09 / useScrollPercentage.ts
Last active March 29, 2023 21:29
useScrollPercentage hook
import { useRef, useState, useEffect } from 'react';
export default function useScrollPercentage(): [
React.RefObject<HTMLDivElement> | React.LegacyRef<HTMLDivElement>,
number
] {
const scrollRef = useRef<HTMLDivElement>(null);
const [scrollPercentage, setScrollPercentage] = useState(NaN);
const reportScroll = (e: any) => {
@luisvinicius09
luisvinicius09 / bg-pattern.css
Created April 2, 2023 17:24
Cube background pattern
html {
--u: 2vmin; /* change size */
--c1: #343a40;
--c2: #212529;
--s1: #0002;
--gp: 50%/calc(var(--u) * 10) calc(var(--u) * 10);
height: 100vh;
background:
repeating-conic-gradient(from 0deg at 50% 13.75%, var(--s1) 0 20.55%, #fff0 21.05% 79.13%, var(--s1) 79.63% 100% ) var(--gp),
repeating-conic-gradient(from 0deg at 50% 50%, #fff0 0 25%, var(--s1) 25% 29%, #fff0 30% 70%, var(--s1) 71% 75%, #fff0 75% 100%) var(--gp),