Skip to content

Instantly share code, notes, and snippets.

View sameroso's full-sized avatar

Samer sameroso

View GitHub Profile
import { useMemo } from "react";
import { debounce } from "lodash";
export function useDebounceCallback(callback: (...values: any[]) => void, delay: number) {
// eslint-disable-next-line react-hooks/exhaustive-deps
const onChangeDebounce = useMemo(() => debounce(callback, delay), []);
useEffect(() => {
return () => onChangeDebounce.cancel();
// eslint-disable-next-line react-hooks/exhaustive-deps
@sameroso
sameroso / queryParamsFactory.ts
Last active September 11, 2021 22:51
Query Params API
interface SpecificParams<T extends Record<string, string>> {
key: keyof T;
value: string;
}
interface GenericParams {
key: string;
value: string;
}
@sameroso
sameroso / queryParamsFactory.test.ts
Last active September 11, 2021 23:14
Query Params API
import { queryParamsFactory } from "../utils/functions/queryParams";
describe("Testing queryParamsFactory functionalities", () => {
test(`add param`, () => {
const queryParamUrlWithAddedParam = queryParamsFactory<{
testKey1: string;
testKey2: string;
}>("?testKey1=testValue1&testKey2=testValue2").addParam({
key: "testKey3",
value: "addedValue3",
@sameroso
sameroso / allTabsFunc.json
Created March 4, 2021 16:46
todas as funcionalidades em tabs no vscode
{
"workbench.editor.wrapTabs": true,
"workbench.editor.decorations.colors": true,
"workbench.editor.decorations.badges": true
}
@sameroso
sameroso / badgeTab,json
Created March 4, 2021 16:44
Estado do arquivo nas tabs no vscode, código de configuração
{
"workbench.editor.decorations.badges": true,
}
@sameroso
sameroso / colorsWraprabs.json
Created March 4, 2021 16:37
Exemplo de cores e wrapTabs em tabs
{
"workbench.editor.wrapTabs": true,
"workbench.editor.decorations.colors": true,
}
@sameroso
sameroso / vscodeTabColors.json
Created March 4, 2021 16:34
como adicionar cores nas tabs do vscode
{
"workbench.editor.decorations.colors": true,
}