Skip to content

Instantly share code, notes, and snippets.

View dockimbel's full-sized avatar

Nenad Rakocevic dockimbel

View GitHub Profile
@dockimbel
dockimbel / unicode.reds
Last active August 29, 2015 13:56 — forked from meijeru/unicode.reds
FIX: typo in 66536 (should be 65536)
Red/System []
utf8-to-codepoint: func [ ; yields an integer >= 0 and < 1114112, or -1
u [c-string!] ; should have length 1 to 4
/local b1 b2 b3 b4
][
either 1 = length? u
[
b1: as-integer u/1
either b1 < 128 [
@dockimbel
dockimbel / JSON-mini.red
Last active September 29, 2020 04:13 — forked from Skrylar/JSON.red
JSON minminal parser for Red
Red []
digit-nz: charset "123456789"
digit: append copy digit-nz #"0"
hex: append copy digit "abcdefABCDEF"
sign: charset "+-"
exponent-e: charset "eE"
dquot: #"^""
exponent: [ exponent-e opt sign some digit ]
@dockimbel
dockimbel / tile-game.red
Last active November 24, 2015 14:03 — forked from meijeru/tile-game.red
Red [Needs: 'view]
view/tight [
title "Tile game, by meijeru"
style piece: button 60x60 [
unless find [0x60 60x0 0x-60 -60x0] face/offset - empty/offset [exit]
temp: face/offset face/offset: empty/offset empty/offset: temp
]
piece "1" piece "2" piece "3" piece "4" return
piece "5" piece "6" piece "7" piece "8" return
@dockimbel
dockimbel / red-updater.r
Last active September 28, 2016 04:05
Red-Updater-Script: This Script updates your Red Installation with the latest master-branch binaries.
Rebol [
Title: "Red-Updater-Script"
File: %red-updater.r
Author: "Neelesh Chandola, @nc-x"
Description: {
This Script updates your Red Installation with the latest master-branch binaries.
}
Instructions: {
Please update the variable `path-to-red-executable` with appropriate
location of the Red executable on your system before running the script.
@dockimbel
dockimbel / comprehensions.md
Created March 27, 2016 17:43 — forked from bearfrieze/comprehensions.md
Comprehensions in Python the Jedi way

Comprehensions in Python the Jedi way

Beautiful is better than ugly. Explicit is better than implicit.

-- The Zen of Python

I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.

All of the tasks presented in the examples can be accomplished with the extensive standard library available in Python. These solutions would arguably be more terse and efficient in some cases. I don't have anything against the standard library. To me there is a certain

Red [needs: view]
turtle: #()
win: layout [ tfield: base 500x500 white draw []
panel [
history: text-list 180x350 data [] return
panel [ button "Save" [save request-file history/data]
button "Load" [commands: load request-file foreach cmd commands [process-cmd cmd]] ]
]
@dockimbel
dockimbel / analog-clock.red
Last active June 15, 2016 03:29 — forked from greggirwin/analog-clock.red
An analog clock for Red
Red [
Title: "Red O'clock"
Author: "Gregg Irwin"
]
degree-to-xy: func [rad "radius" deg "degrees"] [
as-pair (rad * sine deg) (rad * negate cosine deg)
]
sex-to-degree: func ["Sexagesimal to degrees" n] [n * 6]
@dockimbel
dockimbel / bubbles.red
Created June 17, 2016 03:36 — forked from greggirwin/bubbles.red
Animated bubbles
Red [
Title: "Bubbles"
Author: [REBOL version "Gabriele Santilli" Red port "Gregg Irwin"]
File: %bubbles.red
Tabs: 4
Needs: View
]
system/view/auto-sync?: no
@dockimbel
dockimbel / paint.red
Last active June 18, 2016 02:49 — forked from greggirwin/paint.red
Red Paint (World's smallest paint program)
Red [
title: "Paint"
Author: [REBOL version "Frank Sievertsen" Red port "Gregg Irwin"]
File: %paint.red
Tabs: 4
Needs: View
version: 0.0.1
]
draw-blk: copy []
@dockimbel
dockimbel / fill-pen-lab.red
Created June 18, 2016 03:02 — forked from greggirwin/fill-pen-lab.red
Fill-pen Lab for Red
Red [
Title: "Fill-pen Lab"
Author: "Gregg Irwin"
File: %fill-pen-lab.red
Needs: View
]
to-color: function [r g b][
color: 0.0.0
if r [color/1: to integer! 256 * r]