Skip to content

Instantly share code, notes, and snippets.

View rreusser's full-sized avatar
🐩
🏃

Ricky Reusser rreusser

🐩
🏃
View GitHub Profile

An experiement based on Adam Pearce's awesome block to compare using persistent regl.buffers vs. passing static data via an arrow callback each time.

Result: Passing buffers doubles the framerate!

Caveat: But for this case, it doesn't seem to matter until you get up to a ridiculous number of particles (~1M?). Things like antialiasing probably vastly outweigh the manner in which the buffer was passed. Nevertheless, it's a bit more efficient.

Reasoning: Generally speaking for dynamic regl props, buffers are more efficient than arrays because it doesn't have to check whether a buffer has changed. Since a dynamic array may have changed, it has no choice but to update the buffer data on the GPU on every frame.

dynamic-typedarray

Introduction

This module wraps typed arrays with a minimal abstraction so that you can resize and append to them without reallocating and transferring data yourself.

Example

When initializing, you may pass an Array, a typed array, a size, or a dtype string. (Adding a dtype string will cast the data if necessary.) The following are equivalent ways to initialize a double precision dynamic typed array.

@rreusser
rreusser / README.md
Last active May 12, 2022 18:45
Ricky's react template

Ricky's React Template

This gist represents my personal hello-world approach to a simple react-based demo page. It's a bit opinionated in the particular sense that I've come to mistrust a lot of third party tools since I often spend more time debugging them than trying to understand the underlying web technologies. Similarly, sooner or later when you use tools like TypeScript or JSX, there's a moment when you realize you're not actually writing JavaScript. Suddenly you can't paste code into the browser console. You can't send it to another JS environment without rewriting. You can't use that one special tool you need because it has to be fully compatible with the build pipeline which pulls in ten other tools you don't.

That's the basis for my opinions. The result is that I've strived hard to iron out an environment that's as ergonomic as create-react-app with React and JSX, but which avoids the need for any tooling or bundler.

Tools I like

  • htm: Like JSX
@rreusser
rreusser / index.html
Last active November 7, 2022 18:50
Demo
<!DOCTYPE html>
<html>
<head>
<title>Mapbox GL JS debug page</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<link rel='stylesheet' href='mapbox-gl.css' />
<link rel='stylesheet' href='https://unpkg.com/[email protected]/dist/grapick.min.css'>
<link rel='stylesheet' href='https://unpkg.com/[email protected]/spectrum.css'>

pydantic to zod

This repo demonstrates a simple pathway for going from pydantic to zod via JSON schema. To use, run:

python recipe.py > schema.json
npm run generate

The input is recipe.py containing a simple pydantic model, and the ouptut is recipe.ts, TypeScript zod schema.