0

Some websites create random fake names when you create a project file. For example, creating a project within Heroku could generate "immense-bastion-4566" as a project name. I would like to know how they create those names, because I would like to use the same technique in an iOS app.

My guess is they have a DB with names they just randomly pick names, but where do they get these databases from? Any hints?

Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
jona jürgen
  • 1,789
  • 4
  • 22
  • 31
  • 1
    The number part seems fairly straighforward, I would imagine a PRNG would work for that part. As for the names, a noun list, with PRNG seems like it gets the job done. You can find noun lists online. I can't be sure if `Heroku` employs the same method though. – eazar001 Apr 17 '14 at 22:04

3 Answers3

1

It looks like it'd be two tables: one adjective table, one noun table. When creating a project, they could create a name by picking a random entry from each table, then appending a randomly-generated number to the end.

According to this site, one can efficiently pick a random entry from a table like so (assuming a table definition of id/word):

SELECT `word` FROM `nouns` 
    WHERE id >= (SELECT FLOOR(MAX(id) * RAND()) FROM `nouns`)
ORDER BY `id` LIMIT 1

Repeat for an adjective.

Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
1

As you specifically asked for Heroku, you can read up on their implementation here How can I programmatically generate Heroku-like subdomain names?.

Community
  • 1
  • 1
0

RandomUsername in Ruby uses cultivated lists of adjectives & nouns. It doesn't use a dictionary or general-purpose word database because many of those words have a strong negative connotation, and therefore not appropriate in a business context.

m1foley
  • 516
  • 5
  • 9