Why do I have a picture on my contact list of a iPhone number I wrote down?

I wrote down someone’s phone number on my iPhone. He also had an iPhone. However, we are not connected in any way. Example: no social media, he hasn’t sent me a message, no email, etc. I know that the iPhone pulls pictures from many places but in this case, we don’t have anything in common. How would his picture appear on my phone under his contact name? Thank you in advance for the help.

javascript – List sub-folders and its ID in the given path in Google Drive with Google App Script

I am trying to create a doc file which contains the list of folders in a given folder path. The Main function is the entry point.

// This function performs the operation of creating the file of the list of folders in the specific folder.
// Usage: Set the ListDocName, the ListDocFullPath, and the SpecificFolder, then just run Main function.
function Main() {
  // Set Doc (output) file name
  var ListDocName = "RootFolderList";
  
  // Set Doc (output) file path
  var ListDocFullPath = "/";
  
  // Set specific folder, and this program would list its subfolders to Doc file.
  var SpecificFolder = "/";
  
  CreateGoogleDocInSpecificFolder(ListDocName, ListDocFullPath);
  var DocFiles = GoogleDocsInSpecificFolder(ListDocName, ListDocFullPath);
  
  while(DocFiles.hasNext())
  {
    var docFile = DocFiles.next();
    var docID = docFile.getId();
    var doc = DocumentApp.openById(docID);
    
    var Folders = FoldersInSpecificFolder(SpecificFolder);
    while(Folders.hasNext())
    {
      var Folder = Folders.next();
      // Access the body of the document, then add a paragraph.
      doc.getBody().appendParagraph(SpecificFolder + '/' + Folder.getName() + 't' + Folder.getId());
    }
    doc.saveAndClose();
  }
}

// FoldersInSpecificFolder function would return a FileIterator
function FoldersInSpecificFolder(FolderFullPath)
{
  if(FolderFullPath == '/')
  {
    // Return the FolderIterator in Root.
    return getFolder(FolderFullPath);
  }
  else
  {
    // getFolder return the FolderIterator
    var TargetFolders = getFolder(FolderFullPath);
    while (TargetFolders.hasNext())
    {
      var folder = TargetFolders.next();
      return folder.getFolders();
    }
  } 
}

// GoogleDocsInSpecificFolder function would return a FileIterator
function GoogleDocsInSpecificFolder(docName, FolderFullPath)
{
  if(FolderFullPath == '/')
  {
    // Read files in Root, getFilesByName return the FileIterator
    var RootDocs = DriveApp.getRootFolder().getFilesByName(docName);
    return RootDocs;
  }
  else
  {
    // getFolder return the FolderIterator
    var TargetFolders = getFolder(FolderFullPath);   
    while (TargetFolders.hasNext())
    {
      var folder = TargetFolders.next();
      var docFiles = folder.getFilesByName(docName);
      return docFiles;
    }
  } 
}

function CreateGoogleDocInSpecificFolder(docName, FolderFullPath)
{
  var docID;
  if(FolderFullPath == '/')
  {
    // Create a new Google Doc in Root
    var docRoot = DocumentApp.create(docName);
    var docRootID = docRoot.getId();
    docRoot.saveAndClose();
    return docRootID;
  }
  else
  {
    // Create a new Google Doc in Root
    var docRoot = DocumentApp.create(docName);
    var docRootID = docRoot.getId();
    docRoot.saveAndClose();
    
    // Get new Google Doc file ID (Use in copy)
    var docRootFile = DriveApp.getFileById(docRootID);
    
    var TargetFolders = getFolder(FolderFullPath);   
    while (TargetFolders.hasNext())
    {
      var folder = TargetFolders.next();
      
      // Copy Google Doc to correct file path
      var docFile = docRootFile.makeCopy(docName, folder);
      
      docID = docFile.getId();
    }
    
    // Delete Google Doc in Root
    DriveApp.removeFile(docRootFile);
    
    return docID;
  } 
}

// getFolder function would return the FolderIterator which is locate at Path.
function getFolder(Path)
{
  var SubFolder;
  var arr = Path.split("/");
  for (var i = 1; i < arr.length; i = i + 1)
  {
    var FolderName = arr(i);
    if(i == 1)
    {
      SubFolder = DriveApp.getRootFolder().searchFolders("title contains '"+FolderName+"'");
    }
    else
    {
      if (SubFolder.hasNext())
      {
        var folderTemp = SubFolder.next();
        SubFolder = folderTemp.searchFolders("title contains '"+FolderName+"'");
      }
    }
  }
  return SubFolder;
}

If there is any possible improvement about potential drawback, please let me know.

c# – Better way to keep a list of items from a Http Request?

I have a simple web api where each request “item” is stored in a list and thus a list is built without creating a new list per request. I have achieved this via dependency injection , but I want to know if there is a better way to do it?

(ApiController)
(Route("(controller)"))
public class MyController: ControllerBase
{
    private readonly List<string> _items;

    public WeatherForecastController(List<string> items)
    {
        _items = items;
    }

    (HttpPost)
    public ActionResult GetList((FromBody) CustomRequestObject request)
    {
        _items.Add(request.Item);

        return Ok(new CustomResponseObject(){Items = _items});
    }
}

public class CustomRequestObject
{
    public string Item { get; set; }
}

public class CustomResponseObject
{
    public IList<string> Items { get; set; }
}

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllers();
        services.AddSingleton<List<string>>(); //items stored after each request
    }

    //rest of startup methods left for simplicity
}

javascript – Created a basic User Profile List using an API (React)

I’m relatively new when it comes to programming in React and in JavaScript, but have a surface level understanding of what things do. I’ve created a basic program that fetches user data from an API that generates random users, and appends the users to a list when you click a button. I was wondering if what I’m writing is good enough to be considered for a Jr. React Dev position, and if there’s anything I can improve upon the code such as implementation, name convention, readability, efficiency, etc. In particular, in the UserProfile component, I’m mapping through the state that holds the JSON object that was fetched from the API to output the profile picture and name. I’m not sure if there’s anyway to do it better, but it doesn’t feel quite right to me. Any feed back is much appreciated.

UserProfile.jsx

import React, { useState, useEffect } from "react";

const UserProfile = () => {
  const (userData, setUserData) = useState(());

  const fetchUserData = () => {
    fetch("https://randomuser.me/api")
      .then((resp) => resp.json())
      .then((data) => setUserData(data.results));
  };

  //Creates userProfile with picture/full name
  const userProfile = (userMeta) => {
    const {
      name: { first, last },
      picture: { medium }
    } = userMeta;

    return (
      <>
        <img src={medium} alt="" />
        <p>
          {first}, {last}
        </p>
      </>
    );
  };

  //Fetch API data on component mount
  useEffect(() => {
    fetchUserData();
  }, ());

  return (
    <>
      {userData.map((userMeta, idx) => {
        return <div key={idx}>{userProfile(userMeta)}</div>;
      })}
    </>
  );
};

export default UserProfile;

UserList.jsx

import React, { useState } from "react";
import UserProfile from "./UserProfile";

const UserList = () => {
  const (userList, setUserList) = useState(());

  //Appends UserProfile to List
  const addUser = () => {
    setUserList((prevState) => {
      return (...prevState, <UserProfile />);
    });
  };

  return (
    <div>
      <button onClick={addUser}>Add User</button>
      {userList.map((user, idx) => {
        return <React.Fragment key={idx}> {user} </React.Fragment>;
      })}
    </div>
  );
};

export default UserList;

App.js

import React from "react";
import UserList from "./UserList";

export default function App() {
  return (
    <div className="App">
      <p>USER LIST COMPONENT</p>
      <UserList />
    </div>
  );
}

python – How do i flip a vertical list to a horizontal list?

Create a function that flips a horizontal list into a vertical list, and a vertical list into a horizontal list.

In other words, take a 1 X 𝑛 list (1 row and n columns) and flip it into a 𝑛 X 1 list (n rows and 1 column) and vice versa.

# Take a horizontal list and flip it vertical.
 
flip_list(((5), (6), (9))) ➞ (5, 6, 9)
# Take a vertical list and flip it horizontal.
 
flip_list(()) ➞ ()

Table/list: find the last real number element of each row to constitute a list

I have a list (Table), mostly composed of real numbers. The list also contains some non-real elements. The list is similar to the following (but much much larger):

{{0.11011887269, 0.02087291466, 0.02082444233, 0.02083704779, 
  0.02084940959, 0.02086181292, 0.02087425501, 0.02088673503, 
  0.02089925331, 0.02091181001, 0.02092440529, 0.02093703933, 
  0.02094971232, 0.02096242441, test1(18, 15)}, {0.10941526373, 
  0.017604005802, 0.017549654594, 0.017558686829, test1(19, 5), 
  test1(19, 6), test1(19, 7), test1(19, 8), test1(19, 9), 
  test1(19, 10), test1(19, 11), test1(19, 12), test1(19, 13), 
  test1(19, 14), test1(19, 15)}, {0.10890647143, 0.014986243752, 
  0.014927392616, 0.014934004368, test1(20, 5), test1(20, 6), 
  test1(20, 7), test1(20, 8), test1(20, 9), test1(20, 10), 
  test1(20, 11), test1(20, 12), test1(20, 13), test1(20, 14), 
  test1(20, 15)}}

I would like to construct a single row or column list that preserves the last real number element of each row of the above list. For example, with the above table, the resulting list should contain only 3 elements as:

{0.02096242441, 0.017558686829, 0.014934004368}

How can this resulting list be automatically constructed from the original one?

Ultimate Member – Show List of Posts (Post Type) by all users that current logged in user follows

I am new to the ‘Ultimate Member’ plugin and I am using the ‘UM Followers’ extension plugin.

My users can all generate posts (post type).

I would like to set up a page-template in which the current logged in user can see a list of all posts sorted by most recent, only by users that he/she follows.

I had a look at the following template that generates a list of users using their avatars. But can’t figure out how I could use this to generate the list of posts by users my logged in user follows.

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

if ( $following ) {

    foreach ( $following as $k => $arr ) {
        /**
         * @var $user_id1;
         */
        extract( $arr );

        um_fetch_user( $user_id1 ); ?>
    
        <div class="um-followers-user">
    
            <a href="<?php echo esc_url( um_user_profile_url() ); ?>" class="um-followers-user-photo" title="<?php echo esc_attr( um_user( 'display_name' ) ); ?>">
                <?php echo get_avatar( um_user('ID'), 50 ); ?>
            </a>
        
            <div class="um-followers-user-name">
                <a href="<?php echo esc_url( um_user_profile_url() ); ?>" title="<?php echo esc_attr( um_user('display_name') ); ?>">
                    <?php echo esc_html( um_user( 'display_name' ) ); ?>
                </a>
            
                <?php do_action('um_following_list_post_user_name', $user_id, $user_id1 );

                if ( um_user( 'ID' ) == get_current_user_id() ) { ?>
                    <span class="um-followers-user-span"><?php _e( 'You', 'um-followers' ); ?></span>
                <?php } elseif ( UM()->Followers_API()->api()->followed( get_current_user_id(), $user_id1 ) ) { ?>
                    <span class="um-followers-user-span"><?php _e( 'Follows you', 'um-followers' ); ?></span>
                <?php }

                do_action('um_following_list_after_user_name', $user_id, $user_id1 ); ?>
            </div>
        
            <div class="um-followers-user-btn">
                <?php if ( $user_id1 == get_current_user_id() ) {
                    echo '<a href="' . esc_url( um_edit_profile_url() ) . '" class="um-follow-edit um-button um-alt">' . __( 'Edit profile', 'um-followers' ) . '</a>';
                } else {
                    echo UM()->Followers_API()->api()->follow_button( $user_id1, get_current_user_id() );
                } ?>
            </div>
        
            <?php do_action( 'um_following_list_pre_user_bio', $user_id, $user_id1 ); ?>
        
            <div class="um-followers-user-bio">
                <?php echo um_get_snippet( um_filtered_value( 'description' ), 25 ); ?>
            </div>
        
            <?php do_action( 'um_following_list_post_user_bio', $user_id, $user_id1 ); ?>
        
        </div>
    
    <?php }

} else { ?>

    <div class="um-profile-note">
        <span><?php echo ( $user_id == get_current_user_id() ) ? __( 'You did not follow anybody yet.', 'um-followers' ) : __( 'This user did not follow anybody yet.', 'um-followers' ); ?></span>
    </div>

<?php }```

thanks to anyone who could assist :)

unity – How can I convert List To Vector3 type?

using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public class Waypoints : MonoBehaviour
{
    public GameObject objectPrefab;
    public LineRenderer lineRenderer;
    public List<Transform> pointsToMove;
    public float speed;

    private List<GameObject> objectsToMove;

    void Start()
    {
        objectsToMove = new List<GameObject>();

        //Spawn objects and start movement
        for (int i = 0; i < 3; i++)
        {
            objectsToMove.Add(Instantiate(objectPrefab, transform.parent));
            StartCoroutine(Move(i));
        }
    }

    private IEnumerator Move(int i)
    {
        //Wait interval
        yield return new WaitForSeconds(i * 10);

        bool stillTraveling = true;
        int pointIndex = 0;
        float threshold = 0.1f;

        while (stillTraveling)
        {
            //Check if close to point
            if (Vector3.Distance(objectsToMove(i).transform.position, pointsToMove(pointIndex).position) < threshold)
            {
                //Check if can move next point
                if (pointIndex + 1 > pointsToMove.Count - 1)
                {
                    stillTraveling = false;
                }
                //If not stop moving
                else
                {
                    pointIndex++;
                }
            }

            //Move towards point
            objectsToMove(i).transform.position = Vector3.MoveTowards(objectsToMove(i).transform.position, pointsToMove(pointIndex).transform.position, speed * Time.deltaTime);

            yield return null;
        }
    }

    List<Transform> GetLinePointsInWorldSpace()
    {
        pointsToMove = new Vector3(lineRenderer.positionCount).ToList();
        //Get the positions which are shown in the inspector 
        lineRenderer.GetPositions(pointsToMove.ToArray());

        //the points returned are in world space
        return pointsToMove;
    }   
}

When the List is type Transform and I’m adding for example 3 empty gameobjects to the list then the objectsToMove will travel on this points.

but now I want the objectstoMove to travel over a LineRenderer positions and I have two problems.

  1. The script that create the positions to the linerenderer add the positions a bit later and because this script is running first I need somehow to wait first for the line renderer to have the positions then get them with the function GetLinePointsInWorldSpace.

  2. I’m getting errors in the GetLinePointsInWorldSpace function on this line :

    pointsToMove = new Vector3(lineRenderer.positionCount).ToList();

The pointsToMove is List but it’s getting List

and the line

lineRenderer.GetPositions(pointsToMove.ToArray());

pointsToMove is Transform but GetPositions return array of Vector3

  1. Where to start the Coroutine ? I can’t start it in the Start because the line renderer positions is still empty.

The main goal is to move the object on Transform points or Vector3 positions.
I thought there is a way to use one List for both options.

This script start the moving of the objectsToMove in the Start() but because the line renderer don’t have yet the positions.

This script create the positions and add them to the line renderer :

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

(RequireComponent(typeof(LineRenderer)))
public class CurvedLineRenderer : MonoBehaviour
{
    //PUBLIC
    public float lineSegmentSize = 0.15f;
    public float lineWidth = 0.1f;
    (Tooltip("Enable this to set a custom width for the line end"))
    public bool useCustomEndWidth = false;
    (Tooltip("Custom width for the line end"))
    public float endWidth = 0.1f;
    (Header("Gizmos"))
    public bool showGizmos = true;
    public float gizmoSize = 0.1f;
    public Color gizmoColor = new Color(1, 0, 0, 0.5f);
    public static bool linesSet = false;
    //PRIVATE
    private CurvedLinePoint() linePoints = new CurvedLinePoint(0);
    private Vector3() linePositions = new Vector3(0);
    private Vector3() linePositionsOld = new Vector3(0);

    private void Start()
    {
        
    }

    // Update is called once per frame
    public void Update()
    {
        GetPoints();
        SetPointsToLine();
    }

    public void GetPoints()
    {
        //find curved points in children
        linePoints = this.GetComponentsInChildren<CurvedLinePoint>();

        //add positions
        linePositions = new Vector3(linePoints.Length);
        for (int i = 0; i < linePoints.Length; i++)
        {
            linePositions(i) = linePoints(i).transform.position;
        }
    }

    public void SetPointsToLine()
    {
        //create old positions if they dont match
        if (linePositionsOld.Length != linePositions.Length)
        {
            linePositionsOld = new Vector3(linePositions.Length);
        }

        //check if line points have moved
        bool moved = false;
        for (int i = 0; i < linePositions.Length; i++)
        {
            //compare
            if (linePositions(i) != linePositionsOld(i))
            {
                moved = true;
            }
        }

        //update if moved
        if (moved == true)
        {
            LineRenderer line = this.GetComponent<LineRenderer>();

            //get smoothed values
            Vector3() smoothedPoints = LineSmoother.SmoothLine(linePositions, lineSegmentSize);

            //set line settings
            line.positionCount = smoothedPoints.Length;
            line.SetPositions(smoothedPoints);
            line.startWidth = lineWidth;
            line.endWidth = useCustomEndWidth ? endWidth : lineWidth;

            linesSet = true;
        }
    }

    void OnDrawGizmosSelected()
    {
        Update();
    }

    void OnDrawGizmos()
    {
        if (linePoints.Length == 0)
        {
            GetPoints();
        }

        //settings for gizmos
        foreach (CurvedLinePoint linePoint in linePoints)
        {
            linePoint.showGizmo = showGizmos;
            linePoint.gizmoSize = gizmoSize;
            linePoint.gizmoColor = gizmoColor;
        }
    }
}

It was working fine with the List before but now I want it to move over the line renderer positions and not just on TRansforms. It could be better if the objectsToMove could move between Transform’s and/or line renderer positions at the same time.

json formatting – How to display past list items related to a column value?

I have the following SharePoint list in which the “Participant” columns are text values (names of people) and each item in this list is a training event. “Evenement” is the type of training and “Jour” means day of the training.

What I need to do is whenever someone hovers on the name of a participant – I need their past training events to show.
For example if “Participant 1” is Alpha and his “Jour 1” is on 11-05-2021 then “Jour 2” is on 12-05-2021 and “Jour 3” is 13-05-2021 and finally “Jour 4” is 14-05-2021. I need all this information to show on a hovercard if possible?

I am not sure if this makes complete sense or not and if it’s even possible but any guidance would be appreciated, thank you in advance to anyone who replies and please be advised I’m only starting with JSON .

Sharepoint List Preview

How to assign an Integer to a item in list – Python card game

I am new to python and I have been having some trouble making this card game In between also known as Acey Duecy.
I have made my deck of cards using a list with the code :

cardname = ("ACE","TWO","THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE","TEN","JACK","QUEEN","KING")
suit = ( "OF CLUBS","OF DIAMONDS","OF HEARTS","OF SPADES")
deck = ()
for n in range(4):
    for i in range(13):
        all_card = (cardname(i) + " " + suit(n))
        deck.append(all_card)

After assigning a integer to the item in the list, I would like to remove the 2 cards if they are the same, but since I havent assigned them numbers and they are just strings right now the code does not work. I would also not want to have to assign each 52 cards the value manual since in my game the suits don’t matter thus its just the Ace, two, three etc.

first_card = deck(0)
second_card = deck(1)

if first_card == second_card :
    print(".pop = False")
    deck.pop(0)
    deck.pop(0)
    print(deck)
else :
    print("They are not the same card")
```