Skip to content

Instantly share code, notes, and snippets.

View SeedyROM's full-sized avatar
🌚
Programming!

Zack Kollar SeedyROM

🌚
Programming!
View GitHub Profile
@SeedyROM
SeedyROM / macros.rs
Last active May 27, 2025 05:11
Async callback macro helper for `yew`
#[macro_export]
macro_rules! async_callback {
// Version without event parameter
([$($var:ident),* $(,)?] $body:expr) => {
{
$(let $var = $var.clone();)*
Callback::from(move |_| {
$(let $var = $var.clone();)*
wasm_bindgen_futures::spawn_local(async move {
$body
@SeedyROM
SeedyROM / copy_from_git.sh
Created May 9, 2025 05:18
Copy all tracked files (excluding binary and images) from git
#!/bin/bash
# Get all tracked files in git
files=$(git ls-files)
# Create a temporary file to store the output
temp_file=$(mktemp)
# Process each file
for file in $files; do
@SeedyROM
SeedyROM / main.c
Last active January 18, 2025 09:42
Psychotically Optimized C Game Code
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
typedef uint32_t u32;
typedef uint8_t u8;
@SeedyROM
SeedyROM / main.cpp
Created January 29, 2024 04:55
`std::variant` polymorphism example
#include <string>
#include <iostream>
#include <variant>
#include <vector>
struct Vector2 {
float x, y;
};
struct Player {
@SeedyROM
SeedyROM / example.rs
Created January 13, 2023 06:38
Type Erased Blanket Assiocated Types
trait A {}
trait B {
type X: A;
fn test(&self) -> &Self::X;
}
trait C {
fn test(&self) -> &dyn A;
}
impl A for i32 {}
@SeedyROM
SeedyROM / stringifed_any.rs
Last active March 19, 2022 09:37
Rust Envy nested serialization help
//
// Source from: https://github.com/softprops/envy/issues/26#issuecomment-822728576
//
use std::{
fmt::{self, Display},
marker::PhantomData,
str::FromStr,
};
@SeedyROM
SeedyROM / Lib.hs
Created March 11, 2022 23:32
WebSocket Pipes
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Lib where
import Control.Concurrent (forkIO)
import Control.Monad (Monad, forever, unless)
import Control.Monad.Trans (liftIO)
import Data.Aeson (FromJSON (parseJSON), KeyValue ((.=)), ToJSON (toJSON), decode, object, withObject, (.:))
@SeedyROM
SeedyROM / Cargo.toml
Created February 14, 2022 10:23
Rust Setup
[package]
name = "my-package"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
color-eyre = "0.6.0"
tracing = "0.1.30"
@SeedyROM
SeedyROM / test.c
Last active December 20, 2021 06:42
Idempotent ASCII Lowercase/Uppercase char with C
#include <assert.h>
int main(int argc, char *argv[])
{
unsigned char cu = 'X';
unsigned char cl = 'x';
// Idempotent lowercase
assert(cl == (cu | 0x20));
assert(cl == (cl | 0x20));
@SeedyROM
SeedyROM / Makefile
Last active December 17, 2021 04:58
C Makefile Template (OOS Build)
TARGET_EXEC ?= a.out
# Where to build our resources
BUILD_DIR ?= ./build
# Where our code lives
SRC_DIRS ?= ./src
# Makefile magic to build object files and deps for our sources
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)