Skip to content

Instantly share code, notes, and snippets.

View greggirwin's full-sized avatar

Gregg Irwin greggirwin

  • Redlake Technologies
View GitHub Profile
@9214
9214 / scrape.red
Last active April 28, 2024 16:16
The world's smallest web scraper.
Red [
Title: "A Parse-based port of Michael Gilliland's web scraper"
Author: @9214
Date: 16-Oct-2020
Link: https://youtu.be/HDMa4gcgEgI
]
page: read-thru/binary to url! system/script/args
link: [copy match [ahead https:// url!]]
rule: [collect any [link keep (to url! match) | skip]]
@hiiamboris
hiiamboris / into.red
Last active February 22, 2023 18:49
Could INTO be a separate function without breaking the language semantics and/or vastly complicating the interpreter?
Red [title: "An experiment with INTO separation"]
; do %/d/devel/red/common/with.red
buffers*: []
into: func [buffer [series!]] [append/only buffers* buffer exit]
collect': function [code [block!]] [
also buffer: any [
take/last buffers*
@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 / thru.red
Last active February 22, 2022 07:18
Like `range`, but op!
Red [
Author: "Toomas Vooglaid"
Date: 2018-12-11
Improvements: @9214
]
thru: make op! func [a b /local inc op cmp][
inc: pick [1% 1] percent? a
set [op cmp] reduce pick [[:+ :<][:- :>]] a < b
collect [until [keep a b cmp a: a op inc]]
]
@toomasv
toomasv / dir-tree.red
Last active January 6, 2022 11:30
Print a directory tree
Red [
Author: "Toomas Vooglaid"
Date: "2017-05-07"
Changed: "2018-07-09"
Purpose: "Print a directory tree"
File: "%dir-tree.red"
]
context [
; Some helpers
get-char: func [hex][to-char to-integer hex]
@giesse
giesse / profile-gab.red
Last active November 20, 2021 19:13
profile function for Red (two variants)
Red []
e.g.: :comment
; ideally not exported on the global context
delta-time*: function [code count] [
start: now/precise
loop count code
difference now/precise start
]
@toomasv
toomasv / rtbox.red
Last active September 19, 2021 09:16
Red [
Author: "Toomas Vooglaid"
Started: 2018-05-01
Purpose: "First steps into rich-text box"
]
ctx: context [
env: self
start: end: 1
diff: 0
dbl: no
@q60
q60 / red.rst
Last active August 16, 2021 18:02
Red shields.io badges

badge

Click on any of these to get url

@dockimbel
dockimbel / eval2.red
Created April 3, 2018 10:12
Test script for Red/View Android backend
Red [
Title: "Red Android bridge demo"
Author: "Nenad Rakocevic"
File: %eval2.red
Config: [type: 'dll libRed?: no libRedRT?: yes export-ABI: 'cdecl]
Tabs: 4
Needs: 'View
Rights: "Copyright (C) 2013-2017 Nenad Rakocevic. All rights reserved."
License: {
Distributed under the Boost Software License, Version 1.0.
@toomasv
toomasv / intermediate.red
Last active June 25, 2021 10:07
Show intermediate values of expression in console
Red [
Description: "Show values of intermediate expressions"
Date: 12-Jun-2020
]
term: gui-console-ctx/terminal
show: function [][
out2: copy [] out: pos: copy []
found: find/tail term/line "show "