Skip to content

Instantly share code, notes, and snippets.

View rebolek's full-sized avatar

Boleslav Březovský rebolek

  • 15:37 (UTC +02:00)
View GitHub Profile
@rebolek
rebolek / where.red
Last active February 16, 2018 14:58
Find where function is defined
Red[
Title: "Where"
Purpose: "Find where function is defined"
Author: "Boleslav Březovský"
]
where: function [
"Return file where function is defined or NONE, if the definition can't be found"
'name
/in
@rebolek
rebolek / test
Created February 13, 2018 08:13
```
mal-scalar: [
any whitespace [
p: (probe p)
"nil" keep ('nil)
| "true" keep ('true)
| "false" keep ('false)
| tmp: mal-number keep (to-integer tmp)
| tmp: mal-string keep (tmp)
| tmp: mal-keyword keep (to-get-word tmp)
Red[]
count-lines: func [
filename
/local
file count ws
][
ws: charset " ^-"
file: read/lines filename
count: 0
console.log("%main.js");
rooms = null;
users = null;
// load room names
load_rooms = function (){
d3.csv("data/room-list.csv", function(error, data) {
if (error) throw error;
console.log("loading rooms");
Red[]
reduce+: func [
"Reduce with unset!, error! -> none! conversion"
block
/local value new-block
][
new-block: block
collect [
until [
@rebolek
rebolek / base32.red
Created August 16, 2017 20:18
Base 32 encoder and decoder
Red [
file: %base32.red
date: 17-Sep-2015
author: "Graham Chiu"
red-version: "Boleslav Březovský"
version: 0.0.3
notes: {
encodes string to base32 or base32hex
padding to 5 characters is not required in this method
>> to-base32/decode/hex to-base32/hex "yessir"
Red [
Title: "Replace with /CASE support"
]
replace: func [
"Returns the series where a value is found, or NONE. "
series [series!]
pattern
value
/all
@rebolek
rebolek / join.red
Last active February 7, 2018 10:11
Red[]
join: func [
"Reduce values in a block and joins them into a string"
block [block!]
/with "Add delimiter between values"
delimiter
/trim "Remove NONE values"
] [
if empty? block [return ""]
@rebolek
rebolek / nsource.red
Last active June 19, 2019 20:11
Provides source of Red native functions
Red [
Title: "Nsource - native source"
Purpose: "Print source for native functions"
Author: "Boleslav Březovský"
Date: "8-6-2017"
]
indent: func [
"(Un)indent text by tab"
string [string!] "Text to (un)indent"
@rebolek
rebolek / incredidle.red
Created May 15, 2017 17:12
Simple tool to show how faces work
Red []
inc-value: func [
face
color-id
dest-face
/local value rate
] [
unless face/extra [face/font/color: 255.255.255]
overflow?: false