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 { useState, useCallback } from 'react'; | |
export const useStateRef = initialState => { | |
const [state, setState] = useState(() => ({ | |
current: typeof initialState === 'function' ? initialState() : initialState | |
})); | |
const setStateRef = useCallback( | |
(setter, forceRender) => { | |
setState(prev => { |
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
ssh-keygen -t rsa -b 4096 -m PEM -f jwtRS256.key | |
# Don't add passphrase | |
openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub | |
cat jwtRS256.key | |
cat jwtRS256.key.pub |
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
/** | |
* \xe2\x98\x89 Mercury -> ☉ Mercury | |
**/ | |
function unescapeUtf8Hex(s: string): string { | |
if (typeof s !== 'string') return s; | |
return s.replace(/(?:\\x[\da-fA-F]{2})+/g, (m) => decodeURIComponent(m.replace(/\\x/g, '%'))); | |
} | |
/** | |
* \\\\U0001F528 hello \\U0001F528 hello -> 🔨 hello 🔨 hello |