Skip to content

Instantly share code, notes, and snippets.

View jefersonalmeida's full-sized avatar
:octocat:
The source code calms me down

Jeferson Almeida jefersonalmeida

:octocat:
The source code calms me down
View GitHub Profile
@jefersonalmeida
jefersonalmeida / remove-duplicate.js
Last active May 23, 2020 23:54
javascript - function to remove duplicate object via property
const removeDuplicates = (inputArray, prop) =>
prop
? inputArray.filter((obj, pos, arr) =>
obj[prop] ? arr.map((o) => o[prop]).indexOf(obj[prop]) === pos : true
)
: inputArray;
const array = [
{ id: 1, name: 'Test 1' },
{ id: 2, name: 'Test 2' },
@jefersonalmeida
jefersonalmeida / git-deploy.md
Last active August 27, 2021 15:49
Deploy automatizado - GIT Hooks

Deploy automatizado - GIT Hooks

Aqui estão as etapas simples necessárias para criar uma implantação do repositório GIT local para um servidor.

Pré-requisitos

  1. Saiba como usar GIT, Terminal, etc.
  2. Prepare uma cópia local de trabalho
  3. Tenha acesso SSH ao seu servidor usando chave private/public

Tarefas

@jefersonalmeida
jefersonalmeida / 1-balanced-brackets.md
Last active February 23, 2021 15:53
Balanced Brackets

Balanced Brackets

Write a function that takes a string of brackets as the input, and determines if the order of the brackets is valid. A bracket is considered to be any one of the following characters: (, ), {, }, [, or ].

We say a sequence of brackets is valid if the following conditions are met:

  • It contains no unmatched brackets.
  • The subset of brackets enclosed within the confines of a matched pair of brackets is also a matched pair of brackets.

Examples:

  • (){}[] is valid
@jefersonalmeida
jefersonalmeida / retry.interceptor.ts
Created February 23, 2024 12:43
Angular HTTP Interceptor to retry requests when there's an error
import { HttpEvent, HttpHandlerFn, HttpRequest } from '@angular/common/http';
import { Observable, retry, timer } from 'rxjs';
export function retryInterceptor(
request: HttpRequest<unknown>,
next: HttpHandlerFn,
): Observable<HttpEvent<unknown>> {
const initialDelay = 500;
const maxTries = 3;
return next(request).pipe(