Skip to content

Instantly share code, notes, and snippets.

@JohnGemstone
JohnGemstone / ImageInput.tsx
Last active June 6, 2026 21:17
Patch that adds multi-select support to `sanity-plugin-media` for image array fields.
import {useState} from 'react'
import {PatchEvent, insert, setIfMissing, type ArrayOfObjectsInputProps} from 'sanity'
import {mediaAssetSource} from 'sanity-plugin-media'
const MediaAssetSource = mediaAssetSource.component
export function ImagesInput(props: ArrayOfObjectsInputProps) {
const [open, setOpen] = useState(false)
const imageSchemaType = props.schemaType.of[0]
@JohnGemstone
JohnGemstone / ae-trolly-loop.tsx
Created November 7, 2025 03:07
AfterEffects trolly loop for accumulating values over each iteration
loopDur = key(numKeys).time - key(1).time;
// only run while this layer is active
if (time < inPoint) {
// before layer starts → hold first keyframe
key(1).value;
} else if (time > outPoint) {
// after layer ends → hold the final accumulated value at outPoint
tEnd = outPoint - key(1).time;
loopCountEnd = Math.floor(tEnd / loopDur);
@JohnGemstone
JohnGemstone / disconnectStyles.jsx
Created October 12, 2025 21:08
Indesign extendscript for making selected paragraph styles unique
// disconnectStyles.jsx
//
// Generated with Gemini 2.5 Pro
//
// DESCRIPTION:
// This script finds all paragraphs in the user's selection.
// For each unique paragraph style applied to those paragraphs, it creates a new,
// duplicated style with a "_new" suffix. It then applies these new styles
// to the corresponding paragraphs, effectively "disconnecting" them from their
// original styles.