Skip to content

Instantly share code, notes, and snippets.

View jcayzac's full-sized avatar

Julien Cayzac jcayzac

View GitHub Profile
@jcayzac
jcayzac / specdiff.py
Last active July 3, 2026 09:13
Render a Bikeshed spec, diff it against a git baseline, and serve the result.
#!/usr/bin/env -S uv run --script
# SPDX-License-Identifier: MIT AND Apache-2.0
#
# Copyright (c) 2026 Julien Cayzac
#
# ─ MIT License ────────────────────────────────────────────────────────────────
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
@jcayzac
jcayzac / vivid-black.json
Created June 29, 2026 07:51
Vivid Black theme for Zed
{
"$schema": "https://zed.dev/schema/themes/v0.2.0.json",
"name": "Vivid Black",
"author": "Julien Cayzac",
"themes": [
{
"name": "Vivid-black",
"appearance": "dark",
"style": {
"background.appearance": "opaque",
@jcayzac
jcayzac / big-ass-svg.astro
Last active February 7, 2026 01:57
Swap inline SVG contents in/out automatically when they enter/leave the viewport
---
/**
* @file Custom element that wraps an inline SVG and swaps its content in or
* out as the element enters or leaves the viewport, thus keeping the
* DOM lean even when a lot of big-ass SVGs are used on a single page
* (article lists with SVG heroes, for instance).
*/
import type { ImageMetadata } from 'astro'
import { getImage } from 'astro:assets'
import { experimental_AstroContainer as Container } from 'astro/container'

Setting up Miniconda with Conda Forge to avoid licensing issues

brew install miniconda
conda config --remove channels defaults
conda config --add channels conda-forge
conda config --set channel_priority strict

Before changing the config, these are the default channels:

@jcayzac
jcayzac / getTypeName.ts
Last active November 7, 2025 02:32
Get the type name of anything
function getTypeName(x: unknown): string {
return x === undefined ? 'Undefined' : x === null ? 'Null' : /^(?:class|function) (\w+)/.exec(x.constructor.toString())![1]
}
// Better? function Foo yields 'Function', class Foo yields 'Foo'
function getTypeName(x: unknown): string {
return (
x === undefined ? 'Undefined' :
x === null ? 'Null' :
/^(?:class) (\w+)/.exec(x.toString())?.[1] ??
@jcayzac
jcayzac / cloudflare-pages-commands.txt
Created September 25, 2024 23:46
Cloudflare Pages' PATH listing
/bin/[
/bin/aa-enabled
/bin/aa-exec
/bin/aa-features-abi
/bin/aclocal
/bin/aclocal-1.16
/bin/addpart
/bin/addr2line
/bin/apt
/bin/apt-cache
@jcayzac
jcayzac / frontend design decisions.md
Last active September 19, 2024 08:49
A record of decisions for frontend design

Frontend Design Decisions

# Colors

§ Specify colors in OKLCH

This lets us choose from a wider gamut of colors than sRGB, and for instance pick P3 colors.


@jcayzac
jcayzac / git-sync
Last active August 23, 2024 04:54
Git subcommand for sync'ing a working copy's branches and tags
#!/usr/bin/env bash
set -eu -o pipefail
echo "Pruning local tracking branches that don't exist anymore on the remote…"
git update
echo "Pruning local branches that have been merged…"
echo "Note: top-level branches are considered protected, only branches with a / in their name will be deleted."
git branch --format '%(refname:lstrip=2)' --merged | grep '/' || true | xargs -n 1 git branch -d
@jcayzac
jcayzac / python.ts
Last active December 4, 2023 09:43
Running Python code from Deno (no python installed).
Object.defineProperty(self, 'document', { value: {}, })
self.location = new URL('file:///nowhere')
import 'https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.asm.js'
const { loadPyodide } = await import('https://cdn.jsdelivr.net/pyodide/v0.24.1/full/pyodide.mjs')
const pyodide = await loadPyodide()
await pyodide.loadPackage('micropip')
const micropip = pyodide.pyimport('micropip')
await Promise.all([
@jcayzac
jcayzac / sleep.ts
Created November 24, 2022 06:56
The ultimate sleep() method for Typescript
export type SleepOptions = {
signal?: AbortSignal
/** If set, aborting will not fail the promise but instead fulfil it right away. */
skipOnAbort?: true
}
export const sleep = (ms: number, options?: SleepOptions) =>
new Promise<void>((ok, ng) => {
// deno-lint-ignore prefer-const