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?
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?
Piotr W. 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
On Dec 7, 6:13 am, Piotr W. [email protected] 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-forum.com/.
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
Piotr W. 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.
Piotr W. wrote:
Peter H. 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}
Siep K. wrote:
Piotr W. wrote:
Peter H. 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!
Siep K. wrote:
Piotr W. wrote:
Peter H. 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.
On Dec 7, 2007, at 7:13 AM, Piotr W. wrote:
Recently I’ve seen a random user generator for Rails on some blog bu I
can’t find it now.
Peter H. 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.
On Dec 7, 7:48 am, Piotr W. [email protected] wrote:
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-forum.com/.
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
On Dec 7, 6:13 am, Piotr W. [email protected] 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-forum.com/.
Have you looked at faker
http://faker.rubyforge.org/
Luis
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs