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
declare module 'lucide-react' { | |
export * from 'lucide-react/dist/lucide-react.suffixed' | |
} |
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
// Types for the result object with discriminated union | |
type Success<T> = { | |
data: T; | |
error: null; | |
}; | |
type Failure<E> = { | |
data: null; | |
error: E; | |
}; |
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
useEffect(() => { | |
let previousUrl = '' | |
const observer = new MutationObserver((mutations) => { | |
if (window.location.href !== previousUrl) { | |
previousUrl = window.location.href | |
console.log( | |
`URL changed from ${previousUrl} to ${window.location.href}`, | |
) | |
} | |
}) |
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
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks. | |
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/) | |
(() => { | |
const SHOW_SIDES = false; // color sides of DOM nodes? | |
const COLOR_SURFACE = true; // color tops of DOM nodes? | |
const COLOR_RANDOM = false; // randomise color? | |
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com) | |
const MAX_ROTATION = 180; // set to 360 to rotate all the way round | |
const THICKNESS = 20; // thickness of layers | |
const DISTANCE = 10000; // ¯\\_(ツ)_/¯ |
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 As<P = any> = React.ElementType<P>; | |
type PropsOf<C extends As> = React.ComponentProps<C>; | |
type RightJoin<C extends {}, P extends {}> = Omit<C, keyof P> & P; | |
type Props<C> = C extends ForwardRefComponent<any, infer P> ? P : {}; | |
type IntrinsicElement<C> = C extends ForwardRefComponent<infer I, any> | |
? I |
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
declare type As<P = any> = React.ElementType<P>; | |
declare type PropsOf<C extends As> = React.ComponentProps<C>; | |
declare type RightJoin<C extends {}, P extends {}> = Omit<C, keyof P> & P; | |
declare type Props<C> = C extends ForwardRefComponent<any, infer P> ? P : {}; | |
declare type IntrinsicElement<C> = C extends ForwardRefComponent<infer I, any> | |
? I | |
: never; |
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 getTheValueForKey = <TObj extends Record<string, unknown>, TKey extends keyof TObj>( | |
obj: TObj, | |
objKey: TKey | |
) => { | |
return obj[objKey] | |
} | |
const keyForFirst = getTheValueForKey({ | |
a: 1, | |
b: '2', |
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
{ | |
"editor.acceptSuggestionOnCommitCharacter": false, | |
"editor.accessibilitySupport": "off", | |
"editor.cursorBlinking": "smooth", | |
"editor.cursorSmoothCaretAnimation": "on", | |
"editor.codeActionsOnSave": { | |
"source.fixAll.eslint": "explicit", | |
"source.addMissingImports": "explicit", | |
"source.organizeImports": "explicit" | |
}, |
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 { FlatList, Text, View } from "react-native"; | |
const listOne = [ | |
{ | |
id: 1, | |
name: "John", | |
}, | |
]; | |
const listTwo = [ |
NewerOlder