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 / gedcom-parser.red
Last active October 23, 2019 18:03
GEDCOM parser example (basic)
Red [
references: http://user.it.uu.se/~andersa/gedcom/ch1.html#grammar
sample-files: [
http://heiner-eichmann.de/gedcom/gedcom.htm
http://heiner-eichmann.de/gedcom/allged.ged
]
]
gedcom_main: [some gedcom_line]
gedcom_line: [
@greggirwin
greggirwin / rmake-test-1.r
Created April 7, 2018 00:25
Old R2 MAKE dialect experiment
REBOL []
do %rmake.r
change-dir %./test-files/
spec-1: [
target %xxx.bld
depends on [%xxx-0.txt %xxx-1.txt]
@greggirwin
greggirwin / gui-dropper-2.red
Created March 12, 2018 00:34
GUI dropper 2 (drop real faces)
Red [
Purpose: "Show how to drop (real) faces to make a GUI."
]
btn-pos: 700x10
n: 0
view [
size 800x600
@greggirwin
greggirwin / gui-droppper.red
Created March 9, 2018 07:23
Show how to drop loose faces and generate a layout from them.
Red [
Purpose: "Show how to drop faces to make a GUI and save it."
]
spec: copy []
btn-pos: 700x10
n: 0
@greggirwin
greggirwin / draw-red-logo.red
Created February 22, 2018 23:20
Draw commands for Red logos.
Red []
view [
base 200x336 white draw [
pen #eeac29
fill-pen #eeac29 polygon 100x2 100x65 72x49
fill-pen #bc822d polygon 100x2 100x65 128x49
pen #d41c18
fill-pen #d41c18 polygon 100x84 100x146 37x109 64x63
@greggirwin
greggirwin / typed-multiple-dispatch.red
Created February 18, 2018 19:25
Typed multiple dispatch in Red, per CLOS and PMD chat.
Red []
collect-values: func [
"Collect values in a block, by datatype or custom parse rule"
block [block!]
rule "Datatype, prototype value, or parse rule"
/deep "Include nested blocks"
][
rule: switch/default type?/word rule [
datatype! block! typeset! [rule] ; Blocks and typesets (e.g. any-word!) work directly as rules.
@greggirwin
greggirwin / include-example.red
Last active February 3, 2018 19:31
Red #include example
Red []
#include %include-me.red
print incl-int
print mold incl-str
img: load/as incl-img 'png
view [image img]
@greggirwin
greggirwin / sets.red
Created January 12, 2018 23:16
Red set operation mezzanines (unique, intersect, etc.)
Red [
Title: "Red set-related functions"
Author: "Gregg Irwin"
File: %sets.red
Tabs: 4
Rights: "Copyright (C) 2013 All Mankind. All rights reserved."
License: {
Distributed under the Boost Software License, Version 1.0.
See https://github.com/dockimbel/Red/blob/master/BSL-License.txt
}
@greggirwin
greggirwin / toomasv-color-picker.red
Created January 11, 2018 18:15
Mod of @toomasv's color picker
; The original is at https://gist.github.com/toomasv/19e45ce2cbd7dc213548400fcdec1f8b
context [
colors: exclude sort extract load help-string tuple! 2 [glass]
lay: copy [
style color: base 70x70 font [size: 8] wrap top on-down [
write-clipboard form face/extra
tx/data: rejoin [
"Color '" face/extra "' (" get face/extra ") copied to clipboard!"
]
@greggirwin
greggirwin / map-slider-to-range.red
Last active December 12, 2017 22:00
Map slider values to other ranges in Red
Red []
linear-interpolate: func [
src-min [number!]
src-max [number!]
dest-min [number!]
dest-max [number!]
value [number!]
][
add dest-min ((value - src-min) / (src-max - src-min) * (dest-max - dest-min))