How do I make it so that dropdown option selection is linked to radio button selection HTML?

I am brand new to web development, and I was learning about linking radio buttons when faced with a ‘choice’ on a web-site, so that you cannot select multiple radio buttons that are related to a single question.

I thought “Is it possible to make is so that you have a drop-down menu that is linked to the radio buttons, so that when you select an option from the menu, the radio buttons cannot be selected?”

Here’s what I did:

enter image description here

As you can see, I can select both the “Dogs” radio button and an option from the selection menu “Other”. At the top of the URL, it says that the name “animalSelect” is equal to both DOGS and Lemur.

How do I make it so that it only picks one or the other?

(This is also my first question, so if anybody has any suggestions for asking questions on the site, do let me know. Thank you.)

Seeing a weird navigation behavior in modern team site linked to hubsite

I am working with SP Online in modern experience and many team sites created and linked to HubSite “Home”, the hub navigation shows perfectly fine.

Since last couple of days, I am seeing another row of weird navigation in a row below hub nav and I have no idea where this comes from. enter image description here

Can’t enable publishing features on team site modern, so navigation option is not even showing up under site settings, so how can it appear all of a sudden, was not showing up before at all.

Can someone please assist, thanks in advance.

Adjacency List list of linked list or can be repesented in other ways?

I am new to graph data structure. Everywhere on google it is said to be list(or array ) of linked list. My question is can not it be represented as list of list(in java array list of array list) or map of list(in java HashMap with key as node and value as array list of connected node ) ?

In all three mentioned approach I see time complexity

To find if two nodes are connected – O(v) To find all connected nodes – O(v)

Also space complexity will also be more or less same .

So why Adjacency List is said to be list(or array ) of linked list not as list of list or map of list ?

Detecting deadlocks in thread safe linked list

I recently got a homework to implement a thread safe singly linked list which locks elements in hand over hand method which means that there is a single lock for every element in the list.I implemented all the functions and tested them without having to deal with problematic thread situations and they all worked but I wanted to test if there could be a situation of a deadlock or a starvation but I do not know how to do it and can I know from looking at my code if I could have deadlock or starvation ? I am also not sure if there there needs to be this much locking and unlocking in the code. Any help or suggestion regarding my code if it its prone to deadlocks and starvation or any other problems ? I will post my code below. Thanks in advance.

concurrent_list.h :

typedef struct node node; typedef struct list list;  list* create_list(); void delete_list(list* list); void print_list(list* list); void insert_value(list* list, int value); void remove_value(list* list, int value); void count_list(list* list, int (*predicate)(int)); 

concurrent_list.c :

 #include <pthread.h>  #include <stdio.h>  #include <stdlib.h>  #include <limits.h>  #include "concurrent_list.h"  struct node {   int value;   node* next;   pthread_mutex_t lock; // hand over hand implies a lock for every node };  struct list {   node* head; };  // print the value of a node void print_node(node* node) {   if(node)   {     printf("%d ", node->value);   }  }  // create  a new empty list list* create_list() {     list* l =(list*)malloc(sizeof(list));      if(l == NULL) return NULL;      l->head = NULL;      return l; }  // delete the entire list void delete_list(list* list) {   if(list == NULL) return; // if list pointer is NULL then do nothing    node* current = list->head;    if(current == NULL) return; // if list head is NULL then do nothing    pthread_mutex_lock(&(current->lock)); // lock list head    node* temp = current->next;   node* dummy;    if(temp == NULL) // delete the only element in the list   {      pthread_mutex_unlock(&(current->lock));      pthread_mutex_destroy(&(current->lock));      free(current);      return;   }    pthread_mutex_lock(&(temp->lock)); //lock successor of the head    while (1)   {      pthread_mutex_unlock(&(current->lock)); // unlock current node      dummy = current;      current = temp; // current becomes it's successor      pthread_mutex_destroy(&(dummy->lock));      free(dummy); // free dummy because it is a pointer to current      temp = temp->next; // current becomes it's successor      if(temp == NULL) break; // exit loop if we are at the end of the       list      pthread_mutex_lock(&(temp->lock)); // lock current's successor   }       pthread_mutex_unlock(&(current->lock));      pthread_mutex_destroy(&(current->lock));      free(current); // free the last element in the list      list->head = NULL;      free(list); // free the list   }    // insert function for a new value if a value already exists then do    nothing   void insert_value(list* list, int value)   {      if(list == NULL) return; // if list pointer is NULL then do nothing       node* new_node = malloc(sizeof(node)); // create new node       if(new_node == NULL) return; // check if allocation fails       new_node->value = value;       new_node->next = NULL;       pthread_mutex_init(&(new_node->lock),NULL);  // initialize fast mutex lock for the new node       pthread_mutex_lock(&(new_node->lock)); // lock the new node       if(list->head == NULL) // new node is the first element in the list      {         new_node->next = NULL;         list->head = new_node;         pthread_mutex_unlock(&(new_node->lock));         return;      }        pthread_mutex_lock(&(list->head->lock)); // lock the head of the list        node* temp;        if(list->head->value >= new_node->value) // new node comes before the list head      {        new_node->next = list->head;        temp = list->head;        list->head = new_node;        pthread_mutex_unlock(&(list->head->lock));        pthread_mutex_unlock(&(temp->lock));        return;      }      else     {       // Locate the node before the point of insertion //       node* dummy;      node* current = list->head;      temp = current->next;       if(temp == NULL) // new node comes after the list head      {          new_node->next = current->next;          current->next = new_node;          pthread_mutex_unlock(&(new_node->lock));          pthread_mutex_unlock(&(current->lock));          return;      }      pthread_mutex_lock(&(temp->lock)); // lock the successor of the head    // perform hand over hand traversal of the list   // and check if temp reaches the end of the list (NULL)     while (temp->value < new_node->value)    {      pthread_mutex_unlock(&(current->lock));      current = temp;      temp = temp->next;      if(temp == NULL) break;      pthread_mutex_lock(&(temp->lock));    }     if(temp == NULL) // new node will be the last element in this case    {        current->next = new_node;        new_node->next = NULL;        pthread_mutex_unlock(&(current->lock));        pthread_mutex_unlock(&(new_node->lock));        return;    }     else // new node should be inserted inside the list    {        dummy = temp;        new_node->next = current->next;        current->next = new_node;        pthread_mutex_unlock(&(dummy->lock));        pthread_mutex_unlock(&(current->lock));        pthread_mutex_unlock(&(new_node->lock));        return;    }  } }   //delete the first appearance of a value in the list if it exists in the list     void remove_value(list* list, int value)     {       if(list == NULL) return; // if list pointer is NULL then do nothing        node* temp;       node* current = list->head;        if(current == NULL) return; // if list head is NULL then just go to a new line       pthread_mutex_lock(&(current->lock)); // lock the head of the list       if(current->value == value) // delete the head of list if it's value is equal to given value     {         temp = current;         list->head = current->next;         pthread_mutex_unlock(&(temp->lock));         pthread_mutex_destroy(&(temp->lock));        free(temp);        return;    }      else    {        temp = current->next;         if(temp == NULL)        {            pthread_mutex_unlock(&(current->lock));            return;        }         pthread_mutex_lock(&(temp->lock)); // lock the successor of the head          // perform hand over hand traversal of the list        //  and check if temp reaches the end of the list (NULL)      while (temp->value != value) // find the first appearance of a node      that has a value the same as the one given         {           pthread_mutex_unlock(&(current->lock));           current = temp;           temp = temp->next;           if(temp == NULL) break;           pthread_mutex_lock(&(temp->lock));         }           if(temp == NULL) // value not found         {             pthread_mutex_unlock(&(current->lock));             return;         }          else // delete the suitable node         {             current->next = temp->next;             pthread_mutex_unlock(&(current->lock));             pthread_mutex_unlock(&(temp->lock));             pthread_mutex_destroy(&(temp->lock));             free(temp);            return;         }     } }   //print the entire list  void print_list(list* list)  {   if(list == NULL) // if list pointer is NULL then just go to a new line   {       printf("\n");       return;   }        node* current = list->head;        if(current == NULL) // if list head is NULL then just go to a new line       {          printf("\n");          return;       }        pthread_mutex_lock(&(current->lock)); // lock the head of the list        print_node(current); // print the head of the list        node* temp = current->next;        if(temp == NULL) // a list with 1 element       {          printf("\n");          pthread_mutex_unlock(&(current->lock));          return;       }       pthread_mutex_lock(&(temp->lock)); // lock the list head's successor      while (1)     {        pthread_mutex_unlock(&(current->lock)); // unlock current node        current = temp; // current becomes it's successor        print_node(current); // print current node        temp = temp->next; // // temp becomes it's successor        if(temp == NULL) break; // exit loop if we reach the end of the list       pthread_mutex_lock(&(temp->lock)); // lock temp    }      pthread_mutex_unlock(&(current->lock)); // unlock the last list      element    printf("\n"); }   // print how many nodes in the list satisfy a given predicate function  void count_list(list* list, int (*predicate)(int))  {     int count = 0;     if(list == NULL) // if list pointer is NULL then print that count =     0 and finish    {       printf("%d items were counted\n", count);       return;    }     node* current = list->head;     if(current == NULL) // if list head is NULL then print that count =     0 and finish    {        printf("%d items were counted\n", count);        return;    }     pthread_mutex_lock(&(current->lock)); // lock the list head     if(predicate(current->value)) count++; // check the predicate for     the list head     node* temp = current->next;     if(temp == NULL) // list has only 1 element    {       pthread_mutex_unlock(&(current->lock));       printf("%d items were counted\n", count);       return;    }     pthread_mutex_lock(&(temp->lock)); // lock the list head's successor     while (1)   {     pthread_mutex_unlock(&(current->lock)); // unlock current node     current = temp; // current becomes it's successor     if(predicate(current->value)) count++; // check predicate for current node     temp = temp->next; // // temp becomes it's successor     if(temp == NULL) break; // exit loop if we reach the end of the list     pthread_mutex_lock(&(temp->lock)); // lock temp    }     pthread_mutex_unlock(&(current->lock)); // unlock the last list element     printf("%d items were counted\n", count); // print count } 

How to display linked third party sign in methods

I am writing an app. Like Google suggests, the user should be to be able to link multiple sign in methods to their account. In order to do that, the ideas of “identities” and “accounts” are separated in the RESTful backend.

When signing up/in with a third party SDK, the access token (or ID token in the case of Google) gets sent to the backend, which then verifies and forgets about it. The app also forgets about this information, as it receives a separate bearer token from the server.

In the account settings, I now want to display a list of all linked accounts. The app receives an array containing the user IDs from the third party accounts. It should then populate the list with profile pictures and names.

The problem: Third party identity provider APIs only seem to hand out information like usernames and profile pictures if they are given the user’s access token. I looked everywhere for APIs without access tokens. I thought at least the username would be public information and could be retrieved with a simple HTTP GET request and the user ID.

Google seems to have had a Google Plus API that was useful, but that is being shut down. The Google People API gives access to names, but required OAuth2 authentication. Facebook has the Graph API, which also wants the user’s access token. Twitter has https://api.twitter.com/1.1/users/show.json, which requires authentication headers.

How does one go about this?

I could store the access token from the third party sign up on the client. Not only does this seem very sloppy, but it also comes with a problem: If the user buys a new phone, the access tokens are lost and the linked accounts list can’t be displayed correctly.

Another possibility would be to store the access/ID token on the server. The server could then either send all access tokens back to the client when it needs them, or populate usernames and profile pictures itself. But this seems like a huge security issue. Surely, access tokens are not meant to be kept around for a long time?

The backend could store the information like the username, the email address and the profile picture the moment the user signs up with a third party account. It would then not have to keep the access token. However, if the user changes their profile information in the third party account, these changes go unnoticed. In addition to that, storing a third party profile picture on the server seems absurd.

Adding elements of 2 linked list in reverse order

I solved a problem with JavaScript which has the following requirements:

  1. Two non-empty linked lists representing two non-negative integers.
  2. Digits stored in reverse order
  3. Each node contains a single digit
  4. Add the two numbers and return it as a linked list

Sample I/O:

Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Output: 7 -> 0 -> 8 Explanation: 342 + 465 = 807 

My code:

 /**  * Definition for singly-linked list.  * function ListNode(val) {  *     this.val = val;  *     this.next = null;  * }  */ /**  * @param {ListNode} l1  * @param {ListNode} l2  * @return {ListNode}  */ var addTwoNumbers = function(l1, l2) {   let l1Str = "";   let l2Str = "";   while (l1 !== null) {     l1Str += l1.val.toString();     l1 = l1.next;   }    while (l2 !== null) {     l2Str += l2.val.toString();     l2 = l2.next;   }    let sum = (BigInt(l1Str.split("").reverse().join("")) + BigInt(l2Str.split("").reverse().join(""))).toString();    let resultNodeList = new ListNode(sum[sum.length - 1]);   let resultHead = resultNodeList;   for (let i = sum.length - 2;i >= 0;i--) {     resultNodeList.next = new ListNode(sum[i]);     resultNodeList = resultNodeList.next;   }    return resultHead;  };  

Note: I had to use BigInt cause parseInt won’t work on big integers as expected.

Although it passed all test cases, what are some ways to improve this code in terms of both time and space complexity?

what is wrong with my copy constructor for a singly linked list?

I’m trying to write a singly linked list and am stuck on the part of the copy constructor. I got the add and display to work prior to this, and tried using the add for the copy constructor, but it just exits the program with exit code -1 on replit. I’ve asked my friend about it and he got it to work on xcode. But I’ve tried replit visual studio and netbeans with no avail. My node class is just a struct with an int and a pointer to another node. Can you help me with this? thanks

my member functions:

Flist::Flist(const Flist &other) {     Node *x = other.head;     if (other.head == nullptr) {         head = nullptr;     } else {         while (x != nullptr) {             add(x->val);             x = x->next;         }     } }  void Flist::add(const int &value) {     Node *x = head;     if (x == nullptr) {         head = new Node{value, nullptr};     } else {         while (x->next != nullptr) {             x = x->next;         }         Node *n = new Node{value, nullptr};         x->next = n;     }     ++size_; }  void Flist::display() {     Node *x = head;     if (x == nullptr) {         std::cout << "empty";     } else {         while (x != nullptr) {             std::cout << x->val;             x = x->next;         }     } } 

Add and display works and outputs: 56

Flist a; a.add(5); a.add(6); a.display(); 

but doing this exits with -1 on replit

Flist a; a.add(5); a.add(6); Flist b(a); b.display(); 

How to query contact details for linked messaging apps profiles (Specially Telegram) and launch them with tasker?

Since the TouchlessChat app was deleted from the PlayStore I am trying to create a task that simulates the behavior of it.

Right now I am able to capture my message using voice and get the contact ID with AutoContacts. Now I need to do something like:

If Telegram Send Telgram Message Else If WhatsApp Send WhatsApp Message Else Send SMS 

But I am not able to get the Telegram info for it (AutoContacts has a WhatsApp Uri). My closest friends and family use Telegram so it is almost my first option.

Is there a way to query the contact details to get the correct Telegram URI or similar so I can launch the app with it?