Skip to content

Instantly share code, notes, and snippets.

View matthewjberger's full-sized avatar
🦀
Writing something in Rust, probably

Matthew J. Berger matthewjberger

🦀
Writing something in Rust, probably
  • Hyphen
View GitHub Profile
{
"version": "1.10",
"description": "A community-lead fork of the much-loved minimalist roguelike game, Brogue",
"homepage": "https://github.com/tmewett/BrogueCE",
"license": "AGPL-3.0",
"pre_install": "if (!(Test-Path \"$persist_dir\")) { New-Item -Path \"$persist_dir\" -ItemType Directory | Out-Null }",
"architecture": {
"64bit": {
"url": "https://github.com/tmewett/BrogueCE/releases/download/v1.10/BrogueCE-1.10-windows-x86_64.zip",
"hash": "f8a3f1e9eb8dd8fef2a7543e38d6f2edfafc65f5bd295008a4677e413b382235"
@matthewjberger
matthewjberger / Cargo.toml
Last active June 11, 2025 16:16
rerun custom (remember to run cargo update chrono --precise 0.4.39)
[package]
name = "scout"
version = "0.1.0"
edition = "2024"
[dependencies]
mimalloc = "0.1.43"
re_crash_handler = { version = "0.22.1", features = ["analytics"] }
re_grpc_server = "0.22.1"
re_sdk_comms = { version = "0.22.1", features = ["server"] }
@matthewjberger
matthewjberger / gist:006749edc7bec1f7948d44d496e0959a
Last active December 27, 2024 15:49
needed to build rust openssl on windows
vcpkg integrate install
vcpkg.exe install openssl:x64-windows-static-md
@matthewjberger
matthewjberger / downcast.rs
Created December 18, 2024 00:39
Rust downcasting
use std::any::Any;
fn main() {
// Create boxes containing different types, boxed as Any
let integer_box: Box<dyn Any> = Box::new(42);
let string_box: Box<dyn Any> = Box::new(String::from("Hello"));
let float_box: Box<dyn Any> = Box::new(3.14f64);
// Demonstrate successful downcasting
println!("Downcasting examples:");
@matthewjberger
matthewjberger / broker.rs
Last active November 11, 2024 22:02
mini rust message broker
use std::collections::{HashMap, VecDeque};
#[derive(Debug, Clone, PartialEq)]
pub enum Message {
Text(String),
Number(i64),
Binary(Vec<u8>),
Batch(Vec<Message>),
}
@matthewjberger
matthewjberger / ecs.rs
Last active November 12, 2024 06:07
an archetypal statically dispatched macro-based ecs - formal library here: https://github.com/matthewjberger/freecs
#[macro_export]
macro_rules! world {
(
$world:ident {
components {
$($name:ident: $type:ty => $mask:ident),* $(,)?
}$(,)?
$resources:ident {
$($resource_name:ident: $resource_type:ty),* $(,)?
}
@matthewjberger
matthewjberger / fast.rs
Last active November 6, 2024 19:48
Vec<Option<T>> comparison to precomputing entity archetypes
impl_world! {
positions: Position => POSITION = 0,
velocities: Velocity => VELOCITY = 1,
gravities: Gravity => GRAVITY = 2,
healths: Health => HEALTH = 3,
damages: Damage => DAMAGE = 4,
}
pub fn main() {
let mut world = World::default();
@matthewjberger
matthewjberger / ringbuffer.rs
Created October 1, 2024 16:45
A no-std fixed capacity ringbuffer in rust
#![no_std]
pub struct CircularBuffer<T, const N: usize> {
buffer: [T; N],
read_idx: usize,
write_idx: usize,
is_full: bool,
}
impl<T: Copy + Default, const N: usize> CircularBuffer<T, N> {
@matthewjberger
matthewjberger / main.rs
Created September 29, 2024 15:11
more ecs ideas in rust
use std::any::Any;
use std::collections::HashMap;
use std::marker::PhantomData;
// Generic handle type
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Handle<T> {
id: usize,
_phantom: PhantomData<T>,
}
@matthewjberger
matthewjberger / main.rs
Last active September 26, 2024 19:31
Use regex to extract parts of sections of MQTT-like topic strings
use regex::Regex;
use std::collections::HashMap;
#[derive(Debug)]
struct CaptureSpec {
name: String,
position: usize,
regex: Option<String>,
}