Skip to content

Instantly share code, notes, and snippets.

View Luisgustavom1's full-sized avatar

Luis Gustavo Macedo Luisgustavom1

View GitHub Profile
class Calcular {
somar(valor, salarioPessoas) {
let total;
if (total === undefined) {
valor = null;
} else if (valor > 0) {
total = valor;
for (let salario of salarioPessoas) {
snail = function(array) {
if (array.length === 0) return []
if (array.length === 1) return array[0]
const a = []
let bxi = 0
let bxe = array[0].length - 1
let byi = 0
let bye = array.length - 1
function digitalRoot(n) {
if (n < 10) {
return n;
}
let nu = n
let s = 0
while(nu > 0) {
const r = nu % 10
@Luisgustavom1
Luisgustavom1 / example.ts
Last active October 12, 2023 22:34
The purpose this code is to study about more complex type system of typescript. Its a query builder type system
interface User {
id: number;
name: string;
email: string;
password: string;
updated_at: Date;
}
interface Product {
id: number;
@Luisgustavom1
Luisgustavom1 / VScode extensions
Created May 22, 2023 22:57
My vscode extensions
bradlc.vscode-tailwindcss
clinyong.vscode-css-modules
dbaeumer.vscode-eslint
eamodio.gitlens
EditorConfig.EditorConfig
esbenp.prettier-vscode
glenn2223.live-sass
golang.go
jock.svg
Luisao.one-more-coffee
@Luisgustavom1
Luisgustavom1 / settings.json
Last active December 3, 2023 18:23
My VSCode settings
{
"explorer.confirmDragAndDrop": true,
"diffEditor.wordWrap": "on",
"editor.fontSize": 18,
"editor.insertSpaces": true,
"editor.detectIndentation": true,
"launch": {
"configurations": []
},
"editor.codeActionsOnSave": {
@Luisgustavom1
Luisgustavom1 / css-reset.css
Last active May 7, 2023 20:41
A simple reset css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.5%;
}
@Luisgustavom1
Luisgustavom1 / new Proxy().js
Last active November 12, 2022 20:18
An example of new Proxy use
const user = {
name: 'luis'
}
const messages = {
hello: (userName) => `Ola ${userName}, seja bem vindo ao nosso sistema`,
goodBye: (userName) => `Até mais ${userName}, esperamos que volte sempre aqui`,
}
const messagesHandler = {
get(target, prop, receiver) {
return target[prop](user.name)
@Luisgustavom1
Luisgustavom1 / useLocalStorage.ts
Created September 8, 2022 01:26
Hook to use states based in local storage
import React from 'react'
export const useLocalStorage = <T extends string | object>(
item: string,
initialValue = '',
): [string, React.Dispatch<(value: T) => T>] => {
const [localStorageItem, setLocalStorageItem] = React.useState(() => {
const itemStoraged = localStorage.getItem(item)
if (itemStoraged) {
@Luisgustavom1
Luisgustavom1 / ComposeProviders.tsx
Last active December 27, 2022 19:10
Compose React Providers to avoid too much chaining
import React from 'react'
interface IComposeProvidersProps {
with: Array<React.ElementType>
children: React.ReactNode
}
export const ComposeProviders = ({
with: Providers,
children,