Skip to content

Instantly share code, notes, and snippets.

View rlapz's full-sized avatar
👀

Arthur Lapz rlapz

👀
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / audio_player_gpt4o.c
Last active August 3, 2024 13:19
A simple audio player using `ffmpeg` & `SDL2`. Powered by GPT-4o.
#include <stdio.h>
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/opt.h>
#include <libavutil/mathematics.h>
#include <libavutil/samplefmt.h>
#include <libswresample/swresample.h>
#include <SDL2/SDL.h>
#define SDL_AUDIO_BUFFER_SIZE 1024
@rlapz
rlapz / audio_player_deepseek.c
Last active March 30, 2025 16:09
A simple audio player (pipewire & ffmpeg) by DeepSeek.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pipewire/pipewire.h>
#include <spa/utils/defs.h>
#include <spa/utils/string.h>
#include <spa/utils/result.h>
#include <spa/param/audio/format-utils.h>
#include <spa/pod/builder.h>