Skip to content

Instantly share code, notes, and snippets.

View rgchris's full-sized avatar

Christopher Ross-Gill rgchris

View GitHub Profile
@rgchris
rgchris / walker.md
Last active May 5, 2025 14:13
Tree iterator

Tree-Walking Iterator

This script features an iterated method of traversing a tree-structure (specifically, a tree created by the Rebol 2 mezzanine PARSE-XML). The iterator returns events—OPEN, CLOSE, EMPTY, and TEXT—upon request until the tree has been fully traversed.

Concept Note

Using an iterated approach to tree traversal allows for fine control of the process that can be dropped and picked up fairly intuitively, effectively reducing the traversal process to a linear stream of events useful for serialization or extraction. This stands in contrast to the callback approach that fully traverses a tree firing callback functions until the tree has been fully traversed.

@rgchris
rgchris / capture-keys.reb
Created February 2, 2023 03:44
Intercepting Key events in Rebol 2
#!/usr/local/bin/rebview -iv
Rebol [
Title: "Intercepting Key events"
Author: "Christopher Ross-Gill"
Date: 23-Feb-2017
Notes: [
https://rebolforum.com/index.cgi?f=printtopic&topicnumber=579&archiveflag=archive
]
@rgchris
rgchris / dsl-example.r2
Created January 29, 2023 19:01
DSL Example
Rebol [
Title: "DSL Example"
Author: "Christopher Ross-Gill"
Date: 29-Jan-2023
Home: https://gist.github.com/rgchris/2a227b6fa3fc9d2ae7fe729ccb09f016
]
reduce-only: func [
"Evaluates a block of expressions excepting SET-WORD! values"
@rgchris
rgchris / my-num-type.js
Last active July 20, 2022 13:22
Custom Types
// The journey to creating a new object type begins with ... a function
// * It doesn't have to be a named function (that is `function name()`
// as opposed to `name = function ()`) but there are advantages to this
// that are beyond the scope of this comment.
// * As a value, `myNumType` here serves double-duty--as a function in
// the sense of a passable first-class value, as, say, in Rebol
// * --and as a constructor for objects that use `myNumType` as a
// prototype
// * The value of `this` depends on the context in which the function
// `myNumType` is called. If you call it by itself, `this` refers to the
@rgchris
rgchris / pdf.r
Last active July 10, 2022 13:58
PDF Modeller/Constructor for Rebol 2
Rebol [
Title: "PDF Experiment"
Author: "Christopher Ross-Gill"
Date: 18-Jan-2022
Home: https://gist.github.com/rgchris
File: %pdf.r
Version: 0.1.0
Rights: http://opensource.org/licenses/Apache-2.0
Purpose: {
Build a PDF object model for atomic construction of PDF documents
@rgchris
rgchris / unzip.r
Last active January 4, 2022 19:10
Unzip for Rebol 2
Rebol [
Title: "Unzip for Rebol 2"
Date: 3-Jan-2022
Author: "Christopher Ross-Gill"
]
do %tiny-inflate.r
; obtain from
; https://gist.github.com/rgchris/d3fb5f6a6ea6d27ea3817c0e697ac25d
@rgchris
rgchris / minimal-odt.reb
Created December 31, 2021 03:55
Build a minimal ODT (ODF Text) in R3C
#!/usr/local/bin/ren-r3c
Rebol [
Title: "Package a Minimal OpenText Document"
Date: 30-Dec-2021
Author: "Christopher Ross-Gill"
Rights: http://opensource.org/licenses/Apache-2.0
Home: https://gist.github.com/rgchris/e325347625b1688a1a1fe686610c68ba
]
@rgchris
rgchris / tiny-inflate.r
Last active January 4, 2022 01:25
Tiny Inflate for Rebol 2
Rebol [
Title: "Tiny Inflate"
Date: 10-Dec-2021
Author: "Christopher Ross-Gill"
Version: 1.0.3
Type: 'module
Name: 'rgchris.inflate
Exports: [inflate]
History: [
10-Dec-2021 1.0.3 https://github.com/foliojs/tiny-inflate
@rgchris
rgchris / builder.js
Last active November 19, 2021 03:12
DOM Builder
const Bd = function (name, attrs, ...kids) {
const spaces = {
xhtml: 'http://www.w3.org/1999/xhtml',
svg: 'http://www.w3.org/2000/svg'
}
const fullname = name.split(':')
name = fullname.pop()
@rgchris
rgchris / istype.js
Last active April 2, 2021 04:54
A type-checking function in JavaScript
window.istype = function(value, explicit = false) {
let type = Object.prototype.toString.apply(value).match(
/\[object ([A-Za-z_0-9]+)\]/
)[1]
switch (type) {
case "Boolean":
case "String":
case "BigInt":
case "Undefined":