Skip to content

Instantly share code, notes, and snippets.

View CODESOLE's full-sized avatar
🎯
Focusing

CODESOLE CODESOLE

🎯
Focusing
View GitHub Profile
@CODESOLE
CODESOLE / sliding_window.c
Created April 25, 2026 01:39
sliding window in C
/* -*- compile-command: "gcc -O3 sliding_window.c && ./a.out"; -*- */
#include <assert.h>
#include <stdint.h>
#include <stdio.h>
int slide_window(const size_t window_size, const void *const buf, const size_t elm_sz, const size_t n, void **start, void **end) {
assert(buf && start);
assert(buf <= *start && *start <= *end);
assert(window_size > 0 && window_size <= n);
char *buf_end = (char *)buf + (elm_sz * n);
@CODESOLE
CODESOLE / .luarc.json
Last active May 23, 2024 17:12
lua-c interface, util.h/util.c, luarcjson, run_static_analyzer
{
"runtime.version": "Lua 5.4",
"Lua.color.mode": "SemanticEnhanced",
"Lua.hint.setType": true,
"Lua.IntelliSense.traceBeSetted": true,
"Lua.IntelliSense.traceFieldInject": true,
"Lua.IntelliSense.traceLocalSet": true,
"Lua.IntelliSense.traceReturn": true
}
TARGET_EXEC := crypt
CC := clang
BUILD_DIR := build
SRC_DIRS := src dep
INC_DIRS := src dep
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
SRCS := $(shell find $(SRC_DIRS) -name '*.c')
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
@CODESOLE
CODESOLE / rogueutil.c
Last active March 12, 2022 08:56
it' s just https://github.com/sakhmatd/rogueutil but with seperation of .h/.c, renaming function names to sneak_case, added all symbols to `ru_` namespace prefix and removing ifdef __cpluscplus stuff. And also removing msleep function from the code because it contains C11 specific `struct timespec`.
#include "rogueutil.h"
/* Constant strings for ANSI colors ans seqiences */
static const char *RU_ANSI_CLS = "\033[2J\033[3J";
static const char *RU_ANSI_CONSOLE_TITLE_PRE = "\033]0;";
static const char *RU_ANSI_CONSOLE_TITLE_POST = "\007";
static const char *RU_ANSI_ATTRIBUTE_RESET = "\033[0m";
static const char *RU_ANSI_CURSOR_HIDE = "\033[?25l";
static const char *RU_ANSI_CURSOR_SHOW = "\033[?25h";
static const char *RU_ANSI_CURSOR_HOME = "\033[H";