Skip to content

Instantly share code, notes, and snippets.

@kaleidawave
kaleidawave / fixed.rs
Created July 25, 2026 10:32
Fixed point data structure + traits
pub struct Fixed<const N: u8>(u32);
impl<const N: u8> Fixed<N> {
pub const fn from_float(f: f32) -> Self {
let value = (f * 10u32.pow(N as u32) as f32) as u32;
Self(value)
}
}
impl<const N: u8> std::fmt::Display for Fixed<N> {
@kaleidawave
kaleidawave / main.rs
Created July 16, 2026 17:16
24 bit colour terminal background printing. Has some bugs: why the first line has no background... why it takes a few runs in a clean terminal before it prints new lines...?
fn main() {
let colours: &[[u16; 3]] = &[
[204, 12, 56],
[238, 15, 44],
[255, 64, 32],
[255, 101, 39],
[254, 189, 56],
[254, 242, 198]
];
-- Create the new table
CREATE TABLE words AS SELECT * FROM original_words;
-- Can use strlen instead
ALTER TABLE words DROP Count;
-- rogue row
DELETE FROM words WHERE NOT prefix(Definition, '"');
-- Some columns have their POS leak into the definition
@kaleidawave
kaleidawave / snippets.css
Last active December 19, 2023 16:57
Snippets for obsidian latex: https://github.com/artisticat1/obsidian-latex-suite and my custom CSS
.theme-dark {
--background-primary: rgb(14, 13, 11);
--background-secondary: black;
--text-normal: #d4d4d0;
}
.theme-light {
--text-normal: #1e1e1f;
--background-primary: #efedea;
--background-secondary: #e7e7e7;
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
fig, ax = plt.subplots()
ax.set_aspect("equal", adjustable="box")
(path,) = ax.plot([], [], marker="o", color="r", linewidth=1, markersize=0.2)
centres = ax.scatter([], [], marker="o", color="b", linewidth=0.1)

Trying Ezno checking today

This a short overview of some of the things you can do with Ezno today. If you find any problems, file an issue.

The following examples show some errors that have been caught using type checking, partial/const evaluation and effects.

To get started we will install oxidation-compiler which has bindings for Ezno's checker. (you can also get the binary from the releases page).

npm install -g oxidation-compiler@latest
@kaleidawave
kaleidawave / index.rs
Created April 12, 2023 16:42
rust-positions
/// Returns `(line, column)`. Return is zero based
fn get_line_column_from_string_and_idx(end: u32, char_indices: &mut CharIndices) -> (u32, u32) {
let (mut line, mut column) = (0, 0);
for (_, chr) in char_indices.take_while(|(idx, _)| *idx < end.try_into().unwrap()) {
if chr == '\n' {
line += 1;
column = 0;
} else {
column += chr.len_utf8() as u32;
}
const x = 2 + 5;
@kaleidawave
kaleidawave / generator.rs
Created February 9, 2023 21:51
Quasi-Quoted + constant compilation AST generating macro
use proc_macro::{token_stream, Delimiter, Spacing, TokenStream, TokenTree};
use proc_macro2::Span;
use quote::{format_ident, quote};
/// Used for generating parser::ASTNodes using proc macros
///
/// Turns token stream into string.
/// - Finds expressions and registers cursor locations
/// - Parses structure from string and turns it into Rust tokens
#[proc_macro]
@kaleidawave
kaleidawave / repl.rs
Created January 18, 2023 12:33
Ezno's wrapper for the Deno repl
use std::{collections::HashSet, io};
use argh::FromArgs;
use checker::{Project, TypeDefinitionModulePath};
use std::io::{BufRead, BufReader, Write};
use std::process::{Command, Stdio};
use crate::{
error_handling::print_error_warning_info_handler, file_system_resolver,
utilities::read_string_from_cli,