Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Typing a status

pfg pfgithub

💭
Typing a status
View GitHub Profile
@pfgithub
pfgithub / Key.ts
Created Feb 10, 2022
solid js keyed for loop
View Key.ts
import {
createRoot,
createSignal,
createMemo,
onCleanup,
untrack,
JSX,
Accessor
} from "solid-js";
View README.md

nearest neighbor:
image

default opengl linear:
image

fancyupscale.glsl:
image

top to bottom: fancyscale, linear, nearest neighbor:

@pfgithub
pfgithub / CALLOC.md
Last active Dec 16, 2021
wrapper to use a zig allocator in c code
View CALLOC.md

usage

export allocation functinos from zig

comptime {
    @import("calloc").wrapAllocator(struct {
        pub fn getAllocator() std.mem.Allocator {
            return …;
 }
@pfgithub
pfgithub / vimtext.js
Created Nov 20, 2021
\///\/\ /\//\\/\//\ /\\/\//\\ \\// /// //\/\\
View vimtext.js
{
// /\ / \ \/\ /\/\ /\/ \/ \/\/
//
// / i, /\ a, /\/ n, /\/\ m
// \ i, \/ v, \/\ h, \/\/ w
const swslash = {
a: "/\\", i: "/", m: "/\\/\\", n: "/\\/",
};
const swback = {
i: "\\", h: "\\/\\", v: "\\/", w: "\\/\\/",
View gist:11c8a43daa8a6964ac256b39c607b156
{
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";
View build.zig.md

(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 Sep 30, 2020
download the latest zig (fish script oops) (requires: `fish`, `jq`, `curl`, `tar`)
View getlatest.sh
#!/usr/bin/env fish
function start_of_line
echo -ne "\r"(tput el)
end
function fail_error
echo
echo (set_color red)$argv
exit
View discord-font-switcher.js
{
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;
@pfgithub
pfgithub / haveibeenpwned_password.fish
Created Aug 10, 2020
check if a password has been pwned on haveibeenpwned
View haveibeenpwned_password.fish
#!/usr/bin/env fish
set password (read -s)
set sha1hash (echo -n $password | sha1sum)
set firstfiv (string sub -s 1 -l 5 $sha1hash)
set lastpart (string sub -s 6 -l 35 $sha1hash)
curl -s https://api.pwnedpasswords.com/range/$firstfiv | grep -i "^"$lastpart":"
View yy.js
{
function makeBoard(fill) {
// it would be useful if board could center at 0,0 and expand infinitely
let board = [];
let limits;
let reso = {
clear: () => {
board = [];
},