Skip to content

Instantly share code, notes, and snippets.

View dockimbel's full-sized avatar

Nenad Rakocevic dockimbel

View GitHub Profile
@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
root: 5185/7876, runs: 161, mem: 31529432 => 10521672, mark: 3.0ms, sweep: 18.0ms
root: 5185/7876, runs: 162, mem: 12969668 => 11115736, mark: 5.7ms, sweep: 2.0ms
root: 5185/7876, runs: 163, mem: 15180164 => 11257156, mark: 4.0ms, sweep: 3.0ms
root: 5185/7876, runs: 164, mem: 53216424 => 12400444, mark: 6.7ms, sweep: 30.8ms
root: 5185/7876, runs: 165, mem: 16780072
*** Runtime Error 1: access violation
*** in file: /C/dev/Red/runtime/collector.reds
*** at line: 324
***
*** --Frame-- --Code-- --Call--
@dockimbel
dockimbel / gist:8a5bcf3acb470d0dd9f4dd0a07da7817
Created September 8, 2022 14:29
Simple usage example of SCROLLER widget
Red [Needs: View]
scroll-max: 100
start-pos: 0
view [
size 200x200
backdrop cyan
p: panel 100x100 [button "ok"]
do [start-pos: p/offset/y] ;-- saves initial position
@dockimbel
dockimbel / gist:cb5607b0696558d44aa4a3537e930095
Created February 8, 2022 14:13
Global space function stats per type
Red []
count: function [][
list: [native! 0 action! 0 op! 0 function! 0 routine! 0]
foreach w words-of system/words [
if pos: find list type?/word get/any w [pos/2: pos/2 + 1]
]
list
]
@dockimbel
dockimbel / gist:3ebf48b58acdb3781c6e8f7adefe2959
Created December 21, 2021 19:35
Tracing handler for extracting top expressions
Red []
detect: function [
event [word!]
code [any-block! none!]
offset [integer!]
value [any-type!]
ref [any-type!]
frame [pair!]
][