Skip to content

Instantly share code, notes, and snippets.

View dockimbel's full-sized avatar

Nenad Rakocevic dockimbel

View GitHub Profile
Red/System [
Title: "llama.cpp static binding for Red"
Purpose: "Imports the llama-red shim (llama-red.c) bundled with llama.cpp + ggml"
Note: {
Extension-less import: Red's -s static linker resolves llama-red.lib,
a dynamic build would resolve llama-red.dll. The shim keeps every
by-value struct of llama.h on the C side -- only scalars cross here.
}
]
Red [
Title: "llm-demo — a statically-linked LLM inside a Red executable"
File: %llm-demo.red
Note: {
llama.cpp + ggml statically linked via the llama-red shim: one
standalone 32-bit exe, no DLLs, running quantized GGUF models.
Build: redc -r -s -t Windows llm-demo.red
Run: llm-demo <model.gguf> [prompt words...]
llm-demo models/Qwen3-0.6B-Q8_0.gguf Why is the sky blue? /no_think
@dockimbel
dockimbel / llama-red.c
Created July 29, 2026 18:11
C shim library for llama.cpp
/*
** llama-red.c -- minimal extern-C cdecl shim over llama.cpp for Red/System
**
** llama.h passes its config structs by value (llama_model_params,
** llama_context_params, llama_sampler_chain_params, llama_batch). Red/System
** CAN pass structs by value (the `value` keyword), but mirroring these large,
** version-volatile layouts field-for-field on the Red side would break on
** every llama.cpp upgrade -- so they stay behind pointer-and-scalar entry
** points here. One opaque handle carries model+ctx+sampler.
**
@dockimbel
dockimbel / gist:9fb619c9f0fadbfc52b549e131dd8982
Last active March 5, 2026 15:28
Performance testing on INSERT/APPEND on strings
Red []
recycle/off
s: make string! 20e6
clear s
append s "hello"
recycle
mem0: stats
clock [ loop 1e5 [insert s [1 3.14 (1.0, 2,0)]] ]
@dockimbel
dockimbel / codecs.md
Last active June 13, 2025 19:57
Codecs draft design

Codecs

Concept

Codecs are standardized components dedicated to the encoding and decoding of dataset formats accessed through IO or from memory. Codecs are indirectly called by LOAD and SAVE functions.

Mezz-level API

Encoding

@dockimbel
dockimbel / svg.red
Last active May 22, 2025 11:54 — forked from rgchris/svg.red
Red SVG loader/converter
Red [
Title: "SVG Tools"
Date: 27-Jan-2020
Author: "Christopher Ross-Gill"
Rights: http://opensource.org/licenses/Apache-2.0
Version: 0.3.2
History: [
0.3.2 27-Jan-2020 "Better handling of text whitespace; bold/italic"
0.3.1 24-Jan-2020 "PATH model rewrite; VIEW wrapper to view an SVG"
0.3.0 23-Jan-2020 "Reorganise PATH handling; render whole/partial object; further refactoring"
@dockimbel
dockimbel / gist:23249971d59e574ae57ab63eec487393
Last active May 23, 2025 19:37
Pre-prompt for Draw dialect
The following text is the description of the Draw DSL for Red programming language. The word "dialect" which will be used is a synonym for DSL.
1. Preliminary knowledge to be able to read and write Draw dialect programs
1.1 Red datatypes and literal syntax
Draw dialect relies on a subset of Red language values. Each Red value has a unique datatype. By convention, datatype names end with an exclamation mark. The datatypes used by Draw:
1.1.1 Block! datatype
Red [
Needs: View
]
nb: 500
list: []
make-dir folder: %images-test/
loop nb [
append list img: make image! as-pair 100 + random 300 100 + random 300
@dockimbel
dockimbel / almost-equal32.c
Created February 16, 2025 21:15
C function for comparing float values that are close enough (<= 10 ULP)
// generated from https://chatgpt.com/canvas/shared/67afab561d4c8191bbb497e5cef5147b
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#define ULP_TOLERANCE 10
int float_almost_equal(float a, float b) {
root: 5185/7876, runs: 133, mem: 25173016 => 20056768, mark: 6.3ms, sweep: 4.0ms
root: 5185/7876, runs: 134, mem: 25147196 => 20068176, mark: 6.0ms, sweep: 4.0ms
root: 5185/7876, runs: 135, mem: 25160776 => 19639592, mark: 5.4ms, sweep: 3.5ms
root: 5185/7876, runs: 136, mem: 25169800
*** Runtime Error 1: access violation
*** in file: /C/dev/Red/runtime/hashtable.reds
*** at line: 578
***
*** --Frame-- --Code-- --Call--
*** 0105A990h 0042FE5Dh red/_hashtable/mark 274556F0h