Skip to content

Instantly share code, notes, and snippets.

View malerba118's full-sized avatar

Austin Malerba malerba118

View GitHub Profile
@malerba118
malerba118 / props-tunnel.tsx
Created March 1, 2024 17:22
props-tunnel-shadcn-cva
"use client";
import * as React from "react";
import * as TabsPrimitive from "@radix-ui/react-tabs";
import { cn } from "@/lib/utils";
function createPropsTunnel<TunneledProps extends Record<string, any>>(
defaultProps: Required<TunneledProps>
) {
import { action, makeObservable, observable, runInAction } from "mobx";
export class PromiseManager<T extends (...args: any[]) => Promise<any>> {
status: "idle" | "pending" | "fulfilled" | "rejected" = "idle";
executionCount = 0;
asyncFunction: T;
constructor(asyncFunction: T) {
makeObservable(this, {
status: observable.ref,
import { observable, makeObservable, runInAction, action } from "mobx";
import { HistoryManager } from "./history";
import { v4 as uuid } from "uuid";
type Constructor<T> = {
new (...params: any[]): T;
[x: string | number | symbol]: any;
};
type BaseData = {
export interface Project {
id: string;
video: MediaReference; // hosted video
preview_video: MediaReference; // hosted video
background: MediaReference;
speakers: Speaker[];
source_blueprint: {
id: string;
utterances: SourceUtterance[]
// actions
decomposeVideo({ src: 'video-url'}): SourceBlueprint
dub({ source_transcription, target_transcription, source_audio, voice_id }): MediaReference
recomposeVideo(targetBlueprint: TargetBlueprint): MediaReference
// types
interface SourceBlueprint {
video: MediaReference // hosted video
background_audio: MediaReference
// components/Tabs.tsx
import {
Tabs as ArkTabs,
TabList as ArkTabList,
TabTrigger as ArkTabTrigger,
} from '@ark-ui/react'
const tabs = defineMultipartRecipe({
name: 'tabs',
parts: ['root', 'list', 'trigger'],
// client
signIn().then((user) => {
axios.post('/users', user, { headers: { authorization: user.accessToken } })
})
// server
server.middleware((req, res) => {
if (req.headers.authorization) {
try {
const decoded = await firebase.verifyIdToken(req.headers.authorization)
type Book = {
id: string
image: string
title: string
description: string
duration: number // (milliseconds?)
audio: string
chapters: Chapter[]
}
{
"kind": "books#volumes",
"totalItems": 3633,
"items": [
{
"kind": "books#volume",
"id": "o_dvDwAAQBAJ",
"etag": "b9ADYZl9aVQ",
"selfLink": "https://content-books.googleapis.com/books/v1/volumes/o_dvDwAAQBAJ",
"volumeInfo": {
import 'react-app-polyfill/ie11';
import * as ReactDOM from 'react-dom';
import {
theme,
ArrowLeftIcon,
ArrowRightIcon,
ArrowDiagonalIcon,
CollectionsIcon,
Dropdown,
} from '../';