Skip to content

Instantly share code, notes, and snippets.

@draegtun draegtun/spam-comment.r2
Last active Dec 16, 2015

Embed
What would you like to do?
Rebol [
see-gist: https://gist.github.com/miyagawa/5455942
also-this: https://gist.github.com/shanselman/5422230#comment-823247
comment: "My fledgling Rebol port of this Perl code"
requires: "Rebol/View - for https:// port"
github-support: "Thank you Austin@Github for (initiating) the fix for Rebol syntax highlighting"
]
split-string: func [text delim /local s coll] [
coll: copy []
parse/all text [
some [copy s [to delim | to end] (append coll s) delim]
]
coll
]
pick-random: func [from-series] [
random/seed now ; only needs to be done once per script but here so not forgotten!
pick from-series random length? from-series
]
spam-text: read https://gist.github.com/shanselman/5422230/raw/9863d88bde2f9dcf6b2e7a284dd4a428afdc8
samples: split-string spam-text "|^/"
template: pick-random samples
; below replaces {placeholders} within the input stream (template)
parse/all template [
any [
thru "{" begin: copy s to "}" ending:
(
begin: back begin ; move back to include {
ending: next ending ; move forward to include }
text: split-string s "|"
move-mark: change/part begin pick-random text ending
)
:move-mark ; moved the mark to end of change
]
]
print template
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.