Skip to content

Instantly share code, notes, and snippets.

💖
GITHUB DROP ICE

Cassie Jones porglezomp

💖
GITHUB DROP ICE
Block or report user

Report or block porglezomp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@porglezomp
porglezomp / makefile
Created Jan 20, 2020
Convert the "Item Block Heights" video into a summary image
View makefile
# Convert the "Item Block Heights" video into a summary image
# Video: https://www.youtube.com/watch?v=JteRFzrF6U4
# Image: https://twitter.com/porglezomp/status/1219082110704791555
all: abcheight.png
input.mp4:
youtube-dl -f mp4 'JteRFzrF6U4' -o input.mp4
frames: input.mp4
View GroupUniqueId.idr
-- This is a group with a set g, an operation *, and an identity e
record Group g ((*) : g -> g -> g) (e : g) where
constructor MkGroup
-- each of these fields provides a witness of one of the group laws
assoc : (a, b, c : g) -> (a * b) * c = a * (b * c)
ident : (a : g) -> (a * e = a, e * a = a)
inverse : (a : g) -> (b : g ** (a * b = e, b * a = e))
-- Given two groups g1 and g2, with identities e and e', e must be e'
uniquenessOfId : (g1 : Group g o e) -> (g2 : Group g o e') -> e = e'
@porglezomp
porglezomp / rose8.rs
Last active Jan 11, 2020
Rust instructions for ROSE-8
View rose8.rs
// Thanks to Jordan Rose: https://twitter.com/UINT_MIN/status/1215832790958100480
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Op1 {
Zero,
Lsl1,
Lsr1,
Asr1,
Incr,
Decr,
@porglezomp
porglezomp / README.md
Last active Dec 25, 2019
Serializing Binary Data in Rust
View README.md

Serializing Binary Data in Rust

The way I like to serialize data in Rust into binary formats is to let a data structure blit itself into a mutable buffer. This is a relatively composable, low level way to work that lends itself to having other abstractions built on top of it. I recently was serializing network packets, so let's make up a small packet format that illustrates how we can do this.

+-------------+-------------+
|  Tag (u16)  | Count (u16) |
+-------------+-------------+
|                           |
~        Entry (u32)        ~
@porglezomp
porglezomp / conformant_json_parser.py
Created Oct 27, 2016
It's possible to have an extremely simple standard-conformant JSON parser!
View conformant_json_parser.py
# RFC 7159 § 9
# "An implementation may set limits on the size of texts that it accepts."
def parse_json(text):
if len(text) != 1:
raise ValueError("Only accepts single character JSON values")
return int(text[0])
@porglezomp
porglezomp / transforms.md
Last active Dec 3, 2019
Lets do some proofs about how transforms should behave
View transforms.md
@porglezomp
porglezomp / README.md
Last active Oct 20, 2019
Creating a Rust hello world in 0x a presses.
View README.md

This is a Rust "Hello World" program in 0x A presses.

$ vim hello.rs
$ rustc --test hello.rs
$ ./hello --quiet
Hello, World!

If you don't know, [the A Button Challenge] is a Mario 64 speedrun category in which runners attempt to use the A button (the jump button!) as few times as possible. Make sure you watch the classic [Watch for Rolling Rocks - 0.5x A Presses][A Button Challenge] video linked above in order to understand.

@porglezomp
porglezomp / chopper.sh
Last active Oct 2, 2019
A tool to chop GIFs into 25 discord emoji.
View chopper.sh
#!/bin/bash
input=$1
output=$2
prefix=$3
if [ -z "$input" -o -z "$output" ]; then
echo "Usage: $0 <input> <output> [prefix]"
exit 1
fi
@porglezomp
porglezomp / Makefile
Created Sep 23, 2019
Multiple return types
View Makefile
all: union exn variant
%: %.cpp
clang++ -Wall -Wextra -Werror -std=c++17 -O3 $< -o $@
clean:
rm -f union exn variant
@porglezomp
porglezomp / ShitLetsBeSmalltalk.swift
Last active Aug 21, 2019
Where we're going we don't need primitive control flow!
View ShitLetsBeSmalltalk.swift
/// Like a smalltalk bool, but worse. Just used for control flow, we can use real boolean ops.
class ChitChatBool {
func ifTrue<T>(block: () -> T) -> T? { return nil }
}
class True: ChitChatBool {
override func ifTrue<T>(block: () -> T) -> T? { return block() }
}
class False: ChitChatBool { }
You can’t perform that action at this time.