This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
TODO: Simplify this type by creating a PolymorphicComponentWithoutRef | |
first and then a PolymorphicComponentWithRef using React.ElementRef<'div'> | |
*/ | |
/** | |
* Props for a polymorphic React component that includes a ref. | |
* | |
* @template E - The expected React element type. | |
* @template P - Additional props specific to the component. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A utility type that omits specified keys from an object type in a distributive manner. | |
* It uses conditional types to distribute the operation over each property in `T`. | |
* | |
* @template T - The input object type. | |
* @template TOmitted - The keys to be omitted from the input type. | |
*/ | |
export type DistributiveOmit<T, TOmitted extends PropertyKey> = T extends any | |
? Omit<T, TOmitted> | |
: never |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This updated version of ForwardRef was created to be used with generics | |
* typescript can't infer correctly the type of the reference in this scenario. | |
* | |
* The downside is that using this function, we will lose the dsiplayName property | |
* and some other stuff like defaultProperties. | |
* | |
* ref: https://fettblog.eu/typescript-react-generic-forward-refs/#option-3%3A-augment-forwardref | |
*/ | |
export type FixedForwardRef = <T, P = {}>( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http = require('http') | |
import https = require('https') | |
import url = require('url') | |
import {AxiosInstance, AxiosInterceptorManager} from 'axios' | |
import {HttpRequestOptions as HttpFollowRequestOptions, http as httpFollow, https as httpsFollow} from 'follow-redirects' | |
import now = require('performance-now') | |
import httpAdapter = require('axios/lib/adapters/http') | |
import InterceptorManager = require('axios/lib/core/InterceptorManager') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Selecione os primeiros 5 registros da tabela clientes, ordenando-os pelo nome em ordem crescente. | |
Select * from Colaboradores | |
Order By nome | |
LIMIT 5; | |
-- Encontre todos os produtos na tabela produtos que não têm uma descrição associada (suponha que a coluna de descrição possa ser nula). | |
SELECT * from HistoricoEmprego | |
WHERE datatermino IS NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Splits a string based type into an tuple using a delimiter. | |
* | |
* @template S - The input string to be split. | |
* @template D - The delimiter string used for splitting. | |
* @template T - The resulting array of substrings. | |
* | |
* @returns A tuple of strings representing the segments of the original string after being split by the delimiter. | |
* | |
* @example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function bufferPromise< | |
T, | |
PromiseFactoryFn extends (...args: any) => Promise<T> | |
>( | |
promiseFactoryFn: PromiseFactoryFn, | |
maxConcurrency = 5 | |
) { | |
const activePromises: Array<Promise<T>> = []; | |
const queuedPromises: Array<() => Promise<T>> = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type History<T> = Partial<T>[] | |
const undoRedo = <T extends Record<string, unknown>>(object: T) => { | |
const history: History<T> = [{...object}] | |
let currIndex = 0 | |
const getState = (key: any) => { | |
const state = history[currIndex][key] | |
return state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect, useState, useRef } from 'react' | |
const MOBILE_BREAKPOINT = 640 | |
let defaultWindowWidth = 0 | |
/* | |
If using Nextjs, the following validation is necessary to ensure that we only try | |
to access the innerWidth when our code is running on user browser (client-side) | |
*/ | |
if (typeof window !== 'undefined') { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"presets": [ | |
"@babel/preset-env" | |
], | |
"plugins": [ | |
[ | |
"@babel/plugin-proposal-decorators", | |
{ | |
"legacy": true | |
} |
NewerOlder