This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{ | |
env, | |
error::Error, | |
fs::File, | |
process::ExitCode, | |
}; | |
use plotters::prelude::*; | |
use petra_grid::{Grid, GridData}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load petra_grid; | |
%% | |
%entry | |
%name header | |
%type Header | |
%offset 0x0#B | |
%entry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[inline] | |
fn pop_char(s: &str) -> Option<(char, &str)> { | |
let mut chars = s.chars(); | |
chars.next().map(|c| (c, chars.as_str())) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function push(q, val) { | |
if (empty(q)) { | |
q["head"] = 0 | |
q["tail"] = 0 | |
q[0] = val | |
} else { | |
q[q["tail"] + 1] = val | |
q["tail"] = q["tail"] + 1 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Language path: Haskell->Ocaml->Python, mypy typesystem [semantic loss ~31%] | |
# Subject: Zippers as the key insight | |
# what great fun! since mypy ~0.991 (?) we can finally, finally work with | |
# recursive types. this opens up Python to some traditional functional | |
# programming practices with a minimum of bullshit. | |
from typing import NamedTuple, TypeAlias | |
# let's walk amongst the trees for a bit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds, GADTs, KindSignatures, TypeOperators #-} | |
{-# LANGUAGE TypeFamilies #-} | |
module Data.HList | |
( HList(..) | |
, TypeMap | |
) where | |
import Data.Kind (Type) | |
import Data.Maybe (fromJust, fromMaybe) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
base26 :: Integer -> String | |
base26 n = | |
let (m, n') = n `divMod` 26 | |
ones = [toEnum (fromEnum 'A' + fromInteger n')] | |
in case m of | |
0 -> ones | |
m -> base26 (m - 1) ++ ones |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* a deque (double-ended queue) | |
* implemented as a mutable, generic, doubly-linked list in Java | |
* | |
* what do we mean by this? | |
* deque: a Double-Ended QUEue. a data structure supporting fast insertion or | |
* removal at either end, used in various algorithms and data-sharing | |
* techniques. | |
* | |
* mutable: the structure contains state which may be altered by various | |
* mutating operations. for example, when we enqueue an element at the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
So You've Inherited a VB6/VBA Project! | |
Congratulations! You've inherited a large, complex, Visual Basic 6 or VBA | |
project written by another programmer. In terms of transmissible conditions... | |
well, at least it's not AIDS. | |
[Sidebar: why "Visual Basic 6 or VBA"? Well, in 2000-something, Microsoft | |
introduced the .NET platform. This is a managed runtime in the vein of the | |
Java virtual machine, and one of its selling points was the ability to | |
compile multiple source languages to .NET assemblies. Visual Basic was chosen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stddef.h> | |
#include <stdlib.h> | |
typedef struct node { | |
int value; | |
struct node *next; | |
} node, *list; | |
void list_free(list l) |