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 / rawk.r
Created July 29, 2017 20:16
RAWK in R2
REBOL [
Title: "AWK in REBOL"
File: %rawk.r
Author: "Gregg Irwin"
Version: 0.0.8
Comment: {
Inspired by AWK. The core design is very appealing to me: a data
driven app that processes text files automatically iterating over
files and lines, and splitting lines up into fields. I don't care
for much of the AWK syntax, though, so I'm not shooting for
@greggirwin
greggirwin / rgrep.r
Created July 29, 2017 20:17
RGrep (Rebol Grep)
REBOL [
Title: "Grep in REBOL"
File: %rgrep.r
Author: "Gregg Irwin"
Version: 0.0.2
Comment: {
rgrep searches one or more input files for lines containing a match
to a specified pattern. Refinements on EXEC are a shot at familiar
switches used with GREP. Not sure if we need them, though /quiet does
allow a nice optimization as we can break out on the first match.
@greggirwin
greggirwin / red-object-browser.red
Last active October 16, 2020 17:48
Red Object Browser
Red [
title: "Red Object Browser"
author: "Gregg Irwin"
needs: 'View
]
e.g.: :comment
map-ex: func [
"Evaluates a function for all values in a series and returns the results."
@greggirwin
greggirwin / spline-with-variable-nubs.red
Created August 16, 2017 17:51
Spline demo with slider to control number of nubs
Red [
Title: "Spline demo"
Author: "Xie Qingtian, Nenad Rakocevic"
File: %spline.red
Needs: 'View
Date: "22/06/2016"
License: "MIT"
Notes: {
This simple spline tool allows you to drag the control points position
using the mouse, and see the spline's shape change accordingly.
@greggirwin
greggirwin / compare-times.red
Last active October 28, 2017 22:23
compare-times perf test idea for Red
; Stats added by @toomasv
compare-times: func [
blocks "Block of code blocks to performance compare"
/count ct
/local t n baseline res blk stats1 memory time code template
][
ct: any [ct 1]
t: now/time/precise
loop ct [do []]
baseline: now/time/precise - t
@greggirwin
greggirwin / win-calc.red
Created September 12, 2017 16:11
Win7 Calculator basic layout
Red []
view [
style calc-btn: button 34x28
style fn-btn: calc-btn
style fn-btn*: calc-btn font-name "Symbol"
style num-btn: calc-btn white
across
space 4x4
@greggirwin
greggirwin / bounds+range.r
Created September 26, 2017 21:26
R2 `bounds` and `range` funcs
rebol []
; TBD - how to handle an unspecified end value? What to return for it?
; 4.. 12-
; Should time! values be taken as time ranges or should 3:5 be
; the same as [3 to 5]?
; Should we take a series value so we can get the length of it,
; or should we return a special token for the caller to apply?
; What about multiple range specs? [1..4 6..9 12..15]
; What about other separators
@greggirwin
greggirwin / pekrs-news-scroller.red
Last active October 19, 2017 18:31
Pekr's News Scroller, converted to DRAW
Red [
Title: "Simple news scroller"
Author: "@pekr, updated by Gregg Irwin"
]
;system/view/auto-sync?: no
screen-size: system/view/screens/1/size
news-bottom-offset: 0x100
news-height: 0x100
@greggirwin
greggirwin / profile.red
Last active December 28, 2020 06:17
Basic profiling for Red code comparisons
Red []
e.g.: :comment
delta-time: function [
"Return the time it takes to evaluate a block"
code [block! word! function!] "Code to evaluate"
/count ct "Eval the code this many times, rather than once"
][
ct: any [ct 1]
@greggirwin
greggirwin / composite.red
Last active May 16, 2019 17:14
Composite func (compose for strings) for Red
Red [
Author: [@greggirwin @endo @toomasv @hiiamboris]
Purpose: "COMPOSE for strings"
Notes: {
TBD: Security model for eval'ing expressions
TBD: Decide if support for custom marker and eval contexts are worthwhile
TBD: Finalize refinement names
TBD: Decide if suport for function contexts is worthwhile
TBD: Make it a macro?
TBD: Decide if file and url params should be read automatically