Skip to content

Instantly share code, notes, and snippets.

View wchargin's full-sized avatar

Willow Chargin wchargin

View GitHub Profile

Suppose you have a closed, non self-intersecting 2D curve. Split this curve into N parts, not necessarily equal but with maximum length going to zero. Find a TSP solution (shortest tour containing all the points) on the sampled set. Question: for large N, does the solution mimic the curve?

(Some parts of this are underspecified. Fill in the gaps as you like...)

Spoiler wall...

Spoiler wall...

Spoiler wall...

(() => {
function setDark(dark) {
document.documentElement.classList.toggle("dark", dark);
}
const mql = window.matchMedia("(prefers-color-scheme: dark)");
function updateDark() {
const fromLocalStorage = localStorage.getItem("theme");
if (fromLocalStorage != null) {
setDark(fromLocalStorage === "dark");
return;
@wchargin
wchargin / 1cap.html
Created June 26, 2025 02:23
demo of using "font-size: 1cap" to align icons properly
<!doctype html>
<style>
img {
height: 1em;
}
.cap {
font-size: 1cap;
}
@wchargin
wchargin / yg_edAeTruF.go
Created June 6, 2025 05:55
consts and transitivity in go
package main
import (
"fmt"
"math"
)
func main() {
f := math.SmallestNonzeroFloat64
fmt.Println(f == 5e-324)
panic: test timed out after 10m0s
running tests:
TestGORM (10m0s)
goroutine 43 [running]:
testing.(*M).startAlarm.func1()
/Users/wchargin/go/pkg/mod/golang.org/[email protected]/src/testing/testing.go:2373 +0x1dc
created by time.goFunc
/Users/wchargin/go/pkg/mod/golang.org/[email protected]/src/time/sleep.go:215 +0x44
@wchargin
wchargin / gormlock.go
Last active May 25, 2025 04:39
consistent repro for deadlock in Gorm prepared statements (repros at gorm v1.26.1)
package main
import (
"context"
"fmt"
"os"
"runtime/pprof"
"sync"
"time"
// Algebraic regular expression library.
package realg
import (
"fmt"
"regexp"
"strings"
)
type Expr struct {
@wchargin
wchargin / animate-in-lch.html
Created March 30, 2025 07:17
animate colors through a perceptual color space
<!DOCTYPE html>
<style>
@property --fac {
syntax: "<percentage>";
initial-value: 0%;
inherits: true;
}
html,
body {
height: 100%;
@wchargin
wchargin / Dockerfile
Last active February 25, 2025 16:12
protobuf.dart#952 reproducer #2
FROM dart:3.7.0-sdk
RUN apt-get update
RUN apt-get install -y protobuf-compiler libprotobuf-dev
RUN dart pub global activate protoc_plugin
@wchargin
wchargin / Dockerfile
Last active February 25, 2025 16:11
protobuf.dart#952 reproducer #1
FROM dart:3.7.0-sdk
RUN apt-get update
RUN apt-get install -y protobuf-compiler libprotobuf-dev
RUN dart pub global activate protoc_plugin