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 / dyn-tab-panel.red
Created December 11, 2017 21:39
Red dynamic tab panels
Red [needs: view]
detail-tab: first layout/only [panel [text "hello"]]
toggle-detail: function [state [logic!]][
either state [
insert at tabs/data 2 "Detail"
insert at tabs/pane 2 detail-tab
][
remove at tabs/data 2
@greggirwin
greggirwin / chess.red
Last active December 8, 2017 03:14
Edward DeJong's Chess Challenge in Red
Red [
title: "Edward de Jong's Chess Challenge"
author: ["Gregg Irwin"]
]
; This may prove useful as more logic is added. Right now it's not a big win.
array: function [
"Makes and initializes a block of of values (NONE by default)"
size [integer! block!] "Size or block of sizes for each dimension"
/initial "Specify an initial value for elements"
@greggirwin
greggirwin / requesters.red
Last active February 6, 2020 21:41
Red requesters (alert, confirm, prompt, etc.)
Red [
author: ["Gregg Irwin"]
notes: {
Experimental requesters, for design discussion. Not just about the
implementation, but about modal vs modeless dialogs. I think there's
value in the simple, modal approach, but we probably want to provide
more advanced options. e.g. document/sheet modal, and mobile standard
approaches.
TBD: Determine if we want to build everything on inner funcs that are
@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
@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 / 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 / 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 / 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 / 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 / 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.