Skip to content

Instantly share code, notes, and snippets.

View freeitas's full-sized avatar
🏴

Guilherme Freitas freeitas

🏴
View GitHub Profile
export const chaosTestStrings = (): void => {
const textNodes = getAllTextNodes(document.body);
for (const node of textNodes) {
const textNodeLength = node.textContent ? node.textContent.length : 0;
if (node.textContent === null) {
return;
}
if (node.parentElement instanceof Element) {
if (node.parentElement.dataset.originalText === undefined) {
@sibelius
sibelius / floatToCents.ts
Created September 29, 2021 16:32
convert a float to cents
export const floatToCents = (value: number): number => {
return parseInt((value * 100).toFixed(2), 10);
}
@sibelius
sibelius / motivation.md
Last active December 26, 2022 07:05
usePermission react hook to handle frontend authorization concerns

why is this a React hook?

this is a simplified version of the production/real world version

You can consume roles from context/redux/relay or other place to improve dx and void bugs