Skip to content

Instantly share code, notes, and snippets.

View CGamesPlay's full-sized avatar
:bowtie:

Ryan Patterson CGamesPlay

:bowtie:
View GitHub Profile
@CGamesPlay
CGamesPlay / cva.tsx
Last active August 22, 2024 17:10
CVA prop splitting
import { cva } from "cva";
export * from "cva";
type Base = Parameters<typeof cva<unknown>>[0];
type Config<T> = Parameters<typeof cva<T>>[1];
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
type Props<T> = Simplify<
Omit<
Exclude<Parameters<ReturnType<typeof cva<T>>>[0], undefined>,
@CGamesPlay
CGamesPlay / dynamicComponent.test.tsx
Last active August 22, 2024 14:22
Component factory that enables "as" props.
import * as React from "react";
import { expect, test } from "vitest";
import { makeDynamicComponent } from "./dynamicComponent";
type NoProps = object;
const ComponentA1 = (_: { req: "a"; opt?: "a" }) => null;
const ComponentA2 = (_: { req: "a"; opt?: "a" }) => null;
const ComponentB = (_: { req: "b"; opt?: "a" }) => null;
const ComponentC = (_: { opt?: "a" }) => null;
@CGamesPlay
CGamesPlay / import.py
Created December 14, 2024 00:58
Migrate Obsidian (or markdown directory) to Anytype markdown import
#!/usr/bin/env python3
# /// script
# dependencies = [
# "mistune==3.0.2",
# ]
# ///
import os
import sys
import hashlib