Skip to content

Instantly share code, notes, and snippets.

View JoaoVictor6's full-sized avatar
:octocat:
Busy

João Victor JoaoVictor6

:octocat:
Busy
View GitHub Profile
@JoaoVictor6
JoaoVictor6 / work-setup.sh
Created February 15, 2024 22:48
My current work and study setup with nvim and lazygit
#! /bin/bash
root_window_number=$(tmux display-message -p -F '#{window_index}')
folder_name=$1
cd "$folder_name"
neo_vim_window_name="Neo vim"
lazygit_window_name="Lazygit and big terminal"
tmux new-window
tmux rename-window "$neo_vim_window_name"
@JoaoVictor6
JoaoVictor6 / ErrorBoundary.tsx
Last active June 18, 2023 17:29
Error boundary with typescript example
import React, { ReactNode } from "react"
type ErrorInfo = {
componentStack: string
}
type ErrorBoundaryProps = {
children: ReactNode
}
type ErrorBoundaryState = {
hasError: boolean

Senior Frontend Interview Questions

Some questions about frontend development that might be in your next job interview. The questions were formulated by @mauvieira, a super senior fullstack developer

General Frontend

  • What are the strategies we can use to optimize the performance of web applications?

    • CDNs, GraphQL (maybe) to reduce overfetching, improve backend performance, use SSR and/or SSG, lazy loading for loading assets only when it's needed, minimize and compress HTML, CSS and JS files, and optimize images by compressing and resizing them.
  • What are Web Vitals (LCP, FID, CLS)? And how are they applied in the real world?

@JoaoVictor6
JoaoVictor6 / websocket_nodejs_implementation.md
Created April 19, 2023 19:18 — forked from Xavier577/websocket_nodejs_implementation.md
Implementing a websocket server without any libraries with raw nodejs

Code snippet

import { createServer } from "http";
import crypto from "crypto";

const PORT = 8001;

// this is from the web-socket specification and not something that is generated
const WEBSOCKET_MAGIC_STRING_KEY = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
@JoaoVictor6
JoaoVictor6 / using-uuid-as-pk.md
Created April 11, 2023 17:54 — forked from rponte/using-uuid-as-pk.md
Não use UUID como PK nas tabelas do seu banco de dados

Pretende usar UUID como PK em vez de Int/BigInt no seu banco de dados? Pense novamente...

TL;TD

Não use UUID como PK nas tabelas do seu banco de dados.

Um pouco mais de detalhes

plugins=(git zsh-autosuggestions)
source $ZSH/oh-my-zsh.sh
# User configuration
function node_prompt_version {
if ls | grep package.json &> /dev/null; then
if which node &> /dev/null; then
echo "%{$fg_bold[blue]%}node:(%{$fg[red]%}$(node -v)%{$fg[blue]%})"
fi
fi
@JoaoVictor6
JoaoVictor6 / hoc.tsx
Created January 7, 2023 16:29
High Order Component
import { ComponentType, forwardRef, useImperativeHandle, useState } from 'react';
export type PersonalModalProps = {
viewState: boolean;
handleClose: () => void;
}
export type ModalRef = {
open: () => void;
}
@JoaoVictor6
JoaoVictor6 / infer_example.ts
Created August 26, 2022 19:56
exemplo do uso do infer no typescript
// para ientender um infer, basta analisarmos o significado da palavra. é possivel INFERIR(deduzir) um tipo á primeira posição?
// se sim, significa que a mesma existe.
// O infer é muito bom quando temos alguma verificação. Nesse caso, a lóica é simples: caso a array estaja vazia deve ter o tipo NEVER(não deveria existir),
// porém caso esteja vazia o comportamento padrão seria um UNDEFINED.
// Para verificar se tem algo na array precisamos ver ser é possivel INFERIR um tipo na primeira posição, se for significa que existe algo ali(mesmo que seja undefined)
// fonte: https://www.youtube.com/watch?v=dZWJrjzqvv8
type First<TArray extends Array<unknown>> = TArray extends [infer TFirst, ...unknown[]] ? TFirst : never
const result: First<[1,2]>
Array.prototype.filterTwo = function(callback){
const pass = []
const notPass = []
for(let i = 0; i < this.length; i++){
if(callback(this[i], i, this)) {
pass.push(this[i])
}else {
notPass.push(this[i])
}
}

Conventinal Commit Messages

See how a minor change to your commit message style can make a difference. Examples

Have a look at CLI util git-conventional-commits to ensure this conventions and generate changelogs

Commit Formats

Default