World: r3wp
[Core] Discuss core issues
older newer | first last |
Gabriele 8-Jan-2009 [12047x3] | 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 [12076x6] | >> 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 ... | |
also - if you want to use C:\myTemp, better use "C:\myTemp", rebol thinks it is an URL type ... | |
>> to-rebol-file "C:\mypath" == %/C/mypath >> to-rebol-file C:\mypath ** Script Error: to-rebol-file expected path argument of type: file string ** Near: to-rebol-file C:\mypath | |
HTH :-) | |
BenBran 16-Jan-2009 [12082x2] | Yes this helped thank you. |
I'll look some more later, but what seemed to fix it was the built in function 'to-rebol file' :-) | |
Janko 19-Jan-2009 [12084] | can I ask if you know any other options for rebol to talk to other independant processes on linux? For example could I use something like named pipes? |
Chris 19-Jan-2009 [12085x2] | There was a script for Rebol->Arexx once called Pipebridge. Wonder if it's applicable to Linux? |
Rebol<->Arexx | |
btiffin 19-Jan-2009 [12087] | Janko; I'm pretty sure a mkfifo named pipe will work; BUT as usual, either end borks, the other end hangs. |
Janko 19-Jan-2009 [12088x4] | Chris: I googled about what you said but didn't find any source, but interesting.. this stuff was running on amiga at the time :) |
btiffin: I am newbie at linux... you mean I can make a named pipe in command line with mkfifo and then rebol uses that as a normal filename to write/read from it? Similarly the other language has Unix package and can make named pipes by it's own... can rebol create pipe too? (sorry if I got it all wrong) | |
about hanging, yes I read that write does not happen untill there is a read at the other side and vice versa so I was thinking if there is some king of timeout possible.. | |
hm.. but why is it then called fifo if read needs to happen at the same time as write, I thought it's some sort of fifo (first in first out) stack/queue | |
btiffin 19-Jan-2009 [12092] | Well normally fifo files are created in blocking mode, so yeah a write won't complete until a read occurs and a read will wait for a writer (by default). I'll be honest, I've not done this from REBOL, but with 2.7.6 and LOAD/LIBRARY freed, we can do any libc6 calls that we want, so you should be able to set a non blocking mode and get true multiple writes and reads that will return empty if no data is queued. For OpenCOBOL I implemented POSIX Message Queues; as MQ_NOTIFY will make a callback when the queue goes from empty to non-empty and you don't have to worry about spinning on a read. If you don't mind playing with make routine! take a look at mq_open and friends (man mq_overview) it might offer more control for IPC. |
Janko 20-Jan-2009 [12093x2] | thanks btiffin for such great explanation, yes I was looking at message queues too at first but then someone proposed pipes and they do seem more accessible/simple to start in a way. |
Is there any article or blog post about 2.7.6 being able to load native libraries? I searched and couldn't find any info on this.. I found docs for REBOL/Command/SDK version so this would be a place to start experimenting probably | |
btiffin 20-Jan-2009 [12095] | Janko; yep. It's weird, docs wise, but make routine! is a new bonus layer that hasn't made it's way to the main documentation. Our good Gregg is a goto guy when it comes to knowing some of the foibles invovled. If you like learning by example http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=capture-screen.r or http://www.rebol.org/cgi-bin/cgiwrap/rebol/view-script.r?script=capture-screen.r There are other examples. |
Janko 20-Jan-2009 [12096] | great, I love learning by example :) .. btw .. both of your links are the same I think |
older newer | first last |