Skip to content

Instantly share code, notes, and snippets.

@gchiu
gchiu / filter-table.r3
Last active December 19, 2015 13:39
Filter one table based on another
Rebol [
]
ind: [
[1 "Jones" "Tom"]
[2 "Smith" "William"]
[3 "Jones" "Stephen"]
]
@gchiu
gchiu / editor.reb
Created March 29, 2014 04:59
The Rebol2 editor ported to Rebol3
rebol [
title: "editor"
purpose: {Built in editor}
author: "Based on the original Rebol2 editor, ported by Massimiliano Vessi"
version: 2.5
date: 29-March-2014
]
if not value? 'to-text [ load-gui ]
@gchiu
gchiu / gui-server.reb
Created July 12, 2014 08:00
Gui server
REBOL [
title: "A tiny static HTTP server"
author: 'abolka date: 2009-11-04
file: %gui-server.reb
]
load-gui
code-map: make map! [200 "OK" 400 "Forbidden" 404 "Not Found"]
mime-map: make map! ["html" "text/html" "jpg" "image/jpeg" "r" "text/plain"]
@gchiu
gchiu / mci.reb
Last active August 29, 2015 14:27
attempt to use mci
REBOL [
title: "mci.reb"
notes: {
taken from http://rosettacode.org/wiki/Record_sound
}
]
mci: make library! %Winmm.dll
@gchiu
gchiu / collect.reb
Created September 4, 2015 09:50
testing collect
data: collect [
foreach [var val] reduce ["user[email]" user "user[password]" pass "user[remember_me]" "0"][
keep rejoin [var "=" url-encode val "&"]
]
]
data: rejoin data
take/last data
@gchiu
gchiu / chinese.reb
Created September 11, 2015 08:19
translate help strings to chinese
TranslatorToken.o: grab-access-token create-credentials "http://api.microsofttranslator.com"
reb: load https://raw.githubusercontent.com/metaeducation/ren-c/master/src/boot/natives.r
print [ "Length:" length? reb]
translate-to-chinese: function [ text][
request-str: to-webform compose [
text: (text)
from: "en"
to: "zh-CHS"
@gchiu
gchiu / natives.reb
Created September 11, 2015 08:24
natives.r with Chinese strings
ajoin: native ["减少了,加入一个新的字符串值的块。"
block [block!]
]
also: native ["返回第一个值,但是还可以计算第二个。"
value1 [any-type!]
value2 [any-type!]
]
all: native ["快捷方式和评价,在第一的虚假或没有返回。"
block [block!] "表达式块"
]
@gchiu
gchiu / base32hex.reb
Last active September 16, 2015 21:37
Convert string to base32hex
Rebol [
file: %base32.reb
notes: {
padding to 5 characters is not required in this method
}
]
to-base32: function [ st [string!]
/hex {output base32hex}
][
@gchiu
gchiu / prot-.reb
Last active September 27, 2015 07:33
removing until from prot-http.reb
until [
either parse data [
copy chunk-size some hex-digits thru crlfbin mk1: to end
] [
chunk-size: to integer! to issue! to string! chunk-size
either chunk-size = 0 [
if parse mk1 [
crlfbin (trailer: "") to end | copy trailer to crlf2bin to end
] [
trailer: construct trailer
\ tested on 8th 16.07 Windows 32 (3d80ecde)
\ update with using nullndrop; words
\ some variables to store the action and verb for the xhtml form
null var, verb null var, action
: nulldrop; \ x -- x|exit
null? if drop ;;; then ;
: null2drop; \ x y -- x y|exit