Posted in code thoughts
270
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
36
This Month
113
This Year
2247

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...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

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

"Olivia, my eldest daughter, caught measles when she was seven years old. As the illness took its usual course I can remember reading to her often in bed and not feeling particularly alarmed about it. Then one morning, when she was well on the road to recovery, I was sitting on her bed showing her how to fashion little animals out of coloured pipe-cleaners, and when it came to her turn to make one herself, I noticed that her fingers and her mind were not working together and she couldn’t do anything. 'Are you feeling all right?' I asked her. 'I feel all sleepy,' she said. In an hour, she was unconscious. In twelve hours she was dead. The measles had turned into a terrible thing called measles encephalitis and there was nothing the doctors could do to save her. That was...in 1962, but even now, if a child with measles happens to develop the same deadly reaction from measles as Olivia did, there would still be nothing the doctors could do to help her. On the other hand, there is today something that parents can do to make sure that this sort of tragedy does not happen to a child of theirs. They can insist that their child is immunised against measles. ...I dedicated two of my books to Olivia, the first was ‘James and the Giant Peach’. That was when she was still alive. The second was ‘The BFG’, dedicated to her memory after she had died from measles. You will see her name at the beginning of each of these books. And I know how happy she would be if only she could know that her death had helped to save a good deal of illness and death among other children."

I just checked google books for BFG, and the dedication is there. 

https://www.google.com.au/books/edition/_/quybcXrFhCIC?hl=en&gbpv=1 


Roald Dahl, 1986
Random CSS Property

initial

The initial CSS keyword applies the initial (or default) value of a property to an element. It can be applied to any CSS property. This includes the CSS shorthand all, with which initial can be used to restore all CSS properties to their initial state.
initial css reference