Skip to content

Instantly share code, notes, and snippets.

View leifarriens's full-sized avatar
🛠️

Leif Arriens leifarriens

🛠️
View GitHub Profile
@ciiqr
ciiqr / zod-optional-null.ts
Last active June 11, 2025 12:19
zod optional/nullable/nullish differences
// zod schema
z.object({
// valid if string or:
optional: z.string().optional(), // field not provided, or explicitly `undefined`
nullable: z.string().nullable(), // field explicitly `null`
nullish: z.string().nullish(), // field not provided, explicitly `null`, or explicitly `undefined`
});
// type
{
@coleturner
coleturner / framer-motion-use-viewport-scroll-with-element-container.md
Last active November 6, 2024 09:03
(Framer Motion): useViewportScroll with element container

Demo

Context

useViewportScroll is a great way to create a parallax effect as the page scrolls. In some cases however, we only want to scroll when an element is in the viewport area.

So for example, if we have a "landscape" scene, and want to animate the Sun object only when it's in view, we start with our useViewportScroll implementation:

function Sun(props) {
 const { scrollY, scrollYProgress } = useViewportScroll();

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: