Skip to content

Instantly share code, notes, and snippets.

@toomasv
toomasv / color-picker2.red
Last active May 9, 2019 18:28
Yet another color-picker
Red [
Description: "Yet another color-picker"
Date: 9-May-2019
]
context [
colors: []
colors2: [pen off translate 260x280 []]
i: 9
j: 256 / (i - 1)
img: none
@toomasv
toomasv / drop-to-list.red
Created February 13, 2019 09:37
Drag words from area to text-list experiment
Red [
Author: "Toomas Vooglaid"
Date: 13-Feb-2019
Purpose: {Example of dragging words from area to text-list}
]
count-nl: func [face /local text n x][
n: 0 x: face/selected/x
text: copy face/text
while [all [
text: find/tail text #"^/"
@dockimbel
dockimbel / check-brackets.red
Last active January 4, 2019 20:24
PoC script for checking if brackets/parens are matching in a Red file
Red [
Purpose: "PoC script for checking if brackets/parens are matching in a Red file"
]
check-brackets: function [file [file!]][
line: 1
stack: clear []
skip-chars: complement charset "[]()^/"
parse read file [
@toomasv
toomasv / lazy-range.red
Last active April 24, 2018 09:18
Range for on-demand evaluation
Red [
Author: "Toomas Vooglaid"
Date: 27-11-2017
]
lazy-range: function [
"Returns function that generates next value in (possibly infinite) range"
val [scalar!] "Initial value"
/step stp [scalar! block!] "By which to increment each next value"
/limit lim [integer!] "How many new values to generate"
/stop stopval [scalar! block!] "On which value to stop generation of new values; if block, then also after how may matches"
@greggirwin
greggirwin / collect-values.red
Last active February 11, 2018 04:59
Red collect-values and collect-words functions
collect-values: function [
"Collect values in a block, by type or custom parse rule"
block [block!]
rule "Datatype, prototype value, or parse rule"
/deep "Include nested blocks"
/local v
][
rule: switch/default type?/word rule [
datatype! [reduce [rule]] ; Turn a plain datatype into a parse rule for that type.
block! typeset! [:rule] ; Blocks and typesets (e.g. any-word!) work directly as rules.
@zcstarr
zcstarr / Main.html
Created May 24, 2015 23:12
Quick fix for elm-lang example Stamper Gist
<html>
<head>
<title>Embedding Elm in HTML!</title>
<script type="text/javascript" src="elm.js"></script>
</head>
<body>
<h1>Stamper</h1>
<div id="stamper" style="width:50%; height:400px;"></div>
@nellshamrell
nellshamrell / Beneath the Surface: Embracing the True Power of Regular Expressions in Ruby
Last active December 3, 2017 16:35
Resources I consulted when preparing my presentation "Beneath the Surface: Embracing the True Power of Regular Expressions in Ruby"
All of these resources were extremely valuable as I researched regex, finite state machines, and regex in Ruby. Check them out, they're full of fantastic information!
Articles
"Exploring Ruby's Regular Expression Algorithm" by Pat Shaughnessy
http://patshaughnessy.net/2012/4/3/exploring-rubys-regular-expression-algorithm
"Finite State Machines and Regular Expressions" by Eli Bendersky
http://www.gamedev.net/page/resources/_/technical/general-programming/finite-state-machines-and-regular-expressions-r3176
"Regular Expression Matching Can Be Simple and Fast" by Russ Cox
@nedzadarek
nedzadarek / trying_snippet
Last active December 15, 2015 23:19
Nothing interesting
I wanted to try this.
So I added new line.