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

World: r3wp

[Core] Discuss core issues

Gregg
7-Jan-2009
[12029]
There are a lot of ways to do it. Some people use the GUID API on 
Windows. Some use a high-low model, kind of like you are by including 
the PID. Combining clock (with setback checking), counter, machine 
info, and a key (like PID), is plenty good.
Nicolas
7-Jan-2009
[12030x2]
Noticing that many people use two words to time things, I made a 
little timer function.
time: func [s] [
    t: now/time/precise
    if do s [now/time/precise - t]
]
Steeve
7-Jan-2009
[12032]
pffff, i give you a medal
Nicolas
7-Jan-2009
[12033x2]
sorry.
but why do people use two words instead of one?
Steeve
7-Jan-2009
[12035]
because
btiffin
7-Jan-2009
[12036]
Historical?   start (set) and then end (report).    R3 has a dt (delta-time) 
function built in and some other nice profiling words.
Gabriele
8-Jan-2009
[12037x2]
Re: Random: there is some confusion here! /SECURE is *not* an alternative 
to /SEED. You still need a seed as well for both algorithms.
The issue is not "duplicates" but predictability of the sequence. 
How many numbers you need to know before you can predict what the 
next number is going to be. /SECURE is supposed to be much more difficult 
to predict.
Henrik
8-Jan-2009
[12039]
so it's more an issue of predictability than actual level of randomness?
Gabriele
8-Jan-2009
[12040]
predictability = level of randomness :)
Henrik
8-Jan-2009
[12041]
really? perhaps there's no correlation between randomness and risk 
of collision.
Gabriele
8-Jan-2009
[12042]
is a dice "random"?
Henrik
8-Jan-2009
[12043]
I would say it is, but I may be asking the wrong thing of randomness, 
namely a minimal risk of collisions.
Gabriele
8-Jan-2009
[12044]
what is the probability of getting the same number twice in a row? 
or twice in a sequence of 3 rolls? or twice in a sequence of 100 
rolls?
Henrik
8-Jan-2009
[12045]
yes, I see your point.
Gabriele
8-Jan-2009
[12046x4]
the risk of collision depends only on the number of possible outcomes, 
assuming a uniform distribution
and indeed, for UUIDs, it may be ok to be predictable as long as 
you can reduce collisions.
for example, if you had a clock with a precision of 10^-5 seconds, 
and you knew it was impossible to have more than 10000 requests per 
seconds, then you would be fine to just use your clock as your UUID.
the result would be the least random possible, but still unique.
Henrik
8-Jan-2009
[12050x3]
true
I suppose then also if you want a short (6-8 digits) user input ID, 
one you must type in your browser, it's best to use a sequential 
ID accompanied by a passcode.
so there is a sequential part and a random part.
Sunanda
8-Jan-2009
[12053]
Generate a random id, then check if is not already issued. If it 
is, try again.
That works for me!

(Though there is the remote risk that my code starts getting slower 
aftre many thousand years of continuous operation, when clashes start 
becoming likely :-)
Pekr
8-Jan-2009
[12054x2]
I used simple randomized copy/part upon checksum/secure now/time/precise. 
Worked so far ...
Is there an easy way of how to detach message from imported email?
Pavel
8-Jan-2009
[12056]
Probably detach.r from rebol.org?
Pekr
8-Jan-2009
[12057]
yes, I am just looking at it and wondering, why import-email does 
not have such refinement :-)
Geomol
8-Jan-2009
[12058x3]
Henrik, Rebolek posted this code in the "View" group last year to 
illustrate the difference between random and random/secure:

img: make image! 512x512 
repeat i 512 [
	repeat j 512 [
		either i < 256 [
			if 2 = random 2 [
				img/(as-pair i - 1 j - 1): 255.255.255
			]			
		][
			if 2 = random/secure 2 [
				img/(as-pair i - 1 j - 1): 255.255.255
			]
		]
	]
]


view layout [image img across text "RANDOM" tab tab tab text "RANDOM/SECURE"]
Patterns can be easily seen in the left side, where is right secure 
side is more random.
where *the* right secure side is more random.
Maxim
8-Jan-2009
[12061]
to generate IDs, I do a nasty infalable trick on mysql.  i insert 
directly, in a uid table.
Henrik
8-Jan-2009
[12062]
wow, pretty cool
Maxim
8-Jan-2009
[12063x2]
if it doesn't fail, the id is new... if it failed, the id already 
existed.   (the id column is unique, obviously)
but there are no race-conditions, since insert is atomic in mysql.
Henrik
8-Jan-2009
[12065]
Damn, I wish I could blog that piece of code :-/
Steeve
8-Jan-2009
[12066]
not so obvious in that example:
img: make image! 512x512 
repeat i 512 [
	repeat j 512 [
		either i < 256 [
				img/(as-pair i - 1 j - 1): random 255.0.0
		][
				img/(as-pair i - 1 j - 1): random/secure 0.0.255
		]
	]
]


view layout [image img across text "RANDOM" tab tab tab text "RANDOM/SECURE"]
Rebolek
8-Jan-2009
[12067]
Hehe I almost forget about this piece of code :)
Geomol
8-Jan-2009
[12068]
It's a very cool piece of code, Rebolek! :-)
Rebolek
8-Jan-2009
[12069]
Thanks :) Well I think I might use it for enhancing my texture generator...
Pekr
8-Jan-2009
[12070]
hmm, 'detach can't work with forwarded messages ... So after all 
those years, we don't have simple method to extract attachements 
from emails? Interesting :-)
[unknown: 5]
8-Jan-2009
[12071x2]
I actually remember that from long ago.
Rebolek's random/secure sample that is.
Steeve
8-Jan-2009
[12073x2]
i noticed that op! functions can't be reduced, is it a bug ? (in 
R2 and even in the R3).
>> do reduce [:add 1 1]
==2
>> do reduce [1 :+ 1]
** Script error: cannot use add on none! value
** Where: applier do
** Near: op! 1
in fact it works, it's the infix behavior which doesn't work anymore 
on values
>> do reduce [:+ 1 1]
== 2
BenBran
16-Jan-2009
[12075]
The past few weeks I've had more time to devote to Rebol.  I'm working 
on some typical examples and routines to get aquainted with it.  
So I appreciate all the help I'm getting from this forum.  Currently 
just playing with the delete-dir function.

I'm not able to get this to work....is this even possible.....

in the environment: myPath = C:\myTemp

	myPath: probe get-env "myTemp"

 ....(tried several iterations of code here to fix the path perfectly)
	delete-dir myTemp

also tried reduce 

the path has been refomed to //%/myTemp/, %C/myTemp/,  and several 
others forms.

it says that it expects a dir argument of type: file url
Pekr
16-Jan-2009
[12076x3]
>> exists? %c/windows
== false
>> exists? %/c/windows
== true
note two slashes in second examples surrounding /C/
also, you can use handy functions as to-rebol-file, to-local-file, 
to convert to/from local/rebol file/path formats ...