Skip to content

Instantly share code, notes, and snippets.

@evaporei
evaporei / small_array.rs
Last active April 12, 2025 00:07
Odin's Small_Array in Rust
pub struct SmallArray<const N: usize, T> {
data: [T; N],
count: usize,
}
impl<const N: usize, T> Default for SmallArray<N, T> {
fn default() -> Self {
Self {
data: std::array::from_fn(|_| unsafe { std::mem::zeroed() }),
count: 0,
@evaporei
evaporei / rust_good_bad_ugly.md
Created March 20, 2025 18:51
Rust: The Good. The Bad. And The Ugly

Rust: The Good. The Bad. And The Ugly

I have been programming Rust for 6 years now (since 2018 edition). I have also done professional work with it for 4 companies at this point: one for “embedded” (payment terminal protocol), blockchain, web backend services and also video/audio streaming (WebRTC).

I reached a point where the honey moon phase is over, and I have a more holistic view on this programming language.

The Good

Let’s start with the good stuff. Rust has great learning material and it has a rich ecosystem of libraries at this point, covering the most common developer use cases. It is usually a great experience to build and run Rust projects. You can clone a repository, and cargo will do everything for you. 97% of the time you don’t have to deal with linking issues,Makefile s etc, that usually happen in the C/C++ world.

@evaporei
evaporei / dump_tables.lua
Created July 26, 2024 17:43
dump tables love2d
local Game = require('game')
local game = Game.new()
local function count_all(f)
local seen = {}
local count_table
count_table = function(t)
if seen[t] then return end
f(t)
@evaporei
evaporei / rabbit.py
Created July 4, 2024 17:54
Fox/Rabbit in a hole problem
from random import randint
holes = 100
# rabbit jump (pulo do gato)
def step(prev_pos: int) -> int:
if prev_pos == 0:
return prev_pos + 1
elif prev_pos == (holes - 1):
return prev_pos - 1
@evaporei
evaporei / bst_traversals.py
Created June 24, 2024 18:34
bst traversals
from collections import deque
class TreeNode[T]:
val: 'T'
left: 'TreeNode | None'
right: 'TreeNode | None'
def __init__(self, val: T, left=None, right=None):
self.val = val
self.left = left
self.right = right
@evaporei
evaporei / config
Created April 13, 2024 21:19
ghostty config copying kitty
# good defaults coming from Kitty + MacOS
theme = "Pro"
# https://sw.kovidgoyal.net/kitty/conf/#the-color-table
# https://l0go.github.io/ghostty-base16-converter/
font-family = "monospace"
font-size = 22
font-thicken = true
@evaporei
evaporei / tutorial.md
Created September 24, 2023 17:41
ssh mac (host) into linux (remote) in the same network (eg: wifi)

Linux

  1. Get your local IP address
$ ip route
default via IP1 dev wlan0 proto dhcp src IP2 metric 600 
IP3/24 dev wlan0 proto kernel scope link src IP2 metric 600
@evaporei
evaporei / .generate_cringe_key.sh
Created September 24, 2023 16:09
generate cringe key
#!/bin/bash
# pass name via $1
ssh-keygen -t rsa -b 4096 -f ~/.ssh/$1
@evaporei
evaporei / jack_grammar.txt
Created June 3, 2023 11:27
Jack grammar
--- program structure ---
// a Jack program is a collection of files, each should represent a class like the one below
class = "class" className '{' classVarDec* fnDec* '}' ;
classVarDec = ("static" | "field") type varName (',' varName)* ';' ;
fnDec = ("constructor" | "function" | "method") ("void" | type) fnName '(' paramList ')' fnBody ;
paramList = ( (type varName) (',' type varName)* )? ;
fnBody = '{' varDec* statements '}' ;
varDec = "var" type varName (',' type varName)* ';' ;
type = primitive | className ;
@evaporei
evaporei / artblocks_error.rs
Created January 20, 2022 18:49
ArtBlocks Error
// Cargo.toml dependencies:
// hex = "0.4.3"
// ethabi = "16.0.0"
use ethabi::*;
use ethabi::ParamType::*;
use ethabi::StateMutability::*;
fn main() {