Skip to content

Instantly share code, notes, and snippets.

View greggirwin's full-sized avatar

Gregg Irwin greggirwin

  • Redlake Technologies
View GitHub Profile
@greggirwin
greggirwin / url-parser.red
Last active August 14, 2019 21:29
Red URL Parser (now included in Red: %environment/networking.red)
Red [
title: "RFC3986 URL parser"
file: %url-parser.red
author: "@greggirwin"
date: 03-Oct-2018
notes: {
Reference: https://tools.ietf.org/html/rfc3986#page-16
Most rule names are taken from the RFC, with the goal of
making it easy to compare to the reference. Some rules
@greggirwin
greggirwin / inject.red
Last active May 14, 2020 10:59
INJECT func experiment. Alternative to REDUCE or COMPOSE.
Red [
name: 'inject
file: %inject.red
author: "Gregg Irwin"
notes: {
Red version of Ladislav Mecir's R2 `build` func. I can't find his on
the net, to link to, but can post his original if desired. His point
was that `compose` isn't always easy to use, when parens are part of
block you're composing, or how your blocks are structured, whether you
can use `/only` with `compose`. e.g.
@greggirwin
greggirwin / join-combine.red
Created August 8, 2018 20:57
Red JOIN/COMBINE mezzanine ideas
Red []
; TBD: pair tuple
combine: func [
"Merge values, modifying a if possible"
a "Modified if series or map"
b "Single value or block of values; reduced if `a` is not an object or map"
][
if all [block? :b not object? :a not map? :a] [b: reduce b]
case [
@greggirwin
greggirwin / foreach-face-probe.red
Created August 2, 2018 18:44
Red foreach-face examples
win: layout [
title "VID test"
;below
text "Hello"
button "Hello" 100x40 [bar/data: random 100%]
button "World"
return
button "China"
text "Red Language" 100 right
@greggirwin
greggirwin / bezier-tweens.red
Last active July 28, 2018 21:02 — forked from toomasv/bezier-tweens.red
Bezier `curve`-based tweening
Red [
Author: "Toomas Vooglaid"
Date: 2018-07-27
Purpose: {Study of bezier-based tweens}
File: %bezier-tweens.red
Needs: 'View
]
down-flags: [down1? down2? down3? down4? b1-down? b3-down?] ;down?
clear-down-flags: does [set down-flags off]
@greggirwin
greggirwin / get-fonts-windows.r
Created June 23, 2018 21:23
Rebol2/R2 font requestor
;do/args %./fonts/fonts-startup.r %get-fonts-windows.r
;request-font
REBOL [
Title: "get-fonts-windows"
Date: 29-Sep-2002
Name: 'get-fonts-windows
Version: 0.1.0
File: %get-fonts-windows.r
Author: "Gregg Irwin"
@greggirwin
greggirwin / string-conversion-table-gen.red
Created May 31, 2018 00:19
Red string conversion table generator
Red []
; alphabetical datatype listing
; set 'datatype-single-test-values compose [
; action! (:add)
; binary! #{}
; bitset! #[bitset! #{}]
; block! []
; char! #"A"
; closure! (closure [a b] [])
@greggirwin
greggirwin / form-mold-test-gen.r
Created May 30, 2018 23:58
R3 FORM/MOLD table generator.
REBOL []
; alphabetical datatype listing
; set 'datatype-single-test-values compose [
; action! (:add)
; binary! #{}
; bitset! #[bitset! #{}]
; block! []
; char! #"A"
; closure! (closure [a b] [])
@greggirwin
greggirwin / Rebol N-Queens
Created May 30, 2018 23:44
The N-Queens problem, with a different approach
REBOL [
Title: "n-queens"
Author: "Gregg Irwin"
Comment: {
I just cooked this up in my head. It could fail miserably in some cases.
The special N // 6 = 2 case isn't something I discovered, but the
"pathing" algorithm used is mine.
}
]
@greggirwin
greggirwin / r2-rule-stuff.r
Created April 30, 2018 18:44
OLD [2002] rule/logic tinkerings
(is-a horse comet) ;; Comet is a horse
(is-a-parent-of comet prancer) ;; Comet is a parent of Prancer
Comet is a horse
Comet is a parent of Prancer
rule [
name
antecedents