[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Random users generator

qer1

12/7/2007 12:14:00 PM

Recently I've seen a random user generator for Rails on some blog bu I
can't find it now.

I need to generate 1 million non-existing emails with associated names
:-)

Could you please recommend a tool?
--
Posted via http://www.ruby-....

11 Answers

Lloyd Linklater

12/7/2007 12:29:00 PM

0

Piotr Wlodarek wrote:
> Recently I've seen a random user generator for Rails on some blog bu I
> can't find it now.
>
> I need to generate 1 million non-existing emails with associated names
> :-)
>
> Could you please recommend a tool?

I would be surprised if there was one out there. Go to websites and get
lists of names and make a file. You could use baby names list for the
first names. read them into an array and do something like this:


fnames = ["Adam", "Benjamin", "Caleb", "Daniel", "Frank", "Gideon"]
lnames = ["Smith", "Jones", "Washington", "Jefferson", "Gardener",
"Cooper"]
1_000_000.times do
name = fnames[rand(6)] + lnames[rand(6)] + "@foobar.com"
puts name #or whatever you want to do with the name.
end
--
Posted via http://www.ruby-....

MonkeeSage

12/7/2007 12:52:00 PM

0

On Dec 7, 6:13 am, Piotr Wlodarek <q...@wp.pl> wrote:
> Recently I've seen a random user generator for Rails on some blog bu I
> can't find it now.
>
> I need to generate 1 million non-existing emails with associated names
> :-)
>
> Could you please recommend a tool?
> --
> Posted viahttp://www.ruby-....

Heh. What possible *legitimate* need could you have for a million
random email addresses and names? I'm not saying there isn't
one...but...

Regards,
Jordan

Peter Hickman

12/7/2007 1:14:00 PM

0

Piotr Wlodarek wrote:
> Recently I've seen a random user generator for Rails on some blog bu I
> can't find it now.
>
> I need to generate 1 million non-existing emails with associated names
> :-)
>
> Could you please recommend a tool?
>

Well there is a Perl module called Data::RandomPerson that generates
people records (written by yours truly) which creates gender, age, dob,
firstname, lastname and title.

use Data::RandomPerson;
my $r = Data::RandomPerson->new();

for(my $x = 0; $x < 1000000; $x++) {
my $p = $r->create();
print $p{firstname} . " " . $p{lastname} . "\n";
}



I use it to populate databases.

qer1

12/7/2007 1:49:00 PM

0

Peter Hickman wrote:
> Well there is a Perl module called Data::RandomPerson that generates
> people records (written by yours truly) which creates gender, age, dob,
> firstname, lastname and title.
>
> use Data::RandomPerson;
> my $r = Data::RandomPerson->new();

That's exactly what I need! But still Ruby-based solution would be
appreciated.

Jordan Callicoat wrote:
> What possible *legitimate* need could you have for a million
> random email addresses and names?

Testing for performance.
--
Posted via http://www.ruby-....

Siep Korteling

12/7/2007 2:24:00 PM

0

Piotr Wlodarek wrote:
> Peter Hickman wrote:
>> Well there is a Perl module called Data::RandomPerson that generates
>> people records (written by yours truly) which creates gender, age, dob,
>> firstname, lastname and title.
>>
>> use Data::RandomPerson;
>> my $r = Data::RandomPerson->new();
>
> That's exactly what I need! But still Ruby-based solution would be
> appreciated.

how about

name="Aaaaaaaa"
1000000.times {puts name.next}
--
Posted via http://www.ruby-....

Siep Korteling

12/7/2007 2:25:00 PM

0

Siep Korteling wrote:
> Piotr Wlodarek wrote:
>> Peter Hickman wrote:
>>> Well there is a Perl module called Data::RandomPerson that generates
>>> people records (written by yours truly) which creates gender, age, dob,
>>> firstname, lastname and title.
>>>
>>> use Data::RandomPerson;
>>> my $r = Data::RandomPerson->new();
>>
>> That's exactly what I need! But still Ruby-based solution would be
>> appreciated.
>
> how about
>
> name="Aaaaaaaa"
> 1000000.times {puts name.next}

Argh.

next!
--
Posted via http://www.ruby-....

qer1

12/7/2007 2:49:00 PM

0

Siep Korteling wrote:
> Piotr Wlodarek wrote:
>> Peter Hickman wrote:
>>> Well there is a Perl module called Data::RandomPerson that generates
>>> people records (written by yours truly) which creates gender, age, dob,
>>> firstname, lastname and title.
>>>
>>> use Data::RandomPerson;
>>> my $r = Data::RandomPerson->new();
>>
>> That's exactly what I need! But still Ruby-based solution would be
>> appreciated.
>
> how about
>
> name="Aaaaaaaa"
> 1000000.times {puts name.next}

Then measure performance of searching for "Aaaaaaa" name...

For testing, data must as close to real as possible.
--
Posted via http://www.ruby-....

Gary Wright

12/7/2007 3:09:00 PM

0


On Dec 7, 2007, at 7:13 AM, Piotr Wlodarek wrote:

> Recently I've seen a random user generator for Rails on some blog bu I
> can't find it now.

http://faker.ruby...

MonkeeSage

12/7/2007 3:32:00 PM

0

On Dec 7, 7:48 am, Piotr Wlodarek <q...@wp.pl> wrote:
> Peter Hickman wrote:
> > Well there is a Perl module called Data::RandomPerson that generates
> > people records (written by yours truly) which creates gender, age, dob,
> > firstname, lastname and title.
>
> > use Data::RandomPerson;
> > my $r = Data::RandomPerson->new();
>
> That's exactly what I need! But still Ruby-based solution would be
> appreciated.
>
> Jordan Callicoat wrote:
> > What possible *legitimate* need could you have for a million
> > random email addresses and names?
>
> Testing for performance.
> --
> Posted viahttp://www.ruby-....

Sorry. It just sounded kind of fishy to ask for a million random email
addresses. If you don't need actual random email addresses, just
random strings that approximate email addresses, it pretty easy. Let's
say an average email address is 10-20 characters, and an average name
is 20-30...

$data = {}
$abc = ("A".."Z").to_a + ("a".."z").to_a
$host = ["@foo", "@bar", "@baz", "@dolor", "@lorem", "@ipsum"]
$tld = [".com", ".org", ".net", ".us", ".tl"]

def email
handle = []
rand(25).times {
handle << $abc[rand($abc.length)]
}
host = $host[rand($host.length)]
tld = $tld[rand($tld.length)]
"%s%s%s" % [handle.join(""), host, tld]
end
def name
first = []
rand(15).times {
first << $abc[rand($abc.length)]
}
middle = []
rand(11).times {
middle << $abc[rand($abc.length)]
}
last = []
rand(21).times {
last << $abc[rand($abc.length)]
}
"%s %s %s" % [first.join(""),
middle.join(""),
last.join("")]
end

csv = File.open("email_name.csv", "w")
1000000.times {
csv.write("%s,%s\n" % [email, name])
}
csv.close

Takes about 3 minutes to run on my box and generates a ~50 meg CSV
file.

HTH,
Jordan

lrlebron@gmail.com

12/7/2007 4:44:00 PM

0

On Dec 7, 6:13 am, Piotr Wlodarek <q...@wp.pl> wrote:
> Recently I've seen a random user generator for Rails on some blog bu I
> can't find it now.
>
> I need to generate 1 million non-existing emails with associated names
> :-)
>
> Could you please recommend a tool?
> --
> Posted viahttp://www.ruby-....

Have you looked at faker
http://faker.ruby...

Luis