This file contains hidden or 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 VariantValue<T> = { [K in keyof T]?: keyof T[K] } | |
type Variant = { [k: string]: string } | |
type VariantConfig = { [k: string]: Variant } | |
const cns = <T extends VariantConfig>(base: string, variantsConfig?: T, defaultVariants: VariantValue<T> = {}) => (variantsValues: VariantValue<T> = {}): string => { | |
const variants = Object.entries(variantsConfig || {}).map(([name, values]) => values?.[variantsValues[name] || defaultVariants[name]] ?? '') | |
return [base, ...variants].filter(Boolean).join(' ') | |
} | |
const button = cns( |
This file contains hidden or 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
update table1 t1 | |
set "order" = t2.seq | |
from ( | |
select id, row_number () over (partition by target_id order by created_at) as seq | |
from table2 | |
) as t2 | |
where t1.id = t2.id |
This file contains hidden or 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
const S3Client = require('aws-sdk/clients/s3') | |
const sharp = require('sharp') | |
const ACCESS_KEY_ID = '' | |
const SECRET_ACCESS_KEY = '' | |
const REGION = '' | |
const BUCKET = '' | |
const PREFIX = '' | |
const CHUNK_SIZE = 500 | |
const FILTER = (filesName) => { |
This file contains hidden or 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
// INSTRUMENT | |
const fetchMachine = Machine( | |
{ | |
id: 'device', | |
initial: 'connection', | |
context: { | |
retries: 0 | |
}, | |
states: { |
This file contains hidden or 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
// TAP FRONTEND | |
const appMachine = Machine( | |
{ | |
id: 'tap', | |
initial: 'init', | |
context: {}, | |
on: { | |
RESTART: { | |
target: 'init', |
This file contains hidden or 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
// TAP BACKEND | |
const appMachine = Machine( | |
{ | |
id: 'tap', | |
context: {}, | |
initial: 'bootstrap', | |
on: { | |
RESTART: 'bootstrap', | |
}, |
This file contains hidden or 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
const fetchMachine = Machine({ | |
initial: 'images', | |
context: { | |
images: [], | |
expenses: [], | |
category: undefined | |
}, | |
states: { | |
images: { | |
on: { |
This file contains hidden or 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
const Comp = () => { | |
const { getInputProps } = useImask({ | |
mask: [ | |
{ | |
mask: '000.000.000-00', | |
}, | |
{ | |
mask: '00.000.000/0000-00', | |
} | |
], |
This file contains hidden or 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
if (!process.env.NODE_ENV) { | |
process.env.NODE_ENV = 'development' | |
} | |
const clientEnv = require('react-scripts/config/env')().raw | |
console.log(clientEnv) |
This file contains hidden or 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 React, { useRef, useMemo, useState, useCallback, useEffect } from "react"; | |
import ReactDOM from "react-dom"; | |
function applyHooks(hooks, initial, ...args) { | |
return hooks.reduce((prev, next) => { | |
const nextValue = next(prev, ...args); | |
if (typeof nextValue === "undefined") { | |
throw new Error("A hook just returned undefined! This is not allowed."); | |
} |
NewerOlder