Random users generator

P

Piotr Wlodarek

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?
 
L

Lloyd Linklater

Piotr said:
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
 
M

MonkeeSage

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?

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
 
P

Peter Hickman

Piotr said:
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.
 
P

Piotr Wlodarek

Peter said:
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 said:
What possible *legitimate* need could you have for a million
random email addresses and names?

Testing for performance.
 
S

Siep Korteling

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

how about

name="Aaaaaaaa"
1000000.times {puts name.next}
 
P

Piotr Wlodarek

Siep said:
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.
 
M

MonkeeSage

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



Testing for performance.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,274
Messages
2,571,365
Members
48,050
Latest member
Carson62C3

Latest Threads

Top