Skip to content

Instantly share code, notes, and snippets.

View pfgithub's full-sized avatar
💭
Typing a status

pfg pfgithub

💭
Typing a status
View GitHub Profile
@pfgithub
pfgithub / zigmirrors.md
Created February 28, 2026 23:43
Support providing a mirror for a tree of packages without changing the hashes of the packages

I migrated all my packages from downloading off random github URLs to downloading off my server (commit)

  • Because github will throttle downloads of random archive files, causing intermittent CI failures
  • To speed up downloading packages, because some dependencies use the slower git+ URLs rather than archive .tar.gz URLs for their dependencies
  • To ensure building continues to work in the future even if some dependency authors delete their repositories, i.e. to prevent a left-pad incident

Unfortunately, this required updating the hashes of many packages even though their source code is identical. This is because some packages have dependencies that need their URLs updated to use the mirror.

Consider the dependency tree:

  • myapp
new Array(1000).fill(0).map(q => "╱╲"[Math.random() * 2 |0]).join("")
╲╲╱╱╱╱╱╱╲╱╲╲╱╲╱╲╲╲╱╲╲╲╲╲╲╱╲╱╱╱╱╲╲╲╱╱╲╱╱╱╱╱╲╱╲╲╱╱╱╱╱╲╲╱╱
╲╲╲╲╱╲╱╱╱╲╱╱╲╲╱╱╲╱╲╱╲╲╱╱╲╲╱╲╲╲╱╲╲╱╱╲╲╱╲╱╱╱╲╲╱╱╱╲╱╱╱╱╱╱╲
╲╱╱╲╲╱╲╲╲╱╱╱╱╱╲╲╲╲╲╲╲╱╱╲╲╲╲╲╲╲╱╱╱╱╲╱╱╲╱╱╱╱╱╲╲╲╲╲╲╱╱╱╲╲╱
╱╲╲╲╱╲╲╱╲╱╲╲╱╱╲╲╲╱╱╲╱╲╱╱╱╲╲╱╲╲╲╱╲╱╲╲╱╲╲╱╲╲╲╱╱╱╲╱╲╲╱╱╱╱╱
╱╲╲╲╲╱╱╱╱╲╲╱╱╱╱╲╱╱╲╱╱╱╱╱╲╱╱╲╱╱╱╲╱╱╲╲╲╲╱╲╲╱╲╲╱╱╲╲╱╱╲╱╲╱╲
╲╲╱╱╲╲╲╱╲╲╲╲╱╲╲╱╲╲╱╱╲╲╲╱╱╲╱╱╱╲╱╱╲╱╱╱╱╲╲╱╲╱╲╲╲╱╱╲╱╱╲╲╱╱╲
╱╲╲╲╲╱╱╱╲╲╱╲╲╱╲╱╱╲╲╱╱╱╲╱╲╲╲╲╱╲╲╱╱╲╱╱╱╱╱╲╱╲╲╱╱╱╲╱╱╲╱╱╱╱╲
╲╱╲╲╱╲╲╲╱╱╲╱╲╲╱╱╲╱╲╱╲╲╱╲╲╲╲╱╲╲╱╱╱╱╱╲╱╱╱╲╱╱╱╲╲╱╲╱╲╱╱╲╱╱╲
╲╱╱╲╱╲╱╱╱╲╲╱╱╱╱╲╲╱╲╲╲╲╱╱╱╱╱╲╲╲╲╲╱╱╱╲╲╱╱╲╱╲╲╲╱╲╲╲╲╲╱╱╲╱╲
# GraphemeBreakTest-16.0.0.txt
# Date: 2024-05-02, 15:02:48 GMT
# © 2024 Unicode®, Inc.
# Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
# For terms of use and license, see https://www.unicode.org/terms_of_use.html
#
# Unicode Character Database
# For documentation, see https://www.unicode.org/reports/tr44/
#
# Default Grapheme_Cluster_Break Test
@pfgithub
pfgithub / CanvasPanZoom.tsx
Created August 16, 2023 00:28
canvas pan & zoom
import { Accessor, createEffect, createRoot, JSX, onCleanup, untrack } from "solid-js";
import { vec2, Vec2 } from "../util/vec2";
// polyfill roundRect, does not support radius arrays
CanvasRenderingContext2D.prototype.roundRect ??= function (this: CanvasRenderingContext2D, x: number, y: number, width: number, height: number, radius: number) {
if (width < 2 * radius) radius = width / 2;
if (height < 2 * radius) radius = height / 2;
this.beginPath();
this.moveTo(x + radius, y);
this.arcTo(x + width, y, x + width, y + height, radius);
@pfgithub
pfgithub / ios_html_reader.html
Created August 17, 2022 18:20
read html books on ios
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Reader</title>
<meta name="application-name" content="Reader" />
<meta name="apple-mobile-web-app-title" content="Reader" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
@pfgithub
pfgithub / Key.ts
Created February 10, 2022 00:36
solid js keyed for loop
import {
createRoot,
createSignal,
createMemo,
onCleanup,
untrack,
JSX,
Accessor
} from "solid-js";

nearest neighbor:
image

default opengl linear:
image

fancyupscale.glsl:
image

top to bottom: fancyscale, linear, nearest neighbor:

@pfgithub
pfgithub / CALLOC.md
Last active June 3, 2025 23:11
wrapper to use a zig allocator in c code

usage

export allocation functinos from zig

comptime {
    @import("calloc").wrapAllocator(struct {
        pub fn getAllocator() std.mem.Allocator {
            return …;
 }
@pfgithub
pfgithub / vimtext.js
Created November 20, 2021 04:37
\///\/\ /\//\\/\//\ /\\/\//\\ \\// /// //\/\\
{
// /\ / \ \/\ /\/\ /\/ \/ \/\/
//
// / i, /\ a, /\/ n, /\/\ m
// \ i, \/ v, \/\ h, \/\/ w
const swslash = {
a: "/\\", i: "/", m: "/\\/\\", n: "/\\/",
};
const swback = {
i: "\\", h: "\\/\\", v: "\\/", w: "\\/\\/",
{
if(window.__vvviewer) window.__vvviewer.remove();
window.__vvviewer = document.createElement("div");
__vvviewer.setAttribute("style", "position:fixed;left:0;right:0;width:100%;background-color:red;height:4px;z-index:1000000");
document.body.appendChild(__vvviewer);
function update() {
__vvviewer.style.top = visualViewport.offsetTop + "px";