Skip to content

Instantly share code, notes, and snippets.

View rgchris's full-sized avatar

Christopher Ross-Gill rgchris

View GitHub Profile
@rgchris
rgchris / find-word.md
Last active April 26, 2019 20:17
Find whole words in a string

This was my response to a question Explaining Parse Rules on RebolForum wrt. matching whole words in a string.

"The input string can contain any number of delimiters, followed by the word we are searching for, and then any delimiter or else the end of the string. If we find the word, return ??? what exactly? Or, if we don't find the word, then there can be any characters or delimiters to the end. (And then what does the "end skip" do?)

I should start by saying that I don't normally use return in this way: I don't much for return at all, rather let all the branches play out to their conclusion. I used it here for expediency.

The problem here is defined as 'whole words'--we need to discern what a whole word is. In Regex, you might write /\bWordToMatch\b/ with that handy little \b shorthand which is a zero-width match between a stream of \w (word) chara

@rgchris
rgchris / minimal-epub.reb
Last active December 31, 2021 01:34
Build a minimal EPUB in R3C
#!/usr/local/bin/ren-r3c
Rebol [
Title: "Package a Minimal eBook"
Date: 5-Feb-2019
Author: "Christopher Ross-Gill"
Rights: http://opensource.org/licenses/Apache-2.0
Home: https://gist.github.com/rgchris/14e4ce92b1830f8295a1824cbe1628a7
Notes: [
https://ebooks.stackexchange.com/a/1184
@rgchris
rgchris / deep-list.reb
Last active February 5, 2019 04:50
Return a list of a folder's content (recursive)
Rebol [
Title: "Return a listing of a folder's content"
Date: 4-Feb-2019
Author: "Christopher Ross-Gill"
Rights: http://opensource.org/licenses/Apache-2.0
]
deep-list: func [
source [file!]
/hidden /folders
@rgchris
rgchris / svg-experiments.red
Last active January 26, 2019 23:50
Some SVG functions in Red
#!/usr/local/bin/red
Red [
Title: "Parse SVG"
Date: 23-Dec-2018
Author: "Christopher Ross-Gill"
Rights: http://opensource.org/licenses/Apache-2.0
]
; do %altxml.red
@rgchris
rgchris / events.r
Created January 26, 2019 01:54
Experiments with Rebol/View 2.7.8
#!/usr/local/bin/rebview -iqvs
Rebol [
Title: "Events Test"
Date: 12-Dec-2018
Author: "Christopher Ross-Gill"
File: %events.r
Version: 0.1.0
Comments: {
- Linkify Face (http://www.ross-gill.com/page/Beyond_Regular_Expressions)
@rgchris
rgchris / right-align.red
Last active January 23, 2019 19:43
Right-align some TSPANs using Red's SIZE-TEXT to measure each line
#!/usr/local/bin/red
Red [
Title: "Right Aligned Text"
Date: 23-Jan-2019
Author: "Christopher Ross-Gill"
]
font-weight: 'bold
font-size: 30
@rgchris
rgchris / libred.test.r
Last active December 28, 2018 23:21
Attempt to CALL libRed from Rebol 2
#!/usr/local/bin/rebview -iqvs
Rebol [
Title: "libRed Test"
Author: "Christopher Ross-Gill"
Date: 19-Dec-2018
]
libred: make object! [
library: load/library %libRed.dylib
@rgchris
rgchris / json-server.r
Created December 19, 2018 22:34
Small JSON server for Rebol 2
Rebol [
Title: "JSON Server"
Date: 19-Dec-2018
Author: "Christopher Ross-Gill"
]
do http://reb4.me/r/altjson
do http://reb4.me/r/httpd
data: [ ; in lieu of CSV data, from Rebol in Ten Steps
@rgchris
rgchris / linkify-face.r
Last active December 18, 2018 02:46
Add links to text face for Rebol 2
Rebol [
Title: "Link Up"
File: %linkify-face.r
Version: 0.0.1
Home: http://www.ross-gill.com/page/Beyond_Regular_Expressions
Date: 8-Aug-2010
Purpose: "To identify URIs in face/text and overlay with links"
Author: "Christopher Ross-Gill"
]
@rgchris
rgchris / gravatar.r
Last active December 20, 2018 01:48
Gravatar Lookup for Rebol and Red
Rebol [
Title: "Get Gravatar"
File: %gravatar.r
Date: 27-Nov-2012
Purpose: "Generate Gravatar Profile Image URLs"
]
gravatar: use [to-md5][
to-md5: func [val [any-string!]][
lowercase enbase/base checksum/method to binary! lowercase trim form val 'md5 16