Skip to content

Instantly share code, notes, and snippets.

View dockimbel's full-sized avatar

Nenad Rakocevic dockimbel

View GitHub Profile
@toomasv
toomasv / arc.red
Last active May 14, 2019 08:07
Studying tool for shape-dialect 'arc
Red [
Author: "Toomas Vooglaid"
Date: 2018-07-11
Last-edit: 2018-08-21
File: %arc.red
Purpose: "Study of shape-dialect `'arc`"
Licence: "MIT"
]
help: rtd-layout [
{ In } i "shape" /i { dialect drawing of } i "arc" /i b " starts" /b { from the current position. Here I use } i "move" /i { to set initial position.^/}
@hiiamboris
hiiamboris / benchcollect.red
Created May 19, 2018 16:46
A `collect` mezzanine variant of improved performance and RAM footprint
Red []
; outright improvement of collect mezzanine's performance and RAM footprint
; the compiled default "collect"
collect1: :collect
; the interpreted default "collect"
collect2: func spec-of :collect body-of :collect
@toomasv
toomasv / rtbox.red
Last active September 19, 2021 09:16
Red [
Author: "Toomas Vooglaid"
Started: 2018-05-01
Purpose: "First steps into rich-text box"
]
ctx: context [
env: self
start: end: 1
diff: 0
dbl: no
@toomasv
toomasv / color-picker2.red
Last active March 13, 2018 06:19
Another color-picker
Red [
Author: "Toomas Vooglaid"
Date: 2018-03-12
File: %color-picker.red
]
clear-reactions
make-color: func [i][
sector: i - 1 / 64 + 1
switch sector [
1 [as-rgba 255 0 i - 1 * 4 0]
@toomasv
toomasv / matrix-study.red
Last active January 18, 2021 08:07
Study of matrix transformations
Red []
F: ['line 0x-90 50x0 0x10 -40x0 0x30 30x0 0x10 -30x0 0x40]
w1: view/no-wait compose/deep [
title "Reflections"
box 300x300 snow draw [
fill-pen white
line 0x150 300x150 shape [move 300x150 'line -20x5 0x-10] text 280x155 "x"
line 150x0 150x330 shape [move 150x300 'line 5x-20 -10x0] text 125x275 "y"
; Original
translate 150x150 [matrix [ 1 0 0 1 0 0][fill-pen white shape [move 50x-30 (F)]]]
@meijeru
meijeru / count-code-lines.r
Last active January 23, 2018 12:01
Count the number of lines of code in the Red source files
Rebol []
red-source: %/C/Users/Eigenaar/Projects/Red/sources/ ; adapt this for your situation
output-sources: %sources.txt
version: read red-source/version.r
vdate: modified? red-source/version.r
nl: "^/"
@greggirwin
greggirwin / chess.red
Last active December 8, 2017 03:14
Edward DeJong's Chess Challenge in Red
Red [
title: "Edward de Jong's Chess Challenge"
author: ["Gregg Irwin"]
]
; This may prove useful as more logic is added. Right now it's not a big win.
array: function [
"Makes and initializes a block of of values (NONE by default)"
size [integer! block!] "Size or block of sizes for each dimension"
/initial "Specify an initial value for elements"
@toomasv
toomasv / range.red
Last active June 19, 2021 14:41
Range function for multiple datatypes
Red [
Author: "Toomas Vooglaid"
Date: 26-11-2017
]
range: function [val1 val2 /step stp /limit /enbase ebase /debase dbase /unicode][
stp+?: none
stp: any [stp either any [percent? val1 percent? val2] [1%][1]]
if any [all [block? stp zero? stp/3] zero? stp] [return none]
case [
debase [
@greggirwin
greggirwin / profile.red
Last active December 28, 2020 06:17
Basic profiling for Red code comparisons
Red []
e.g.: :comment
delta-time: function [
"Return the time it takes to evaluate a block"
code [block! word! function!] "Code to evaluate"
/count ct "Eval the code this many times, rather than once"
][
ct: any [ct 1]
@toomasv
toomasv / hanoi.red
Last active October 26, 2017 17:48
Red [
Author: "Toomas Vooglaid"
Date: 2017-10-24
Needs: View
]
context [
system/view/auto-sync?: dragable?: off-the-post?: no
offset: pos-x: post: current-post: post1: post2: post3: disc: disc1: disc2: disc3: disc4: steps: thickness: none
post1-narrow: charset [ 48 - 52]
post2-narrow: charset [148 - 152]