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 / 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 / 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 / decorator.py
Last active July 17, 2024 07:25
Fully-typed Python decorator for functions, methods, staticmethods, and classmethods.
"""
Showcase a fully-typed decorator that can be applied to functions, methods,
staticmethods, and classmethods.
This example has some limitations due to the limited expressiveness of the
Python type system:
1. When applying the decorator to a function whose first argument is an
optional type object, the returned function's first argument is shown as
required.
@CGamesPlay
CGamesPlay / bench.py
Created July 1, 2024 02:17
MappingProxyType performance
import timeit
import types
def create_benchmark(test_dict):
def benchmark():
for key in range(100):
if key in test_dict:
value = test_dict[key]
return benchmark
@CGamesPlay
CGamesPlay / ARCHITECTURE.md
Created April 4, 2024 10:31
Plandex LLM Usage

Based on analyzing the code, here is a high-level overview of the main prompts used in this project and how they fit into the overall flow:

The core prompts are defined in the model/prompts package:

  1. SysCreate (create.go) - This is the main system prompt that defines the AI's identity as Plandex, an AI programming assistant. It provides detailed instructions on how to collaboratively create a 'plan' with the user to complete a programming task. The prompt covers things like assessing if there is a clear task, breaking down large tasks into subtasks, generating code blocks, using open source libraries, and ending responses.

  2. ListReplacementsFn (build.go) - Used when building code files from a plan. It analyzes proposed code updates and produces a structured list of changes to make.

  3. SysDescribe (describe.go) - Used to generate a commit message summarizing the changes made in a plan.

@CGamesPlay
CGamesPlay / AHRS.ipynb
Last active February 6, 2024 23:34
AHRS
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@CGamesPlay
CGamesPlay / user-script.js
Created October 4, 2023 22:58
Convert em media queries to px
// ==UserScript==
// @name px-media-queries
// @description Convert all media queries to use px instead of em.
// @match *://*/*
// @exclude https://github.com/*
// @exclude https://developer.mozilla.org/*
// @exclude http://localhost:*/*
// ==/UserScript==
// Breaks Dark mode on Github for some reason.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import { Methods, Context } from "./.hathora/methods";
import { Response } from "../api/base";
import {
UserId,
PlayerState,
IJoinGameRequest,
IChooseGestureRequest,
INextRoundRequest,
Gesture,
} from "../api/types";
import { z, UserId, Response, Engine } from "./util";
const Gesture = z.enum(["ROCK", "PAPER", "SCISSORS"]);
type Gesture = z.infer<typeof Gesture>;
const PlayerInfo = z.object({
id: UserId,
score: z.number(),
gesture: Gesture.nullable(),
});
const PlayerState = z.object({