Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am dander on github.
  • I am zentrog (https://keybase.io/zentrog) on keybase.
  • I have a public key ASCuqh1j3qQKj19_LB0DsfA2IVRSuZt1j3MjMElSu5dYUQo

To claim this, I am signing this object:

@dander
dander / find-pattern.red
Last active December 14, 2019 08:46
Searches Red source files for a parse pattern
Red [
Title: "Find pattern"
Description: "Searches Red source files for a parse pattern"
]
allow: func [any][yes]
get-files: function [
"recursively collects the full file paths for all the files in the given directory"
dir [file!] /filter "only collect files where the predicate evaluates to true" pred [function!]
@dander
dander / solarized.red
Created January 17, 2019 09:27
solarized color palette
Red [
Title: "solarized colors"
Source: https://ethanschoonover.com/solarized
Values: {
SOLARIZED HEX 16/8 TERMCOL XTERM/HEX L*A*B sRGB HSB
--------- ------- ---- ------- ----------- ---------- ----------- -----------
base03 #002b36 8/4 brblack 234 #1c1c1c 15 -12 -12 0 43 54 193 100 21
base02 #073642 0/4 black 235 #262626 20 -12 -12 7 54 66 192 90 26
base01 #586e75 10/7 brgreen 240 #4e4e4e 45 -07 -07 88 110 117 194 25 46
base00 #657b83 11/7 bryellow 241 #585858 50 -07 -07 101 123 131 195 23 51
@dander
dander / dicewords.red
Created October 2, 2018 05:27
simple GUI app which generates random passphrases from the EFF dice word list
Red [
Title: "Diceword passphrase generator"
Needs: 'View
]
word-list: https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt
words: parse load-thru word-list [collect some [keep word! | skip]]
random/seed now/precise
view [
@dander
dander / Words-and-Bindings.md
Created September 10, 2018 23:41
Attempting to produce a simple / concise explanation of words in Red

What are words?

Words form the grammar of the Red programming language. For people familiar with more mainstream languages, word! replaces keywords, variables, and operators. However, unlike other programming languages where those constructs have fixed definitions hard-wired in the compiler, in Red words are just a basic type of data. This makes the structure of a program extremely flexible.

Parts of a word!

A word! is made of up of 3 basic parts.

  • name - The symbolic representation of the word. It's just the text that you typed to create the word
  • context - This determines the meaning of the word. Just as in spoken language, a word can change its meaning depending on the context. In Red, a context is a mapping of words to their meanings.
@dander
dander / Macros.md
Created February 8, 2018 21:18
JacobGood1's macros page

Macros(SPEL:-semantic-programming-enhancement-logic).md First of all, I advocate we call macros SPELs in order to get rid of the confusion when people come from other languages. This will also allow people who want to write tutorials about such a feature to easily(or more easily) google the word SPEL over macro. My recommendation of SPEL is not my own idea it comes from Conrad Barski: http://www.lisperati.com/no_macros.html

Shen, a dialect of lisp, will be what is used for spel examples. I will try to explain the syntax in order for readers of this wiki to be able to absorb the idea of spels. Come to this channel for questions, comments, approvals, disapprovals, or whatever else: https://gitter.im/red/red/lisp

We will begin(and end) by discussing two examples: max and thread.

In Shen, one defines a function at the repl like so...

@dander
dander / profile.red
Created November 14, 2017 06:21 — forked from greggirwin/profile.red
Basic profiling for Red code comparisons
Red []
e.g.: :comment
delta-time: function [
"Return the time it takes to evaluate a block"
block [block! word! function!] "Block to evaluate"
/count ct "Eval the block this many times, rather than once"
][
ct: any [ct 1]
@dander
dander / generators.red
Last active August 27, 2020 07:29
An experiment to make a general purpose generator-creating function
Red [
Title: "generator function experiments"
Author: "Dave Andersen"
Date: 27-Sep-2017
]
reload: does [do system/options/script]
; @JacobGood's closure func
closure1: func [
@dander
dander / range-generator.red
Created April 26, 2017 06:04
lazy range enumeration
Red [
Title: "range generator attempt (4?)"
]
; @JacobGood's closure func
closure: func [
vars [block!]
spec [block!]
body [block!]
][
@dander
dander / redLib.linq
Created February 17, 2017 09:10
LINQPad "hello libRed" script
<Query Kind="Program">
<Reference>&lt;RuntimeDirectory&gt;\System.Runtime.InteropServices.dll</Reference>
<Namespace>System.Runtime.InteropServices</Namespace>
</Query>
void Main()
{
redOpen();
redDo("view [text {hello, libRed!}]");
}