Skip to content

Instantly share code, notes, and snippets.

View greggirwin's full-sized avatar

Gregg Irwin greggirwin

  • Redlake Technologies
View GitHub Profile
Red [
Author: "Toomas Vooglaid"
Date: 2017-10-23
]
context [
A: B: C: D: E: F: G: H: I: J: K: L: M: N: O: P: Q: R: S: T: U: V: W: X: Y: Z: none
numbers: make block! 10
nums: make block! 10
out: make block! 10
letters: make block! 10
; proof of concept (but usable!) implementation of immutable persistent 'blocks' in Red
; author: Jay G. Porcasi (@numberjay)
; the exported API is at the bottom, starting with: set '<function name> ...
; free to use without any warranty of any kind: use at your own leisure and risk
; for bugs, suggestions, questions... comment here below or reach me on Gitter (@numberjay)
; copyright Jay G. Porcasi 2017
context [
; all functions ending with ' are helper functions working on 'immutable' blocks only
@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 [
@toomasv
toomasv / lazy-range.red
Last active April 24, 2018 09:18
Range for on-demand evaluation
Red [
Author: "Toomas Vooglaid"
Date: 27-11-2017
]
lazy-range: function [
"Returns function that generates next value in (possibly infinite) range"
val [scalar!] "Initial value"
/step stp [scalar! block!] "By which to increment each next value"
/limit lim [integer!] "How many new values to generate"
/stop stopval [scalar! block!] "On which value to stop generation of new values; if block, then also after how may matches"
@toomasv
toomasv / format.red
Last active April 11, 2018 17:53
Poor man's format
Red [
Author: "Toomas Vooglaid"
Date: 27-11-2017
]
context [
tmp: x: none
ord: func [val /local v][
rejoin [
v: to-string val
either find [11 12 13] val ["th"][
@mikeyaunish
mikeyaunish / Livecode-enhanced.red
Created December 7, 2017 05:29
Based on Dockimbel and Didier VID livecode. Added saving and loading of files and window configuration. Make VID updates controllable.
Red [
Title: "Simple GUI livecoding demo"
Author: "Nenad Rakocevic / Didier Cadieu / Mike Yaunish"
File: %livecode-enhanced.red
Version: 1.3.0
Needs: 'View
Usage: {
Type VID code in the bottom left area, you will see the resulting GUI components
rendered live on the right side and fully functional (events/actors/reactors working live).
The top left area lets you define Red's values to be used in your VID code, even functions or anything.
@toomasv
toomasv / ring.red
Last active November 15, 2019 11:33
Red [
Author: "Toomas Vooglaid"
Date: 2017-12-12
]
set 'ring function [ser [series!]][
context [
series: ser
circle: function [/at aval /skip sval /next /back /part pval][
case/all [
at [
@toomasv
toomasv / unicode.red
Last active December 29, 2017 17:25
Red [
Author: "Toomas Vooglaid"
Date: 2017-12-16
Needs: %range.red
Needs-Gist: https://gist.github.com/toomasv/0e3244375afbedce89b3719c8be7eac0
]
do %range.red
context [
md: make font! [name: "Consolas" size: 12 color: black]
ft: make font! [name: "Tahoma" size: 36 color: black];;Lucida Sans Unicode;Unifont;EversonMono
@Phryxe
Phryxe / red-predefined-colors.red
Last active December 21, 2017 18:13
Red's Predefined Colors
Red [
Needs: 'View
]
b-or-w?: func [color [tuple!] /local darkness [float!]] [
darkness: 1 - (((0.299 * color/1) + (0.587 * color/2) + (0.114 * color/3)) / 255)
either (darkness < 0.5) [return black][return white]
]
size: 100x25
@toomasv
toomasv / graph.red
Last active July 11, 2018 02:22
Toy graph DSL
Red [
Author: "Toomas Vooglaid"
Date: 2017-12-31
History: [
2017-12-28 {First draft}
2018-01-20 {Added arrows, subtree moving, elementary interactive editing}
2018-01-24 {Edges formatting}
2018-02-01 {Added differnt edge-ends, layout orientations, improved options-handling}
2018-02-03 {Implemented stepped (orthogonal) edges, improved star layout}
2018-02-06 {Added directions `across` (default: perpendicular to the step-away direction) and `away` (in the step-away direction).