Automatic username generation from name fields at registration

Drupal core 8.6.5

I am trying to change the user registration process to omit the username field and generate the username from first name and last name.

Since I am new to Drupal and want to learn more I try to go without project modules for that task.

So far I set up a custom module and deactivated the username field. Now I should set a default value for it.

How can I set the username built of first name and last name before the process is going on? And strip some blancs, unallowed characters, …

My module so far:

/** * Implements hook_form_FORM_ID_alter(). */ function my_register_form_user_register_form_alter(&$ form, FormStateInterface $ form_state, $ form_id) {
$ form[‘account’][‘name’][‘#access’] = FALSE; $ form[‘account’][‘name’][‘#default_value’] =’tbd’; }

Thanks for your help!

A generation of Weierstrass approxiamation theorem.

By Weierstrass’s approximation theorem , every continuous function $ f$ supported on an closed interval can be uniform approximated by polynomials . But , is it true that for every continuous $ f$ on $ [0,1]$ , there exist a sequence of polynomials $ \{f_n\}_{n=0}^{\infty}$ with $ f_N=\sum_{n=0}^N a_n x^n$ ($ a_N \neq 0$ ) such that $ f_n$ converges to $ f$ ?

My attempt:

For function $ f=0$ , we can let $ g_n=\frac{e^x}{n}$ and let $ $ f_N=\frac{\sum_0^N \frac{1}{n!}x^n}{N}$ $ then we can find $ f_n$ converges to $ 0$ uniformly . For each continuous function $ g$ supported on $ [0,1]$ , if we can find a sequence of polynomials $ \{h_n \}_{n=0}^{\infty}$ such that $ h_n$ converges to $ g$ uniformly and the degree of $ g_n$ is less than $ n$ , then with $ f_N$ defined above , let $ g_n=h_n+f_n$ . We can prove that $ g_n$ converges to $ g$ uniformly .

So, to prove the assertion above , it suffice to prove that following statement :
For every continuous function $ f$ supported on $ [0,1]$ , we can find a sequence of polynomials $ \{f_n \}_{n=0}^{\infty}$ with the degree of $ f_n$ less than $ n+1$ , such that $ f_n$ converges to $ f$ .

Let $ \{g_n \}$ be polynomials converges to $ f$ uniformly , and let $ k(n)$ denot the degree of $ g_n$ . Then we can contrust $ f_n$ such that $ f_0=f_1=…=f_{k(0)-1}=0$ , $ f_{k(0)}=g_0$ . For $ n={1,2,3,…} $ , if $ k(n)\le n$ then $ f_{n}=g_{n}$ . If $ k(n) \gt n$ , let $ f_n=f_{n+1}=…=f_{k(n)-1}=f_{n-1}$ and $ f_{k(n)}=g_n$ . Since $ f_n$ conveges to $ f$ uniformly , the proof is complete . Is my proof correct ?

Here’s a token generation system in py3.7

I’ve created a system to generate tokens that could potentially be used in some sort of program.

# is simply to generate the tokens, not to check them.  import string, secrets, random  # String is for getting all ascii letters and digits. # Secrets is for a cryptographically secure function to choose chars. # Random is providing a random number generator.  # Base functions used to generate a token  def _tknFrag(length: int=32):     """Generates a tknFrag, or Token Fragment."""     return ''.join(secrets.choice(string.ascii_letters + string.digits) for _ in range(length))  def _tknFragLen():     """Returns the tknFrag's tknFragLen, or Token Fragment Length, an int in between 30 and 34"""     return int(random.randint(30, 34))  def _insDot(tknFrag: str):     """Inserts a dot in the tknFrag at the end"""     tknFrag += "."     return tknFrag  def _insDash(tknFrag: str):     """Inserts a dash in the tknFrag at the end"""     tknFrag += "-"     return tknFrag  def _ins(tknFrag: str):     """Inserts a dash or a dot inside of the tknFrag"""     return {         "0" : lambda frag: _insDot(tknFrag=frag),         "1" : lambda frag: _insDash(tknFrag=frag)     }[str(random.randint(0, 1))](tknFrag)  # Now on to actually generating the tokens  # This is one last helper function, completely generating a fragment def tokenFragment(repetition):     """Generates a fragment with the random length, and the dot/dash. The repetition is to determine wether or not to actually put the dot/dash at the end of the token."""     return _ins(_tknFrag(length=_tknFragLen())) if repetition != 2 else _tknFrag(length=_tknFragLen())  def token():     """Generates a three-fragment-long token"""     return "".join([tokenFragment(repetition) for repetition in range(3)])  # Gotta test it somehow  if __name__ == '__main__':     print(token()) 

Here are five results from running the above code:






Any advice would be appreciated! ^w^

Problems with videos after 12 minutes on iPod Nano 3rd generation

I’m watching videos on a 3rd generation iPod Nano and there is a strange problem. Some videos, maybe 10% of all videos, specifically after around 12 minutes, either stop completely (the video player exits back to the list of videos), or video and audio gets out of sync (the video seems to skip ahead up to 10 minutes, while the audio keeps playing where it’s supposed to).

Some additional details:

  • The video plays fine in VLC or mplayer on the Mac
  • The problem persists if I remove the audio track (ffmpeg -an)

Update: Interestingly, I’ve discovered that the videos that fail on the iPod Nano also seem to fail in iTunes and QuickTime on the Mac, but in different ways and places. For example, one video plays fine in QuickTime until 3:45, after which video fails to play while audio plays fine. Also, at this point, pausing QuickTime causes VTDecoderXPCService to use all available CPU.

My best guess is that a particular encoding scheme must be enforced for Apple-specific video players. Can anyone explain the phenomenon and suggest a cure?

This is the conversion method I’m using:

ffmpeg in.mp4 -vcodec libx264 -acodec aac -ac 2 -ar 44100 -ab 128k -profile:v baseline -level 3.0 -pix_fmt yuv420p -vf scale=320:240 out.mp4 

Possible solution: Adding -r 30000/1001 from here makes the video play in iPod and QuickTime, but can anyone explain why? (Input file framerate is 23.98, while 30000/1001 is 29.97.)

Lead Generation Linkedin Emails for $5

Lead Generation Linked in Emails 1.I can figure you out 10 lead generation emails from linkedin,if you want more you can order multiple. 2.Only genuine email id’s will be provided 3.Remember you must Provide your target source 4.We are only accepting linked in profiles 5.If you want more info ,you have to fisrt message me.then only order 6.100% Trustworthy And Genuine Service 7.Very Usefull for B2B Bussiness Growth 8.If i am unable to give you result,i will intiate a full refund.So no money lose !

by: rsoorajs
Created: —
Category: Other
Viewed: 93