Skip to content

Instantly share code, notes, and snippets.

@toomasv
toomasv / layout-demo.red
Created March 20, 2019 14:01
Layout adjustment demo
Red []
context [
env: self
canvas: none
tab-pan: drawing-panel-tab: animations: none
info-panel: edit-options-panel: options-panel: drawing-panel: figs-panel: anim-panel: none
layer: layer1: drawing: selection-layer: grid-layer: drawing-layer: edit-layer: none
win: layout/options compose/deep [;
title "Drawing pad"
size 540x465
@toomasv
toomasv / rtd-simple.red
Last active March 16, 2019 22:24
Simplified syntax for rich-text
Red [
Author: "Toomas Vooglaid"
Date: 9-Mar-2019
Purpose: {Simplified syntax for rich-text specification}
]
context [
format-word: no
format-any: copy []
in-string?: no
sp: charset " ^-"
@toomasv
toomasv / dbquery.red
Created February 28, 2019 09:20
Simple query dialect
Red [
Author: "Toomas Vooglaid"
Date: 2019-02-27
Challenge: https://gitter.im/red/help?at=5c75b4d7d2d62067b7101b03
File: %dbquery.red
Purpose: {Simple query dialect}
TBD: {change delete}
]
;@GiuseppeChillemi [February 26, 2019 11:51 PM](https://gitter.im/red/help?at=5c75b4d7d2d62067b7101b03)
assign: func [words values][
@toomasv
toomasv / syntax.rtd
Created January 14, 2019 18:47
Study of syntax highlighting
Red [
Author: "Toomas Vooglaid"
Date: 2019-01-14
Purpose: {Study of syntax highlighting}
]
skp: charset " ^/^-[]()/"
initial-size: 800x800
addr: func [s1 s2 style] bind [keep as-pair i: index? s1 (index? s2) - i keep style] :collect
rule: [any [s:
skp
@toomasv
toomasv / lcs.red
Last active March 16, 2019 22:25
Longest Common Subsequence
Red [
Purpose: "Longest Common Subsequence"
Partially-based-on: http://rosettacode.org/wiki/Longest_common_subsequence
Date: 8-Jan-2019
Last: 10-Jan-2019
]
lcs: function [s t][
case [ ; preliminary checks
s = t [return copy s]
any [empty? s empty? t] [return copy ""]
@toomasv
toomasv / levenshtein.red
Last active March 16, 2019 22:25
Implementation of Levenshtein distance
Red [
Date: 6-Jan-2019
File: %levenshtein.red
]
lev: function [s t][
unless string? s [s: mold s]
unless string? t [t: mold t]
case [
s = t [return 0]
empty? s [return (length? t)]
@toomasv
toomasv / check.red
Last active March 16, 2019 22:25
Checking for matching/closing of nested thing and strings
Red []
ctx: context [
char: charset {([{}])"} ;"
opens: charset "[("
closes: charset "])"
line: 1
stack: make block! 1000
mark: comm: none
instr: false
inmulti: 0
@toomasv
toomasv / freehand-on-area.red
Last active March 16, 2019 22:25
Study of freehand drawing on area
Red [
Author: "Toomas Vooglaid"
Date: 2018-12-09
Purpose: {Study of freehand drawing on area}
]
do load-thru https://tinyurl.com/ybmvx58e ; make-transparent
img: draw 200x200 [box 0x0 199x199]
img: make-transparent img 255
style: 'thin
view [