Posted in code thoughts
1762
12:34 am, November 30, 2022
 

generate a random username function thoughts

I was looking though some of my functions to make more useful web tools from them and i came across the function for generating a username. 

I think originally i created this function to generate random usernames for comments so that the user did not have to select a username manually. 

I cant remember where i got the list from, but it seems to be quite duplicated.

How the function for username generation works?

  1. There is a string called usernames with names seperated by spaces.
  2. Then the names are added to an array using a string to array function. 
  3. There is another string with username prefixes
  4. The prefix string also gets added to an array
  5. There is a random function on the loop count to check how many usernames are added to the return string
  6. Count the total items in the username array
  7. Pick a random prefix from the array
  8. Enter the loop
    1. Shuffle the array
    2. Pick out an item from the array
    3. If prefixes are set then add a prefix
  9. Return the username

Keep it Simple or Make it more Complex?

When i was writing the tool for this i thought, oh i can add this to an api and return a username, but then i have to be able to specify how many names it returns, and then check the list of names that it generates from, should i add more names, where do i get the names from, should the names be in a database or just leave as a string.

It is better to leave it simple or does it benifit from making it more complex. 

Keep it simple for the initial tool page, and then make it more complex for the api version and release it on rapid an API to generate usernames.

View the Generate Random Username Tool

View Statistics
This Week
50
This Month
230
This Year
646

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Items in code thoughts
Search Articles
Search Articles by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
therock Somewhere along this crazy road I learned (often times the hard way) the most important things I can do is be authentic, trust my gut, be the hardest worker in the room, celebrate the mistakes, be a grateful man and always remember that it's nice to be important, but it's more important to be nice.
The Rock
Random CSS Property

border-block-end-color

The border-block-end-color CSS property defines the color of the logical block-end border of an element, which maps to a physical border color depending on the element's writing mode, directionality, and text orientation. It corresponds to the border-top-color, border-right-color, border-bottom-color, or border-left-color property depending on the values defined for writing-mode, direction, and text-orientation.
border-block-end-color css reference