Skip to content

Instantly share code, notes, and snippets.

View rlapz's full-sized avatar
👀

Arthur Lapz rlapz

👀
View GitHub Profile
@rlapz
rlapz / exmail.c
Last active January 30, 2023 16:09
An --ex-- extreme mail server without including any external library (for linux x86_64 only).
// SPDX-License-Identifier: GPL-2.0-only
/* ExMail (WIP)
* An --ex-- extreme mail server without including any external library
* (for linux x86_64 only).
*
* This simple mail-server aims to implements some of these RFCs:
* SMTP: https://datatracker.ietf.org/doc/html/rfc2821
* POP3: https://datatracker.ietf.org/doc/html/rfc1939
*
* ----------------------------------------------------------------------
@rlapz
rlapz / esmail.c
Created January 30, 2023 20:35
Simple mail server (SMTP & POP3 implementations).
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
/*
* Slots
*/
@rlapz
rlapz / mempool.c
Last active April 7, 2024 17:28
memory pool: fast allocate & deallocate a single item memory
#include <errno.h>
#include "mempool.h"
int
mempool_init(MemPool *m, size_t nmemb, size_t size)
{
m->nmemb = nmemb;
m->head = NULL;
@rlapz
rlapz / thrd_queue.c
Last active December 24, 2023 07:32
Thread queue sync
#include <threads.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
typedef struct _Node {
struct _Node *prev;
struct _Node *next;
} Node;
import ctypes
import struct
"""
c-struct
typedef struct {
uint64_t fsize; // offset: 0
uint8_t fname_len; // offset: 8
char fname[255]; // offset: 9
"""
I F*CKING HATE THE EXCEPTION!!!
"""
import os
import socket
import signal
import ctypes
import struct
@rlapz
rlapz / fturing.zig
Created April 22, 2023 14:49
fturing: zig implementation
const std = @import("std");
const assert = std.debug.assert;
const fmt = std.fmt;
const heap = std.heap;
const mem = std.mem;
const log = std.log;
const os = std.os;
const io = std.io;
const net = std.net;
const std = @import("std");
const fmt = std.fmt;
const io = std.io;
const mem = std.mem;
const net = std.net;
const os = std.os;
const dprint = std.debug.print;
// caller owns the returned memory
@rlapz
rlapz / lru.zig
Last active July 26, 2023 14:49
LRU cache
const std = @import("std");
const debug = std.debug;
const mem = std.mem;
const net = std.net;
const time = std.time;
const dprint = debug.print;
const assert = debug.assert;
pub fn Lru(comptime T: type, comptime key_size: u16) type {
@rlapz
rlapz / blog.c
Last active January 8, 2024 13:42
A simple static site generator for blog
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the