Skip to content

Instantly share code, notes, and snippets.

View tmcw's full-sized avatar
💭
merging your prs

Tom MacWright tmcw

💭
merging your prs
View GitHub Profile
import { Draft2019 } from "json-schema-library";
console.log(Draft2019);
@tmcw
tmcw / README.md
Last active May 28, 2024 13:49
CodeMirror extension to detect and fix missing JSX Pragma

We make JSX configuration a per-val setting by requiring a jsxPragma: https://docs.deno.com/runtime/manual/advanced/jsx_dom/jsx

But most code doesn't do that and relies on a project-wide jsx setting. So, to provide better DX for missing JSX pragmas, we use this CodeMirror extension that detects the lack of a pragma and the presence of JSX syntax, by using CodeMirror's existing syntax tree.

There are two options for the Placemark Globe dataset:

Visionscarto

This is "Visionscarto’s “World Atlas”, which is very well-described by the linked document. It's based on Natural Earth but includes some changes:

  • Western Sahara as the UN point of view
  • Crimea as part of Ukraine
  • Increased width of Gaza strip to avoid it being removed by simplification

These are the two main commits used to transition part of Placemark to Deck.gl. It may make sense to reverse these: Deck caused some bugs, and while the performance was a little better, there was no way to transition fully.

import {
encodeBase64,
decodeBase64,
} from "https://deno.land/std@0.210.0/encoding/base64.ts";
import process from "node:process";
import SuperJSON from "npm:superjson@2.1.0";
SuperJSON.registerCustom<Function, string>(
{
isApplicable: (v: any): v is Function => typeof v === "function",
export default 42;
@tmcw
tmcw / README.md
Created December 28, 2022 17:00
PMTiles to SVG

Request a single tile from PMTiles, use the vector-tiles module to read it, the d3-geo tools to turn it into a string. d3-geo is probably unnecessary.

This approach feels limited:

Requires restitching tiles if more than one. Limited attributes. Any tile-based solution is going to make compromises in favor of responsiveness and lightweight data. What this wants is completeness and non-sliced data.

import { Context } from "https://edge.netlify.com/";
const DOMAIN = "macwright.com";
const USERS = new Map([
[
`acct:photos@macwright.com`,
{
subject: `acct:photos@${DOMAIN}`,
aliases: [],
import { Portal } from "@radix-ui/react-portal";
import clsx from "clsx";
import { useAtom } from "jotai";
import { atomWithMachine } from "jotai/xstate";
import { useRouter } from "next/router";
import { useEffect } from "react";
import { assign, createMachine } from "xstate";
import clamp from "lodash/clamp";
export function useMapKeybindings() {
const rep = usePersistence();
const historyControl = rep.useHistoryControl();
const transact = rep.useTransact();
useHotkeys(
"Command+z, Ctrl+z",
(e) => {
e.preventDefault();
historyControl("undo");