Skip to content

Instantly share code, notes, and snippets.

View rlapz's full-sized avatar
👀

Arthur Lapz rlapz

👀
View GitHub Profile
@rlapz
rlapz / thrd_pool.c
Last active June 17, 2024 19:28
Generic Thread Pool
#include <stdlib.h>
#include "thrd_pool.h"
typedef struct thrd_pool_job {
ThrdPoolFn func;
void *udata;
struct thrd_pool_job *next;
} ThrdPoolJob;
@rlapz
rlapz / queue.c
Last active June 17, 2024 10:48
queue
#include <stdio.h>
#include <stdlib.h>
typedef void (*Func) (void *udata);
typedef struct node {
Func func;
void *udata;
struct node *next;
@rlapz
rlapz / str.c
Last active May 27, 2024 16:11
C String library
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "str.h"
static int
@rlapz
rlapz / cstrmap.h
Last active April 7, 2024 07:41
c string hash map
/*
* fixed-size string hashmap (FNV-1)
*/
#ifndef __CSTRMAP_H__
#define __CSTRMAP_H__
#include <assert.h>
#include <errno.h>
#include <stdint.h>
@rlapz
rlapz / mem_pool.zig
Last active January 23, 2024 13:55
A simple memory pool.
const std = @import("std");
const mem = std.mem;
const debug = std.debug;
const assert = debug.assert;
const dprint = debug.print;
pub fn MemPool(comptime T: type) type {
return struct {
allocator: mem.Allocator,
@rlapz
rlapz / log.c
Last active November 30, 2023 12:47
simple logger
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include <time.h>
struct log {
pthread_mutex_t mutex;
@rlapz
rlapz / fsconf.h
Last active November 23, 2023 13:22
A f*cking simple, error prone, and slow key-value-based file configuration reader
#ifndef __FSCONF_H__
#define __FSCONF_H__
/* A f*cking simple, error prone, and slow key-value-based file configuration
*
* File name: file.fsconf
* ------------------------
* key0(value)\n
* key1(value)\n
@rlapz
rlapz / build.sh
Last active October 29, 2023 10:53
#!/bin/sh
set -e
cc -g -Wall -Wextra moetr.c $(pkg-config --cflags gtk4 libsoup-3.0 json-glib-1.0)\
$(pkg-config --libs gtk4 libsoup-3.0 json-glib-1.0) -o moetr
@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
@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 {