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 cloneObject = <TObject extends { [key: string]: unknown }>(object: TObject): TObject => | |
JSON.parse(JSON.stringify(object)) | |
/* | |
* Essa função serve para remover propriedades de um objeto sem a necessidade de fazer mutações | |
* Dessa forma, você não perde a referência do objeto original se precisar utilizá-lo posteriormente | |
* | |
* | |
@param | |
object - O objeto que você quer remover uma propriedade. | |
* |
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 { useEffect } from 'react' | |
type KeyPress = { | |
key: string | |
action: () => void | |
} | |
const useKeyPress = ({ key, action }: KeyPress) => { | |
const onKeyDown = (e: KeyboardEvent) => { | |
if (e.key === key) action() |
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
url: https://google-webfonts-helper.herokuapp.com/ | |
download the font you want to use, remove the .woff files, leaving only the .woff2 ones. | |
Create a /fonts folder in the /public folder and put the .woff2 files there | |
then, in your global styles, you add this (just an example): | |
@font-face { | |
font-family: 'Roboto'; | |
font-style: normal; | |
font-weight: 400; |
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
/* first of all, install "tsconfig-paths-webpack-plugin" */ | |
/* yarn add --dev tsconfig-paths-webpack-plugin */ | |
/* then, integrate it with storybook's default main.js configuration */ | |
// before: | |
module.exports = { | |
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], | |
addons: ['@storybook/addon-links', '@storybook/addon-essentials'], | |
framework: '@storybook/react', |
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
-moz-appearance: none; | |
-webkit-appearance: none; | |
appearance: none; | |
background-color: #fff; | |
background-image: url('data:image/svg+xml;charset=US-ASCII,<svg%20xmlns%3D"http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg"%20width%3D"292.4"%20height%3D"292.4"><path%20fill%3D"%23000000"%20d%3D"M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z"%2F><%2Fsvg>'); | |
background-repeat: no-repeat, repeat; | |
background-position: right 0.7em top 50%, 0 0; | |
background-size: 0.65em auto, 100%; |
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
/* | |
* Complete the 'fizzBuzz' function below. | |
* | |
* The function accepts INTEGER n as parameter. | |
*/ | |
function fizzBuzz(n) { | |
for (let i = 1; i <= n; i++) { | |
// const isMultipleOfThreeAndFive = i % 3 === 0 && i % 5 === 0; | |
const isMultipleOfThreeOnly = i % 3 === 0 && i % 5 !== 0; |
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
curl -d '{"key1":"value1", "key2":"value2"}' -H "Content-Type: application/json" -X POST http://localhost:3000/data | |
source: https://gist.github.com/subfuzion/08c5d85437d5d4f00e58 |
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
function getKeysToBeRemoved(key) { | |
const hasDot = key.includes('.'); | |
if (!hasDot) { | |
return [key]; | |
} | |
const [key1, key2] = key.split('.'); | |
return [key1, key2]; | |
} | |
function removePropsFromObject(_obj, keysToRemove) { |
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
# | |
# MP: Matches Played | |
# W: Matches Won | |
# D: Matches Drawn (Tied) | |
# L: Matches Lost | |
# P: Points | |
# | |
# output expected: | |
# Team | MP | W | D | L | P | |
# Devastating Donkeys | 3 | 2 | 1 | 0 | 7 |
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 from "react"; | |
type Status = "idle" | "pending" | "resolved" | "rejected"; | |
interface RequestState<DataType> { | |
data: DataType | null; | |
status: Status; | |
error: unknown; | |
} |