问:
How to handle multiple inputs in Java in one application
Perhaps my title is not very clear, but I try to understand this problem.

Problem: I have many assignments and different persons solve them using their own way. They may need input from user process it and do what they want, I want to individually run their solutions as well as in a framework which run all solutions in one go. Below is the overall simplistic approach I designed as a framework.

But as this code straight showing me that I will get NoSuchElementException (using Scanner) StreamClosed (using BufferedReader) approach.

How can I achieve this or am I thinking very wrong or missing any core concepts?

I don't want a scanner in main and pass its instance to all my code,( is this the only approach I can solve it)

public class AssignmentRunner {

    public static void main(String[] args) {
        AssignmentRunner runner = new AssignmentRunner();
        AssignmentExecutor executor = new AssignmentExecutor();
        executor.execute();
    }
}

public interface Assignment {
    void execute();
}

class AssignmentExecutor {
    public List<Assignment> assignmentList ;

    private void addAssignments(){
        assignmentList = new ArrayList<Assignment>();
        assignmentList.add(new Assignment1());
        assignmentList.add(new Assignment2());
    }

    public void execute() {
        addAssignments();
        for (Assignment assigment : assignmentList) {
            assigment.execute();
        }
    }
}

public class Assignment1 implements Assignment {
    String inputString;

    @Override
    public void execute() {
        input();
        System.out.println(inputString);
    }

    private void input() {
        Scanner scanner = new Scanner(System.in);
        try {
            inputString = scanner.nextLine();
        }
        catch (Exception e) {
            System.err.println(e.getMessage());
        }
        finally {
            scanner.close();
        }
    }
}

public class Assignment2 implements Assignment  {
    String inputString;

    @Override
    public void execute() {
        input();
        System.out.println("Hello"+inputString);
    }

    private void input() {
        Scanner scanner = new Scanner(System.in);
        try {
            inputString = scanner.nextLine();
        }
        catch (Exception e) {
            System.err.println(e.getMessage());
        }
        finally {
            scanner.close();
        }
    }
}
```
<p><strong>EDIT:</strong> As per some comments and one answer I have made few modifications,kindly help me to understand is this the only best thing we can do or any other way to design my need.</p>
<p><strong>NEED</strong> Different students can have different assignments for example (some may need input,others may not need any input)</p>
<ol>
<li>simply print hello world</li>
<li>input string and show word count</li>
<li>input number show factorial</li>
<li>input number print its table</li>
</ol>
<p>We want to execute each assignment class individually as well as from one Runner class as  shown above.</p>
<p><strong>MODIFICATION</strong> I did these modifications to all classes, showing sample for understanding what I did.</p>
```class AssignmentExecutor {
    public List<Assignment> assignmentList ;

    private void addAssignments(){
        assignmentList = new ArrayList<Assignment>();
        assignmentList.add(new Assignment1());
        assignmentList.add(new Assignment2());
    }

    public void execute() {
        Scanner scanner = new Scanner(System.in);
        addAssignments();
        for (Assignment assigment : assignmentList) {
            assigment.execute(scanner);
        }
        scanner.close();
    }
}

    public class Assignment1 implements Assignment {
        String inputString;

    public static void main(String args[]) {
        Assignment1 assignment1 =new Assignment1();
        Scanner scanner = new Scanner(System.in);
        assignment1.execute(scanner);
        scanner.close();
    }

        @Override
        public void execute(scanner) {
            input(scanner);
            System.out.println(inputString);
        }

        private void input(scanner) {
            scanner = new Scanner(System.in);
            try {
                inputString = scanner.nextLine();
            }
            catch (Exception e) {
                System.err.println(e.getMessage());
            }
        }
    }
```

Body:
Perhaps my title is not very clear, but I try to understand this problem.

Problem: I have many assignments and different persons solve them using their own way. They may need input from user process it and do what they want, I want to individually run their solutions as well as in a framework which run all solutions in one go. Below is the overall simplistic approach I designed as a framework.

But as this code straight showing me that I will get NoSuchElementException (using Scanner) StreamClosed (using BufferedReader) approach.

How can I achieve this or am I thinking very wrong or missing any core concepts?

I don't want a scanner in main and pass its instance to all my code,( is this the only approach I can solve it)

public class AssignmentRunner {

    public static void main(String[] args) {
        AssignmentRunner runner = new AssignmentRunner();
        AssignmentExecutor executor = new AssignmentExecutor();
        executor.execute();
    }
}

public interface Assignment {
    void execute();
}

class AssignmentExecutor {
    public List<Assignment> assignmentList ;

    private void addAssignments(){
        assignmentList = new ArrayList<Assignment>();
        assignmentList.add(new Assignment1());
        assignmentList.add(new Assignment2());
    }

    public void execute() {
        addAssignments();
        for (Assignment assigment : assignmentList) {
            assigment.execute();
        }
    }
}

public class Assignment1 implements Assignment {
    String inputString;

    @Override
    public void execute() {
        input();
        System.out.println(inputString);
    }

    private void input() {
        Scanner scanner = new Scanner(System.in);
        try {
            inputString = scanner.nextLine();
        }
        catch (Exception e) {
            System.err.println(e.getMessage());
        }
        finally {
            scanner.close();
        }
    }
}

public class Assignment2 implements Assignment  {
    String inputString;

    @Override
    public void execute() {
        input();
        System.out.println("Hello"+inputString);
    }

    private void input() {
        Scanner scanner = new Scanner(System.in);
        try {
            inputString = scanner.nextLine();
        }
        catch (Exception e) {
            System.err.println(e.getMessage());
        }
        finally {
            scanner.close();
        }
    }
}

EDIT: As per some comments and one answer I have made few modifications,kindly help me to understand is this the only best thing we can do or any other way to design my need.

NEED Different students can have different assignments for example (some may need input,others may not need any input)

simply print hello world

input string and show word count

input number show factorial

input number print its table

We want to execute each assignment class individually as well as from one Runner class as  shown above.

MODIFICATION I did these modifications to all classes, showing sample for understanding what I did.

class AssignmentExecutor {
    public List<Assignment> assignmentList ;

    private void addAssignments(){
        assignmentList = new ArrayList<Assignment>();
        assignmentList.add(new Assignment1());
        assignmentList.add(new Assignment2());
    }

    public void execute() {
        Scanner scanner = new Scanner(System.in);
        addAssignments();
        for (Assignment assigment : assignmentList) {
            assigment.execute(scanner);
        }
        scanner.close();
    }
}

    public class Assignment1 implements Assignment {
        String inputString;

    public static void main(String args[]) {
        Assignment1 assignment1 =new Assignment1();
        Scanner scanner = new Scanner(System.in);
        assignment1.execute(scanner);
        scanner.close();
    }

        @Override
        public void execute(scanner) {
            input(scanner);
            System.out.println(inputString);
        }

        private void input(scanner) {
            scanner = new Scanner(System.in);
            try {
                inputString = scanner.nextLine();
            }
            catch (Exception e) {
                System.err.println(e.getMessage());
            }
        }
    }


来源: stackexchange

问:
How do I run PlayOnLinux on Ubuntu Server?
I can't find the system requirements for PlayOnLinux, but all I got from their website is how to install on Ubuntu 20.04 - is it even possible to install on Ubuntu 20.04 sever?

I've installed PlayOnLinux_4.3.4 .deb (link below) on Ubuntu Server and I get the message below - which make me think PlayOnLinux works on Ubuntu Desktop (not server edition):

"xrdb: Can't open display ''
Unable to access the X Display, is $DISPLAY set properly?

Is this the case?
Thanks

https://www.playonlinux.com/en/download.html  ** PlayOnLinux installer for Ubuntu

I downloaded: > PlayOnLinux_4.3.4.deb
Then installed as below:

sudo dpkg -i playonlinux_4.3.4.deb

ContentLicense: CC BY-SA 4.0


问:
Is there any way to use react-bootstrap nav.link with its default responsive behavior without loading?
On my reactjs project, I'm using react bootstrap. Here I used the Navbar component with responsive behavior. Here is the docummentation: (https://react-bootstrap.github.io/components/navbar/#responsive-behaviors).

When I'm on mobile view and I click any of the routes from the navlink, because of its responsive behavior, the nav automatically toggles off and takes me to the route. But the problem is that there is a little bit of reloading.

Because of the navlink looks like:
Features

If I use navlink as={Link} to="/features" instead of href="/features" then the reloading is off, but the responsive behavior is not working.

Example:
Features

I wanted to use the react-bootstrap navbar component, with its responsive behavior and no reloading.
If anybody has any solution to this problem, kindly share it with me. Thanks in advance.


问:
SystemChrome.setEnabledSystemUIMode adds "Viewing full screen" dialog?
I'd like to remove the status bar at the top of android screens. When I add the code below to my first screen

```<code>void initState() {
  super.initState();
  SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
}
</code>```

it removes the bar but adds the dialog below? How do I just remove the status bar?

Body:
I'd like to remove the status bar at the top of android screens. When I add the code below to my first screen

void initState() {
  super.initState();
  SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
}

it removes the bar but adds the dialog below? How do I just remove the status bar?


问:
Compare two sheets of data and highlight difference
I need to find a way to compare two sheets of data in a workbook. The columns are exactly the same. However, the rows are not the same. The conditional formatting would have to compare the cell to all of the cells in a column on another sheet to see if there was a match if yes then color red. If no, then color green.

I have tried another solution provided here but it didn't work since the rows were different.

Is this possible?

This is what I have tried.

Formula:

```<code>=AND($C1<>"",COUNTIFS($C:$C,$C1,'Existing Data'!$C:$C,$C1)=0)
</code>```

Highlight is green.

I'm trying to find the ones that are not already in the existing data.

I tried the formula I entered in above.

Body:
I need to find a way to compare two sheets of data in a workbook. The columns are exactly the same. However, the rows are not the same. The conditional formatting would have to compare the cell to all of the cells in a column on another sheet to see if there was a match if yes then color red. If no, then color green.

I have tried another solution provided here but it didn't work since the rows were different.

Is this possible?

This is what I have tried.

Formula:

=AND($C1<>"",COUNTIFS($C:$C,$C1,'Existing Data'!$C:$C,$C1)=0)

Highlight is green.

I'm trying to find the ones that are not already in the existing data.

I tried the formula I entered in above.


问:
How can i fix org.apache.catalina.core.standardservice.initinternal failed to initialize connector [connector [HTTP/1.1-443]]
[This is my server.xml

```<code><Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="443" />
</code>```

and i added jks

```<code><Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true">
        <SSLHostConfig>
            <Certificate certificateKeystoreFile="C:\runtime\apache-tomcat-8.5.45\conf\www.******.jks" certificateKeystorePassword="*******"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>
</code>```

](https://i.stack.imgur.com/6jDja.jpg)

I already try using

```<code>taskkill -pid
</code>```

to kill the PID but it's doesn't work

Body:
[This is my server.xml

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="443" />

and i added jks

<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true">
        <SSLHostConfig>
            <Certificate certificateKeystoreFile="C:\runtime\apache-tomcat-8.5.45\conf\www.******.jks" certificateKeystorePassword="*******"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>

](https://i.stack.imgur.com/6jDja.jpg)

I already try using

taskkill -pid

to kill the PID but it's doesn't work


问:
App Access for Google play console Details
I  am developing flutter app which uses qr code scanning to generate a base url , then the url saved locally and accessed for further api calls . The login functions only starts after the qr scanning , so in this type of scnerio how to give them the qr code for testing . The app is using mobile number otp login I have provided those details but it will only works after the qr scanning , so how can proceed this .</p>


问:
How integers are implemented in python?
I was wondering how python integers are implemented behind-the-scene, so that it is unbounded. If we consider implementation of integer data type of most other programming languages, 2's complement is used for those.

And 2's complement cannot be implemented with unlimited number of bits. But how python is doing that? Is it using some other technique rather than 2's complement? If yes, how addition and subtraction is done in python?

As far as I know, if we use 2's complement, a single circuit can be used to accomplish the operations of both addition and subtraction. Does python have two different circuits for these two operations?

Title: How integers are implemented in python?


问:
Capturing output from interactive, embedded terminal
I'm working on a Neovim plugin that's basically rich integration for an external CLI program. Users of this plugin would typically already be regular manual CLI users of this program. When my plugin needs to shell out to the CLI, I'd like to have the option to have that process run inside an interactive shell session in the embedded terminal. This puts the invocations into shell history, so they can easily be modified manually or looked up later.

I know I can send input to the terminal via its PTY channel but is there any way to access its stdout and exit codes, e.g. by attaching callbacks? Especially since the process would be running inside the interactive shell, not directly as the command passed to :terminal, I don't see an easy way to do it. Can't just read the buffer, and TermClose autocommands won't work.

I.e. is there a way I can implement something like plenary.job but have that job execute inside a currently running shell in embedded terminal?


问:
Problem understanding a subquery with the FROM clause
Im having trouble understanding how can this subquery can calculate the number of rides of each bike station.
Can someone help me break it down an understand it?

```<code>SELECT
    station_id,
    name,
    number_of_rides.
FROM
(
    SELECT
        start_station_id,
        COUNT(*) number_of_rides
    FROM
        bigquery-public-data.new_york.citibike_trips
    GROUP BY
        start_station_id
)
INNER JOIN
    bigquery-public-data.new_york_citibike.citibike_stations ON
        station_id = start_station_id
ORDER BY
number_of_rides DESC
</code>```

Below I attach the result of the query I run.

Body:
Im having trouble understanding how can this subquery can calculate the number of rides of each bike station.
Can someone help me break it down an understand it?

SELECT
    station_id,
    name,
    number_of_rides.
FROM
(
    SELECT
        start_station_id,
        COUNT(*) number_of_rides
    FROM
        bigquery-public-data.new_york.citibike_trips
    GROUP BY
        start_station_id
)
INNER JOIN
    bigquery-public-data.new_york_citibike.citibike_stations ON
        station_id = start_station_id
ORDER BY
number_of_rides DESC

Below I attach the result of the query I run.


问:
Proxy in Selenium Python with Firefox
This is the code that I'm using, I've tried numerous other solutions from stackoverflow, but everytime I make a request to httpbin.org/ip I see my own IP.

```<code># Selenium Logging
    selenium_logger = logging.getLogger('seleniumwire')
    selenium_logger.setLevel(logging.ERROR)

    # Web driver settings
    # Profile
    profile = webdriver.FirefoxProfile()
    profile.accept_untrusted_certs = True
    # Capabilities
    firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
    firefox_capabilities['marionette'] = True
    # Options
    options = Options()
    options.headless = False

    brightdata_proxy = "personal_brighdata_url"

    firefox_proxies = Proxy()
    firefox_proxies.ssl_proxy = brightdata_proxy
    firefox_proxies.add_to_capabilities(firefox_capabilities)

    self._driver = webdriver.Firefox(executable_path=GeckoDriverManager().install(),
                                     firefox_profile=profile,
                                     capabilities=firefox_capabilities,
                                     options=options,
                                    )
</code>```

Can anybody help me to figure those proxies out ?

Title: Proxy in Selenium Python with Firefox

Body:
This is the code that I'm using, I've tried numerous other solutions from stackoverflow, but everytime I make a request to httpbin.org/ip I see my own IP.

# Selenium Logging
    selenium_logger = logging.getLogger('seleniumwire')
    selenium_logger.setLevel(logging.ERROR)

    # Web driver settings
    # Profile
    profile = webdriver.FirefoxProfile()
    profile.accept_untrusted_certs = True
    # Capabilities
    firefox_capabilities = webdriver.DesiredCapabilities.FIREFOX
    firefox_capabilities['marionette'] = True
    # Options
    options = Options()
    options.headless = False

    brightdata_proxy = "personal_brighdata_url"

    firefox_proxies = Proxy()
    firefox_proxies.ssl_proxy = brightdata_proxy
    firefox_proxies.add_to_capabilities(firefox_capabilities)

    self._driver = webdriver.Firefox(executable_path=GeckoDriverManager().install(),
                                     firefox_profile=profile,
                                     capabilities=firefox_capabilities,
                                     options=options,
                                    )

Can anybody help me to figure those proxies out ?


问:
Unable to create an Azure subscription for a dev Azure AD
I have created a new Dev Azure AD in Azure , When i switch Directories to this new AD, i am unable to create a subscription under the Dev AD Tenant, The Error message is;

"You don't have permission to create a subscription for this billing account, contact the billing account owners."

I have worked with the Billing accountenter image description here owner to verify i have all the required permissions, still yet i can't create this resource. Am an owner on the Dev AD Tenant, can there be any other reason why am unable to create this resource?


问:
Creating load balancer failed Reason: Server Certificate not found for the key
I am facing a a weird issue trying to rebuild a Elastic Beanstalk Environment. The error is:

```<code>Creating load balancer failed Reason: Server Certificate not found for the key: arn:aws:acm:us-east-1:************:certificate/f0fc94b2-9c9b-423c-8e00-4a6eef316473 (Service: AmazonElasticLoadBalancing; Status Code: 400; Error Code: CertificateNotFound; Request ID: e0c2604a-5b56-4eb0-be72-9275fedce0cf; Proxy: null)
</code>```

I tried to follow the steps at here  but I'm getting this error while trying to change the configuration

```<code>Environment named env-name is in an invalid state for this operation. Must be Ready.
</code>```

I was wondering if there's a way to relocate a certificate for that key or change the key it's trying to find?

Body:
I am facing a a weird issue trying to rebuild a Elastic Beanstalk Environment. The error is:

Creating load balancer failed Reason: Server Certificate not found for the key: arn:aws:acm:us-east-1:************:certificate/f0fc94b2-9c9b-423c-8e00-4a6eef316473 (Service: AmazonElasticLoadBalancing; Status Code: 400; Error Code: CertificateNotFound; Request ID: e0c2604a-5b56-4eb0-be72-9275fedce0cf; Proxy: null)

I tried to follow the steps at here  but I'm getting this error while trying to change the configuration

Environment named env-name is in an invalid state for this operation. Must be Ready.

I was wondering if there's a way to relocate a certificate for that key or change the key it's trying to find?


问:
Uncaught Error: Unrecognized extension value in extension set ([object Object])
I'm building a code editor using Sandpack. I am getting an error message in the console after integrating a @codemirror/autocomplete extension in the default SandpackCodeEditor component. But it's not showing an error message on the browser window, and I'm not able to write code in the code editor (I think after adding that extension, the code editor goes into read-only mode).

Any help would be highly appreciated!

Error message:

```<code>index.js:1346 Uncaught Error: Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.
</code>```

My Code:

```<code>import {
  SandpackCodeEditor,
  SandpackConsole,
  SandpackLayout,
  SandpackPreview,
  SandpackProvider,
} from "@codesandbox/sandpack-react";
import { autocompletion, completionKeymap } from "@codemirror/autocomplete";

export default function MySandpack() {
  return (
    <SandpackProvider>
      <SandpackLayout>
        <SandpackCodeEditor
          extensions={[autocompletion()]}
          extensionsKeymap={[completionKeymap]}
          showTabs
          showLineNumbers={false}
          showInlineErrors
          wrapContent
          closableTabs
        />
        <SandpackPreview />
        <SandpackConsole />
      </SandpackLayout>
    </SandpackProvider>
  );
}

</code>```

Body:
I'm building a code editor using Sandpack. I am getting an error message in the console after integrating a @codemirror/autocomplete extension in the default SandpackCodeEditor component. But it's not showing an error message on the browser window, and I'm not able to write code in the code editor (I think after adding that extension, the code editor goes into read-only mode).

Any help would be highly appreciated!

Error message:

index.js:1346 Uncaught Error: Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.

My Code:

import {
  SandpackCodeEditor,
  SandpackConsole,
  SandpackLayout,
  SandpackPreview,
  SandpackProvider,
} from "@codesandbox/sandpack-react";
import { autocompletion, completionKeymap } from "@codemirror/autocomplete";

export default function MySandpack() {
  return (
    <SandpackProvider>
      <SandpackLayout>
        <SandpackCodeEditor
          extensions={[autocompletion()]}
          extensionsKeymap={[completionKeymap]}
          showTabs
          showLineNumbers={false}
          showInlineErrors
          wrapContent
          closableTabs
        />
        <SandpackPreview />
        <SandpackConsole />
      </SandpackLayout>
    </SandpackProvider>
  );
}


问:
ViewPager2 - iterate through an array within an object and display the respective image
everyone. I have an array of images in an object that is in a collection group. Now I would like to display the images with a ViewPager2. So far I have the following, which only ever shows me the first picture. So I can't swipe through the array. What am I doing wrong?

DetailActivity.kt:
db.collectionGroup("Objekte").whereEqualTo("timestamp",key.toString()).get().addOnSuccessListener { result->

```<code>        for(document in result.documents)
        {

            val house = document.toObject(Houses::class.java)
            if (house != null) {
                setHouse = house
            }
        }

        viewPager2 = findViewById(R.id.detialViewPager)

        myAdapter = AdapterForDetailView(this,setHouse)

        viewPager2.adapter = myAdapter

    }
</code>```

AdapterForDetailView.kt:

```<code>class AdapterForDetailView(val context: Context, val singleHouse: Houses):RecyclerView.Adapter<AdapterForDetailView.MyViewHolder>() {

inner class MyViewHolder(view: View): RecyclerView.ViewHolder(view){

    val iv_images: ImageView = view.findViewById(R.id.iv_images)

}

override fun getItemCount(): Int {
    return 1
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {

    val inflater = LayoutInflater.from(context).inflate(R.layout.image_slider_item,parent,false)

    return MyViewHolder(inflater)
}

override fun onBindViewHolder(holder: MyViewHolder, position: Int) {

    Glide.with(context).load(singleHouse.listImages[position]).into(holder.iv_images)

  }
}
</code>```

Body:
everyone. I have an array of images in an object that is in a collection group. Now I would like to display the images with a ViewPager2. So far I have the following, which only ever shows me the first picture. So I can't swipe through the array. What am I doing wrong?

DetailActivity.kt:
db.collectionGroup("Objekte").whereEqualTo("timestamp",key.toString()).get().addOnSuccessListener { result->

        for(document in result.documents)
        {

            val house = document.toObject(Houses::class.java)
            if (house != null) {
                setHouse = house
            }
        }

        viewPager2 = findViewById(R.id.detialViewPager)

        myAdapter = AdapterForDetailView(this,setHouse)

        viewPager2.adapter = myAdapter

    }

AdapterForDetailView.kt:

class AdapterForDetailView(val context: Context, val singleHouse: Houses):RecyclerView.Adapter<AdapterForDetailView.MyViewHolder>() {

inner class MyViewHolder(view: View): RecyclerView.ViewHolder(view){

    val iv_images: ImageView = view.findViewById(R.id.iv_images)

}

override fun getItemCount(): Int {
    return 1
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {

    val inflater = LayoutInflater.from(context).inflate(R.layout.image_slider_item,parent,false)

    return MyViewHolder(inflater)
}

override fun onBindViewHolder(holder: MyViewHolder, position: Int) {

    Glide.with(context).load(singleHouse.listImages[position]).into(holder.iv_images)

  }
}


问:
How to extend Context or Provider in ReactJS to display a Loading Spinner
I would like to add a loading spinner during transitions. For example, when the app is fetching if the user is authenticated. How can this additional variable be added to the Context(Provider)?

My idea was to extend my AuthProvider (see below) with an additional variable, but its unclear to me if this is a good practice, and also if it can be actually consumed properly. The below example resulted that the variable loading is always false in the Consumer.js:

See [PartX] linked to my comment above.

App.js

```<code>import { AuthProvider } from "./auth/firebase/AuthProvider";

function App() {
  return (
    <AuthProvider>
        <p>
           Hello <code>world</code>
        </p>
    </AuthProvider>
  );
}
</code>```

AuthProvider.js

```<code>import React, { useEffect, useState } from "react";
import auth from "./configAuth";

export const AuthContext = React.createContext();

export const AuthProvider = ({ children }) => {
  const [user, setUser] = useState(null);
  const [loading, setLoading] = useState(true);  // <--- [PartX]

  useEffect(() => {
    auth.onAuthStateChanged(setUser, setLoading(false));  // <--- [PartX]
  }, []);

  return (
    <AuthContext.Provider value={{ user }}>{children}</AuthContext.Provider>
  );
};
</code>```

Consumer.js

```<code>import React, { useState, useContext } from "react";
import Button from "@mui/material/Button";
import Menu from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem";

import { SignInButton, SignOutButton } from "../sign-in/SignInModal";
import { AuthContext } from "../firebase/AuthProvider";

export default function ProfileBox() {

  /* General Anchor Clicks */
  const [anchorEl, setAnchorEl] = useState(null);
  const open = Boolean(anchorEl);
  const handleClick = (event) => {
    setAnchorEl(event.currentTarget);
  };
  const handleClose = () => {
    setAnchorEl(null);
  };

  /* Auth state */
  const { user, loading } = useContext(AuthContext);

  // [PartX] ----> Does not work, always False
  console.log(loading)

  if (!user) {
    return (
      <SignInButton />
    );
  } else {
    return (
      <div>
        <Button
          color="inherit"
          id="basic-button"
          aria-controls={open ? 'basic-menu' : undefined}
          aria-haspopup="true"
          aria-expanded={open ? 'true' : undefined}
          onClick={handleClick}
        >
          {user.displayName}
        </Button>
        <Menu
          disableScrollLock={true}
          id="basic-menu"
          anchorEl={anchorEl}
          open={open}
          onClose={handleClose}
          MenuListProps={{
            'aria-labelledby': 'basic-button',
          }}
        >
          <MenuItem onClick={handleClose}> <SignOutButton /></MenuItem>
        </Menu>
      </div>
    );
  }
}
</code>```

Body:
I would like to add a loading spinner during transitions. For example, when the app is fetching if the user is authenticated. How can this additional variable be added to the Context(Provider)?

My idea was to extend my AuthProvider (see below) with an additional variable, but its unclear to me if this is a good practice, and also if it can be actually consumed properly. The below example resulted that the variable loading is always false in the Consumer.js:

See [PartX] linked to my comment above.

App.js

import { AuthProvider } from "./auth/firebase/AuthProvider";

function App() {
  return (
    <AuthProvider>

           Hello world

    </AuthProvider>
  );
}

AuthProvider.js

import React, { useEffect, useState } from "react";
import auth from "./configAuth";

export const AuthContext = React.createContext();

export const AuthProvider = ({ children }) => {
  const [user, setUser] = useState(null);
  const [loading, setLoading] = useState(true);  // <--- [PartX]

  useEffect(() => {
    auth.onAuthStateChanged(setUser, setLoading(false));  // <--- [PartX]
  }, []);

  return (
    <AuthContext.Provider value={{ user }}>{children}</AuthContext.Provider>
  );
};

Consumer.js

import React, { useState, useContext } from "react";
import Button from "@mui/material/Button";
import Menu from "@mui/material/Menu";
import MenuItem from "@mui/material/MenuItem";

import { SignInButton, SignOutButton } from "../sign-in/SignInModal";
import { AuthContext } from "../firebase/AuthProvider";

export default function ProfileBox() {

  /* General Anchor Clicks */
  const [anchorEl, setAnchorEl] = useState(null);
  const open = Boolean(anchorEl);
  const handleClick = (event) => {
    setAnchorEl(event.currentTarget);
  };
  const handleClose = () => {
    setAnchorEl(null);
  };

  /* Auth state */
  const { user, loading } = useContext(AuthContext);

  // [PartX] ----> Does not work, always False
  console.log(loading)

  if (!user) {
    return (
      <SignInButton />
    );
  } else {
    return (

        <Button
          color="inherit"
          id="basic-button"
          aria-controls={open ? 'basic-menu' : undefined}
          aria-haspopup="true"
          aria-expanded={open ? 'true' : undefined}
          onClick={handleClick}
        >
          {user.displayName}
        </Button>
        <Menu
          disableScrollLock={true}
          id="basic-menu"
          anchorEl={anchorEl}
          open={open}
          onClose={handleClose}
          MenuListProps={{
            'aria-labelledby': 'basic-button',
          }}
        >
          <MenuItem onClick={handleClose}> <SignOutButton /></MenuItem>
        </Menu>

    );
  }
}


问:
jquery parseInt on lis
When I run this code I get NaN, but it reads the initial lis correctly. Does .each not work correctly on html elements?

function computeTotal() {
  let total = 0;
  $("li").each(() => {
    total += parseInt($(this).text(), 10);
  });

  $("#total").text(`Total: ${total}`);
}

computeTotal();```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul>
  <li>10</li>
  <li>50</li>
  <li>10</li>
</ul>
<div id="total"></div></code>```

It should output a simple total of the numbers inside the lis. But calling this.text() on each li does not return the number inside it.

Title: jquery parseInt on lis

Body:
When I run this code I get NaN, but it reads the initial lis correctly. Does .each not work correctly on html elements?

function computeTotal() {
  let total = 0;
  $("li").each(() => {
    total += parseInt($(this).text(), 10);
  });

  $("#total").text(`Total: ${total}`);
}

computeTotal();

10

50

10

It should output a simple total of the numbers inside the lis. But calling this.text() on each li does not return the number inside it.


问:
How to resolve this window output warning in VS Code? - <warning> Settings pattern "keyboard.*" doesn't match any settings
This warning appears every time I open my settings in the UI.

None of the settings in the json contain this regex pattern. Opening the json doesn't produce the error.

Can't find reference to this error elsewhere on the web.


问:
Is it possible to reduce the size of react-dom in electron renderer for development start up time?
I'm using webpack-bundle-analyzer to track the size of my bundled electron application on the renderer side. I've done a few other optimizations but the largest module by far in the analyzer is react-dom at ~1000KB. Is it possible to reduce the bundle size in some way FOR DEVELOPMENT? Start up time takes an annoying amount of time, my goal is to get the renderer process to render quicker.


问:
By-value methods on trait objects
Consider the following code:

```<code>trait Consume {
    fn consume(self);
}

struct Foo;

impl Consume for Foo {
    fn consume(self) {}
}

fn main() {
    let mut f = Box::new(Foo {}) as Box<dyn Consume>;
    f.consume();
}
</code>```

The purpose of having this definition of Consume is as follows:

to allow the consume method to move out of the struct fields; and

to ensure that consume is only ever run once.

There is a technical error in the code above, though, as of version 1.67.0 and edition 2021:

```<code>error[E0161]: cannot move a value of type `dyn Consume`
  --> src/bin/consuming_self_in_traits.rs:12:5
   |
12 |     f.consume();
   |     ^^^^^^^^^^^ the size of `dyn Consume` cannot be statically determined
</code>```

My expectation is that if the compiler is able to generate a Consume vtable for Foo, it must also be able to achieve similar semantics.

Can the code above be compiled without changing the definition of Consume and still using dynamic dispatch on Foo? I do not mind using unsafe.

Title: By-value methods on trait objects

Body:
Consider the following code:

trait Consume {
    fn consume(self);
}

struct Foo;

impl Consume for Foo {
    fn consume(self) {}
}

fn main() {
    let mut f = Box::new(Foo {}) as Box<dyn Consume>;
    f.consume();
}

The purpose of having this definition of Consume is as follows:

to allow the consume method to move out of the struct fields; and

to ensure that consume is only ever run once.

There is a technical error in the code above, though, as of version 1.67.0 and edition 2021:

error[E0161]: cannot move a value of type `dyn Consume`
  --> src/bin/consuming_self_in_traits.rs:12:5
   |
12 |     f.consume();
   |     ^^^^^^^^^^^ the size of `dyn Consume` cannot be statically determined

My expectation is that if the compiler is able to generate a Consume vtable for Foo, it must also be able to achieve similar semantics.

Can the code above be compiled without changing the definition of Consume and still using dynamic dispatch on Foo? I do not mind using unsafe.


问:
Can I access an Azure file share with non root user?
In this url https://learn.microsoft.com/en-us/azure/container-instances/container-instances-volume-azure-files, it says that:

Azure file share volume mount requires the Linux container run as root .

Azure File share volume mounts are limited to CIFS support.

I have an azure container instance with postgres and postgres doesn't allow me to run the server as root.
The Azure file share owner is set to root and the user group also set to root and I will not be able to change both the permissions and the owner and the user group of the azure file share folder?
I would want to set the owner and group of the folder to postgres for example and change its permissions.


问:
Jquery returns same value on changing dropdown
I have a dropdown like this:

```<code><form action="" id="myForm" method="post">
<select id="choose">
<option value="test1">Test1</option>
<option value="test2">Test2</option>
<option value="test3">Test3</option>
</select>
</code>```

I use this script to call another page, and load the data in div UPDATE:

```<code><div id="update"></div>

 <script type="text/javascript">
  $(document).ready(function () {
    var datum = $('#choose option:selected').text();
    $("#choose").on("change", function () {
          $("#update").load("boekingstap0_inlay.php?zipcodeFrom=<?php echo $_POST['zipcodeFrom']; ?>&date="+datum);

    });
});
</code>```

When I change the dropdown, the returned value stays "test1". The page does reload, I put an Alert message on the page to be loaded, which echoës the value $_GET['date'].

What am I doin' wrong?

Body:
I have a dropdown like this:

<form action="" id="myForm" method="post">
<select id="choose">
<option value="test1">Test1</option>
<option value="test2">Test2</option>
<option value="test3">Test3</option>
</select>

I use this script to call another page, and load the data in div UPDATE:


问:
Windows deleting jars from embedded tomcat directory in temporary directory
I have embedded tomcat container running and deploying project demo and its dependency jars in the following path:

c:\users{user}\AppData\Local\Temp\Stem_Tomcat\webapps\demo\Web-Inf\lib

Issue is, windows cleaner will delete the web-inf\lib files periodically. This happens even when the supporting Stem application is still running although the demo webpage may been closed.

How do I configure to prevent web-inf\lib*.jars from being deleted when Stem is still running ?

I was hoping to do this without having to resort to change the java.io.tmpdir location path to something else.

For context, we were originally using Jetty and windows was not able to delete the files when the Stem application was still running. I am unsure what conf changes needs to be done.


问:
IntelliJ IDEA - How to align fields inside anonymous classes
I'm trying to align/reformat code in my IntelliJ IDEA IDE. But, it's not aligning fields inside anonymous classes. Checkout below example code:

```<code>public class Hello {
    private int   x   = 1;
    private float xyz = 100F;

    public static void main(String[] args) {
        System.out.println("Hello World");

        (new Thread() {
            private int a = 1;
            private String abc = "alphabet";

            @Override
            public void run() {
                super.run();
            }
        }).start();
    }
}
</code>```

In above code x & xyz fields are aligned properly. But, a & abc fields
are not aligning. How to solve this issue?

Body:
I'm trying to align/reformat code in my IntelliJ IDEA IDE. But, it's not aligning fields inside anonymous classes. Checkout below example code:

public class Hello {
    private int   x   = 1;
    private float xyz = 100F;

    public static void main(String[] args) {
        System.out.println("Hello World");

        (new Thread() {
            private int a = 1;
            private String abc = "alphabet";

            @Override
            public void run() {
                super.run();
            }
        }).start();
    }
}

In above code x & xyz fields are aligned properly. But, a & abc fields
are not aligning. How to solve this issue?


问:
I need to use Devexpress Angular Document Viewer for front end side and Devexpress Reporting for .net Core API side
I need to use Devexpress Angular Document Viewer for the front-end side and Devexpress Reporting for the .NET Core API side. Currently, I have Angular 11.0.1 for the front-end and .NET Core 6 for API in an existing project. Which Devexpress version is compatible with my front and backend? I tried this command:

```<code>npm install devextreme@22.2-stable @devexpress/analytics-core@22.2-stable devexpress-reporting-angular@22.2-stable
</code>```

From this link. https://docs.devexpress.com/XtraReports/119430/web-reporting/javascript-reporting/angular/document-viewer/quick-start/document-viewer-integration-in-angular

But throws an error. I haven't purchased the Devexpress license yet, but want to try with trial version before purchasing. If it works, I have to go for getting a license. Has anybody tried the above combination?

I need to generate dynamic pdf by passing dynamic columns and format styles from the backend.

Body:
I need to use Devexpress Angular Document Viewer for the front-end side and Devexpress Reporting for the .NET Core API side. Currently, I have Angular 11.0.1 for the front-end and .NET Core 6 for API in an existing project. Which Devexpress version is compatible with my front and backend? I tried this command:

npm install devextreme@22.2-stable @devexpress/analytics-core@22.2-stable devexpress-reporting-angular@22.2-stable

From this link. https://docs.devexpress.com/XtraReports/119430/web-reporting/javascript-reporting/angular/document-viewer/quick-start/document-viewer-integration-in-angular

But throws an error. I haven't purchased the Devexpress license yet, but want to try with trial version before purchasing. If it works, I have to go for getting a license. Has anybody tried the above combination?

I need to generate dynamic pdf by passing dynamic columns and format styles from the backend.


问:
Android Java Geocoder address line not same with coordinates latitude and longitude
I am using Geocoder to get the address line and city of the location based coordinates get. I successfully extracted the coordinates latitude and longitude and when displayed on a map, it is accurate, however the problem is, the address line on geocoder is sometimes way off compared to the latitude and longitude(which is accurate, since I have tested it on a map). The address line shows the location on the next street, which is incorrect. I dont understand why it does that since, I am getting its location based on the accurate latitude and longitude.

Sometimes the location gives random letters and numbers plus the street name, city and so on, like this(H4WM+Q5G, Strawberry Ln, City Name, Province Name, Country Name), which is preferable since the street is correct, compared to the innacurate location like for example (#45 Avocado Drive, City Name, Province name, country name) wherein the correct address is located in a different street name usually the street beside it.

Overall it varies from location to location, I've done testing on different places, sometimes it works out fine, but sometimes its innacurate.

This is my code:

```<code>private void getCurrentLocation() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        if (ActivityCompat.checkSelfPermission(SendReport.this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {

            if (isGPSEnabled()) {
                LocationServices.getFusedLocationProviderClient(SendReport.this)
                        .requestLocationUpdates(locationRequest, new LocationCallback() {
                            @Override
                            public void onLocationResult(@NonNull LocationResult locationResult) {
                                super.onLocationResult(locationResult);

                                LocationServices.getFusedLocationProviderClient(SendReport.this)
                                        .removeLocationUpdates(this);

                                if (locationResult != null && locationResult.getLocations().size() >0){

                                    int index = locationResult.getLocations().size() - 1;
                                    double latitude = locationResult.getLocations().get(index).getLatitude();
                                    double longitude = locationResult.getLocations().get(index).getLongitude();

                                    Geocoder geocoder = new Geocoder(SendReport.this, Locale.getDefault());
                                    List<Address> addresses = null;
                                    try {
                                        addresses = geocoder.getFromLocation(latitude, longitude, 1);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }

                                    textViewAdd.setText(addresses.get(0).getAddressLine(0));
                                    textViewCity.setText(addresses.get(0).getLocality());
                                    textViewLatt.setText(" "+ latitude);
                                    textViewLong.setText(" "+ longitude);
                                }
                            }
                        }, Looper.getMainLooper());

            } else {
                turnOnGPS();
            }

        } else {
            requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
        }
    }
}
</code>```

Body:
I am using Geocoder to get the address line and city of the location based coordinates get. I successfully extracted the coordinates latitude and longitude and when displayed on a map, it is accurate, however the problem is, the address line on geocoder is sometimes way off compared to the latitude and longitude(which is accurate, since I have tested it on a map). The address line shows the location on the next street, which is incorrect. I dont understand why it does that since, I am getting its location based on the accurate latitude and longitude.

Sometimes the location gives random letters and numbers plus the street name, city and so on, like this(H4WM+Q5G, Strawberry Ln, City Name, Province Name, Country Name), which is preferable since the street is correct, compared to the innacurate location like for example (#45 Avocado Drive, City Name, Province name, country name) wherein the correct address is located in a different street name usually the street beside it.

Overall it varies from location to location, I've done testing on different places, sometimes it works out fine, but sometimes its innacurate.

This is my code:

private void getCurrentLocation() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        if (ActivityCompat.checkSelfPermission(SendReport.this, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {

            if (isGPSEnabled()) {
                LocationServices.getFusedLocationProviderClient(SendReport.this)
                        .requestLocationUpdates(locationRequest, new LocationCallback() {
                            @Override
                            public void onLocationResult(@NonNull LocationResult locationResult) {
                                super.onLocationResult(locationResult);

                                LocationServices.getFusedLocationProviderClient(SendReport.this)
                                        .removeLocationUpdates(this);

                                if (locationResult != null && locationResult.getLocations().size() >0){

                                    int index = locationResult.getLocations().size() - 1;
                                    double latitude = locationResult.getLocations().get(index).getLatitude();
                                    double longitude = locationResult.getLocations().get(index).getLongitude();

                                    Geocoder geocoder = new Geocoder(SendReport.this, Locale.getDefault());
                                    List<Address> addresses = null;
                                    try {
                                        addresses = geocoder.getFromLocation(latitude, longitude, 1);
                                    } catch (IOException e) {
                                        e.printStackTrace();
                                    }

                                    textViewAdd.setText(addresses.get(0).getAddressLine(0));
                                    textViewCity.setText(addresses.get(0).getLocality());
                                    textViewLatt.setText(" "+ latitude);
                                    textViewLong.setText(" "+ longitude);
                                }
                            }
                        }, Looper.getMainLooper());

            } else {
                turnOnGPS();
            }

        } else {
            requestPermissions(new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 1);
        }
    }
}


问:
JSON schema conditional render
I have a field called transportation_assistance_needed which if is true, then are_there_transportation_accommodations_needed should either render or be enabled, if it's false then is should either not render or be disabled. I was able to accomplish this logic using if/else however I'm using Retool to render the form and it doesn't support JSON Schema if/else statements. Any idea of what can be the equivalent using dependencies?

```<code>    "properties": {
        "preferred_times": {
            "items": {
                "type": "string",
                "anyOf": [
                    {
                        "enum": [
                            "morning"
                        ],
                        "title": " Mornings",
                        "type": "string"
                    },
                    {
                        "title": " Afternoons",
                        "type": "string",
                        "enum": [
                            "afternoon"
                        ]
                    }
                ]
            },
            "type": "array",
            "title": "Preferred time(s)",
            "uniqueItems": true
        },
        "preferred_days": {
            "items": {
                "type": "number",
                "anyOf": [
                    {
                        "title": " Monday",
                        "enum": [
                            1
                        ],
                        "type": "number"
                    },
                    {
                        "type": "number",
                        "title": " Tuesday",
                        "enum": [
                            2
                        ]
                    },
                    {
                        "type": "number",
                        "title": " Wednesday",
                        "enum": [
                            3
                        ]
                    },
                    {
                        "enum": [
                            4
                        ],
                        "type": "number",
                        "title": " Thursday"
                    },
                    {
                        "enum": [
                            5
                        ],
                        "title": " Friday",
                        "type": "number"
                    }
                ]
            },
            "uniqueItems": true,
            "type": "array",
            "title": "Preferred day(s)"
        },
        "transportation_assistance_needed": {
            "title": "Is transportation assistance needed?",
            "oneOf": [
                {
                    "Title": "Yes",
                    "const": "Yes"
                },
                {
                    "title": "No",
                    "const": "No"
                }
            ],
            "type": "string"
        }
    },
    "type": "object",
    "if": {
        "properties": {
            "transportation_assistance_needed": {
                "const": "Yes"
            }
        }
    },
    "then": {
        "properties": {
            "are_there_transportation_accommodations_needed": {
                "title": "Are any transportation accommodations needed, like wheelchair accessibility?",
                "type": "string"
            }
        }
    }
}
</code>```

Title: JSON schema conditional render

Body:
I have a field called transportation_assistance_needed which if is true, then are_there_transportation_accommodations_needed should either render or be enabled, if it's false then is should either not render or be disabled. I was able to accomplish this logic using if/else however I'm using Retool to render the form and it doesn't support JSON Schema if/else statements. Any idea of what can be the equivalent using dependencies?

    "properties": {
        "preferred_times": {
            "items": {
                "type": "string",
                "anyOf": [
                    {
                        "enum": [
                            "morning"
                        ],
                        "title": " Mornings",
                        "type": "string"
                    },
                    {
                        "title": " Afternoons",
                        "type": "string",
                        "enum": [
                            "afternoon"
                        ]
                    }
                ]
            },
            "type": "array",
            "title": "Preferred time(s)",
            "uniqueItems": true
        },
        "preferred_days": {
            "items": {
                "type": "number",
                "anyOf": [
                    {
                        "title": " Monday",
                        "enum": [
                            1
                        ],
                        "type": "number"
                    },
                    {
                        "type": "number",
                        "title": " Tuesday",
                        "enum": [
                            2
                        ]
                    },
                    {
                        "type": "number",
                        "title": " Wednesday",
                        "enum": [
                            3
                        ]
                    },
                    {
                        "enum": [
                            4
                        ],
                        "type": "number",
                        "title": " Thursday"
                    },
                    {
                        "enum": [
                            5
                        ],
                        "title": " Friday",
                        "type": "number"
                    }
                ]
            },
            "uniqueItems": true,
            "type": "array",
            "title": "Preferred day(s)"
        },
        "transportation_assistance_needed": {
            "title": "Is transportation assistance needed?",
            "oneOf": [
                {
                    "Title": "Yes",
                    "const": "Yes"
                },
                {
                    "title": "No",
                    "const": "No"
                }
            ],
            "type": "string"
        }
    },
    "type": "object",
    "if": {
        "properties": {
            "transportation_assistance_needed": {
                "const": "Yes"
            }
        }
    },
    "then": {
        "properties": {
            "are_there_transportation_accommodations_needed": {
                "title": "Are any transportation accommodations needed, like wheelchair accessibility?",
                "type": "string"
            }
        }
    }
}


问:
Django REST Framework - Logic and filters : better in Serializers or in ViewSets?
I am developing a Django REST Framework API. It has 13 models, 21 Serializers, and many related fields. Some serializers are nested and quite complex, to achieve an optimal result with a minimum number of front-end requests.

I am familiar with coding everything (excepted GET filters) in Serializers. For each request URL, I always create a basic ViewSet (I only mention the permission_class, serializer_class and queryset). I code in the ViewSet only the queryset filters for GET requests. All the additional logic (saving objects, calculating MethodFields, updating objects in multiple models for a unique request, sending notification emails...) is coded in the serializer.

Is it a good practice ? Or is there a more efficient way of sharing the logic between the serializer and the ViewSet ? Are there performance-improving opportunities ?


问:
need to show name by value should be id for passing backend in html
I am working on selecting options on HTML, I am getting the data of members as name, address, phonenumbers from the backend I used Django forms direct select method but there is an issue when the names are the same for two persons so, chosen to manually add the input field,

code is given below

```<code><div class="col-lg-7 col-sm-4">
  <div class="form-group local-forms">
      <label for="select_person">Select Person
           <span class="login-danger">*</span>
      </label>
      <input required class="form-control" type="text" name="purchasedPerson" list="members_list">
      <datalist id="members_list">
         <select id="select_person">
         {% for mem in members %}
         <option value="{{mem.id}}">{{mem.name}} - {{mem.address}} - {{mem.phoneNo}}</option>
         {% endfor %}
         </select>
       </datalist>
    </div>
</div>
</code>```

the issue is when I select the option presently shows the member id in the input field, but for convenient I need to have the member name,

and if I change the value="{{mem.id}}" to value="{{mem.name}}" name shows in the input field but in backend also name is passed issue in getting the data on the selected member

so need to show the name in the input field, but the name place holder should be the members id,

please suggest an answer to approach this method.. thank you

Body:
I am working on selecting options on HTML, I am getting the data of members as name, address, phonenumbers from the backend I used Django forms direct select method but there is an issue when the names are the same for two persons so, chosen to manually add the input field,

code is given below

      Select Person
           *

      <input required class="form-control" type="text" name="purchasedPerson" list="members_list">
      <datalist id="members_list">
         <select id="select_person">
         {% for mem in members %}
         <option value="{{mem.id}}">{{mem.name}} - {{mem.address}} - {{mem.phoneNo}}</option>
         {% endfor %}
         </select>
       </datalist>

the issue is when I select the option presently shows the member id in the input field, but for convenient I need to have the member name,

and if I change the value="{{mem.id}}" to value="{{mem.name}}" name shows in the input field but in backend also name is passed issue in getting the data on the selected member

so need to show the name in the input field, but the name place holder should be the members id,

please suggest an answer to approach this method.. thank you


问:
How to ensure root view controller is not nil, when handling deep link from home widgets for app fresh launched case?
Currently, this is how I handle deep link from home widgets.

```<code>extension UIWindow {
    //
    // https://stackoverflow.com/a/58031897/72437
    //
    static var key: UIWindow? {
        // Get connected scenes
        UIApplication
            .shared
            .connectedScenes
            .compactMap { $0 as? UIWindowScene }
            .flatMap { $0.windows }
            .first { $0.isKeyWindow }
    }
}

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    // App launched for the first time
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // https://stackoverflow.com/questions/63697132/detect-app-launch-from-widgetkit-widget-extension
        if let url = connectionOptions.urlContexts.first?.url {
            handleIncomingURL(url)
        }
    }

    // App restored from background stack
    func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        if let url = URLContexts.first?.url {
            handleIncomingURL(url)
        }
    }

    private func handleIncomingURL(_ url: URL) {
        guard let rootViewController = UIWindow.key?.rootViewController else { return }

        ...
    }
}
</code>```

There are 2 cases I need to handle when user clicks on the home widget.

App launched freshly.

App restored from background stack.

In my deep link handling logic (function handleIncomingURL), I need a non nil UIViewController, so that I can perform appropriate action to handle home widget's deep link.

In case "App restored from background stack", everything is fine because the UIWindow.key?.rootViewController is able provide me a non nil UIViewController.

However, in the case of "App launched freshly", I am always getting a nil result from UIWindow.key?.rootViewController.

Is there a way for me to obtain a non nil UIViewController during app fresh launched, during home widget's deep link handling?

Body:
Currently, this is how I handle deep link from home widgets.

extension UIWindow {
    //
    // https://stackoverflow.com/a/58031897/72437
    //
    static var key: UIWindow? {
        // Get connected scenes
        UIApplication
            .shared
            .connectedScenes
            .compactMap { $0 as? UIWindowScene }
            .flatMap { $0.windows }
            .first { $0.isKeyWindow }
    }
}

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    // App launched for the first time
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // https://stackoverflow.com/questions/63697132/detect-app-launch-from-widgetkit-widget-extension
        if let url = connectionOptions.urlContexts.first?.url {
            handleIncomingURL(url)
        }
    }

    // App restored from background stack
    func scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) {
        if let url = URLContexts.first?.url {
            handleIncomingURL(url)
        }
    }

    private func handleIncomingURL(_ url: URL) {
        guard let rootViewController = UIWindow.key?.rootViewController else { return }

        ...
    }
}

There are 2 cases I need to handle when user clicks on the home widget.

App launched freshly.

App restored from background stack.

In my deep link handling logic (function handleIncomingURL), I need a non nil UIViewController, so that I can perform appropriate action to handle home widget's deep link.

In case "App restored from background stack", everything is fine because the UIWindow.key?.rootViewController is able provide me a non nil UIViewController.

However, in the case of "App launched freshly", I am always getting a nil result from UIWindow.key?.rootViewController.

Is there a way for me to obtain a non nil UIViewController during app fresh launched, during home widget's deep link handling?


问:
PySimpleGUI Checkbox
Idk why, but when i check a checkbox in the menu nothings, happens, but if i close the menu the cheat start. I think that i made some mistakes setting up the checkboxes, but im trying to fix this problem from 3 days now and i can't continue anymore. Can someone help?

```<code>import PySimpleGUI as sg
import threading
from globals import *
import math
import time
import keyboard

switch = True
rcsonoff = True
r = 255
g = 3
b = 3

def normalizeAngles(viewAngleX, viewAngleY):
    if viewAngleX > 89:
        viewAngleX -= 360
    if viewAngleX < -89:
        viewAngleX += 360
    if viewAngleY > 180:
        viewAngleY -= 360
    if viewAngleY < -180:
        viewAngleY += 360
    return viewAngleX, viewAngleY

def checkangles(x, y):
    if x > 89:
        return False
    elif x < -89:
        return False
    elif y > 360:
        return False
    elif y < -360:
        return False
    else:
        return True

def nanchecker(first, second):
    if math.isnan(first) or math.isnan(second):
        return False
    else:
        return True

layout = [
    # Use a modern font and color scheme
    [sg.Text("External 2.3", font="Helvetica 20", text_color="#d80fc6")],
    # Use tabs to organize the buttons into different categories
    [sg.TabGroup([
        # Tab for aim-related buttons
        [sg.Tab("Aim", [[
            sg.Column(
                # Define the grid layout for the buttons
                [
                    [sg.Checkbox("No Recoil", default=False, key="no_recoil_checkbox")],
                    [sg.Checkbox("TriggerBot", default=False, key="triggerbot_checkbox")]
                ],
                # Set the number of rows and columns in the grid
            )
        ]]),
         # Tab for visual-related buttons
         sg.Tab("Visuals", [[
             sg.Column(
                 # Define the grid layout for the buttons
                 [
                     [sg.Checkbox("Glow", default=False, key="glow_checkbox")],
                     [sg.Checkbox("Chams", default=False, key="chams_checkbox")],
                     [sg.Checkbox("Fov", default=False, key="fov_checkbox")],
                     [sg.Text("Fov Value (MAX 140): "), sg.InputText(key="fov")],
                     [sg.Button("Set FOV Value", button_color=("magenta", "#a9a9a9"))]
                 ],
                 # Set the number of rows and columns in the grid
             )
         ]]),
         sg.Tab("Misc", [[
             sg.Column(
                 [
                     [sg.Checkbox("Bunny Hop", default=False, key="bunny_hop_checkbox")],
                     [sg.Checkbox("Radar Hack", default=False, key="radar_hack_checkbox")],
                     [sg.Checkbox("Show Rank", default=False, key="show_rank_checkbox")],
                     [sg.Checkbox("Third Person", default=False, key="3_person_checkbox")],
                     [sg.Checkbox("No Flash", default=False, key="no_flash_checkbox")]
                 ],
             )
         ]]),
         sg.Tab("LocalPlayer", [[
             sg.Column(
                 [
                     [sg.Text("Player Health:")],
                     [sg.Text(key="Health")],
                     [sg.Text("Armor:")],
                     [sg.Text(key="Armor")],
                     [sg.Text("Enter a new value:")],
                     [sg.InputText(key="NewArmor")],
                     [sg.Button("Update Armor")],
                     [sg.Text("Enter a new money value:")],
                     [sg.InputText(key="Money")],
                     [sg.Button("Update Money")]

                 ],
             )
         ]]),
         # Tab for color-related buttons
         sg.Tab("Color and Debug", [[
             sg.Column(
                 # Define the grid layout for the sliders
                 [
                     [sg.Button("Debug", button_color=("magenta", "#a9a9a9"))],
                     [sg.Text("Enter the glow color values:")],
                     [sg.Text("Red:"), sg.InputText(key="Red")],
                     [sg.Text("Green:"), sg.InputText(key="Green")],
                     [sg.Text("Blue:"), sg.InputText(key="Blue")],
                     [sg.Button("Set Glow Color")]
                 ],
                 # Set the number of rows and columns in the grid
             )
         ]])
         ]])]
]

window = sg.Window("Buck3ts41", layout, element_justification="center")

def debug():
    while True:
        print("crossID ", crosshairID)
        print("corssTeam ", crosshairTeam)
        print("LocalPlayer ", player)
        print("LocalTeam ", localTeam)
        print("GlowManager ", glow_manager)
        print("GetTeam ", getTeam)
        time.sleep(2)

def esp():
    while True:
        try:
            if glow == True:

                for i in range(1, 32):
                    entity = pm.read_int(client + dwEntityList + i * 0x10)
                    if entity:
                        entity_hp = pm.read_uint(entity + m_iHealth)
                        entity_team_id = pm.read_uint(entity + m_iTeamNum)
                        entity_dormant = pm.read_uint(entity + m_bDormant)
                        entity_glow = pm.read_uint(entity + m_iGlowIndex)

                        if entity_team_id == 2 and localTeam != 2 and not entity_dormant:  ###TERRORIST###
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x8, float(r))  # R
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0xC, float(g))  # G
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x10, float(b))  # B
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x14, float(255))  # A
                            pm.write_int(glow_manager + entity_glow * 0x38 + 0x28, 1)  # START
                        elif entity_team_id == 3 and localTeam != 3 and not entity_dormant:  ###COUNTER###
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x8, float(r))  # R
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0xC, float(g))  # G
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x10, float(b))  # B
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x14, float(255))  # A
                            pm.write_int(glow_manager + entity_glow * 0x38 + 0x28, 1)  # START
        except Exception as err:
            pass
        time.sleep(0.001)

def chamshack():
    if chams:
        rgbt = [255, 0, 0]
        rgbc = [0, 0, 255]
        while True:
            try:
                time.sleep(0.001)
                for i in range(1, 32):
                    entity = pm.read_int(client + dwEntityList + i * 0x10)
                    if entity:
                        entity_team_id = pm.read_uint(entity + m_iTeamNum)
                        if entity_team_id == 2:  # terrorist
                            pm.write_int(entity + m_clrRender, (rgbt[0]))  # R
                            pm.write_int(entity + m_clrRender + 0x1, (rgbt[1]))  # G
                            pm.write_int(entity + m_clrRender + 0x2, (rgbt[2]))  # B
                        elif entity_team_id == 3:  # counter
                            pm.write_int(entity + m_clrRender, (rgbc[0]))  # R
                            pm.write_int(entity + m_clrRender + 0x1, (rgbc[1]))  # G
                            pm.write_int(entity + m_clrRender + 0x2, (rgbc[2]))  # B
                        else:
                            pass
            except Exception as err:
                pass
            time.sleep(0.001)

def norcs():
    if no_recoil:
        oldpunchx = 0.0
        oldpunchy = 0.0
        while switch:
            try:
                time.sleep(0.01)
                if rcsonoff:
                    rcslocalplayer = pm.read_uint(client + dwLocalPlayer)
                    rcsengine = pm.read_uint(engine + dwClientState)
                    if pm.read_int(rcslocalplayer + m_iShotsFired) > 1:
                        rcs_x = pm.read_float(rcsengine + dwClientState_ViewAngles)
                        rcs_y = pm.read_float(rcsengine + dwClientState_ViewAngles + 0x4)
                        punchx = pm.read_float(rcslocalplayer + m_aimPunchAngle)
                        punchy = pm.read_float(rcslocalplayer + m_aimPunchAngle + 0x4)
                        newrcsx = rcs_x - (punchx - oldpunchx) * 2.0
                        newrcsy = rcs_y - (punchy - oldpunchy) * 2.0
                        newrcs, newrcy = normalizeAngles(newrcsx, newrcsy)
                        oldpunchx = punchx
                        oldpunchy = punchy
                        if nanchecker(newrcsx, newrcsy) and checkangles(newrcsx, newrcsy):
                            pm.write_float(rcsengine + dwClientState_ViewAngles, newrcsx)
                            pm.write_float(rcsengine + dwClientState_ViewAngles + 0x4, newrcsy)
                    else:
                        oldpunchx = 0.0
                        oldpunchy = 0.0
                        newrcsx = 0.0
                        newrcsy = 0.0

            except Exception as err:
                pass
            time.sleep(0.001)

def bhop():
    if bunny_hop:
        while True:
            try:
                if keyboard.is_pressed("space"):
                    force_jump = client + dwForceJump
                    player = pm.read_int(client + dwLocalPlayer)
                    on_ground = pm.read_int(player + m_fFlags)
                    if player and on_ground and on_ground == 257:
                        pm.write_int(force_jump, 5)
                        time.sleep(0.08)
                        pm.write_int(force_jump, 4)

            except Exception as err:
                pass
            time.sleep(0.001)

def fovhack():
    if fov:
        while True:
            try:
                player = pm.read_int(client + dwEntityList)
                pm.write_int(player + m_iDefaultFOV, Fov)
            except Exception as err:
                pass
            time.sleep(0.001)

def r5():
    if radar_hack:
        while True:
            try:
                for i in range(1, 32):
                    entity = pm.read_int(client + dwEntityList + i * 0x10)
                    if entity:
                        pm.write_uchar(entity + m_bSpotted, 1)
            except Exception as err:
                pass
            time.sleep(0.001)

def trigger():
    if triggerbot:
        while True:
            try:

                # If the crosshair is on an enemy, shoot
                if crosshairID > 0 and crosshairID < 64 and crosshairTeam != localTeam:
                    keyboard.press("attack")
                    time.sleep(0.1)
                    keyboard.release("attack")
                time.sleep(0.1)
            except Exception as err:
                pass
            time.sleep(0.001)

def person():
    if third_person:
        switch = 0
        while True:
            try:
                localplayer = pm.read_int(client + dwLocalPlayer)

                if keyboard.is_pressed('z') and switch == 0:
                    pm.write_int(localplayer + m_iObserverMode, 1)
                    switch = 1
                    time.sleep(0.5)
                if keyboard.is_pressed('z') and switch == 1:
                    pm.write_int(localplayer + m_iObserverMode, 0)
                    switch = 0
                    time.sleep(0.5)
            except Exception as err:
                pass
            time.sleep(0.001)

def noflash():
    if no_flash:
        if player:
            flash_value = player + m_flFlashMaxAlpha
            if flash_value:
                pm.write_float(flash_value, float(0))
        else:
            pass

def rank():
    if show_rank:
        ranks = ["Unranked",
                 "Silver I",
                 "Silver II",
                 "Silver III",
                 "Silver IV",
                 "Silver Elite",
                 "Silver Elite Master",
                 "Gold Nova I",
                 "Gold Nova II",
                 "Gold Nova III",
                 "Gold Nova Master",
                 "Master Guardian I",
                 "Master Guardian II",
                 "Master Guardian Elite",
                 "Distinguished Master Guardian",
                 "Legendary Eagle",
                 "Legendary Eagle Master",
                 "Supreme Master First Class",
                 "The Global Elite"]
        for i in range(0, 32):
            entity = pm.read_uint(client.lpBaseOfDll + dwEntityList + i * 0x10)
            if entity:
                entity_team_id = pm.read_uint(entity + m_iTeamNum)
                if entity_team_id:
                    player_info = pm.read_uint(
                        (pm.read_uint(engine.lpBaseOfDll + dwClientState)) + dwClientState_PlayerInfo)
                    player_info_items = pm.read_uint(pm.read_uint(player_info + 0x40) + 0xC)
                    info = pm.read_uint(player_info_items + 0x28 + (i * 0x34))
                    playerres = pm.read_uint(client.lpBaseOfDll + dwPlayerResource)
                    rank = pm.read_uint(playerres + m_iCompetitiveRanking + (i * 4))
                    wins = pm.read_uint(playerres + m_iCompetitiveWins + i * 4)
                    if pm.read_string(info + 0x10) != 'GOTV':
                        print(rank)
                        print(pm.read_string(info + 0x10) + "   -->   " + ranks[rank])
                        print(wins)

global glow, chams, no_recoil, triggerbot, bunny_hop, radar_hack, fov, third_person, no_flash, show_rank

while True:

    event, values = window.read(timeout=100)
    if event == "exit" or event == sg.WIN_CLOSED:
        break
    if event == "__TIMEOUT__":
        # Read the health value of the player
        health = pm.read_uint(player + m_iHealth)

        # Update the displayed health value
        window["Health"].update(str(health))
    if event == "Set Glow Color":
        # Split the input string into a list of strings representing the red, green, and blue values
        r = values["Red"]
        g = values["Green"]
        b = values["Blue"]

            # Convert the strings to integers
        r = int(r)
        g = int(g)
        b = int(b)
    if event == "Update Money":
        # Read the new money value from the textbox
        new_money = values["Money"]

            # Convert the new money value to an integer
        new_money = int(new_money)

            # Write the new money value to the game's memory
        pm.write_int(player + m_iAccountID, new_money)
    if event == "Update Armor":
            # Read the new armor value from the textbox
        new_armor = values["NewArmor"]

            # Convert the new armor value to an integer
        new_armor = int(new_armor)

            # Update the armor value
        pm.write_int(player + m_ArmorValue, new_armor)

            # Update the displayed armor value
        window["Armor"].update(str(new_armor))
    if event == "Set FOV Value":
        Fov = values["fov"]
        Fov = int(Fov)
    if values["glow_checkbox"] == True:
        glow = True
    else:
        glow = False
    if values["chams_checkbox"] == True:
        chams = True
    else:
        chams = False
    if values["bunny_hop_checkbox"] == True:
        bunny_hop = True
    else:
        bunny_hop = False
    if values["fov_checkbox"] == True:
        fov = True
    else:
        fov = False
    if values["radar_hack_checkbox"] == True:
        radar_hack = True
    else:
        radar_hack = False
    if values["triggerbot_checkbox"] == True:
        triggerbot = True
    else:
        triggerbot = False
    if values["3_person_checkbox"] == True:
        third_person = True
    else:
        third_person = False
    if values["no_flash_checkbox"] == True:
        no_flash = True
    else:
        no_flash = False
    if values["show_rank_checkbox"] == True:
        show_rank = True
    else:
        show_rank = False
    if values["no_recoil_checkbox"] == True:
        no_recoil = True
    else:
        no_recoil = False
    if event == "Debug":
        debug()

def start_threads():
    try:

        threading.Thread(target=esp, name='esp').start()
        threading.Thread(target=chamshack, name='chamshack').start()
        threading.Thread(target=person, name='person').start()
        threading.Thread(target=rank, name='rank').start()
        threading.Thread(target=norcs, name='norcs').start()
        threading.Thread(target=trigger, name='trigger').start()
        threading.Thread(target=bhop, name='bhop').start()
        threading.Thread(target=r5, name='r5').start()
        threading.Thread(target=noflash, name='noflash').start()
        threading.Thread(target=fovhack, name='fovhack').start()
    except Exception as err:
        print(f'Threads have been canceled! Exiting...\nReason: {err}\nExiting...')
        exit(1)

start_threads()
window.close()

</code>```

i really don't know what im i doing wrong, i have decent experience with python but pysimpleGUI is another thing...

Title: PySimpleGUI Checkbox

Body:
Idk why, but when i check a checkbox in the menu nothings, happens, but if i close the menu the cheat start. I think that i made some mistakes setting up the checkboxes, but im trying to fix this problem from 3 days now and i can't continue anymore. Can someone help?

import PySimpleGUI as sg
import threading
from globals import *
import math
import time
import keyboard

switch = True
rcsonoff = True
r = 255
g = 3
b = 3

def normalizeAngles(viewAngleX, viewAngleY):
    if viewAngleX > 89:
        viewAngleX -= 360
    if viewAngleX < -89:
        viewAngleX += 360
    if viewAngleY > 180:
        viewAngleY -= 360
    if viewAngleY < -180:
        viewAngleY += 360
    return viewAngleX, viewAngleY

def checkangles(x, y):
    if x > 89:
        return False
    elif x < -89:
        return False
    elif y > 360:
        return False
    elif y < -360:
        return False
    else:
        return True

def nanchecker(first, second):
    if math.isnan(first) or math.isnan(second):
        return False
    else:
        return True

layout = [
    # Use a modern font and color scheme
    [sg.Text("External 2.3", font="Helvetica 20", text_color="#d80fc6")],
    # Use tabs to organize the buttons into different categories
    [sg.TabGroup([
        # Tab for aim-related buttons
        [sg.Tab("Aim", [[
            sg.Column(
                # Define the grid layout for the buttons
                [
                    [sg.Checkbox("No Recoil", default=False, key="no_recoil_checkbox")],
                    [sg.Checkbox("TriggerBot", default=False, key="triggerbot_checkbox")]
                ],
                # Set the number of rows and columns in the grid
            )
        ]]),
         # Tab for visual-related buttons
         sg.Tab("Visuals", [[
             sg.Column(
                 # Define the grid layout for the buttons
                 [
                     [sg.Checkbox("Glow", default=False, key="glow_checkbox")],
                     [sg.Checkbox("Chams", default=False, key="chams_checkbox")],
                     [sg.Checkbox("Fov", default=False, key="fov_checkbox")],
                     [sg.Text("Fov Value (MAX 140): "), sg.InputText(key="fov")],
                     [sg.Button("Set FOV Value", button_color=("magenta", "#a9a9a9"))]
                 ],
                 # Set the number of rows and columns in the grid
             )
         ]]),
         sg.Tab("Misc", [[
             sg.Column(
                 [
                     [sg.Checkbox("Bunny Hop", default=False, key="bunny_hop_checkbox")],
                     [sg.Checkbox("Radar Hack", default=False, key="radar_hack_checkbox")],
                     [sg.Checkbox("Show Rank", default=False, key="show_rank_checkbox")],
                     [sg.Checkbox("Third Person", default=False, key="3_person_checkbox")],
                     [sg.Checkbox("No Flash", default=False, key="no_flash_checkbox")]
                 ],
             )
         ]]),
         sg.Tab("LocalPlayer", [[
             sg.Column(
                 [
                     [sg.Text("Player Health:")],
                     [sg.Text(key="Health")],
                     [sg.Text("Armor:")],
                     [sg.Text(key="Armor")],
                     [sg.Text("Enter a new value:")],
                     [sg.InputText(key="NewArmor")],
                     [sg.Button("Update Armor")],
                     [sg.Text("Enter a new money value:")],
                     [sg.InputText(key="Money")],
                     [sg.Button("Update Money")]

                 ],
             )
         ]]),
         # Tab for color-related buttons
         sg.Tab("Color and Debug", [[
             sg.Column(
                 # Define the grid layout for the sliders
                 [
                     [sg.Button("Debug", button_color=("magenta", "#a9a9a9"))],
                     [sg.Text("Enter the glow color values:")],
                     [sg.Text("Red:"), sg.InputText(key="Red")],
                     [sg.Text("Green:"), sg.InputText(key="Green")],
                     [sg.Text("Blue:"), sg.InputText(key="Blue")],
                     [sg.Button("Set Glow Color")]
                 ],
                 # Set the number of rows and columns in the grid
             )
         ]])
         ]])]
]

window = sg.Window("Buck3ts41", layout, element_justification="center")

def debug():
    while True:
        print("crossID ", crosshairID)
        print("corssTeam ", crosshairTeam)
        print("LocalPlayer ", player)
        print("LocalTeam ", localTeam)
        print("GlowManager ", glow_manager)
        print("GetTeam ", getTeam)
        time.sleep(2)

def esp():
    while True:
        try:
            if glow == True:

                for i in range(1, 32):
                    entity = pm.read_int(client + dwEntityList + i * 0x10)
                    if entity:
                        entity_hp = pm.read_uint(entity + m_iHealth)
                        entity_team_id = pm.read_uint(entity + m_iTeamNum)
                        entity_dormant = pm.read_uint(entity + m_bDormant)
                        entity_glow = pm.read_uint(entity + m_iGlowIndex)

                        if entity_team_id == 2 and localTeam != 2 and not entity_dormant:  ###TERRORIST###
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x8, float(r))  # R
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0xC, float(g))  # G
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x10, float(b))  # B
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x14, float(255))  # A
                            pm.write_int(glow_manager + entity_glow * 0x38 + 0x28, 1)  # START
                        elif entity_team_id == 3 and localTeam != 3 and not entity_dormant:  ###COUNTER###
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x8, float(r))  # R
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0xC, float(g))  # G
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x10, float(b))  # B
                            pm.write_float(glow_manager + entity_glow * 0x38 + 0x14, float(255))  # A
                            pm.write_int(glow_manager + entity_glow * 0x38 + 0x28, 1)  # START
        except Exception as err:
            pass
        time.sleep(0.001)

def chamshack():
    if chams:
        rgbt = [255, 0, 0]
        rgbc = [0, 0, 255]
        while True:
            try:
                time.sleep(0.001)
                for i in range(1, 32):
                    entity = pm.read_int(client + dwEntityList + i * 0x10)
                    if entity:
                        entity_team_id = pm.read_uint(entity + m_iTeamNum)
                        if entity_team_id == 2:  # terrorist
                            pm.write_int(entity + m_clrRender, (rgbt[0]))  # R
                            pm.write_int(entity + m_clrRender + 0x1, (rgbt[1]))  # G
                            pm.write_int(entity + m_clrRender + 0x2, (rgbt[2]))  # B
                        elif entity_team_id == 3:  # counter
                            pm.write_int(entity + m_clrRender, (rgbc[0]))  # R
                            pm.write_int(entity + m_clrRender + 0x1, (rgbc[1]))  # G
                            pm.write_int(entity + m_clrRender + 0x2, (rgbc[2]))  # B
                        else:
                            pass
            except Exception as err:
                pass
            time.sleep(0.001)

def norcs():
    if no_recoil:
        oldpunchx = 0.0
        oldpunchy = 0.0
        while switch:
            try:
                time.sleep(0.01)
                if rcsonoff:
                    rcslocalplayer = pm.read_uint(client + dwLocalPlayer)
                    rcsengine = pm.read_uint(engine + dwClientState)
                    if pm.read_int(rcslocalplayer + m_iShotsFired) > 1:
                        rcs_x = pm.read_float(rcsengine + dwClientState_ViewAngles)
                        rcs_y = pm.read_float(rcsengine + dwClientState_ViewAngles + 0x4)
                        punchx = pm.read_float(rcslocalplayer + m_aimPunchAngle)
                        punchy = pm.read_float(rcslocalplayer + m_aimPunchAngle + 0x4)
                        newrcsx = rcs_x - (punchx - oldpunchx) * 2.0
                        newrcsy = rcs_y - (punchy - oldpunchy) * 2.0
                        newrcs, newrcy = normalizeAngles(newrcsx, newrcsy)
                        oldpunchx = punchx
                        oldpunchy = punchy
                        if nanchecker(newrcsx, newrcsy) and checkangles(newrcsx, newrcsy):
                            pm.write_float(rcsengine + dwClientState_ViewAngles, newrcsx)
                            pm.write_float(rcsengine + dwClientState_ViewAngles + 0x4, newrcsy)
                    else:
                        oldpunchx = 0.0
                        oldpunchy = 0.0
                        newrcsx = 0.0
                        newrcsy = 0.0

            except Exception as err:
                pass
            time.sleep(0.001)

def bhop():
    if bunny_hop:
        while True:
            try:
                if keyboard.is_pressed("space"):
                    force_jump = client + dwForceJump
                    player = pm.read_int(client + dwLocalPlayer)
                    on_ground = pm.read_int(player + m_fFlags)
                    if player and on_ground and on_ground == 257:
                        pm.write_int(force_jump, 5)
                        time.sleep(0.08)
                        pm.write_int(force_jump, 4)

            except Exception as err:
                pass
            time.sleep(0.001)

def fovhack():
    if fov:
        while True:
            try:
                player = pm.read_int(client + dwEntityList)
                pm.write_int(player + m_iDefaultFOV, Fov)
            except Exception as err:
                pass
            time.sleep(0.001)

def r5():
    if radar_hack:
        while True:
            try:
                for i in range(1, 32):
                    entity = pm.read_int(client + dwEntityList + i * 0x10)
                    if entity:
                        pm.write_uchar(entity + m_bSpotted, 1)
            except Exception as err:
                pass
            time.sleep(0.001)

def trigger():
    if triggerbot:
        while True:
            try:

                # If the crosshair is on an enemy, shoot
                if crosshairID > 0 and crosshairID < 64 and crosshairTeam != localTeam:
                    keyboard.press("attack")
                    time.sleep(0.1)
                    keyboard.release("attack")
                time.sleep(0.1)
            except Exception as err:
                pass
            time.sleep(0.001)

def person():
    if third_person:
        switch = 0
        while True:
            try:
                localplayer = pm.read_int(client + dwLocalPlayer)

                if keyboard.is_pressed('z') and switch == 0:
                    pm.write_int(localplayer + m_iObserverMode, 1)
                    switch = 1
                    time.sleep(0.5)
                if keyboard.is_pressed('z') and switch == 1:
                    pm.write_int(localplayer + m_iObserverMode, 0)
                    switch = 0
                    time.sleep(0.5)
            except Exception as err:
                pass
            time.sleep(0.001)

def noflash():
    if no_flash:
        if player:
            flash_value = player + m_flFlashMaxAlpha
            if flash_value:
                pm.write_float(flash_value, float(0))
        else:
            pass

def rank():
    if show_rank:
        ranks = ["Unranked",
                 "Silver I",
                 "Silver II",
                 "Silver III",
                 "Silver IV",
                 "Silver Elite",
                 "Silver Elite Master",
                 "Gold Nova I",
                 "Gold Nova II",
                 "Gold Nova III",
                 "Gold Nova Master",
                 "Master Guardian I",
                 "Master Guardian II",
                 "Master Guardian Elite",
                 "Distinguished Master Guardian",
                 "Legendary Eagle",
                 "Legendary Eagle Master",
                 "Supreme Master First Class",
                 "The Global Elite"]
        for i in range(0, 32):
            entity = pm.read_uint(client.lpBaseOfDll + dwEntityList + i * 0x10)
            if entity:
                entity_team_id = pm.read_uint(entity + m_iTeamNum)
                if entity_team_id:
                    player_info = pm.read_uint(
                        (pm.read_uint(engine.lpBaseOfDll + dwClientState)) + dwClientState_PlayerInfo)
                    player_info_items = pm.read_uint(pm.read_uint(player_info + 0x40) + 0xC)
                    info = pm.read_uint(player_info_items + 0x28 + (i * 0x34))
                    playerres = pm.read_uint(client.lpBaseOfDll + dwPlayerResource)
                    rank = pm.read_uint(playerres + m_iCompetitiveRanking + (i * 4))
                    wins = pm.read_uint(playerres + m_iCompetitiveWins + i * 4)
                    if pm.read_string(info + 0x10) != 'GOTV':
                        print(rank)
                        print(pm.read_string(info + 0x10) + "   -->   " + ranks[rank])
                        print(wins)

global glow, chams, no_recoil, triggerbot, bunny_hop, radar_hack, fov, third_person, no_flash, show_rank

while True:

    event, values = window.read(timeout=100)
    if event == "exit" or event == sg.WIN_CLOSED:
        break
    if event == "__TIMEOUT__":
        # Read the health value of the player
        health = pm.read_uint(player + m_iHealth)

        # Update the displayed health value
        window["Health"].update(str(health))
    if event == "Set Glow Color":
        # Split the input string into a list of strings representing the red, green, and blue values
        r = values["Red"]
        g = values["Green"]
        b = values["Blue"]

            # Convert the strings to integers
        r = int(r)
        g = int(g)
        b = int(b)
    if event == "Update Money":
        # Read the new money value from the textbox
        new_money = values["Money"]

            # Convert the new money value to an integer
        new_money = int(new_money)

            # Write the new money value to the game's memory
        pm.write_int(player + m_iAccountID, new_money)
    if event == "Update Armor":
            # Read the new armor value from the textbox
        new_armor = values["NewArmor"]

            # Convert the new armor value to an integer
        new_armor = int(new_armor)

            # Update the armor value
        pm.write_int(player + m_ArmorValue, new_armor)

            # Update the displayed armor value
        window["Armor"].update(str(new_armor))
    if event == "Set FOV Value":
        Fov = values["fov"]
        Fov = int(Fov)
    if values["glow_checkbox"] == True:
        glow = True
    else:
        glow = False
    if values["chams_checkbox"] == True:
        chams = True
    else:
        chams = False
    if values["bunny_hop_checkbox"] == True:
        bunny_hop = True
    else:
        bunny_hop = False
    if values["fov_checkbox"] == True:
        fov = True
    else:
        fov = False
    if values["radar_hack_checkbox"] == True:
        radar_hack = True
    else:
        radar_hack = False
    if values["triggerbot_checkbox"] == True:
        triggerbot = True
    else:
        triggerbot = False
    if values["3_person_checkbox"] == True:
        third_person = True
    else:
        third_person = False
    if values["no_flash_checkbox"] == True:
        no_flash = True
    else:
        no_flash = False
    if values["show_rank_checkbox"] == True:
        show_rank = True
    else:
        show_rank = False
    if values["no_recoil_checkbox"] == True:
        no_recoil = True
    else:
        no_recoil = False
    if event == "Debug":
        debug()

def start_threads():
    try:

        threading.Thread(target=esp, name='esp').start()
        threading.Thread(target=chamshack, name='chamshack').start()
        threading.Thread(target=person, name='person').start()
        threading.Thread(target=rank, name='rank').start()
        threading.Thread(target=norcs, name='norcs').start()
        threading.Thread(target=trigger, name='trigger').start()
        threading.Thread(target=bhop, name='bhop').start()
        threading.Thread(target=r5, name='r5').start()
        threading.Thread(target=noflash, name='noflash').start()
        threading.Thread(target=fovhack, name='fovhack').start()
    except Exception as err:
        print(f'Threads have been canceled! Exiting...\nReason: {err}\nExiting...')
        exit(1)

start_threads()
window.close()

i really don't know what im i doing wrong, i have decent experience with python but pysimpleGUI is another thing...