Fake names

Needed to generate fake names and emails today for a stub API I’m developing. Found a github gist that did the trick. Very easy. Just had to install the faker gem first:

$ sudo gem install faker

The example generates to CSV but I needed from object instances for C# so changed the code as such:

require 'faker'
require 'securerandom'

File.open("output.txt", "wb") do |file|
  i=0
  until i == 500
    uuid = SecureRandom.uuid
    fake = "new SearchUserResult("" + Faker::Name.name + "", "" +
        Faker::Internet.email + "", UserType.Person, "" + uuid + ""),n"
    file << fake
    i=i+1
  end
end

Published by

lekkim

Positive, competent, out-spoken, frank and customer focused architect and developer with a strong foundation in web, cloud and product development. I'm a strong advocate for API first and cloud based solutions and development. I have a knack for being able to communicate and present technically complicated matters in conference, customer and training settings. I've previously acted as team member and leader in a product organisation.