Skip to content

Instantly share code, notes, and snippets.

View dockimbel's full-sized avatar

Nenad Rakocevic dockimbel

View GitHub Profile
@Oldes
Oldes / wav-reader-test.reds
Created September 14, 2015 14:23
Experimental WAV file parser
Red/System [
Title: "Red/System stream-io test - WAV reader"
Author: "Oldes"
]
#define handle! [pointer! [integer!]]
#define GENERIC_WRITE 40000000h
#define GENERIC_READ 80000000h
#define FILE_SHARE_READ 00000001h
@meijeru
meijeru / split.red
Last active September 28, 2015 14:48
Red mezzanine function to split a string
Red [
Title: "Split mezzanine"
Purpose: {split a string}
Author: "Rudolf W. MEIJER"
File: %split.red
Version: "0.0.0"
Date: "10-May-2015"
Rights: "(c) Copyright 2015 Rudolf W. MEIJER"
License: "TBD" ; source license (URL or full text)
]
@qtxie
qtxie / random.reds
Last active December 18, 2015 19:09
Mersenne Twister algorithm Red/System implementation -- generates a random number using the Mersenne Twister algorithm. Reference http://code.google.com/p/c-standard-library/source/browse/src/internal/_rand.c
Red/System [
Title: "Mersenne Twister Random Function"
Author: "XieQ"
Tabs: 4
Purpose: {
Generates a random number using the Mersenne Twister algorithm.
Reference http://code.google.com/p/c-standard-library/source/browse/src/internal/_rand.c
}
]
make object! [
; Private Unicode Area for encoded delimiters and octets
url-pua-start: #"^(e000)"
url-pua-end: #"^(e0ff)"
delimiter: charset ":/?#[]@!$&'()*+,;="
hex-digit: charset [#"0" - #"9" #"a" - #"f" #"A" - #"F"]
ascii: charset [#"^(00)" - #"^(7f)"]
@rgchris
rgchris / rebol.ebnf
Last active December 12, 2015 06:08
EBNF Notation describing the REBOL (and family) Message Format
/*
REBOL Syntax
2012 by Christopher Ross-Gill
Based in Part on REBOLSource / REBOL Syntax by Earl, Ladislav and Steeve
https://github.com/rebolsource/rebol-syntax/
Designed for use with:
http://railroad.my28msec.com/rr/ui
For Future Ref:
@orlp
orlp / ipow.c
Last active February 7, 2025 13:21
int64_t ipow(int64_t base, uint8_t exp) {
static const uint8_t highest_bit_set[] = {
0, 1, 2, 2, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 255, // anything past 63 is a guaranteed overflow with base > 1
@dockimbel
dockimbel / ftoi.reds
Created June 12, 2012 20:28
Float32! to integer! conversion routine
Red/System [
Title: "Float32! to integer! conversion routine"
Author: "Nenad Rakocevic"
Rights: "Copyright (C) 2011 Nenad Rakocevic. All rights reserved."
License: "BSD-3 - https://github.com/dockimbel/Red/blob/origin/BSD-3-License.txt"
Note: "Thanks to François Jouen for providing me the C code for ftoi()"
]
float-to-integer: func [
f [float32!] ;-- float 32-bit value to convert
@jboner
jboner / latency.txt
Last active April 19, 2025 21:29
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@dockimbel
dockimbel / sub64.reds
Created January 24, 2012 23:59
Rough implementation of 64-bit integer subtraction
Red/System []
int64!: alias struct! [high [integer!] low [integer!]]
sub64: func [
a [int64!]
b [int64!]
return: [int64!]
/local
diff [int64!] offset [integer!]
@dockimbel
dockimbel / sym-test.reds
Created January 22, 2012 23:53
Simple math function bindings generates a missing symbol on Linux (works ok on Win/OSX)
Red/System []
#import [
LIBC-file cdecl [
sin: "sin" [
x [float!]
return: [float!]
]
]
]