Skip to content

Instantly share code, notes, and snippets.

@staltz
staltz / introrx.md
Last active May 24, 2024 07:56
The introduction to Reactive Programming you've been missing
@gregmac
gregmac / signtool.msbuild.tasks
Created December 12, 2014 01:40
SignTool MSBuild Task
<!--
Sign .exe files using signtool.exe.
(c) 2014 Greg MacLellan, Licensed under MIT http://opensource.org/licenses/MIT
Features:
* Hides password from being displayed in build output
* Retries against multiple timestamp servers if the server returns an invalid response (fairly common)
Usage:
Red [
Title: "Tile game"
Purpose: {An implementation in Red of the 4x4 sliding tile puzzle}
Author: "Rudolf W. MEIJER (meijeru)"
File: %tile-game.red
Needs: 'View
Usage: {
Click on any tile that is adjacent to the empty space
and it will shift to that space.
Try to obtain a given configuration, e.g. 1 to 15 in order.
@greggirwin
greggirwin / arity-of.red
Last active April 12, 2021 17:47
Red arity-of function
; We have other reflective functions (words-of, body-of, etc.), but
; this is a little higher level, sounded fun to do, and may prove
; useful as we write more Red tools. It also shows how to make your
; own typesets and use them when parsing.
arity-of: function [
"Returns the fixed-part arity of a function spec"
spec [any-function! block!]
/with refs [refinement! block!] "Count one or more refinements, and add their arity"
][
@greggirwin
greggirwin / greggs-mezz.red
Last active June 21, 2018 18:54
A bunch of general purpose mezzanine funcs for Red.
Red [
File: %greggs-mezz.red
Author: "Gregg Irwin"
Purpose: "An interim mezzanine dump, while Red is still moving fast."
Tabs: 4
Comment: {
Not everything here has been well-tested or, well, tested. Most
of the functions are ports from R2, with many more to come. I'm
combining everything in one file for ease of experimentation, so
you don't have to worry about includes or dependencies with the
@DideC
DideC / Livecode enhanced
Last active February 20, 2018 19:32
Based on Dockimbel VID livecode, this is a little more advanced version where you can define Red's values used by the VID code. The window is resizable and there is spliters to rearange space.
Red [
Title: "Simple GUI livecoding demo"
Author: "Nenad Rakocevic / Didier Cadieu"
File: %livecode.red
Version: 1.2.1
Needs: 'View
Usage: {
Type VID code in the bottom right area, you will see the resulting GUI components
rendered live on the left side and fully functional (events/actors/reactors working live).
The top right area let you define Red's values to be used in your VID code, even functions or anything.
@greggirwin
greggirwin / *-while.red
Last active March 27, 2017 23:04
Various <action>-while example funcs for Red.
; A number of languages have `take-while/drop-while` funcs. This is just to show how you
; can build them in Red.
; This model can be applied to any function that has a `/part` refinement, or extended in
; any number of ways. We don't yet have a standard `apply` or `refine` function in Red.
; Once we do, a more general HOF version could take the action as an arg, as well as the
; test to apply.
; Should this return the position, like FIND, rather than an integer?
; No match would then mean a NONE result. REMOVE/TAKE/COPY with /PART
@dockimbel
dockimbel / to-Roman.red
Last active October 12, 2016 20:16
Arabic to Roman numbers converter in Red
Red [
Purpose: "Arabic to Roman numbers converter"
Date: "06-Oct-2016"
]
table: [1000 M 900 CM 500 D 400 CD 100 C 90 XC 50 L 40 XL 10 X 9 IX 5 V 4 IV 1 I]
to-Roman: function [n [integer!]] reduce [
'case collect [
foreach [a r] table [
@greggirwin
greggirwin / world-sim-blocks.red
Last active December 14, 2016 05:53
A simple simulator thought experiment, using blocks as the main data structure
Red [
author: "Gregg Irwin"
]
comment {
From Gitter, @this-gavagai asked about modeling in Red compared to modeling
in traditional OOP languages. Here's the concrete example given:
"
Imagine you wanted to simulate economic dynamics in a third world village. You
@PeterWAWood
PeterWAWood / typing.red
Last active February 12, 2019 20:55
Entering text into Notepad from Red
Red []
#system [
chr: 1
handle: 0
KEYDOWN: 0
KEYUP: 2
minus-one: -1
pointer-to-minus-one: :minus-one
rs-phrase: ""