r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

Dockimbel
8-Feb-2011
[904x2]
do load

 does not work with the serialized form (I tried it)?" I'm not sure 
 to understand what you mean there. SAVE/ALL uses MOLD/ALL to serialize 
 values, so binding information is not preserved. If you want to restore 
 correct binding in a object! serialized using /ALL format, you need 
 to write some code to walk through object's functions body blocks 
 and bind object's words explicitely using BIND.
This would be similar to what MAKE does on an object's spec block! 
but a bit smarter as you need to dive into function! values (MAKE 
doesn't do that AFAICT). You need to see the distinction between 
"unevaluated code" (source form) and "evaluated code" (reduced form) 
to get a clear picture on this issue.
BrianH
8-Feb-2011
[906]
Nested bindings are faked using a procedural process in REBOL. Serialized 
syntax is declarative, and there isn't a reference to the bindings 
in that syntax. It would be possible to make a serialized syntax 
that includes binding references, and the proposal to do that is 
called Rebin.
Rebolek
9-Feb-2011
[907]
Is there sort function (comparator) for no sorting, so this will 
be TRUE ?

block = sort/compare copy block :comparator
Sunanda
9-Feb-2011
[908x2]
The only one I can think of only works if the entries in _block_ 
are unique:

     sort/compare copy block func [a b][return (index? find block a) < 
     index? find block b]
This may work too:
  sort/compare/skip block func [a b][return true] length? block
ChristianE
9-Feb-2011
[910x2]
sort/compare [t r y t h 1 s] func [a b] [0]
If you want SORT to be stable, return -1, 0, 1 instead of just TRUE 
and FALSE.
Rebolek
9-Feb-2011
[912x2]
Doesn't seem to work in R3.
>> sort/compare [t r y t h 1 s] func [a b] [0]
== [r y t h 1 s t]
ChristianE
9-Feb-2011
[914x2]
It's not supposed to work in R3.
R3 currently has no stable sort. At least not on all platforms.
Rebolek
9-Feb-2011
[916]
Ah, ok.
Andreas
9-Feb-2011
[917]
(Which is http://issue.cc/r3/1152.)
Sunanda
9-Feb-2011
[918]
This does a null sort in R2 and R3.....but it requires the func to 
know the name of the block being sorted:

    sort/compare block func [a b /local c] [c: [] if 0 = length? c [append 
    c block]  block: copy c 0]
Pekr
9-Feb-2011
[919]
sort is mostly useless anyway - it will not work with unicoded alphabets 
anyway, no?
Sunanda
9-Feb-2011
[920]
R2 needed some heroics for other collating sequences. Not tried this 
sort of thing in R3 yet.
   http://www.rebol.org/ml-display-message.r?m=rmlMWWJ
DideC
11-Feb-2011
[921]
Argh! Does one remember how to convert integer! to its binary equivalent 
and the opposite, in R2 and in R3 (it's different IIRC) ?
Sunanda
11-Feb-2011
[922]
R2 way is to use to-hex
    to-hex 100
    == #00000064
DideC
11-Feb-2011
[923x3]
Yes, but issue! are not binary!
I need to make some binary mask with some integer value like :
	var: random 99999999
	res: var and #{00ff0000}
OK. Find a solution.

to-integer #{00ff0000} give me an integer, so I will make some "constant" 
values from the binary I need and will make the AND between integers.
Ladislav
11-Feb-2011
[926x2]
>> to integer! binary: debase/base to-hex integer: 11 16
== 11
(not very convenient, I admit)
DideC
11-Feb-2011
[928]
LoL
Ladislav
11-Feb-2011
[929]
In R3 is is much more comfortable
Geomol
11-Feb-2011
[930]
Another option:

>> do http://www.fys.ku.dk/~niclasen/rebol/libs/bit.r
>> enhex 100 
== #{00000064}
GrahamC
12-Feb-2011
[931x4]
I want to block all of eastern europe ( sorry guys ) from my sites 
...
now vbulletin only allows blocking by ip address eg. 1.2.3.*
but the country blocks appear like this 

# Country: RUSSIAN FEDERATION
# ISO Code: RU
# Total Networks: 4,256
# Total Subnets:  35,139,848
2.60.0.0/255.252.0.0
2.92.0.0/255.252.0.0
31.28.0.0/255.255.224.0
46.0.0.0/255.255.0.0
46.3.0.0/255.255.0.0
is there some code I can use to transform the bottom into the top?
should I just simply replace the first occurence of a 0 on the left 
with a * ?
Andreas
12-Feb-2011
[935]
depends on the accuracy you need
GrahamC
12-Feb-2011
[936x2]
I don't need accuracy!
I just to block every spammer that lives in Eastern Europe
Andreas
12-Feb-2011
[938]
then replace every non-255 occurence with * :)
GrahamC
12-Feb-2011
[939]
eh?

2.60.0.0 => * ??
Andreas
12-Feb-2011
[940x2]
from the mask :)
this will match several million false positives too, but well :)
GrahamC
12-Feb-2011
[942x2]
vbulletin doesn't use masks
ok, so where there isn't a 255 in the mask, then replace the same 
point in the ip address with a *
Andreas
12-Feb-2011
[944x3]
2.60.0.0/255.252.0.0 is 2.60.0.0/22
2.60.*.* will match less than 2.60.0.0/22
2.*.*.* will match more than 2.60.0.0/22
GrahamC
12-Feb-2011
[947x2]
well, I think I would use 2.*
will that stop Putin posting?
Andreas
12-Feb-2011
[949]
blocking several gazillion non-eastern europe users as well :)
GrahamC
12-Feb-2011
[950x3]
collaterall damage
Rebol []

data: {# Country: AFGHANISTAN
# ISO Code: AF
# Total Networks: 22
# Total Subnets:  98,560
27.116.56.0 - 27.116.59.255
58.147.128.0 - 58.147.159.255
61.5.192.0 - 61.5.207.255
111.125.152.0 - 111.125.159.255
111.223.244.0 - 111.223.247.255
117.55.192.0 - 117.55.207.255
117.104.224.0 - 117.104.231.255
119.59.80.0 - 119.59.87.255
121.100.48.0 - 121.100.55.255
121.127.32.0 - 121.127.63.255
124.199.112.0 - 124.199.127.255
125.213.192.0 - 125.213.223.255
175.106.32.0 - 175.106.63.255
180.94.64.0 - 180.94.95.255
180.222.136.0 - 180.222.143.255
182.50.176.0 - 182.50.191.255
202.56.176.0 - 202.56.191.255
202.86.16.0 - 202.86.31.255
203.174.27.0 - 203.174.27.255
203.215.32.0 - 203.215.47.255
210.80.0.0 - 210.80.31.255
210.80.32.0 - 210.80.63.255
}

output: copy ""

foreach line parse/all data "^/" [
	if line [
		trim/head/tail line
		if not find/part line "#" 1 [
			ranges: parse/all line "-"
			from-ip: load trim/head/tail ranges/1
			to-ip: load trim/head/tail ranges/2
			; they diverge on the 3rd number
			from: from-ip/3
			to: to-ip/3
			for i from to 1 [

    append output rejoin ["" from-ip/1 "." from-ip/2 "." i ".*^/"]
			]
		]
	]
]

print output
gives ...

27.116.56.*
27.116.57.*
27.116.58.*
27.116.59.*
58.147.128.*
58.147.129.*
58.147.130.*
58.147.131.*
58.147.132.*
58.147.133.*
58.147.134.*
58.147.135.*

etc ..
Does that look okay?
Andreas
12-Feb-2011
[953]
looks ok :)