Skip to content

Instantly share code, notes, and snippets.

View jordangarcia's full-sized avatar

Jordan Garcia jordangarcia

View GitHub Profile
{
"type": "doc",
"content": [
{
"type": "document",
"attrs": {
"aiOptions": { "imageOptions": {} },
"docId": null,
"background": { "type": "none" },
"docFlags": {},
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>80x80 Pixel Weight Physics Simulation</title>
<style>
body {
margin: 0;
padding: 20px;
[
[
1,
1,
1,
1,
1,
1,
1,
1,
{
"type": "doc",
"content": [
{
"type": "document",
"attrs": {
"aiOptions": {
"preserveLayouts": false,
"imageOptions": {
"stylePreset": "Custom",
class CustomPromise<R> {
private status: 'awaiting' | 'resolved' | 'rejected' = 'awaiting';
private resolvedValue: R | undefined = undefined;
private rejectedReason: unknown = undefined;
private successFns: ((val: R) => void)[] = [];
private rejectFns: ((reason: unknown) => void)[] = [];
class CustomPromise<R, R2 = unknown> {
public status: 'awaiting' | 'resolved' | 'rejected' = 'awaiting';
public resolvedValue: R | undefined = undefined;
public rejectedReason: R2 | undefined = undefined;
private successFns: ((val: R) => void)[] = [];
private rejectFns: ((reason: R2) => void)[] = [];
// Type for a value that might be a Promise
type MaybePromise<T> = T | Promise<T>;
// Async pipe with proper type inference for up to 10 functions
function asyncPipe<A, B>(
ab: (a: A) => MaybePromise<B>
): (a: A) => Promise<B>;
function asyncPipe<A, B, C>(
ab: (a: A) => MaybePromise<B>,
// Type for a value that might be a Promise
type MaybePromise<T> = T | Promise<T>;
// Async compose with proper type inference for up to 10 functions
function asyncCompose<A, B>(
ab: (a: A) => MaybePromise<B>
): (a: A) => Promise<B>;
function asyncCompose<A, B, C>(
bc: (b: B) => MaybePromise<C>,
import { S3Client, PutObjectCommand, GetObjectCommand, ListObjectsV2Command } from '@aws-sdk/client-s3';
import { createHash } from 'crypto';
// Types for our chat system
interface ChatMessage {
id: string;
timestamp: number;
role: 'user' | 'assistant';
content: string;
metadata?: Record<string, any>;