Skip to content

Instantly share code, notes, and snippets.

use std::borrow::Cow;
use std::sync::Arc;
use anyhow::Result;
use iced::Font;
use iced::Pixels;
use iced::Size;
use iced::Theme;
use iced::widget;
use iced_core::text::Renderer as _;
@MarinPostma
MarinPostma / main.rs
Last active December 2, 2024 16:24
execution models explorations
use std::time::Instant;
use cranelift_jit::{JITBuilder, JITModule};
use cranelift::prelude::*;
use cranelift_module::{Linkage, Module};
// row:
// |... sized columns/unsized col meta | ... unsized column
enum Value {
@MarinPostma
MarinPostma / bufferpool.rs
Created November 19, 2024 15:34
bufferpool
//! A lock-free buffer pool implementation for managing fixed-size page buffers.
//!
//! This buffer pool provides efficient allocation and deallocation of fixed-size memory pages
//! using a bitmap-based allocation strategy. Key features include:
//!
//! - Lock-free concurrent access using atomic operations
//! - Fixed-size page allocation
//! - Efficient bitmap-based tracking of free/used pages
//! - Three-level hierarchy for managing pages:
//! - Bins (32 pages per bin)
@MarinPostma
MarinPostma / tokio-sqlite.rs
Created September 5, 2024 10:05
tokio sqlite
use std::{future::Future, io, task::{Poll, Waker}};
use std::cell::RefCell;
use corosensei::{stack::DefaultStack, ScopedCoroutine, Yielder};
use rand::Rng;
use rusqlite::OpenFlags;
use sqlite_vfs::{register, DatabaseHandle, LockKind, Vfs, WalDisabled};
use tokio::io::{AsyncReadExt, AsyncSeekExt, AsyncWriteExt as _};
thread_local! {
@MarinPostma
MarinPostma / test.rs
Last active September 12, 2023 15:56
tokio run_until bug
use std::time::Duration;
use tokio::task::LocalSet;
fn main() {
let mut builder = tokio::runtime::Builder::new_current_thread();
let tokio = builder.enable_time().start_paused(true).build().unwrap();
let local = LocalSet::new();
let fut = async move {
tokio::task::spawn_blocking(move || {
use std::borrow::Cow;
use std::ops::Deref;
use std::collections::HashSet;
use std::fs::File;
use std::mem::{size_of, transmute};
use std::os::unix::prelude::FileExt;
use bytemuck::{Zeroable, Pod, pod_read_unaligned, bytes_of, try_from_bytes};
use bytes::{BytesMut, Bytes};
@MarinPostma
MarinPostma / lazy_entity.ts
Last active September 20, 2022 10:11
POC lasy chisel entities
abstract class ChiselEntity {
__data: any;
__ctx_id: number;
public Ready: Promise.IThenable<any>;
public isReady = false;
}
class Person extends ChiselEntity {
// these just end up as dummies
name: string;
This file has been truncated, but you can view the full file.
[START][2021-11-01 14:12:20] LSP logging initiated
[START][2021-11-01 14:12:30] LSP logging initiated
[START][2021-11-01 14:13:10] LSP logging initiated
[START][2021-11-01 14:15:34] LSP logging initiated
[START][2021-11-01 14:16:09] LSP logging initiated
[START][2021-11-01 14:16:22] LSP logging initiated
[START][2021-11-01 14:16:46] LSP logging initiated
[START][2021-11-01 14:17:05] LSP logging initiated
[START][2021-11-01 14:17:59] LSP logging initiated
[START][2021-11-01 14:18:13] LSP logging initiated
@MarinPostma
MarinPostma / main.rs
Created September 8, 2021 18:51
meili nom parser
use nom::{IResult, branch::alt, bytes::complete::{take_while1, tag}, character::complete::{char, multispace0}, combinator::map, error::ParseError, multi::many0, sequence::{delimited, tuple, preceded}};
fn is_key_component(c: char) -> bool {
c.is_alphanumeric() || ['_', '-', '.'].contains(&c)
}
fn parse_key(input: &str) -> IResult<&str, &str> {
let key = |input| take_while1(is_key_component)(input);
alt((key, delimited(char('"'), key, char('"'))))(input)
}
@MarinPostma
MarinPostma / main.rs
Created September 8, 2021 18:10
nom meili parser
use nom::{
IResult,
character::complete::{char, multispace0},
combinator::map,
branch::alt,
sequence::{delimited, tuple, preceded},
multi::many0,
bytes::complete::{take_while1, tag},
};