How Can I generate uuid ? any references or Ideas could You people suggest.I have not even heard about it?
on 2008-08-28 10:48
on 2008-08-28 12:02
Newb Newb wrote: > How Can I generate uuid ? any references or Ideas could You people > suggest.I have not even heard about it? http://en.wikipedia.org/wiki/Uuid#Ruby
on 2008-08-31 10:46
Lex Williams wrote: > Newb Newb wrote: > >> How Can I generate uuid ? any references or Ideas could You people >> suggest.I have not even heard about it? >> > > http://en.wikipedia.org/wiki/Uuid#Ruby > In Windows, you can use this code. I'm not sure where I found this from, so I can't tell you who to thank :P require 'Win32API' @uuid_create = Win32API.new('rpcrt4', 'UuidCreate', 'P', 'L') def new_guid result = ' ' * 16 @uuid_create.call(result) a, b, c, d, e, f, g, h = result.unpack('SSSSSSSS') sprintf('{%04X%04X-%04X-%04X-%04X-%04X%04X%04X}', a, b, c, d, e, f, g, h) end puts new_guid Cheers, Mohit. 8/31/2008 | 2:28 PM.
on 2008-08-31 18:13
On Aug 28, 2008, at 2:43 AM, Newb Newb wrote: > How Can I generate uuid ? any references or Ideas could You people > suggest.I have not even heard about it? not mine, but here's a copy: http://s3.amazonaws.com/drawohara.com.ruby/uuid.rb a @ http://codeforpeople.com/
on 2008-09-01 03:18
2008/8/28 Newb Newb <hema@angleritech.com>: > How Can I generate uuid ? any references or Ideas could You people > suggest.I have not even heard about it? You get get UUID on the WEB like this: require 'open-uri' uuid = open('http://www.famkruithof.net/uuid/uuidgen'). read.scan(/<h3>([-[:alnum:]]+)<\/h3>/).to_s puts uuid Regards, Park Heesob
on 2008-09-01 23:35
On Aug 31, 2008, at 6:12 PM, Heesob Park wrote: > > Regards, > > Park Heesob One thing I;ve found is that all of the UUID generators are painfully slow if you need to make a bunch of uuid's. Here is a way to cheat, but do so at your own risk as this is not garaunteed to be as safe as a true uuid but in practice works very well. def fast_token values = [ rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x0010000), rand(0x1000000), rand(0x1000000), ] "%04x%04x%04x%04x%04x%06x%06x" % values end Cheers- -Ezra
on 2008-09-01 23:54
On Sep 1, 2008, at 4:27 PM, Ezra Zygmuntowicz wrote: >> read.scan(/<h3>([-[:alnum:]]+)<\/h3>/).to_s >> puts uuid >> >> Regards, >> >> Park Heesob > > > One thing I;ve found is that all of the UUID generators are > painfully slow if you need to make a bunch of uuid's. My favorite trick is: uuid = `uuidgen`.strip It has always been fast enough for my needs. James Edward Gray II
on 2008-09-02 01:02
On 1 sep 2008, at 23.48, James Gray wrote: >>> require 'open-uri' >> painfully slow if you need to make a bunch of uuid's. > > My favorite trick is: > > uuid = `uuidgen`.strip > > It has always been fast enough for my needs. > > James Edward Gray II > > The variation I use is uuid = "x_#{`uuidgen`.strip}" The advantage is that the generated uuid is always suitable as an xml ID
on 2008-09-02 01:46
On Sep 1, 2008, at 14:48 , James Gray wrote: > My favorite trick is: > > uuid = `uuidgen`.strip > > It has always been fast enough for my needs. that's nice. 10k real uuids in 1 minute is perfectly acceptable for almost all cases. thanks. % ./blah.rb 10000 # of iterations = 10000 user system total real null_time 0.000000 0.000000 0.000000 ( 0.001486) ezra 0.200000 0.000000 0.200000 ( 0.201678) uuidgen 1.160000 12.630000 58.190000 ( 56.684045) ---- puts "# of iterations = #{max}" Benchmark::bm(20) do |x| x.report("null_time") do for i in 0..max do # do nothing end end x.report("ezra") do for i in 0..max do fast_token end end x.report("uuidgen") do for i in 0..max do `uuidgen`.strip end end end
on 2008-09-02 02:21
On Sep 1, 2008, at 5:38 PM, Ryan Davis wrote: > almost all cases. thanks. > puts "# of iterations = #{max}" > end > end > > x.report("uuidgen") do > for i in 0..max do > `uuidgen`.strip > end > end > end > > cfp:~ > cat a.rb require 'open-uri' uri = 'http://s3.amazonaws.com/drawohara.com.ruby/uuid.rb' eval open(uri).read a = Time.now.to_f ( n = 1000 ).times{ uuid = UUID.string } b = Time.now.to_f elapsed = b - a puts "uuid/min : #{ n / elapsed * 60 }" cfp:~ > ruby a.rb uuid/min : 113947.784509223 it's kinda a POS, but with the addition of macaddr and a few other tidbits (state using AR for instance) it's pretty dang good : 10 times faster and pure ruby. a @ http://codeforpeople.com/
on 2008-09-02 18:09
Newb Newb wrote: > How Can I generate uuid ? any references or Ideas could You people > suggest.I have not even heard about it? sudo gem install guid irb(main):001:0> require 'guid' => true irb(main):002:0> Guid.new => b93e5a88-acf7-be64-af0b-6de00bd83fd3
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.