Skip to content

Instantly share code, notes, and snippets.

View dockimbel's full-sized avatar

Nenad Rakocevic dockimbel

View GitHub Profile
@dockimbel
dockimbel / gist:8a5bcf3acb470d0dd9f4dd0a07da7817
Created September 8, 2022 14:29
Simple usage example of SCROLLER widget
Red [Needs: View]
scroll-max: 100
start-pos: 0
view [
size 200x200
backdrop cyan
p: panel 100x100 [button "ok"]
do [start-pos: p/offset/y] ;-- saves initial position
@dockimbel
dockimbel / gist:cb5607b0696558d44aa4a3537e930095
Created February 8, 2022 14:13
Global space function stats per type
Red []
count: function [][
list: [native! 0 action! 0 op! 0 function! 0 routine! 0]
foreach w words-of system/words [
if pos: find list type?/word get/any w [pos/2: pos/2 + 1]
]
list
]
@dockimbel
dockimbel / gist:3ebf48b58acdb3781c6e8f7adefe2959
Created December 21, 2021 19:35
Tracing handler for extracting top expressions
Red []
detect: function [
event [word!]
code [any-block! none!]
offset [integer!]
value [any-type!]
ref [any-type!]
frame [pair!]
][
* PROLOG: when entering a function.
* EPILOG: when exiting a function.
* ENTER: when a block is about to be evaluated.
* EXIT: when current evaluated block's end has been reached.
* OPEN: when a new function (any-function!) call is pushed on stack and a new stack frame is opened.
* RETURN: when a function call has returned and its stack frame has been closed.
* FETCH: a value is read from the input block to be evaluated.
* PUSH: a value has been pushed on the stack.
* SET: a set-word is set to a value.
@dockimbel
dockimbel / surprise-msg.red
Last active August 15, 2019 21:47
Red generator for encoded messaged
Red [
Purpose: {
Red generator for encoded messaged as in:
http://www.rebol.com/oneliners.html#section-17
}
]
gen-hack: function [secret [string!]][
;-- First build a list of integers from 1 to the last index of the secret string
table: collect [repeat i len: length? secret [keep i]]
@dockimbel
dockimbel / redbox-joypad.red
Last active July 18, 2019 17:31
Rebox game in Red with gpio-powered joypad. Asset files: https://github.com/hyzwhu/redbox
Red [
Needs: View
Title: "red-box"
Author: "Huang Yongzhao"
File: %redbox.red
Tabs: 4
Version: "Alpha"
Purpose: "Famous BoxWorld! game ported to red"
Rights: "Copyright (C) 2015-2018 Red Foundation. All rights reserved."
License: {
@dockimbel
dockimbel / rloc.red
Last active January 11, 2019 09:26
Lines of code statistics from Red files
Red [
Title: "Lines of code statistics from Red files"
Author: "Nenad Rakocevic"
File: %rloc.reds
Tabs: 4
Purpose: {
Counts the number of files, lines of code and inline comments in Red/Rebol files, across folders,
filtering files using a list of suffixes and excluding files from a given list of subfolders.
}
]
@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 [
Verifying my identity on Peepeth.com 0x1e33e78b9fc22c63740b0ed0cd441acbac5109f2
@dockimbel
dockimbel / get-arguments.red
Last active October 4, 2018 04:46
Extracting current stack frame values using R/S.
Red []
get-arguments: routine [
/local
list [red-block!]
s [red-value!]
t [red-value!]
top
][
top: stack/ctop - 3 ;-- might need adjustments depending on interpreted vs compiled code.