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 composeDecorators = (first, ...decorators) => | |
decorators.reduce( | |
(accumulatedDecorators, nextDecorator) => storyFn => | |
accumulatedDecorators(() => nextDecorator(storyFn)), | |
first, | |
); | |
// please don't | |
const ds = (i, ...r) => r.reduce((a, d) => f => a(() => d(f)), 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
password: Yup.string() | |
.required("Password is required") | |
.min(8, "Password must be at least 8 characters long") | |
.matches(/\d/, "Password must contain a number") | |
.matches( | |
/[\W_]/, | |
"Password must contain a non-alphanumberic character", | |
), | |
// new RegExp(`^((?!${name}).)*$`); |
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 useInputValue = initialValue => { | |
const [value, setX] = React.useState(initialValue); | |
const prop = p => o => o[p]; | |
const setValue = Ramda.compose( | |
setX, | |
prop("value"), | |
prop("target"), | |
); |
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 { useCallback, useState } from "react"; | |
export default function useMutation(mutate) { | |
const [isLoading, setIsLoading] = useState(false); | |
const [data, setData] = useState(null); | |
const [error, setError] = useState(null); | |
const runMutation = useCallback( | |
(...args) => { | |
setIsLoading(true); |
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
class SetInterval extends React.Component { | |
componentDidMount() { | |
this.setNewInterval(); | |
} | |
componentDidUpdate(prevProps) { | |
if (this.props.delay !== prevProps.delay) { | |
clearInterval(this.interval); | |
this.setNewInterval(); | |
} |
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
# bash | |
eval $(/opt/homebrew/bin/brew shellenv) | |
alias bashrefresh=". ~/.bash_profile" | |
alias bashopen="open ~/.bash_profile" | |
# fnm | |
eval "$(fnm env)" | |
# mac | |
alias big-sur="xcode-select --install" |
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
// could you do something like this: | |
const actionsToTake = actions.filter(({ type }) => type.endsWith('_FAILURE')); | |
yield actionsToTake.map(action => takeEvery(action.type, genericSaga)); |
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
alias dkr-die="docker ps -a -q | xargs docker stop | xargs docker rm" |
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 cached = fn => { | |
const c = Object.create(null); | |
return a => { | |
if (a in c) return c[a]; | |
const value = fn(a); | |
c[a] = value; | |
return value; | |
}; |
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 AppContextConsumer = ({ children }) => ( | |
<PermissionContext.Consumer> | |
{permissions => ( | |
<ThemeContext.Consumer> | |
{theme => children({ permissions, theme })} | |
</ThemeContext.Consumer> | |
)} | |
</PermissionContext.Consumer> | |
); |