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 / 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 November 20, 2022 17:44
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";
@pfgithub
pfgithub / build.zig.md
Last active January 15, 2021 17:41
build.zig

(written on zig version 0.7.1+d96f5b38a)

Basics

zig build <step> runs a specified step from the build.zig file. build.zig is a file written in zig that describes all the available things that can be built

An empty build file:

const std = @import("std");
@pfgithub
pfgithub / getlatest.sh
Last active September 30, 2020 19:53
download the latest zig (fish script oops) (requires: `fish`, `jq`, `curl`, `tar`)
#!/usr/bin/env fish
function start_of_line
echo -ne "\r"(tput el)
end
function fail_error
echo
echo (set_color red)$argv
exit
@pfgithub
pfgithub / discord-font-switcher.js
Created September 15, 2020 01:00
discord font switcher
{
window.buttonarea && window.buttonarea.remove();
const buttonarea = document.createElement("div");
window.buttonarea = buttonarea;
const ttl = document.querySelector("#app-mount > div.app-1q1i1E > div > div.layers-3iHuyZ.layers-3q14ss > div > div > nav > div.scroller-2TZvBN.none-2Eo-qx.scrollerBase-289Jih > div:nth-child(2)");
if(!ttl) alert("Uh oh! discord class hashes or app layout changed!");
ttl.appendChild(buttonarea);
const mkbtn = (txt, ffmly, onev) => {
const btn = document.createElement("button");
btn.textContent = txt;