Skip to content

Instantly share code, notes, and snippets.

@gchiu
gchiu / gist:5233739
Created March 24, 2013 21:59
Basic tcp port testing
rebol [
]
android-request: {{"params": ["Hello, Android!"], "id":1, "method": "makeToast"}^/}
android-port: make port! tcp://192.168.1.103:4321
android-port/awake: func [event /local tcp-port] [
tcp-port: event/port
print [ "port equality?" equal? tcp-port android-port ]
@gchiu
gchiu / confirm
Created March 30, 2013 00:26
A net-utils like confirm function for R3
confirm: func [ tcp-port [port!] challenge [string!] code [string!]
/local data
][
write tcp-port challenge
tcp-port/awake: func [ event ][
tcp-port: event/port
switch/default event/type [
wrote [
@gchiu
gchiu / who-is-online
Created March 30, 2013 10:24
greet new people
who-is-online: func [ message-id
/silent
/local out page username userid len newbies addressees
][
addressees: copy ""
len: length? visitors
out: copy []
newbies: copy []
page: to string! read html-url
parse page [
@gchiu
gchiu / prot-smtp.r
Created April 1, 2013 22:29
prot-smtp with numeric codes
Rebol [
system: "Rebol [R3] Language interpreter"
title: "Rebol 3 SMTP scheme"
author: "Graham"
date: [9-Jan-2010 20-Jan-2013 29-Mar-2013]
rights: 'BSD
name: 'smtp
type: 'module
version: 0.0.8
file: %prot-smtp.r
@gchiu
gchiu / gist:5323356
Created April 5, 2013 23:00
Mini http read
; mini-http is a minimalistic http implementation
mini-http: func [ url [url!] method [word! string!] code [string!] timeout [integer!]
/local url-obj http-request payload result port
][
http-request: {$method $path HTTP/1.0
Host: $host
User-Agent: Mozilla/5.0
Accept: text/html
Referer: http://$host
Content-Length: $len
@gchiu
gchiu / dragbutton.r3
Last active December 17, 2015 13:29
create a draggable button - working version
Rebol [
file: %dragndrop.r3
title: "DragNdrop example"
author: "Graham Chiu"
date: 22-may-2013
purpose: "show how drag and drop works"
]
update-field-data: func [arg] [
set-face offset arg/delta + arg/base
@gchiu
gchiu / button.r3
Created May 23, 2013 07:27
unable to access list from button
Rebol [
date: 21-May-2013
author: "Graham Chiu"
]
i: load http://www.rebol.com/bay.jpg
gob-list2: []
go: make object! [name: offset: type: none]
append gob-list2 make go []
@gchiu
gchiu / h2a.r3
Last active December 18, 2015 02:38
convert embedded html tables to asciid doc format
REBOL [
author: "Ingo Hohmann"
date: 2013-06-04
purpose: "Change html tables to asciidoc format"
Version: 0.5
]
ht2at: html-table-2asciidoc: funct [ input ] [
output: copy #{}
space: #{20}
@gchiu
gchiu / clean-script.r3
Created June 8, 2013 01:32
First attempt to port clean-script to pretty indent r3 souce
Rebol [
file: clean-script.r3
]
script-cleaner: make object! [
out: none ; output text
spaced: off ; add extra bracket spacing
indent: "" ; holds indentation tabs
@gchiu
gchiu / mini-http.r3
Last active December 18, 2015 16:29
mini-http
rebol []
; mini-http is a minimalistic http implementation
mini-http: funct [url [url!] method [word! string!] code [string!] timeout [integer!]
/callback cb
/cookies cookie [string!]
] [
url-obj: http-request: payload: result: port: none