Skip to content

Instantly share code, notes, and snippets.

View andrevandal's full-sized avatar
🇧🇷
BR Hu3

André Vandal andrevandal

🇧🇷
BR Hu3
View GitHub Profile
@andrevandal
andrevandal / prompt.md
Created October 24, 2023 19:11
big-o-prompt

You are a world-class software engineer. You are particularly good at improving code taking into consideration modern development best practices like DRY, KISS, and better readability.

Big O Notation: Quick Cheat Sheet

Time Complexity

Constant Time: O(1)

Your algorithm runs in the same amount of time, regardless of the input size.

places.ts:

import {
  mysqlTable,
  bigint,
  varchar,
  text,
  timestamp,
  double,
@andrevandal
andrevandal / validation.ts
Created April 20, 2023 15:40
refactor middleware validation from @lukinhas711
import { RequestHandler } from 'express';
import { ValidationError, ObjectSchema, Maybe, AnyObject } from 'yup';
import { StatusCodes } from 'http-status-codes';
type TProperty = 'body' | 'header' | 'params' | 'query';
type TGetSchema = <T extends Maybe<AnyObject>>(schema: ObjectSchema<T>) => ObjectSchema<any>;
type TAllSchemas = Record<TProperty, ObjectSchema<any>>;
type TGetAllSchemas = (getSchema: TGetSchema) => Partial<TAllSchemas>;
type TValidation = (getAllSchemas: TGetAllSchemas) => RequestHandler;
const pagina = ''
const handleBusca = (e) => {
const params = Object
.entries({ pagina, busca: e.target.value })
.filter(([key, value]) => !!value)
return setSearchParams(Object.fromEntries(params))
}
@andrevandal
andrevandal / .zshrc
Created April 6, 2022 16:14
enabling auto nvm use
# place this after nvm initialization!
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [ "$nvmrc_node_version" = "N/A" ]; then
@andrevandal
andrevandal / getSprintIssues.js
Created December 14, 2021 12:51
This code will collect all issues from a sprint based on its `aria-controls-name` attr.
function getSprintIssues (ariaControlsName) {
if(!ariaControlsName) return
const [header, _, content] = [
...document.querySelector(`[aria-controls="${ariaControlsName}"]`).children
]
const sprintName = header.querySelector('[role="button"] > div:nth-child(2)').textContent
console.log(sprintName)
const items = [...content.querySelector('[role="rowgroup"]').children]
<template>
<header
:class="[
'header',
{
'header--visible': showing,
'header--hidden': !showing,
},
]"
>
@andrevandal
andrevandal / blip.js
Last active September 9, 2020 19:11
blip script dynamic menu
"use strict";
function run(source) {
var isWhatsApp = source === "WhatsApp";
var csTypes = ["Certificado Digital", "DFe", "Fintech", "Mobile"];
var menuTitle = "Qual tipo de atendimento você deseja?";
var template = function template(e, i) {
return isWhatsApp ? "*" + ++i + "*: " + e : "{\"text\": " + e + ", \"previewText\": " + e + ", \"value\": null, \"index\": " + i + ", \"type\": null }";
};
services:
mysql:
container_name: mysql
image: yobasystems/alpine-mariadb
env_file:
- .env
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
volumes:
- "./data/db:/var/lib/mysql:delegated"
window.__svg_sprite = "<!--\nDiscourse SVG subset of Font Awesome Free by @fontawesome - https://fontawesome.com\nLicense - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)\n-->\n<svg xmlns='http://www.w3.org/2000/svg' style='display: none;'>\n<symbol id=\"discourse-compress\" viewBox=\"0 0 1792 1792\">\n <path d=\"M896 960v448q0 26-19 45t-45 19-45-19l-144-144-332 332q-10 10-23 10t-23-10l-114-114q-10-10-10-23t10-23l332-332-144-144q-19-19-19-45t19-45 45-19h448q26 0 45 19t19 45zm755-672q0 13-10 23l-332 332 144 144q19 19 19 45t-19 45-45 19h-448q-26 0-45-19t-19-45v-448q0-26 19-45t45-19 45 19l144 144 332-332q10-10 23-10t23 10l114 114q10 10 10 23z\"/>\n</symbol><symbol id=\"discourse-expand\" viewBox=\"0 0 1792 1792\">\n <path d=\"M883 1056q0 13-10 23l-332 332 144 144q19 19 19 45t-19 45-45 19h-448q-26 0-45-19t-19-45v-448q0-26 19-45t45-19 45 19l144 144 332-332q10-10 23-10t23 10l114 114q10 10 10 23zm781-864v448q0 26-19 45t-45 19-45-19l-144-144-332 332q-10 10-23 10t-23-1