Skip to content

Instantly share code, notes, and snippets.

@prozacchiwawa
prozacchiwawa / main.rs
Last active February 5, 2023 05:59
Haskell inspired type based destructuring in rust
use serde_json;
pub enum And<T,U> {
These(T,U)
}
pub enum Field<T> {
Named(&'static str,T)
}
#[cfg(any(test, feature = "fuzzer"))]
use rand::prelude::*;
use rand::Error;
use random_lfsr_256_galois::{LFSRGalois, LFSRGaloisBuilder};
// A pseudo RNG which uses a slice for all entropy. It iterates a given slice
// many times, scrambling the bits through an LFSR in subsequent passes so that
// the fuzzer maintains a relationship between the original input bits and the
// output with some predictability.
@prozacchiwawa
prozacchiwawa / div2.v
Last active September 26, 2022 08:24
very crap proof that n/2 < n for n > 0
Fixpoint nat_lt (a : nat) (b : nat) : bool :=
match b with
| 0 => false
| (S b1) =>
match a with
| 0 => true
| (S a1) => nat_lt a1 b1
end
end.
@prozacchiwawa
prozacchiwawa / xtwrap.py
Last active June 5, 2022 08:55
xtwrap - wrap cool-retro-term to suit gxemul's way of calling xterm
#!/usr/bin/env python3
import os
import sys
import tty
import time
import uuid
import signal
import socket
import argparse
/* no warnings in desmet c 2.4
C> C88 FORBIDDE.C
C> BIND FORBIDDE.O
*/
#include <stdio.h>
struct X {
int typ;
int x_str;
int next;
#include <stdio.h>
#include <graph.h>
#include <math.h>
#include <float.h>
#include <dos.h>
#include <malloc.h>
int *buf;
unsigned short off;
double direction;

Keybase proof

I hereby claim:

  • I am prozacchiwawa on github.
  • I am arty (https://keybase.io/arty) on keybase.
  • I have a public key ASBOAvnkixLoUYOuqvhsBNHwYj_vltAecfEJ9JdgC7nH5Qo

To claim this, I am signing this object:

import Decidable.Equality
data RETree : (t : Type) -> Type where
End : RETree t
Item : t -> RETree t
Sequence : RETree t -> RETree t -> RETree t
OneOrTheOther : RETree t -> RETree t -> RETree t
Repeated : RETree t -> RETree t -> RETree t
simpleItemAppliesToRE : (DecEq t) => t -> t -> Bool
@prozacchiwawa
prozacchiwawa / parse_schema.py
Created November 11, 2021 02:48
very stupid sqlite schema parser
def mini_parse_schema(lines):
have_tables = {}
for line in lines:
first_paren_idx = line.index('(')
if first_paren_idx == -1:
continue
end_paren_idx = line.rindex(')')
if end_paren_idx == -1:
continue
@prozacchiwawa
prozacchiwawa / copy_wallet_blocks.py
Created November 10, 2021 04:56
chia: copy block data from one wallet to another to speed up sync
#!/usr/bin/env python
import sys
import sqlite3
COPY_BLOCKS=1000
block_records_fields = [
'header_hash',
'prev_hash',
'height',
'weight',