Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Typing a status

pfg pfgithub

💭
Typing a status
View GitHub Profile
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 = [];
},
@pfgithub
pfgithub / zig suggestions.md
Last active Apr 1, 2020
zig suggestions for the first day of the month
View zig suggestions.md

zig suggestions for the first day of the month

only one number type

zig is very confusing because it has so many number types. u16, i64, f32? what does all this mean‽ zig should follow the path of similar languages and simplify this down to one number type. I propose u0 because it can fill in for any other number type with a minimal loss of precision and takes less memory to store.

exceptions

instead of the confusing explicit error returns, zig should have untyped exceptions. that way, you have to be on edge every time you call a function and you have to worry if it might decide to error. it's especially nice because the errors shouldn't be mentioned in the docs. this makes programming more fun and exciting whenever you encounter a new error that you didn't know about.

View video time.js
let video = document.querySelector("video");
let frameTime = 0.01;
let timeElem = document.createElement("div");
let q = document.createTextNode("---");
timeElem.style.position = "fixed";
timeElem.style.top = "0";
timeElem.style.right = "0";
timeElem.style.padding = "10px";
timeElem.style.fontSize = "24pt";
timeElem.style.backgroundColor = "#fff";
@pfgithub
pfgithub / iroAceToMonarch.js
Last active May 16, 2019
Convert an ace syntax highlighter generated with iro to a monarch one
View iroAceToMonarch.js
let ace = {/*your syntax highlighter here*/}
let tokens = {/*your syntax highlighter tokens and values*/}
console.log(JSON.stringify((() => {
let monarchTokenizer = {}
Object.keys(acerules).forEach(key => {
let value = acerules[key];
monarchTokenizer[key] = [];
@pfgithub
pfgithub / plistthing.js
Created Oct 16, 2018
simple plist thing
View plistthing.js
var bplistCreator, bplistParser, plist;
bplistParser = require('bplist-parser');
bplistCreator = require('bplist-creator');
plist = require('plist');
// reveal the underlying modules
exports.plist = plist;
View pfgs goi mods.md

pfgs mods

You Are The Hammer:

PlayerControl Start() Bottom:

base.GetComponent<PolygonCollider2D>().isTrigger = true;
base.transform.Find("PotCollider").GetComponent<PolygonCollider2D>().isTrigger = true;