Skip to content

Instantly share code, notes, and snippets.

View markmals's full-sized avatar

Mark Malstrom markmals

View GitHub Profile
@markmals
markmals / remix-3.md
Created October 15, 2025 18:48
An overview of Remix 3

Remix v3

This project is a monorepo of experiments for the pre-alpha preview release of Remix 3. Remix 3 is not related in any way to the previous versions of Remix nor React Router; they are just created by the same team.

Eventing

Remix 3 starts from events as its first principles since events are extraordinarily fundamental to interactive user interfaces on the web. To compliment these first principles, Remix 3 includes the @remix-run/events package, which provides a type-safe abstraction on top of DOM events and event composition.

Now instead of doing this:

@markmals
markmals / Counters.tsx
Created September 3, 2025 01:51
Microstore using the same API as React's upcoming store API: https://github.com/facebook/react/pull/33215
import { createStore, useStore } from "./store";
type CountStore = { count: number; doubled: number };
const counter = createStore<CountStore, number>(
{ count: 0, doubled: 0 },
(_prev, next) => ({
count: next,
doubled: next * 2,
}),
@markmals
markmals / deno-codex-setup.sh
Created June 7, 2025 16:17
Set up Deno to work in OpenAI Codex Universal
# Deno for Codex Universal: https://github.com/openai/codex-universal
set -euo pipefail
apt-get update
update-ca-certificates
LATEST=$(curl -fsSL https://dl.deno.land/release-latest.txt)
curl -fsSL "https://dl.deno.land/release/${LATEST}/deno-x86_64-unknown-linux-gnu.zip" -o /tmp/deno.zip
mkdir -p "${HOME}/.deno/bin"
unzip /tmp/deno.zip -d "${HOME}/.deno/bin" && rm /tmp/deno.zip
echo 'export DENO_INSTALL="$HOME/.deno"' >> ~/.bashrc
echo 'export PATH="$HOME/.deno/bin:$PATH"' >> ~/.bashrc
@markmals
markmals / Counter.tsx
Created May 30, 2025 02:25
Fine(r)-grained rendering for React, backed by Solid's reactive primitives
import { createComponent, For } from "./runtime";
import { createMemo, createSignal } from "solid-js";
import { createMutable as createStore } from "solid-js/store";
export const Counter = createComponent<{ initialValue: number }>(props => {
const [counter, setCounter] = createSignal(props.initialValue);
const doubled = () => counter() * 2;
const inc = () => setCounter(c => c + 1);
return () => (
@markmals
markmals / counters.tsx
Created May 30, 2025 02:03
React hook to subscribe to a Solid signal (or reactive function) and expose its value to React components, with proper reactivity and referential stability for React's rendering model
import { createSignal } from "solid-js";
import { createStore, reconcile } from "solid-js/store";
import { useSignal } from "./use-signal";
const [count, setCount] = createSignal(0);
const doubled = () => count() * 2;
export function Counter() {
const ct = useSignal(count);
const db = useSignal(doubled);
@markmals
markmals / ServerViewsDemo.swift
Last active February 7, 2025 00:43
An exploration of "server views" (server components) in Swift with a SwiftUI-like API
import SwiftData
import SwiftUI
import Vapor
let container = try! ModelContainer(for: [Message.self, User.self])
let context = ModelContext(container)
@ClientView
struct Counter: View {
@State var count = 0
@markmals
markmals / ivi-server-components.ts
Last active February 2, 2025 17:24
Sketch of a server-first meta-framework for ivi
import { html, component, useState, getProps } from 'ivi';
import { cache, route, serverFunction, useActionState, use, Suspense } from 'ivi-router';
import { db, Messages } from 'db.server';
import { eq } from 'drizzle-orm';
// Block virtual DOM
// Compiler optimizations
// Small vendor & component bundle sizes
// Tagged template literals
@markmals
markmals / signal-helpers.ts
Last active November 8, 2024 22:10
Helper functions missing from Angular's Signal implementation
import { signal, computed } from '@angular/core'
function writable<T>(fn: () => T) {
const c = computed(() => signal(fn()))
const w = () => c()()
Object.assign(w, { set: value => c().set(value) })
return w
}
function derived<T>(value: T, fn: (previous: T) => T) {
@markmals
markmals / vanilla-rsc.tsx
Last active February 7, 2025 00:55
Playing around with ideas for a 'close to the metal' React framework
import { Suspense, useState, use, useActionState, cache, JSX, Fragment, ReactNode } from "react";
import { defineRoute, withState } from "reverb";
import { db, Messages, Users } from "./db.server";
import { eq } from "drizzle-orm";
function Counter() {
"use client";
const [count, setCount] = useState(0);
@markmals
markmals / *Pointer.swift
Last active November 12, 2024 16:44
An approximation of Rust & C++ smart pointers in Swift with non-copyable types
public protocol Pointer<Pointee>: ~Copyable {
associatedtype Pointee
var pointee: Pointee { get nonmutating set }
}
public struct UniquePointer<Pointee>: ~Copyable, Pointer {
private let memory: UnsafeMutablePointer<Pointee>
public var pointee: Pointee {
get { memory.pointee }