Skip to content

Instantly share code, notes, and snippets.

View wolfspider's full-sized avatar
🔧
Tooling on FP

Jesse Bennett wolfspider

🔧
Tooling on FP
  • NCFL
View GitHub Profile
@wolfspider
wolfspider / rust_buf.rs
Created December 5, 2024 02:18
Rust Filter Graph
use buffer::Buffer;
use std::fmt::Debug;
use std::io::{self, BufRead, BufReader, Write};
use std::ops::Deref;
trait Process: Debug {
fn process<'a, B>(&mut self, input: B, output: &mut (impl Buffer<'a> + Write + ?Sized))
where
for<'b> B: BufRead;
}
@wolfspider
wolfspider / build_packet.zig
Created December 3, 2024 05:18
Formal RingBuffer 3: Getting Low and Getting Results
pub fn buildPacket() []const u8 {
// Define the packet components
const dest_mac: [6]u8 = [_]u8{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; // Destination MAC
const src_mac: [6]u8 = [_]u8{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; // Source MAC
const ethertype: [2]u8 = [_]u8{ 0x08, 0x00 }; // EtherType (IPv4)
const payload: [46]u8 = [_]u8{0} ** 46; // Payload (46 bytes of zeroes)
// Combine all components into a single array
const packet: [60]u8 = [_]u8{
// Destination MAC
@wolfspider
wolfspider / synchro_ring.c
Created November 29, 2024 05:10
Formal RingBuffer 2: Synchronicity
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
typedef struct t__int32_t_s
{
int32_t *b;
uint32_t *first;
uint32_t *length;
uint32_t total_length;
@wolfspider
wolfspider / limbo-perf.txt
Created November 4, 2024 05:29
Limbo AIO-MIO FreeBSD Perf Results
generic I/O benches:
Running benches/benchmark.rs (target/release/deps/benchmark-ae59633aa8fa8e87)
Gnuplot not found, using plotters backend
Benchmarking limbo/Prepare statement: 'SELECT 1': Collecting 100 samples in estimated 5.0117 s (1.8Mlimbo/Prepare statement: 'SELECT 1'
time: [2.8154 µs 2.8430 µs 2.8732 µs]
thrpt: [348.05 Kelem/s 351.74 Kelem/s 355.19 Kelem/s]
Found 5 outliers among 100 measurements (5.00%)
2 (2.00%) high mild
3 (3.00%) high severe
@wolfspider
wolfspider / ringbuffer.c
Created October 31, 2024 15:07
Formal Methods Ring Buffers
#include <stdio.h>
#include <stdint.h>
typedef struct t__int32_t_s
{
int32_t *b;
uint32_t *first;
uint32_t *length;
uint32_t total_length;
@wolfspider
wolfspider / fibersched.bsq
Last active October 14, 2024 14:53
Bosque Scheduler
namespace NSMain;
entity Func {
invariant $lf != "";
field lf: String;
factory static enqueue(f: fn() -> String):
{ lf: String }
{
return { lf = f() };
@wolfspider
wolfspider / fp.jl
Created August 27, 2024 02:15
More code alchemy
using Underscores
using Transducers
using WebAssemblyCompiler
function fpwasm(f)
z = Iterators.countfrom() |> Map(x -> 2x) |> TakeWhile(x -> x < 10)
j = reduce(+, z)
return j
end
@wolfspider
wolfspider / GCTypes.c
Created August 2, 2024 14:33
Low* GCTypes exploration
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
// Define the list structure
typedef struct Prims_list__uint32_t {
enum { Prims_Cons, Prims_Nil, Prims_Null } tag;
union {
struct {
struct Prims_list__uint32_t *tl;
@wolfspider
wolfspider / main.rs
Created February 19, 2024 06:36
Tokio SSE Client
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
use tokio::net::TcpStream;
async fn read_stream(stream: TcpStream) -> Result<(), Box<dyn std::error::Error>> {
let mut buf_reader = BufReader::new(stream);
let mut is_200_response = false;
let mut is_sse_mode = false;
loop {
let mut line = String::new();
@wolfspider
wolfspider / devfs.conf
Created September 17, 2019 00:48
/etc/devfs.conf
# Allow a user in the wheel group to query the smb0 device
#perm smb0 0660
# Allow members of group operator to cat things to the speaker
#own speaker root:operator
#perm speaker 0660
perm /dev/dri/card0 0666