Skip to content

Instantly share code, notes, and snippets.

View gabrielfreirebraz's full-sized avatar
🎯
Focusing

Gabriel Braz gabrielfreirebraz

🎯
Focusing
View GitHub Profile
@gabrielfreirebraz
gabrielfreirebraz / axios.ts
Last active June 8, 2024 22:59
Axios configuration to api requests
import axios from 'axios'
export const api = axios.create({
baseURL: 'http://localhost:3000',
headers: {
'Content-Type': 'application/json',
},
timeout: 10000, // Timeout de 10 segundos
})
@gabrielfreirebraz
gabrielfreirebraz / compose.yaml
Last active April 27, 2024 01:10
Basic structure to get start docker compose file
services:
api:
build:
context: .
ports:
- "80:4000"
environment:
NODE_ENV: production
restart: always
@gabrielfreirebraz
gabrielfreirebraz / Dockerfile
Last active March 30, 2024 00:04
Dockerfile example to get start a new api rest
FROM node:18.16.1-alpine
WORKDIR /api
COPY package.json .
RUN yarn install
COPY . .
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: transparent;
overflow-x: hidden;
margin: 0;
padding: 0;
@gabrielfreirebraz
gabrielfreirebraz / konami.ts
Last active January 12, 2024 20:45
Konami code for typescript
export const Konami = (() => {
// up, up, down, down, left, right, left, right, b, a, enter
const SEQUENCE: Array<number> = [
38,
38,
40,
40,
37,
CREATE FUNCTION [dbo].[F_SPLIT_STRING]( @STRING NVARCHAR (MAX), @DELIMITER NVARCHAR (10) )
RETURNS @VALUETABLE TABLE ([VALUE] NVARCHAR(MAX))
BEGIN
DECLARE @NEXTSTRING NVARCHAR(4000)
DECLARE @POS INT
DECLARE @NEXTPOS INT
DECLARE @COMMACHECK NVARCHAR(1)
@gabrielfreirebraz
gabrielfreirebraz / find_procs.sql
Last active November 24, 2023 22:32
How to find contents or names of procedures on SQL Server
SELECT
P.NAME,
C.TEXT
FROM
syscomments C
INNER JOIN
sys.procedures P
ON P.object_id = C.id
@gabrielfreirebraz
gabrielfreirebraz / valid_cpf.js
Created May 31, 2023 14:54
Checking up of CPFs
const cpfValidation = (value) => {
if (!value) return false
// Aceita receber o valor como string, número ou array com todos os dígitos
const validTypes =
typeof value === 'string' || Number.isInteger(value) || Array.isArray(value)
// Elimina valores com formato inválido
if (!validTypes) return false
@gabrielfreirebraz
gabrielfreirebraz / valid_cnpj.js
Last active June 11, 2023 20:21
Validar CNPJ se o cálculo é válido
const cnpjValidation = (value) => {
if (!value) return false
// Aceita receber o valor como string, número ou array com todos os dígitos
const isString = typeof value === 'string'
const validTypes = isString || Number.isInteger(value) || Array.isArray(value)
// Elimina valor de tipo inválido
const calSub = (x, y) => {
let z = x - y;
return z;
}
console.log("Subtraction : " + calSub(7, 4));