Skip to content

Instantly share code, notes, and snippets.

View maiconrs95's full-sized avatar
🐛
- Under construction

Maicon Silva maiconrs95

🐛
- Under construction
View GitHub Profile
@maiconrs95
maiconrs95 / API.md
Created October 8, 2019 15:21 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@maiconrs95
maiconrs95 / README-Template.md
Created November 13, 2019 01:37 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

# wich-db-to-choose
| Requisito/Modelo DB | Relacional (sql) | Documental | Chave/Valor | Grafo |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------|------------|-------------|-------|
| Integridade absoluta dos dados | x | x | | |
| Portabilidade | x | | | |
| Relatórios Gerenciais
export function update<T>(
cache: T[] | undefined,
predicate: (value: T, index: number, data: T[]) => boolean,
updater: (data: T) => T
): T[] | undefined {
if (!cache) {
return cache;
}
const data = [...cache];
@maiconrs95
maiconrs95 / usePaginatedList.ts
Last active January 11, 2023 19:19
Custom React hook to paginate array list
import * as React from 'react';
export const paginateArray = (arr = [], size = 10) =>
arr.reduce((acc, val, i) => {
const idx = Math.floor(i / size);
const page = acc[idx] || (acc[idx] = []);
page.push(val);
return acc;
@maiconrs95
maiconrs95 / use-on-screen.ts
Created January 16, 2023 13:44
React Intersection observer hook
import { useCallback, useState } from 'react';
import * as React from 'react';
type Result = {
measureRef: (node: unknown) => void;
isIntersecting: boolean;
observer?: IntersectionObserver;
};
@maiconrs95
maiconrs95 / updateByListKey.ts
Last active August 2, 2023 16:59
Used to update current list with next list values using some list key
/**
* Update "current" list with "next" list values using some valid list key
*
* @param current "current" list
* @param next "next" list containing values to update into "current" list
* @param key used to map values to be updated
* @returns updated list
*/
export function updateByListKey<T>(current: T[], next: T[], key: keyof T): T[] {
const listMap = new Map();
export const paginateArray = <T>(arr: T[] = [], size: number = 10): T[][] =>
arr.reduce<T[][]>((acc, val, i) => {
const idx = Math.floor(i / size);
const page = acc[idx] || (acc[idx] = []);
page.push(val);
return acc;
}, []);
@maiconrs95
maiconrs95 / useOneClickOutside.ts
Created March 1, 2024 16:44
Check click outside element target
import { useEffect, useState, useRef } from "react";
function useOneClickOutside() {
const node = useRef(null);
const [open, setOpen] = useState(false);
const handleClickOutside = (e) => {
if (node.current.contains(e.target)) {
return;
}
@maiconrs95
maiconrs95 / use-wizard.js
Created March 6, 2024 19:08
React wizard stepper
import * as React from 'react';
const handleNextStep = maxStep => currentStep => {
if (maxStep) {
if (currentStep < maxStep) return currentStep + 1;
return currentStep;
}
return currentStep + 1;
};