Skip to content

Instantly share code, notes, and snippets.

@x8x
x8x / clean-path.red
Last active February 11, 2020 16:02
Alternative clean-path to fix some issues.
Red []
clean-path: func [{Cleans-up '.' and '..' in path; returns the cleaned path}
path [file! url! string!]
/only "Do not prepend current directory"
/dir "Add a trailing / if missing"
/local count e file is-root? is-url? items out prefix s
][
count: 0
@x8x
x8x / colors.red
Last active October 22, 2018 20:52
Console colors
Red []
join: func ["Concatenate values"
a "Coerced to string if not a series, map, or object"
b {Single value or block of values; reduced if a is not an object or map}
][
if all [block? :b not object? :a not map? :a] [b: reduce b]
case [
series? :a [append copy a :b]
map? :a [extend copy a :b]
@x8x
x8x / Rebol.plist
Created March 10, 2018 00:29
TM-rebol-syntax
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>r</string>
</array>
<key>foldingStartMarker</key>
<string>\[{?(\s*;.*)*$</string>
@x8x
x8x / code.red
Last active December 30, 2017 10:11
Improved ls and some utilities functions (TESTED on Linux and macOS only)
Red []
#if config/OS <> 'Windows [
colors: [black red green yellow blue magenta cyan white]
;https://en.wikipedia.org/wiki/ANSI_escape_code
color: function [s f /bg b /space][
o: clear {}
s: form s
if space [s: rejoin [{ } s { }]]
@x8x
x8x / build-console.red
Last active June 1, 2017 06:14
Linux and macOS console history + init script:
Red []
;short version utils:
join: func[a b][append copy a b]
delete: func[f][call/wait rejoin ["rm '" f "'"]]
#include %console.red
system/options/home: join to-file get-env "HOME" %/