Skip to content

Instantly share code, notes, and snippets.

View rlapz's full-sized avatar
👀

Arthur Lapz rlapz

👀
View GitHub Profile
@rlapz
rlapz / less_than_vers.zig
Last active March 31, 2025 14:13
strverscmp-like in zig
pub fn less_than_vers(s1: []const u8, s2: []const u8) bool {
var ii1: usize = 0;
var ii2: usize = 0;
const n1 = s1.len;
const n2 = s2.len;
while (ii1 < n1 and ii2 < n2) {
const c1 = s1[ii1];
const c2 = s2[ii2];
@rlapz
rlapz / audio_player_deepseek_2.c
Created March 30, 2025 16:50
A simple audio player (pipewire & ffmpeg) by DeepSeek. (ncurses version)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
#include <pthread.h>
#include <ncurses.h>
#include <pipewire/pipewire.h>
#include <spa/utils/result.h>
#include <spa/param/audio/format-utils.h>
@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>
@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 / 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;