Skip to content

Instantly share code, notes, and snippets.

@lepinekong
lepinekong / static-var.red
Created December 27, 2017 09:35
static variable in Red
static-function: function[ /local static-var][
static-var: []
; initialization
if empty? static-var [
append static-var 0
]
; cum
@lepinekong
lepinekong / debug2.red
Last active December 27, 2017 14:13
Debug with counter: doesn't work well when calling subfunction
??: func [
"Prints a word and the value it refers to (molded)"
'value [word! path! string!]
/start
/local cum
][
cum: []
; initialization
@lepinekong
lepinekong / counter for ??
Created December 28, 2017 13:23
?? counter by @9214
context [
counter: 0
set '?? func ['value /reset][
if reset [counter: 0]
counter: counter + 1
print rejoin [
"[" counter "]" tab value ":" space
mold get/any value
]
]
@lepinekong
lepinekong / for by @toomasv
Created December 29, 2017 17:23
Rebol equivalent
>> foreach i range 5 10 [print i]
5
6
7
8
9
10
>> foreach i range/step 10 5 2 [print i]
10
8
Red [
Author: "Toomas Vooglaid"
Date: 2017-12-16
Needs: %range.red
Needs-Gist: https://gist.github.com/toomasv/0e3244375afbedce89b3719c8be7eac0
]
do %range.red
context [
md: make font! [name: "Consolas" size: 12 color: black]
ft: make font! [name: "Tahoma" size: 36 color: black];;Lucida Sans Unicode;Unifont;EversonMono
@lepinekong
lepinekong / split-quotes.red
Created January 3, 2018 08:48
split quotes
quotes: {[{"date":1405699200,"high":0.0045388,"low":0.00403001,"open":0.00404545,"close":0.00435873,"volume":44.34555992,"quoteVolume":10311.88079097,"weightedAverage":0.00430043},{"date":1405713600,"high":0.00435,"low":0.00412,"open":0.00428012,"close":0.00412,"volume":19.12271662,"quoteVolume":4531.85801066,"weightedAverage":0.00421961}]}
replace/all quotes "[" ""
replace/all quotes "]" ""
quotes2: split quotes ","
;-> [{^{"date":1405699200} {"high":0.0045388} {"low":0.00403001} {"open":0.00404545} {"close":0.00435873} {"volume":44.34555992} {"quoteVolume":10311.88079097} {"weightedAverage":0.00430043^}} {^{"date":1405713600} {"high":0.00435} {"low":0.00412} {"open":0.00428012} {"close":0.00412} {"volume":19.12271662} {"quoteVolume":4531.85801066} {"weightedAverage":0.00421961^}}]
@lepinekong
lepinekong / .systems.utils.debug.red
Last active January 4, 2018 12:45
base58 Hexadecimal Euclidian Division
Red [
Title: "For debug"
]
__DEBUG_LINE_COUNTER__: 0
??: func [
"Prints a word and the value it refers to (molded)"
'value [word! path! string!]
/start
@lepinekong
lepinekong / base58.hexa.red
Last active January 4, 2018 14:04
basse58.hexa
Red [
Title: "Base58 hexa"
Uses: https://gist.github.com/lepinekong/4fd51a2897b81f81d1257d5f694bdc7a
Description: {
This implementation deals with division in hexadecimal
as Red doesn't currently support Big Integer. For example:
to-integer #{48656C6C6F} ; -> 1214606444 BUG
should have been 310939249775 https://www.binaryhexconverter.com/hex-to-decimal-converter
to-binary 310939249775 -> #{4252195B1B1BC000} BUG
}
@lepinekong
lepinekong / json.example.red
Last active January 4, 2018 20:50
json parser
json/decode read https://poloniex.com/public?command=returnChartData&currencyPair=BTC_XMR&end=9999999999&period=14400&start=1405699200
@lepinekong
lepinekong / table.to.block.red
Last active January 8, 2018 23:59
table.to.block
table: {Bitcoin | BTC | Digital gold
Ethereum | ETH | Programmable contracts and money
Bitcoin Cash | BCH | Bitcoin clone
Ripple | XRP | Enterprise payment settlement network
Litecoin | LTC | Faster Bitcoin
Dash | DASH | Privacy-focused Bitcoin clone
NEO | NEO | Chinese-market Ethereum
NEM | XEM | Batteries-included digital assets
Monero | XMR | Private digital cash
Ethereum Classic| ETC | Ethereum clone