Skip to content

Instantly share code, notes, and snippets.

View greggirwin's full-sized avatar

Gregg Irwin greggirwin

  • Redlake Technologies
View GitHub Profile
@toomasv
toomasv / replace-each.red
Last active April 13, 2020 12:03
Replace several items in one run + example converters
Red [
Description: {Replace several items in one run + example conversions}
Date: 27-Mar-2020
Author: "Toomas Vooglaid"
]
context [
sp: charset " ^-"
sp*: [any sp]
digit: charset "0123456789"
integer: [some digit]
@toomasv
toomasv / named-color-picker.red
Last active February 29, 2020 04:14
Pick named Red-colors and Web-colors
Red [
Date: 28-Feb-2020
Description: "Another color-picker with named Red-colors and Web-colors"
Licence: "Public domain"
File: %named-color-picker.red
Idea: https://gitter.im/red/red/gui-branch?at=5e58287f4eb23e6ae179f475
]
context [
red-colors: split replace/all lowercase trim help-string tuple! [some [#" " | #"^/"]] #" " #" "
remove back tail red-colors
@toomasv
toomasv / m2-pricing.red
Last active November 22, 2019 22:38
Little unit handling dialect
Red [
Description: "Exercise in limited unit handling"
Date: 22-Nov-2019
Author: "Toomas Vooglaid"
Licence: "Public domain"
]
context [
digit: charset "0123456789."
num: [some digit]
unit: ["$/m2" | #"$" | "m2"]
http://news.e-scribe.com/193
To move, you tell the computer how many numbers (counting from the left) to reverse.
For example, if the current list is 2 3 4 5 1 6 7 8 9 and you reverse 4,
the result will be 5 4 3 2 1 6 7 8 9. Now if you reverse 5, you win.
• Comment from Pascal
Funny game, here is a REBOL version of this game. An interesting thing is its readability.
numbers: random ordered: [1 2 3 4 5 6 7 8 9]
@toomasv
toomasv / form-to.red
Last active November 3, 2022 06:33
Form number to given precision
Red [
Description: "Form number to given precision"
Date: 2019-0-13
]
form-to: func [
"Form number to a given floating-point precision"
number [number!] "Number to be formed"
precision [integer!] "Decimal places (positive integer)"
/local pcnt?
][
@toomasv
toomasv / autoselect
Last active October 13, 2019 22:11
Dropdown autoselect mimick
Red [
Description: "Drop-down autoselect"
]
blk: [
["Blog" http://www.red-lang.org]
["About" https://www.red-lang.org/p/about.html]
["Getting Started" https://www.red-lang.org/p/getting-started.html]
["Download" https://www.red-lang.org/p/download.html]
["Documents" https://www.red-lang.org/p/documentation.html]
["Contributions" https://www.red-lang.org/p/contributions.html]
@toomasv
toomasv / quat.red
Created September 21, 2019 18:40
Some quaternion manipulation funcs
Red [
Description: {Some quaternion manipulation funcs}
Date: 21-Sep-2019
Author: "Toomas Vooglaid"
]
quaternion: context [
quaternion!: make typeset! [block! hash! vector!]
e-pow: function [q][
sc: x: y: z: none
set [sc x y z] q
@meijeru
meijeru / check-update.red
Created September 20, 2019 12:02
Check for update to the Red executable
Red [
Title: {Update checker}
Purpose: {Check for update to Red executable}
Author: "Rudolf W. MEIJER"
File: %check-update.red
Rights: "Copyright (c) 2019 Rudolf W. MEIJER"
Language: 'English
Tabs: 4
]
@toomasv
toomasv / gen-hack2.red
Last active August 17, 2019 03:27
(de)randomize argument
Red [
Date: 16-Aug-2019
See: {[August 15, 2019 9:56 PM](https://gitter.im/red/red?at=5d55aacd4e17537f5239de0c) forward}
Description: {Combined from @grggirwin's and @dockimbel's with some spice}
]
gen-hack2: function [
{Generates randomly suffled copy of the argument and the seed to get it stright}
secret [any-string! any-block! binary!]
][
random/seed stats
@dockimbel
dockimbel / surprise-msg.red
Last active August 15, 2019 21:47
Red generator for encoded messaged
Red [
Purpose: {
Red generator for encoded messaged as in:
http://www.rebol.com/oneliners.html#section-17
}
]
gen-hack: function [secret [string!]][
;-- First build a list of integers from 1 to the last index of the secret string
table: collect [repeat i len: length? secret [keep i]]