Skip to content

Instantly share code, notes, and snippets.

View djanatyn's full-sized avatar

Jonathan Strickland djanatyn

View GitHub Profile
@djanatyn
djanatyn / print_binary_tree.py
Created June 7, 2022 13:00
print binary tree exploration
from typing import Optional, Any, List
from dataclasses import dataclass
@dataclass
class Node:
value: Any
left: Optional["Node"]
right: Optional["Node"]
@djanatyn
djanatyn / codegen.md
Created May 29, 2022 19:46
some thoughts on code generation for melee structs

i only have captain falcon supported (and he is unfinished):

    /// DAT files for Captain Falcon, used as replacement targets.
    #[allow(dead_code)]
    #[derive(Debug, Clone)]
    pub enum CaptainFalconFile {
        /// NTSC data & shared textures.
        PlCa,
        /// Blue costume.
        PlCaBu,
@djanatyn
djanatyn / progress.md
Created May 27, 2022 23:02
more melee hacking progress

so, i have a test that updates the filesystem table, replacing Captain Falcon's green costume with a Potemkin skin:

my test run will generate a new filesystem table, potemkin-fst.bin:

running 1 test
Replacement { target: CaptainFalcon(PlCaGr), replacement: "falcon/POTEMKIN FALCON.dat" }
[src/main.rs:226] matching.original_size - new_data_length as u32 = 123584
fst entry 0xa18: 0x551a0000 -> 0x551be2c0 [EfCoData.dat]
fst entry 0xa24: 0x4fe90000 -> 0x4feae2c0 [EfDkData.dat]
// Definition for a binary tree node.
// #[derive(Debug, PartialEq, Eq)]
// pub struct TreeNode {
// pub val: i32,
// pub left: Option<Rc<RefCell<TreeNode>>>,
// pub right: Option<Rc<RefCell<TreeNode>>>,
// }
//
// impl TreeNode {
// #[inline]
@djanatyn
djanatyn / melee-project-updates.md
Created May 21, 2022 16:43
pair programming on melee stuff

a major goal of my code is to replace files (like character textures, or stages) within the ISO, something like this:

let iso = GcmFile::open(ISO_PATH).expect("could not open ISO");     
                                                                    
let replacements = vec![                                            
    // replace common files                                         
    Replacement {                                                   
        target: Character::CaptainFalcon(CaptainFalconFile::PlCa),  
        replacement: PathBuf::from("n64-falcon/PlCa.dat"),          
    },                                                              
@djanatyn
djanatyn / hex.dump
Created May 21, 2022 15:12
don't have swing42 motion!!! (melee ISO at 0x003e2644)
0x003e2638 800c cf14 800c cf1c 800c cf0c ............
0x003e2644 646f 6e27 7420 6861 7665 2073 don't have s
0x003e2650 7769 6e67 3432 206d 6f74 696f wing42 motio
0x003e265c 6e21 2121 0a00 0000 6670 2d3e n!!!....fp->
0x003e2668 6974 656d 5f67 6f62 6a20 213d item_gobj !=
0x003e2674 204e 554c 4c00 0000 800c cff0 NULL.......
0x003e2680 800c cfe8 800c cff8 800c d018 ............t
@djanatyn
djanatyn / transformers.md
Created May 19, 2022 19:44
the resources i used to start learning about monad transformer implementation

this is where i first heard about monad transformers, reading real world haskell:

Understanding monad transformers by building one

To give ourselves some insight into how monad transformers in general work, we will create one and describe its machinery as we go. Our target is simple and useful. Surprisingly, though, it is missing from the mtl library: MaybeT.

this looks more modern and accessible to me, implementing ExceptT:

Then we’ll also have to change the name from ExceptIO to ExceptT. Why the T, you ask? Because it’s a monad transformer. Congratulations! You made it all the way. You’ve created and used your first monad transformer. That’s no small feat.

@djanatyn
djanatyn / effects.md
Last active May 19, 2022 19:41
thoughts + quotes on algebraic effects's relation to dependency injection

algebraic effect handlers make dependency injection unnecessary

so, i think i first picked up this idea reading LtuPatternFactory:

the idea of this resource is to:

  • identify design patterns (mostly from the book by the gang of four, mostly in mutation-heavy oop languages),
  • talk about the problems they attempt to solve, and to
  • show how the same problem can be solved using a functional language (like Haskell)
@djanatyn
djanatyn / compiling-c.md
Last active May 17, 2022 23:55
plan 9 install party notes

reading C Programming in Plan 9. in plan 9, you use "error strings" instead of numbers?

Immediately, expert C programmers will say things like “Where did stdio go?” and shout at the top of their lungs things like “You can’t declare main as returning void!” If you’re one of these guys, then you better get used to it.

A better idea is to give the programmer the ability to handle any error that comes in without worry of losing standards compliance or clarity, and to generate any error without falling into a surfeit of possibility. So the designers of Plan 9 decided to use strings instead of numbers. Each program has an error string which is set by routines when an error occurs. And each program returns a string to the host environment with the exits system call. The value given to exits can be accessed from rc through the environment variable $status.

i wrote a small program to explore:

#include <u.h>
#include <libc.h>
@djanatyn
djanatyn / Messages.log
Created May 17, 2022 00:06
running pdf-tools-install with no-private-headers branch: https://github.com/vedang/pdf-tools/compare/no-private-headers
Building the PDF Tools server succeeded
evil-line-move: End of buffer
Quit
pdf-info-query: epdfinfo: Unable to create temporary file
condition-case: Error in a Doom startup hook: pdf-view-mode-hook, pdf-tools-enable-minor-modes, (error "epdfinfo: Unable to create temporary file")