Skip to content

Instantly share code, notes, and snippets.

View dockimbel's full-sized avatar

Nenad Rakocevic dockimbel

View GitHub Profile
@luce80
luce80 / dates-calcs.red
Last active November 26, 2017 08:20
Some useful functions for calculations of dates
Red [
Author: "luce80"
Licence: 'PD
]
; from https://en.wikipedia.org/wiki/Julian_day
julian-day-number: func [day month year /local a y m] [ ; in Red 0.6.2, integer calcs give integer result so we could remove to-integer(s)
; TBD check params
a: to-integer 14 - month / 12
y: year + 4800 - a
@meijeru
meijeru / arith.txt
Last active September 6, 2017 15:36
Types of artihmetic operations
Updated to Red for Windows version 0.6.2 built 7-Jun-2017/15:13:57+2:00
The table gives type of first operand, type of second operand, result type
for + (add), - (subtract), * (multiply), / (divide), // (modulo) and % (remainder)
For vectors, the element type is distinguished.
There is one case (time with time) where the result type is not the same
for all allowed operations.
After each type combination, the reverse combination is given.
The fourth column gives the operators for which the combination is forbidden.
If the result type is error, the combination is forbidden for all operators.
@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
@toomasv
toomasv / regex.red
Last active November 20, 2017 18:22
Regex to parse translator
Red [
Author: "Toomas Vooglaid"
file: "%regex.red"
Purpose: {Regex to parse converter}
History: {Started: 2017-05-09
v.0.1: 2017-05-12 -- first working version with:
start `^^` and end `$` anchors,
non-capturing groups (one level) with alterns,
quantifiers (possessive),
some character-classes.
@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 { }]]
Red [
author: {Maxim Velesyuk}
description: {draw dialect playground}
]
demo: trim {
fill-pen gray
box 0x0 400x400
do [c: to-tuple reduce [
random 255 random 255 random 255]
Red [
description: {simple game}
author: {Maxim Velesyuk}
version: 2.2
changelog: {
2.2
* added sleep to the loop to reduce CPU load
2.1
* added win screen display time
@maximvl
maximvl / poor-mans-scopes.red
Last active August 14, 2019 12:30
Dynamic variables in Red
Red [
author: "Maxim Velesyuk"
description: "Dynamic variables implementation for Red"
]
; utils
forskip: func ['series skipn body /local s] [
s: get series
while [ not tail? s ] [
do body
@meijeru
meijeru / split-url.red
Last active May 8, 2017 21:46
Split a url! value into components
Red [
Title: "URL splitter"
Purpose: {split a url into its compoments}
Author: "Rudolf W. MEIJER"
File: %split-url.red
Version: 0.2.0
Date: "02-Apr-2017"
Rights: "Copyright (c) Rudolf W. MEIJER"
History: [
[0.0.0 "25-Mar-2017" {Start of project}]
@maximvl
maximvl / restarts.red
Last active August 14, 2019 12:30
CL condition-restarts in Red
Red [
author: "Maxim Velesyuk"
description: "Common Lisp condition-restart system implementation for Red"
]
; utils
*word-counter*: 0
gen-word: does [
*word-counter*: *word-counter* + 1
to-word append "G-" to-string *word-counter*