问:
How do you change multiple groups of images separately?
Yesterday I posted a question asking for help on how to change multiple instances of the same image to another image. I was using id to change them so I was only able to change the first of that image that is shown. Now that I know id is supposed to be unique and that I learned to use class instead I wanted to see if there was a way to do it multiple times for different images.

```<code>function changeImage()
{
    var element = document.getElementsByClassName("bicycle")
    ;
    for(var x=0;x<element.length;x++)
    {
        element[x].src="images/car.jpg"
    }
}

function changeImage()
    {
        var element = document.getElementsByClassName("plane")
        ;
        for(var x=0;x<element.length;x++)
        {
            element[x].src="images/helicopter.jpg"
        }
    }

<button onclick="changeImage()"><img src="images/bicycle.jpg" class="bicycle"></button>
<button onclick="changeImage()"><img src="images/bicycle.jpg" class="bicycle"></button>
<button onclick="changeImage()"><img src="images/bicycle.jpg" class="bicycle"></button>
<button onclick="changeImage()"><img src="images/bicycle.jpg" class="plane"></button>
<button onclick="changeImage()"><img src="images/bicycle.jpg" class="plane"></button>
<button onclick="changeImage()"><img src="images/bicycle.jpg" class="plane"></button>
</code>```

This is what I have so far and wanted to change each when I click on the image for each. So theoretically what I would be doing is clicking on the bicycle button and changing it to a car image and then also be able to click on the plane button and changing the image to a helicopter image. What happens when I try to do that now is no matter what button I click on only the plane image changes, not the bicycle.

Is there a way to click on the button to get the first set of images to change, stay changed, and then also change the next set of images without the others reverting?

Body:
Yesterday I posted a question asking for help on how to change multiple instances of the same image to another image. I was using id to change them so I was only able to change the first of that image that is shown. Now that I know id is supposed to be unique and that I learned to use class instead I wanted to see if there was a way to do it multiple times for different images.

function changeImage()
{
    var element = document.getElementsByClassName("bicycle")
    ;
    for(var x=0;x<element.length;x++)
    {
        element[x].src="images/car.jpg"
    }
}

function changeImage()
    {
        var element = document.getElementsByClassName("plane")
        ;
        for(var x=0;x<element.length;x++)
        {
            element[x].src="images/helicopter.jpg"
        }
    }

<button onclick="changeImage()"></button>
<button onclick="changeImage()"></button>
<button onclick="changeImage()"></button>
<button onclick="changeImage()"></button>
<button onclick="changeImage()"></button>
<button onclick="changeImage()"></button>

This is what I have so far and wanted to change each when I click on the image for each. So theoretically what I would be doing is clicking on the bicycle button and changing it to a car image and then also be able to click on the plane button and changing the image to a helicopter image. What happens when I try to do that now is no matter what button I click on only the plane image changes, not the bicycle.

Is there a way to click on the button to get the first set of images to change, stay changed, and then also change the next set of images without the others reverting?


来源: stackexchange

问:
iOS 16 Orientation .portraitUpsideDown not working
I have been working on an iOS app which uses CNC communications to move motors and so the iPhone in my app is mounted on the holder on a machine. Since it is held on a machine, the user views its iPhone device upside down.
My question is, my app was working very well in portrait upside down (The entire app including the launch screens, UIAlertViews and VC's) till I had updated it to the iOS 16. Now I am not getting the methods to get it back to the upside down mode.

Basically, I want the application to run upside down.

Kindly help

```<code>    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return .portraitUpsideDown
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have been working on an iOS app which uses CNC communications to move motors and so the iPhone in my app is mounted on the holder on a machine. Since it is held on a machine, the user views its iPhone device upside down.
My question is, my app was working very well in portrait upside down (The entire app including the launch screens, UIAlertViews and VC's) till I had updated it to the iOS 16. Now I am not getting the methods to get it back to the upside down mode.

Basically, I want the application to run upside down.

Kindly help

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    return .portraitUpsideDown
}


问:
Chrome mobile tab grid layout issue
Chrome suddenly changed tab grid layout from "cards" with preview to the simple list of tabs. I checked Chrome://flags, specifically tab-grid-layout. But every setting-switch seems like no effect.
I need a 101% workable method, how to force Chrome work normally.</p>

Title: Chrome mobile tab grid layout issue


问:
Directory structure for controllers, routes, services, and models
The following structure seems to be the popular suggestion (from an online search):

```<code>model/user.js
route/user.js
service/user.js
controller/user.js
</code>```

What are the benefits/tradeoffs of that structure vs. the inverse?

```<code>user/model.js
user/route.js
user/service.js
user/controller.js
</code>```

The latter seems to be more self-contained, and presumably easier to break out to a separate service if/when needed.

What are the tradeoffs and why might one be preferred over the other?

Body:
The following structure seems to be the popular suggestion (from an online search):

model/user.js
route/user.js
service/user.js
controller/user.js

What are the benefits/tradeoffs of that structure vs. the inverse?

user/model.js
user/route.js
user/service.js
user/controller.js

The latter seems to be more self-contained, and presumably easier to break out to a separate service if/when needed.

What are the tradeoffs and why might one be preferred over the other?


问:
Jumble word game written in Java using a random number generator non-deterministically gets the user stuck in an infinite loop. How to fix?
I was given instructions to program a jumble word game in Java last semester, as an assignment. My instructor said I could post this on stackoverflow after the due date for the assignment had expired, so nothing here is unauthorized outside help (aka cheating). A good description of the program is as follows:

This program reads from a file of a long list of words, randomly selects one of those words, then randomly jumbles one of those words. The user will then see the jumbled word,
and see a menu that allows them to either take a guess, get a hint, get a new word, or quit. Each new word gives a possible 10 points, but guessing incorrectly and getting hints
will decrease the total number of possible points the user can get from guessing the word correctly.

If the total number of possible points reaches zero for a word,
the program will generate a new word for the user. If the user guesses the word correctly, the program will congratulate them, and display the number of points gained
from that word, as well as the user's total score. Upon the exit of the program by the user, the program will display the final score of the user for that specific run.

The file that has the list of words that I used is called words.txt, and it looks like this:

screenshot of 'words.txt'

The first line is the number of words in the file. I use that to define the array size.

Everything about the program works fine, except that sometimes when I play the game over and over again, I will get stuck in an infinite loop. The worst part is, there's no apparent pattern to the infinite loops, save for the fact that the infinite loop always occurs after the program identifies the word to be jumbled. But other than that, there is no easy pattern to see.

I asked my instructor for help, and he said he didn't find anything that jumped out to him that was obviously faulty code-wise. He said he could've found out the problem if he stared at it for hours, but he didn't have that much time. Since he couldn't find out what was the with the code itself, he let me submit my code without penalty for this weird bug. I remember getting a perfect score on the assignment.

Sometimes the bug will manifest itself in the first few iterations of the program:

Example1

Example2

But sometimes it will take longer for the bug to manifest:

Example3

Here is the computer program that I wrote:

```<code>import java.util.*;
import java.io.*;

public class Proj5{
  public static void main(String [] args) throws IOException {
    Scanner keyboard = new Scanner(System.in);
    Random randGen = new Random();

    System.out.print("Enter in text file containing words (Ex: words.txt): ");
    String filename = keyboard.nextLine();
    System.out.println();

    Scanner s = new Scanner(new File(filename));

    String line = s.nextLine();
    int arraySize = Integer.parseInt(line);

    String [] WordList = new String [arraySize];

    for(int i = 0; i < arraySize; i++){
      WordList[i] = s.nextLine();
    }

    s.close();

    boolean OuterExitValue = true;

    int totalScore = 0;

    while(OuterExitValue){

    int RandomWord = randGen.nextInt(WordList.length);

    String CorrectWord = WordList[RandomWord];

    int RandomN, k = 0, i = 0;

    System.out.print("Word = " + CorrectWord);

    char [] JumbledWord = new char [CorrectWord.length()];
    boolean [] check = new boolean [CorrectWord.length()];

    while( i < CorrectWord.length() ) {

      RandomN = randGen.nextInt(CorrectWord.length());

      if ( !(check[RandomN % CorrectWord.length()]) ) {

        JumbledWord[RandomN % CorrectWord.length()] = CorrectWord.charAt(i);
        //System.out.println(JumbledWord[i]);
        check[RandomN % CorrectWord.length()] = true;
        i++;

      }

      if ( i == CorrectWord.length() ){

        for(int j = 0; j < CorrectWord.length(); j++){

          if( JumbledWord[j] == CorrectWord.charAt(j) )
            k++;
        }

      }

      if ( k == CorrectWord.length() ) {

          i = 0;

          for(int j = 0; j < CorrectWord.length(); j++){
            check[j] = false;
          }

        }

    }

    System.out.println();

    int NPoints = 10;
    String guess = "a";
    boolean InnerExitValue = true;

    while(InnerExitValue){

      System.out.print("Current puzzle: ");

      for (i = 0; i < CorrectWord.length(); i++)
        System.out.print(JumbledWord[i]);

        System.out.println("\nCurrent points for word: " + NPoints);
        System.out.print("Enter (g)uess, (n)ew word, (h)int, or (q)uit: ");
        char option = keyboard.next().toLowerCase().charAt(0);

        switch (option) {

          case 'q':
            InnerExitValue = false;
            OuterExitValue = false;
            System.out.println("\nThanks for Playing! Goodbye!");
            System.out.println("Final score: " + totalScore);
            System.exit(0);
            break;

          case 'h':
            int RandomLetter = randGen.nextInt(CorrectWord.length());
            int RandomSpot = RandomLetter + 1;
            System.out.println("\nThe letter at spot " + RandomSpot + " is " + CorrectWord.charAt(RandomLetter) + "\n" );
            NPoints = NPoints/2;
            break;

          case 'g':

            System.out.print("\nEnter your guess: ");
            guess = keyboard.next();

            if ( !(guess.equalsIgnoreCase(CorrectWord)) ) {
              NPoints -= 1;
              System.out.println("Sorry, try again.\n");
            }
            else{
              totalScore += NPoints;
              System.out.println("Congratulations! You guessed it!");
              System.out.println("Score for word: " + NPoints);
              System.out.println("Total score: " + totalScore);
              System.out.println();
              InnerExitValue = false;
            }
            break;

          case 'n':
            InnerExitValue = false;
            System.out.println();
            break;

          default:
            System.out.println("Invalid Choice - 'g', 'n' 'h' or 'q' only.\n");
        }

        if(NPoints == 0){
          System.out.println("Word points = 0. Generating a new word");
          InnerExitValue = false;
        }

      }

    }

}
}
</code>```

I tried some things out with my code. I used traces to find out where my code was getting stuck in an infinite loop, and it turns out that the infinite loop is always occurring in the first while loop that has the purpose of jumbling a word and checking that it's jumbled properly. I added this trace at the bottom of the first while loop, right before the bracket, where I just inputted:

```<code>for(int m = 0; m < CorrectWord.length(); m++)
          System.out.print(JumbledWord[m]);
</code>```

This trace allowed me to see what jumbled word is being seen by the computer before it becomes a properly jumbled word that the user can deal with. This allowed me to see this:

Program output with trace in code

If you look carefully, you can see that every 'current puzzle' is just the last four or five sequence of characters in that jumbled mess of letters. Presumably, this means the last sequence is being grabbed by the computer to become the 'current puzzle', which is in line with the logic inside my program, so that's a good sign that the program is working as intended. So what about using this trace to find what an infinite loop will look like?

Here is another screenshot:

Program output with trace showing infinite loop

In the above image, we see the program jumbling the word, but for some reason, the w character becomes more, and more frequently printed to the screen compared to all the other ones, and then it just keeps being printed to the screen indefinitely. But that is not something I expect to see given my code. I suspect there is a teeny tiny error in the algorithm that I concocted. It seems that the program occasionally jumbles words in a way that leaves out essential letters that need to be in that sequence of characters in order for the word to be correctly jumbled. We can see the same phenomena with this other screenshot:

Program output with trace showing infinite loop 2

In both pictures, one letter is being oddly left out with the first couple of 'jumbles.' For the last picture, it is 'd' and for the second to last picture, it is 'k'. This may be a hint that with my algorithm, I am not actually 'jumbling' letters, instead I am copying and pasting letters into certain indexes, inevitably resulting in odd cases where at least one letter is just 'pasted' over or overwritten by other letters, never appearing again. I am not sure that this decisively solves the issue for me, though.

Body:
I was given instructions to program a jumble word game in Java last semester, as an assignment. My instructor said I could post this on stackoverflow after the due date for the assignment had expired, so nothing here is unauthorized outside help (aka cheating). A good description of the program is as follows:

This program reads from a file of a long list of words, randomly selects one of those words, then randomly jumbles one of those words. The user will then see the jumbled word,
and see a menu that allows them to either take a guess, get a hint, get a new word, or quit. Each new word gives a possible 10 points, but guessing incorrectly and getting hints
will decrease the total number of possible points the user can get from guessing the word correctly.

If the total number of possible points reaches zero for a word,
the program will generate a new word for the user. If the user guesses the word correctly, the program will congratulate them, and display the number of points gained
from that word, as well as the user's total score. Upon the exit of the program by the user, the program will display the final score of the user for that specific run.

The file that has the list of words that I used is called words.txt, and it looks like this:

screenshot of 'words.txt'

The first line is the number of words in the file. I use that to define the array size.

Everything about the program works fine, except that sometimes when I play the game over and over again, I will get stuck in an infinite loop. The worst part is, there's no apparent pattern to the infinite loops, save for the fact that the infinite loop always occurs after the program identifies the word to be jumbled. But other than that, there is no easy pattern to see.

I asked my instructor for help, and he said he didn't find anything that jumped out to him that was obviously faulty code-wise. He said he could've found out the problem if he stared at it for hours, but he didn't have that much time. Since he couldn't find out what was the with the code itself, he let me submit my code without penalty for this weird bug. I remember getting a perfect score on the assignment.

Sometimes the bug will manifest itself in the first few iterations of the program:

Example1

Example2

But sometimes it will take longer for the bug to manifest:

Example3

Here is the computer program that I wrote:

import java.util.*;
import java.io.*;

public class Proj5{
  public static void main(String [] args) throws IOException {
    Scanner keyboard = new Scanner(System.in);
    Random randGen = new Random();

    System.out.print("Enter in text file containing words (Ex: words.txt): ");
    String filename = keyboard.nextLine();
    System.out.println();

    Scanner s = new Scanner(new File(filename));

    String line = s.nextLine();
    int arraySize = Integer.parseInt(line);

    String [] WordList = new String [arraySize];

    for(int i = 0; i < arraySize; i++){
      WordList[i] = s.nextLine();
    }

    s.close();

    boolean OuterExitValue = true;

    int totalScore = 0;

    while(OuterExitValue){

    int RandomWord = randGen.nextInt(WordList.length);

    String CorrectWord = WordList[RandomWord];

    int RandomN, k = 0, i = 0;

    System.out.print("Word = " + CorrectWord);

    char [] JumbledWord = new char [CorrectWord.length()];
    boolean [] check = new boolean [CorrectWord.length()];

    while( i < CorrectWord.length() ) {

      RandomN = randGen.nextInt(CorrectWord.length());

      if ( !(check[RandomN % CorrectWord.length()]) ) {

        JumbledWord[RandomN % CorrectWord.length()] = CorrectWord.charAt(i);
        //System.out.println(JumbledWord[i]);
        check[RandomN % CorrectWord.length()] = true;
        i++;

      }

      if ( i == CorrectWord.length() ){

        for(int j = 0; j < CorrectWord.length(); j++){

          if( JumbledWord[j] == CorrectWord.charAt(j) )
            k++;
        }

      }

      if ( k == CorrectWord.length() ) {

          i = 0;

          for(int j = 0; j < CorrectWord.length(); j++){
            check[j] = false;
          }

        }

    }

    System.out.println();

    int NPoints = 10;
    String guess = "a";
    boolean InnerExitValue = true;

    while(InnerExitValue){

      System.out.print("Current puzzle: ");

      for (i = 0; i < CorrectWord.length(); i++)
        System.out.print(JumbledWord[i]);

        System.out.println("\nCurrent points for word: " + NPoints);
        System.out.print("Enter (g)uess, (n)ew word, (h)int, or (q)uit: ");
        char option = keyboard.next().toLowerCase().charAt(0);

        switch (option) {

          case 'q':
            InnerExitValue = false;
            OuterExitValue = false;
            System.out.println("\nThanks for Playing! Goodbye!");
            System.out.println("Final score: " + totalScore);
            System.exit(0);
            break;

          case 'h':
            int RandomLetter = randGen.nextInt(CorrectWord.length());
            int RandomSpot = RandomLetter + 1;
            System.out.println("\nThe letter at spot " + RandomSpot + " is " + CorrectWord.charAt(RandomLetter) + "\n" );
            NPoints = NPoints/2;
            break;

          case 'g':

            System.out.print("\nEnter your guess: ");
            guess = keyboard.next();

            if ( !(guess.equalsIgnoreCase(CorrectWord)) ) {
              NPoints -= 1;
              System.out.println("Sorry, try again.\n");
            }
            else{
              totalScore += NPoints;
              System.out.println("Congratulations! You guessed it!");
              System.out.println("Score for word: " + NPoints);
              System.out.println("Total score: " + totalScore);
              System.out.println();
              InnerExitValue = false;
            }
            break;

          case 'n':
            InnerExitValue = false;
            System.out.println();
            break;

          default:
            System.out.println("Invalid Choice - 'g', 'n' 'h' or 'q' only.\n");
        }

        if(NPoints == 0){
          System.out.println("Word points = 0. Generating a new word");
          InnerExitValue = false;
        }

      }

    }

}
}

I tried some things out with my code. I used traces to find out where my code was getting stuck in an infinite loop, and it turns out that the infinite loop is always occurring in the first while loop that has the purpose of jumbling a word and checking that it's jumbled properly. I added this trace at the bottom of the first while loop, right before the bracket, where I just inputted:

for(int m = 0; m < CorrectWord.length(); m++)
          System.out.print(JumbledWord[m]);

This trace allowed me to see what jumbled word is being seen by the computer before it becomes a properly jumbled word that the user can deal with. This allowed me to see this:

Program output with trace in code

If you look carefully, you can see that every 'current puzzle' is just the last four or five sequence of characters in that jumbled mess of letters. Presumably, this means the last sequence is being grabbed by the computer to become the 'current puzzle', which is in line with the logic inside my program, so that's a good sign that the program is working as intended. So what about using this trace to find what an infinite loop will look like?

Here is another screenshot:

Program output with trace showing infinite loop

In the above image, we see the program jumbling the word, but for some reason, the w character becomes more, and more frequently printed to the screen compared to all the other ones, and then it just keeps being printed to the screen indefinitely. But that is not something I expect to see given my code. I suspect there is a teeny tiny error in the algorithm that I concocted. It seems that the program occasionally jumbles words in a way that leaves out essential letters that need to be in that sequence of characters in order for the word to be correctly jumbled. We can see the same phenomena with this other screenshot:

Program output with trace showing infinite loop 2

In both pictures, one letter is being oddly left out with the first couple of 'jumbles.' For the last picture, it is 'd' and for the second to last picture, it is 'k'. This may be a hint that with my algorithm, I am not actually 'jumbling' letters, instead I am copying and pasting letters into certain indexes, inevitably resulting in odd cases where at least one letter is just 'pasted' over or overwritten by other letters, never appearing again. I am not sure that this decisively solves the issue for me, though.


问:
API call timeout using spring web client vs reactor.netty HttpClient
I'm trying to setup timeout on an API call, if response take more than specified time then I need to throw a timeout exception. I'm using spring webclient to make these API calls.
I found two ways to implement it but not able to understand what is the major differences between both the implementations and which one is good in performance, could anyone help me with this ?

Approach 1:

```<code>webClient.get()
        .uri("/someUri")
        .retrieve()
        .bodyToFlux(Foo.class)
        .timeout(Duration.ofMillis(10_000));
</code>```

Approach 2:

```<code>HttpClient httpClient = HttpClient.create()
                .tcpConfiguration(client ->
                        client.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)
                        .doOnConnected(c -> c
                                .addHandlerLast(new ReadTimeoutHandler(70))
                                .addHandlerLast(new WriteTimeoutHandler(80)))
                        .responseTimeout(Duration.ofMillis(100));

        ClientHttpConnector conn = new ReactorClientHttpConnector(httpClient.wiretap(true));

        return WebClient.builder()
                .baseUrl("http://localhost:8080")
                .clientConnector(conn)
                .build();
</code>```

Also, could anyone clairfy in approach 2, why we need a "ReadTimeoutHandler" when we have "responeTimeout" ?

Thank you in advance.

I tried both approches but not able to get which approach is idle.

Body:
I'm trying to setup timeout on an API call, if response take more than specified time then I need to throw a timeout exception. I'm using spring webclient to make these API calls.
I found two ways to implement it but not able to understand what is the major differences between both the implementations and which one is good in performance, could anyone help me with this ?

Approach 1:

webClient.get()
        .uri("/someUri")
        .retrieve()
        .bodyToFlux(Foo.class)
        .timeout(Duration.ofMillis(10_000));

Approach 2:

HttpClient httpClient = HttpClient.create()
                .tcpConfiguration(client ->
                        client.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10000)
                        .doOnConnected(c -> c
                                .addHandlerLast(new ReadTimeoutHandler(70))
                                .addHandlerLast(new WriteTimeoutHandler(80)))
                        .responseTimeout(Duration.ofMillis(100));

        ClientHttpConnector conn = new ReactorClientHttpConnector(httpClient.wiretap(true));

        return WebClient.builder()
                .baseUrl("http://localhost:8080")
                .clientConnector(conn)
                .build();

Also, could anyone clairfy in approach 2, why we need a "ReadTimeoutHandler" when we have "responeTimeout" ?

Thank you in advance.

I tried both approches but not able to get which approach is idle.


问:
Convolutional Neural Network starts training with a very high accuracy, and decreases with each epoch
My code:

```<code>model.add(layers.Conv2D(32, kernel_size=3, padding='same', activation='relu', input_shape=(64, 64, 1)))
model.add(layers.MaxPooling2D(pool_size=2))
model.add(layers.Conv2D(24, kernel_size=3, padding='same', activation='relu'))
model.add(layers.MaxPooling2D(pool_size=2))
model.add(layers.Conv2D(16, kernel_size=3, padding='same', activation='relu'))
model.add(layers.Flatten())
model.add(layers.Dense(144, activation='relu'))
model.add(layers.Dense(3, activation='sigmoid'))
</code>```
```<code>model.compile(optimizer='sgd',
              loss = tf.keras.losses.BinaryCrossentropy(),
              metrics=['accuracy'])

history = model.fit(train_images, train_labels, epochs=50,
                    validation_data=(val_images, val_labels))
</code>```

The library I used is Tensorflow/Keras.

The training process is acting very weird. The first epoch starts with an accuracy of over 90%, and with each epoch, it decreases up to 50% by the end of 50 epochs. Sometimes it goes back up to 70% at random times. Those are the accuracies on validation and train data. However on test data, the result is 0%.

The problem is a multi-label classification one. There are 3 labels, 2 classes each (0 and 1).

In case you want to test the code and reproduce the problem, here is the link to the dataset:

https://drive.google.com/drive/folders/1jC7aYmMJdM55-DMwZkNEwhr-_A3uxO9-?usp=sharing

Body:
My code:

model.add(layers.Conv2D(32, kernel_size=3, padding='same', activation='relu', input_shape=(64, 64, 1)))
model.add(layers.MaxPooling2D(pool_size=2))
model.add(layers.Conv2D(24, kernel_size=3, padding='same', activation='relu'))
model.add(layers.MaxPooling2D(pool_size=2))
model.add(layers.Conv2D(16, kernel_size=3, padding='same', activation='relu'))
model.add(layers.Flatten())
model.add(layers.Dense(144, activation='relu'))
model.add(layers.Dense(3, activation='sigmoid'))

model.compile(optimizer='sgd',
              loss = tf.keras.losses.BinaryCrossentropy(),
              metrics=['accuracy'])

history = model.fit(train_images, train_labels, epochs=50,
                    validation_data=(val_images, val_labels))

The library I used is Tensorflow/Keras.

The training process is acting very weird. The first epoch starts with an accuracy of over 90%, and with each epoch, it decreases up to 50% by the end of 50 epochs. Sometimes it goes back up to 70% at random times. Those are the accuracies on validation and train data. However on test data, the result is 0%.

The problem is a multi-label classification one. There are 3 labels, 2 classes each (0 and 1).

In case you want to test the code and reproduce the problem, here is the link to the dataset:

https://drive.google.com/drive/folders/1jC7aYmMJdM55-DMwZkNEwhr-_A3uxO9-?usp=sharing


问:
Why is CMake throwing an error for an unknown target library?
I'm currently attempting to build a project via CMake, but am getting and error during the CXX compiler ABI info step that I don't quite understand.

```<code>PS C:\Sandbox\Project1\build> cmake -G "NMake Makefiles" ../
-- The CXX compiler identification is MSVC 19.29.30137.0
-- Detecting CXX compiler ABI info
CMake Error at C:/Sandbox/Project1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:19 (target_link_libraries):
  Cannot specify link libraries for target "cmTC_f5772" which is not built by
  this project.

CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCompilerABI.cmake:49 (try_compile):
  Failed to configure test project build system.
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
  CMakeLists.txt:6 (project)

-- Configuring incomplete, errors occurred!
See also "C:/Sandbox/Project1/build/CMakeFiles/CMakeOutput.log".
</code>```

Taking a look at some of the errors:

```<code>CMake Error at C:/Sandbox/Project1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:19 (target_link_libraries):
  Cannot specify link libraries for target "cmTC_f5772" which is not built by
  this project.
</code>```

The referenced file doesn't exist, and the "cmTC_f5772" package does not exist nor am I trying to find it in my CMake file.

Does anything stand out as adherently incorrect?

Some extra information:

I can't provide the original CMakeList.txt file because of proprietary information.

This same project builds on another Windows 10 Virtual Machine without issue. Not sure why this one fails.

Body:
I'm currently attempting to build a project via CMake, but am getting and error during the CXX compiler ABI info step that I don't quite understand.

PS C:\Sandbox\Project1\build> cmake -G "NMake Makefiles" ../
-- The CXX compiler identification is MSVC 19.29.30137.0
-- Detecting CXX compiler ABI info
CMake Error at C:/Sandbox/Project1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:19 (target_link_libraries):
  Cannot specify link libraries for target "cmTC_f5772" which is not built by
  this project.

CMake Error at C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeDetermineCompilerABI.cmake:49 (try_compile):
  Failed to configure test project build system.
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.22/Modules/CMakeTestCXXCompiler.cmake:26 (CMAKE_DETERMINE_COMPILER_ABI)
  CMakeLists.txt:6 (project)

-- Configuring incomplete, errors occurred!
See also "C:/Sandbox/Project1/build/CMakeFiles/CMakeOutput.log".

Taking a look at some of the errors:

CMake Error at C:/Sandbox/Project1/build/CMakeFiles/CMakeTmp/CMakeLists.txt:19 (target_link_libraries):
  Cannot specify link libraries for target "cmTC_f5772" which is not built by
  this project.

The referenced file doesn't exist, and the "cmTC_f5772" package does not exist nor am I trying to find it in my CMake file.

Does anything stand out as adherently incorrect?

Some extra information:

I can't provide the original CMakeList.txt file because of proprietary information.

This same project builds on another Windows 10 Virtual Machine without issue. Not sure why this one fails.


问:
Fix all list re-rendering when only one component is changed
I need to prevent rerendering, I know the problem in the line where I pass props onClick in the Todo component, but I don't know how to fix it.

```<code>const Todo = memo(({ text, done, onClick }: TodoProps) => {
  const ref = useRenderHighlight(css.render);
  return (
    <li ref={ref} onClick={onClick} className={css.listItem}>
      {done ? '[x]' : '[ ]'} {text}
    </li>
  );
});

export const Optimize1 = () => {
  const [todos, setTodos] = useState(todosData);

  const handleTodoClick = useCallback(
    (id: number) => {
      setTodos(todos.map((todo) => (todo.id === id ? { ...todo, done: !todo.done } : todo)));
    },
    [todos],
  );

  return (
    <CenteredLayout className="gap-4">
      <div className="text-3xl">It re-renders all items! =\</div>
      <div>We need to fix that</div>
      <ul>
        {todos.map((item) => (
          <Todo
            key={item.id}
            text={item.text}
            done={item.done}
            onClick={() => handleTodoClick(item.id)} ////This line do rerender all list
          />
        ))}
      </ul>
    </CenteredLayout>
  );
};
</code>```

I'm tried pass onClick={ handleTodoClick}, and then  in children pass the request, but it still doesn't work

Body:
I need to prevent rerendering, I know the problem in the line where I pass props onClick in the Todo component, but I don't know how to fix it.

const Todo = memo(({ text, done, onClick }: TodoProps) => {
  const ref = useRenderHighlight(css.render);
  return (

      {done ? '[x]' : '[ ]'} {text}

  );
});

export const Optimize1 = () => {
  const [todos, setTodos] = useState(todosData);

  const handleTodoClick = useCallback(
    (id: number) => {
      setTodos(todos.map((todo) => (todo.id === id ? { ...todo, done: !todo.done } : todo)));
    },
    [todos],
  );

  return (
    <CenteredLayout className="gap-4">

It re-renders all items! =\

We need to fix that

        {todos.map((item) => (
          <Todo
            key={item.id}
            text={item.text}
            done={item.done}
            onClick={() => handleTodoClick(item.id)} ////This line do rerender all list
          />
        ))}

    </CenteredLayout>
  );
};

I'm tried pass onClick={ handleTodoClick}, and then  in children pass the request, but it still doesn't work


问:
PCI device I/O ports work under Windows but not under Linux
[Edited]

I am trying to access an I/O port of a PCI device under Linux x86_64, however

inl() only ever reads 0xFFFFFFFF

outl() does not effect the hardware

It works under Windows (XP x86) as long as any driver (I tested with a completely empty one) is loaded for that device.

The I/O port range is different under the OSes and seems to be auto-configured by PCI bus driver.

No amount of enabling/disabling/installing/configuring other devices, buses or BIOS settings changes the port range that is assigned to the device by either OS.

The linux driver does only the following:

From my kernel module init() function:

pci_register_driver() specifying relevant PCI vendor/device IDs

From my pci_probe() handler function:

pci_enable_device()

pci_resource_*() which return same PCI BAR data as lspci

pci_request_regions()

inl() / outl()

From my kernel module exit() function

pci_unregister_driver()

Here is the code:

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/uaccess.h>

static void pci_release(struct pci_dev* pcidev)
{
    pci_release_regions(pcidev);
    pci_disable_device(pcidev);
    pr_err("pci_disable_device");
    return;
}

static int pci_probe(struct pci_dev* pcidev, const struct pci_device_id* pcidev_id)
{
    long result;

    result = pci_enable_device(pcidev);
    pr_err("pci_enable_device()=%ld", result);

    pr_err("res0=0x%lX", (ulong)pci_resource_flags(pcidev, 0));
    pr_err("start=0x%lX", (ulong)pci_resource_start(pcidev, 0));
    pr_err("end=0x%lX", (ulong)pci_resource_end(pcidev, 0));

    result = pci_request_regions(pcidev, "iotest");
    pr_err("pci_request_regions()=%ld", result);

    result = inl(pci_resource_start(pcidev, 0));
    pr_err("inl()=%lX", result);

    return 0;
}

static struct pci_device_id pci_ids[] =
{
    { PCI_DEVICE(0x4321, 0x9876), },
    { 0, }
};
MODULE_DEVICE_TABLE(pci, pci_ids);

static struct pci_driver pcidriver =
{
    .probe = pci_probe,
    .remove = pci_release,
    .id_table = pci_ids,
    .name = "iotest"
};

static int __init kmodule_init(void)
{
    pr_err("init");
    return pci_register_driver(&pcidriver);
}

static void __exit kmodule_exit(void)
{
    pr_err("exit");
    pci_unregister_driver(&pcidriver);
}

module_init(kmodule_init);
module_exit(kmodule_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("iotest");
MODULE_DESCRIPTION("iotest");
MODULE_VERSION("1.0");
```
<p>My <code>pci_probe()</code> function is called, no errors are returned, but I/O behaves as if ports are not truly allocated.</p>
```[ 8809.201100] init
[ 8809.203209] pci_enable_device()=0
[ 8809.205237] res0=0x40101
[ 8809.206911] start=0xEF00
[ 8809.208574] end=0xEF3F
[ 8809.210230] pci_request_regions()=0
[ 8809.211868] inl()=FFFFFFFF
[ 8820.426361] exit
```
<p>The I/O ports are reported to be the same as in <code>lspci -n -vv</code> output:</p>
```03:0e.0 1100: 4321:9876
    Subsystem: 4321:9876
    Control: I/O+ Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
    Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
    Interrupt: pin A routed to IRQ 22
    Region 0: I/O ports at ef00 [size=64]
```
<p>relevant section of <code>/proc/ioports</code>:</p>
```0d00-ffff : PCI Bus 0000:00
  e000-efff : PCI Bus 0000:02
    e000-efff : PCI Bus 0000:03
      ef00-ef3f : 0000:03:0e.0
        ef00-ef3f : iotest
```

Does anyone have any ideas why can this be happening? Am I missing something?

Body:
[Edited]

I am trying to access an I/O port of a PCI device under Linux x86_64, however

inl() only ever reads 0xFFFFFFFF

outl() does not effect the hardware

It works under Windows (XP x86) as long as any driver (I tested with a completely empty one) is loaded for that device.

The I/O port range is different under the OSes and seems to be auto-configured by PCI bus driver.

No amount of enabling/disabling/installing/configuring other devices, buses or BIOS settings changes the port range that is assigned to the device by either OS.

The linux driver does only the following:

From my kernel module init() function:

pci_register_driver() specifying relevant PCI vendor/device IDs

From my pci_probe() handler function:

pci_enable_device()

pci_resource_*() which return same PCI BAR data as lspci

pci_request_regions()

inl() / outl()

From my kernel module exit() function

pci_unregister_driver()

Here is the code:

#include <linux/types.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/uaccess.h>

static void pci_release(struct pci_dev* pcidev)
{
    pci_release_regions(pcidev);
    pci_disable_device(pcidev);
    pr_err("pci_disable_device");
    return;
}

static int pci_probe(struct pci_dev* pcidev, const struct pci_device_id* pcidev_id)
{
    long result;

    result = pci_enable_device(pcidev);
    pr_err("pci_enable_device()=%ld", result);

    pr_err("res0=0x%lX", (ulong)pci_resource_flags(pcidev, 0));
    pr_err("start=0x%lX", (ulong)pci_resource_start(pcidev, 0));
    pr_err("end=0x%lX", (ulong)pci_resource_end(pcidev, 0));

    result = pci_request_regions(pcidev, "iotest");
    pr_err("pci_request_regions()=%ld", result);

    result = inl(pci_resource_start(pcidev, 0));
    pr_err("inl()=%lX", result);

    return 0;
}

static struct pci_device_id pci_ids[] =
{
    { PCI_DEVICE(0x4321, 0x9876), },
    { 0, }
};
MODULE_DEVICE_TABLE(pci, pci_ids);

static struct pci_driver pcidriver =
{
    .probe = pci_probe,
    .remove = pci_release,
    .id_table = pci_ids,
    .name = "iotest"
};

static int __init kmodule_init(void)
{
    pr_err("init");
    return pci_register_driver(&pcidriver);
}

static void __exit kmodule_exit(void)
{
    pr_err("exit");
    pci_unregister_driver(&pcidriver);
}

module_init(kmodule_init);
module_exit(kmodule_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("iotest");
MODULE_DESCRIPTION("iotest");
MODULE_VERSION("1.0");

My pci_probe() function is called, no errors are returned, but I/O behaves as if ports are not truly allocated.

[ 8809.201100] init
[ 8809.203209] pci_enable_device()=0
[ 8809.205237] res0=0x40101
[ 8809.206911] start=0xEF00
[ 8809.208574] end=0xEF3F
[ 8809.210230] pci_request_regions()=0
[ 8809.211868] inl()=FFFFFFFF
[ 8820.426361] exit

The I/O ports are reported to be the same as in lspci -n -vv output:

03:0e.0 1100: 4321:9876
    Subsystem: 4321:9876
    Control: I/O+ Mem- BusMaster- SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
    Status: Cap- 66MHz- UDF- FastB2B+ ParErr- DEVSEL=fast >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
    Interrupt: pin A routed to IRQ 22
    Region 0: I/O ports at ef00 [size=64]

relevant section of /proc/ioports:

0d00-ffff : PCI Bus 0000:00
  e000-efff : PCI Bus 0000:02
    e000-efff : PCI Bus 0000:03
      ef00-ef3f : 0000:03:0e.0
        ef00-ef3f : iotest

Does anyone have any ideas why can this be happening? Am I missing something?


问:
How to display an image on a cell after a user has clicked on the cell on UICollectionView?
I have a UICollectionView which loads images from an api for users to rate, which works perfectly well. My problem is I want a way to show the user the selected the cell with an emoji based on their rating type (Good, bad etc). Clicking on a cell shows a modal which the user will rate, I have been able to pass data from the modal to the main collection view. Now I want to be able to use the data from the modal to display an emoji on the cell to allow the user to see what they chose

```<code>//my protocol delegate for the modal
    protocol ModalDelegate {
    func changeValue(userChoice: String, rateMovieID: String, rateImageUrl: String)
}

    //Main class conforming to modalDelegate

class GuestRateMovieView: UIViewController, ModalDelegate {
    func changeValue(userChoice: String, rateMovieID: String, rateImageUrl: String) {
        self.userChoice = userChoice
        print("choice =>", userChoice, "id =>", rateMovieID, "url =>", rateImageUrl)
    }
}

    //My custom cell

class MoviesCollectionCell: UICollectionViewCell {
    private var movieImages = NSCache<NSString, NSData>()
    weak var textLabel: UILabel!
    let movieImage: UIImageView = {
        let image = UIImageView()
        image.translatesAutoresizingMaskIntoConstraints = false
        image.clipsToBounds = true
        image.contentMode = .scaleAspectFill
        image.layer.cornerRadius = 10
        return image
    }()

    let btnRate: UIImageView = {
        let image = UIImageView()
        image.translatesAutoresizingMaskIntoConstraints = false

        image.clipsToBounds = true
        image.contentMode = .scaleAspectFit
        image.alpha = 0
        return image
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)

        contentView.addSubview(movieImage)
        movieImage.addSubview(btnRate)
    }

    override func prepareForReuse() {
        super.prepareForReuse()
        movieImage.image = nil
    }

    func configure(with urlString: String){
        //check for cached image
        if let imageData = movieImages.object(forKey: urlString as NSString){
//            print("using cache image")
            DispatchQueue.main.async {
                let image = UIImage(data: imageData as Data)
                self.movieImage.image = image
            }
        }else{
            guard let url = URL(string: urlString) else{
                return
            }
            //Downloading images
            URLSession.shared.dataTask(with: url) {[weak self] data, _, error in
                guard let data = data, error == nil else {
                    return
                }
                DispatchQueue.main.async{
                    self?.movieImages.setObject(data as NSData, forKey: url.absoluteString as NSString)
                    let image = UIImage(data: data)
                    self?.movieImage.image = image
                }
            }.resume()
        }

    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        NSLayoutConstraint.activate([
            movieImage.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 10),
            movieImage.topAnchor.constraint(equalTo: contentView.topAnchor),
            movieImage.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -10),
            movieImage.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),

            btnRate.centerXAnchor.constraint(equalTo: movieImage.centerXAnchor),
            btnRate.centerYAnchor.constraint(equalTo: movieImage.centerYAnchor),
            btnRate.widthAnchor.constraint(equalToConstant: 30),
            btnRate.heightAnchor.constraint(equalToConstant: 30)
        ])
    }

}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reUseMoviesCellID, for: indexPath) as! MoviesCollectionCell
        var movieTitle = [String]()
        for obj in moviesArray {
            if let movieObj = obj as? NSDictionary {
                   let packShotObj = movieObj.value(forKey: "packShot") as! NSDictionary?
                   let id = movieObj.value(forKey: "id") as! String?
                   let title = movieObj.value(forKey: "title") as! String?
                   if let packShots = packShotObj{
                        let thumbs = packShots.value(forKey: "thumbnail") as! String?
                        if let thumbnails = thumbs{
                            movieThumbnails.append(thumbnails)
                            movieTitle.append(title ?? "")
                        }
                    }
            }
        }
        let imageUrl = movieThumbnails[indexPath.row]
        cell.movieImage.image = nil
        cell.configure(with: imageUrl)
        if userChoice == "Hate it" {
            cell.btnRate.image = UIImage(named: "HateIt")
            moviesCollectionView.reloadData()
        }

        return cell
    }
</code>```

A short demonstration on what I want to achieve.
https://www.seasfarm.com/collections.mp4

Body:
I have a UICollectionView which loads images from an api for users to rate, which works perfectly well. My problem is I want a way to show the user the selected the cell with an emoji based on their rating type (Good, bad etc). Clicking on a cell shows a modal which the user will rate, I have been able to pass data from the modal to the main collection view. Now I want to be able to use the data from the modal to display an emoji on the cell to allow the user to see what they chose

//my protocol delegate for the modal
    protocol ModalDelegate {
    func changeValue(userChoice: String, rateMovieID: String, rateImageUrl: String)
}

    //Main class conforming to modalDelegate

class GuestRateMovieView: UIViewController, ModalDelegate {
    func changeValue(userChoice: String, rateMovieID: String, rateImageUrl: String) {
        self.userChoice = userChoice
        print("choice =>", userChoice, "id =>", rateMovieID, "url =>", rateImageUrl)
    }
}

    //My custom cell

class MoviesCollectionCell: UICollectionViewCell {
    private var movieImages = NSCache<NSString, NSData>()
    weak var textLabel: UILabel!
    let movieImage: UIImageView = {
        let image = UIImageView()
        image.translatesAutoresizingMaskIntoConstraints = false
        image.clipsToBounds = true
        image.contentMode = .scaleAspectFill
        image.layer.cornerRadius = 10
        return image
    }()

    let btnRate: UIImageView = {
        let image = UIImageView()
        image.translatesAutoresizingMaskIntoConstraints = false

        image.clipsToBounds = true
        image.contentMode = .scaleAspectFit
        image.alpha = 0
        return image
    }()

    override init(frame: CGRect) {
        super.init(frame: frame)

        contentView.addSubview(movieImage)
        movieImage.addSubview(btnRate)
    }

    override func prepareForReuse() {
        super.prepareForReuse()
        movieImage.image = nil
    }

    func configure(with urlString: String){
        //check for cached image
        if let imageData = movieImages.object(forKey: urlString as NSString){
//            print("using cache image")
            DispatchQueue.main.async {
                let image = UIImage(data: imageData as Data)
                self.movieImage.image = image
            }
        }else{
            guard let url = URL(string: urlString) else{
                return
            }
            //Downloading images
            URLSession.shared.dataTask(with: url) {[weak self] data, _, error in
                guard let data = data, error == nil else {
                    return
                }
                DispatchQueue.main.async{
                    self?.movieImages.setObject(data as NSData, forKey: url.absoluteString as NSString)
                    let image = UIImage(data: data)
                    self?.movieImage.image = image
                }
            }.resume()
        }

    }

    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    override func layoutSubviews() {
        super.layoutSubviews()
        NSLayoutConstraint.activate([
            movieImage.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 10),
            movieImage.topAnchor.constraint(equalTo: contentView.topAnchor),
            movieImage.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -10),
            movieImage.bottomAnchor.constraint(equalTo: contentView.bottomAnchor),

            btnRate.centerXAnchor.constraint(equalTo: movieImage.centerXAnchor),
            btnRate.centerYAnchor.constraint(equalTo: movieImage.centerYAnchor),
            btnRate.widthAnchor.constraint(equalToConstant: 30),
            btnRate.heightAnchor.constraint(equalToConstant: 30)
        ])
    }

}

func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reUseMoviesCellID, for: indexPath) as! MoviesCollectionCell
        var movieTitle = [String]()
        for obj in moviesArray {
            if let movieObj = obj as? NSDictionary {
                   let packShotObj = movieObj.value(forKey: "packShot") as! NSDictionary?
                   let id = movieObj.value(forKey: "id") as! String?
                   let title = movieObj.value(forKey: "title") as! String?
                   if let packShots = packShotObj{
                        let thumbs = packShots.value(forKey: "thumbnail") as! String?
                        if let thumbnails = thumbs{
                            movieThumbnails.append(thumbnails)
                            movieTitle.append(title ?? "")
                        }
                    }
            }
        }
        let imageUrl = movieThumbnails[indexPath.row]
        cell.movieImage.image = nil
        cell.configure(with: imageUrl)
        if userChoice == "Hate it" {
            cell.btnRate.image = UIImage(named: "HateIt")
            moviesCollectionView.reloadData()
        }

        return cell
    }

A short demonstration on what I want to achieve.
https://www.seasfarm.com/collections.mp4


问:
How does Chrome display esoteric unicode characters
Here are two cool and esoteric Unicode characters: ⌀ and ⎘. I'm trying to debug why these two characters aren't showing correctly in my ConEmu shell, which instead shows ugly rectangles with a question mark.

What is confusing to me is that when I paste these characters in Chrome, they show perfectly. I initially considered that maybe Chrome is using a better font than ConEmu which has more characters, but even when I set Chrome to use the same Consolas font as ConEmu, it shows the symbols correctly. In my anger, I even had Chrome render a sentence containing these symbols using the "Comic Sans MS" font, only to see that Chrome cheerfully continues to succeed in rendering these symbols.

What is Chrome's trick for rendering symbols correctly when the fonts don't define glyphs for them? Does it have some kind of fallback font that it uses? I'm hoping that whatever trick this is, I could use it in ConEmu as well.


问:
How do I fix a Capacitor Community Admob banner not pushing footer content?
I'm using the Capacitor Admob Comunity plugin to put a banner on my app.

It runs smoothly, but the banner doesn't work like I thought it would.
It should push the webview up. And it is currently overlaying the content in the footer.

Anyone knows how to fix it?

This is my bannerOptions

```<code>private _bannerOptions: BannerAdOptions = {
    adId: BANNER_ADID,
    adSize: BannerAdSize.BANNER,
    position: BannerAdPosition.BOTTOM_CENTER,
    margin: 0,
    isTesting: false
}
</code>```

Body:
I'm using the Capacitor Admob Comunity plugin to put a banner on my app.

It runs smoothly, but the banner doesn't work like I thought it would.
It should push the webview up. And it is currently overlaying the content in the footer.

Anyone knows how to fix it?

This is my bannerOptions

private _bannerOptions: BannerAdOptions = {
    adId: BANNER_ADID,
    adSize: BannerAdSize.BANNER,
    position: BannerAdPosition.BOTTOM_CENTER,
    margin: 0,
    isTesting: false
}


问:
Is there a way to fit an image into an irregular shape using css
On the home page of my website, I want to my image to fill 100% of the screen width and only 95% of the height. Along the bottom edge of the image I also want to fill in a small circle with the image. I've attached an image of what I hope my end result will look like, as well as my current code.

So far I've figured out how to scale the image to 100% width and 95% height, but I'm stuck here.


问:
Website jumps around when virtual keyboard is up
I have a login page. ( used in full screen mode like a PWA. Added to home screen )

When the user clicks on one of the input boxes the virtual keyboard pops up.
When the user finishes typing the username he either wants to click away from the box to be able to click to the login button or wants to click to the password input box. When the user clicks away the virtual keyboard hides but bring the page with itself to the bottom. And if the user clicks again, the website jumps back to it's normal position.

Here is a gif demonstrating the problem:

Here is a snippet:

var usernameEl = document.querySelector("#username");
var passwordEl = document.querySelector("#password");
var loginBtnEl = document.querySelector(".login-btn");

function pwVisibilityEvent(){
    let pwShowBtn = document.querySelector(".pw-show-btn");
    pwShowBtn.addEventListener("click",function(e){
        pwShowBtn.classList.toggle("visible");
        if( pwShowBtn.classList.contains("visible") ){
            passwordEl.setAttribute("type","text");
        }else{
            passwordEl.setAttribute("type","password");
        }
    },false);
}
pwVisibilityEvent();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>*{
    box-sizing: border-box;

    --light-base-color: #183153;
    --dark-base-color: white;
    --hitec-base-color: #34bdeb;

    --bg-color: #f8f7f5;
    --dark-bg-color: #222222;

    --header-bg-color: #34bdeb;
    --dark-header-bg-color: #087195;

    --pw-show-bg-color: #34bdeb;
    --dark-pw-show-bg-color: #087195;

    --input-color: dimgray;
    --dark-input-color: #34bdeb;

    --input-placeholder-color: #69696996;
    --dark-input-placeholder-color: #34bdebc0;

    --login-btn-bg-color: #34bdeb;
    --dark-login-btn-bg-color: #087195;
}

body {
    position: relative;
    width: 100%;
    padding: 0px;
    margin: 0px;
    height: 100vh;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 35px;
}

html{
    background-color: var(--bg-color);
}

html.dark-theme {
    background-color: var(--dark-bg-color);
}

.header {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

span.header-text {
    font-size: 1.5em;
    color: var(--header-bg-color);
}

html.dark-theme span.header-text {
    color: var(--dark-header-bg-color);
}

.logo-wrapper {
    width: 100px;
    height: 100px;
    border-radius: 0.5em;
    overflow: hidden;
    box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
}

.logo-wrapper img{
    width: 100%;
    height: 100%;
}

form.login {
    width: 80%;
    max-width: 500px;
}

span.made-by-wrap {
    position: absolute;
    bottom: 5px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    font-weight: bold;
}

button.pw-show-btn {
    width: 55px;
    height: 30px;
    border: none;
    transition: color 0.2s ease;
    background-color: var(--pw-show-bg-color);
    color: white;
    border-radius: 0.3em;
    cursor: pointer;
}

html.dark-theme button.pw-show-btn {
    background-color: var(--dark-pw-show-bg-color);
}

button.pw-show-btn.visible{
    background-color: orangered;
}

button.pw-show-btn svg{
    width: 100%;
    height: 100%;
}

button.pw-show-btn span {
    width: 100%;
    height: 100%;
}

button.pw-show-btn .pw-locked{
    display: block;
}
button.pw-show-btn .pw-unlocked{
    display: none;
}

button.pw-show-btn.visible .pw-locked{
    display: none;
}
button.pw-show-btn.visible .pw-unlocked{
    display: block;
}

input {
    padding: 10px;
    font-size: 1em;
    border: none;
    background-color: white;
    border-radius: 0.5em;
    box-shadow: rgb(0 0 0 / 5%) 1.95px 1.95px 2.6px;
    width: 100%;
    color: var(--input-color);
    transition: box-shadow 0.2s ease;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    transition: background-color 5000s ease-in-out 0s;
    -webkit-text-fill-color: #34bdeb !important;
    opacity:1;
}

input:focus-visible{
    border: none;
    outline: none;
    box-shadow: rgba(0, 0, 0, 0.315) 1.95px 1.95px 2.6px;
}

input::placeholder{
    color: var(--input-placeholder-color);
    font-size: 0.9em;
}

html.dark-theme input {
    background-color: #222222;
    box-shadow: rgb(0 0 0 / 78%) 0px 1px 2.6px;
    color: var(--dark-input-color);
}

html.dark-theme input::placeholder{
    color: var(--dark-input-placeholder-color);
}

.fields {
    width: 100%;
    margin: 40px 0px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pw-field {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.form-field {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

span.error-label {
    padding-left: 10px;
    font-size: 0.95em;
    color: orangered;
}

button.login-btn {
    cursor: pointer;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    padding: 10px;
    border-radius: 0.5em;
    background-color: var(--login-btn-bg-color);
    font-size: 1.1em;
    color: white;
    transition: background-color 0.2s ease;
    box-shadow: rgb(0 0 0 / 5%) 1.95px 1.95px 2.6px;
}

html.dark-theme button.login-btn {
    box-shadow: rgb(0 0 0 / 72%) 1.95px 1.95px 2.6px;
    background-color: var(--dark-login-btn-bg-color);
}

button.login-btn.error{
    animation: shakeOnErr .1s ease;
    background-color: #be0000 !important;
}

@keyframes shakeOnErr{
    0%{
        transform: translate(-10px);
    }
    50%{
        transform: translate(10px);
    }
    100%{
        transform: translate(0px);
    }
}

span.made-by {
    color: #df609f;
}

.made-by-link {
    color: #34bdeb;
    padding: 5px;
    transition: font-size 0.2s ease;
}

.made-by-link:hover{
    font-size: larger;
}</code>```

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>HsH Login</title>

    <link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png">
    <link rel="manifest" href="/assets/hsh.webmanifest">
    <link rel="mask-icon" href="/assets/icons/safari-pinned-tab.svg" color="#5bbad5">
    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="theme-color" content="#ffffff">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">

    <link rel="stylesheet" href="/pages/login/css/style.css">

    <form action="" class="login">

            Test

                <input type="text" lang="Username" name="username" class="username" id="username" placeholder="Username">

                    <input type="password" lang="Password" name="password" class="password" id="password" placeholder="Password">
                    <button class="pw-show-btn" type="button">

                            <svg viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                                <path d="M9.76406 5.29519C10.4664 5.10724 11.2123 5 12 5C18.3636 5 22 12 22 12C22 12 21.171 13.5958 19.612 15.2635M4.34912 8.77822C2.8152 10.4307 2 12 2 12C2 12 5.63636 19 12 19C12.8021 19 13.5608 18.8888 14.2744 18.6944M11.5 14.9585C10.4158 14.7766 9.52883 14.0132 9.17071 13M12.5 9.04148C13.7563 9.25224 14.7478 10.2437 14.9585 11.5M3 3L21 21" stroke="#001A72" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
                            </svg>

                            <svg version="1.1" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 512 512">
                                <g><g>
                                    <path d="m499.4,250.8c-51-86.3-143.6-140.4-243.4-140.4s-192.5,54.1-243.4,140.4c-2.1,3.1-2.1,7.3 5.32907e-15,10.4 51,86.3 143.6,140.4 243.4,140.4s192.5-54.1 243.4-140.4c2.1-3.1 2.1-7.3 0-10.4zm-243.4,130c-90.5,0-174.8-47.8-221.6-124.8 46.8-77 131.1-124.8 221.6-124.8s174.8,47.8 221.6,124.8c-46.8,77-131.1,124.8-221.6,124.8z"/>
                                    <path d="m256,162.4c-52,0-93.6,41.6-93.6,93.6 0,52 41.6,93.6 93.6,93.6s93.6-41.6 93.6-93.6c0-52-41.6-93.6-93.6-93.6zm0,166.4c-40.6,0-72.8-32.3-72.8-72.8s32.3-72.8 72.8-72.8 72.8,32.3 72.8,72.8-32.2,72.8-72.8,72.8z"/>
                                    <path d="m256,214.4v20.8c11.4,0 20.8,9.4 20.8,20.8s-9.4,20.8-20.8,20.8-20.8-9.4-20.8-20.8h-20.8c0,22.9 18.7,41.6 41.6,41.6 22.9,0 41.6-18.7 41.6-41.6s-18.7-41.6-41.6-41.6z"/>
                                </g></g>
                            </svg>

                    </button>

            <button type="submit" class="login-btn" lang="Login">Login</button>

    </form>

        test.hu

```

I have the same problem on other pages, where this exact same problem occours on any input field on mobile.

Body:
I have a login page. ( used in full screen mode like a PWA. Added to home screen )

When the user clicks on one of the input boxes the virtual keyboard pops up.
When the user finishes typing the username he either wants to click away from the box to be able to click to the login button or wants to click to the password input box. When the user clicks away the virtual keyboard hides but bring the page with itself to the bottom. And if the user clicks again, the website jumps back to it's normal position.

Here is a gif demonstrating the problem:

Here is a snippet:

var usernameEl = document.querySelector("#username");
var passwordEl = document.querySelector("#password");
var loginBtnEl = document.querySelector(".login-btn");

function pwVisibilityEvent(){
    let pwShowBtn = document.querySelector(".pw-show-btn");
    pwShowBtn.addEventListener("click",function(e){
        pwShowBtn.classList.toggle("visible");
        if( pwShowBtn.classList.contains("visible") ){
            passwordEl.setAttribute("type","text");
        }else{
            passwordEl.setAttribute("type","password");
        }
    },false);
}
pwVisibilityEvent();

*{
    box-sizing: border-box;

    --light-base-color: #183153;
    --dark-base-color: white;
    --hitec-base-color: #34bdeb;

    --bg-color: #f8f7f5;
    --dark-bg-color: #222222;

    --header-bg-color: #34bdeb;
    --dark-header-bg-color: #087195;

    --pw-show-bg-color: #34bdeb;
    --dark-pw-show-bg-color: #087195;

    --input-color: dimgray;
    --dark-input-color: #34bdeb;

    --input-placeholder-color: #69696996;
    --dark-input-placeholder-color: #34bdebc0;

    --login-btn-bg-color: #34bdeb;
    --dark-login-btn-bg-color: #087195;
}

body {
    position: relative;
    width: 100%;
    padding: 0px;
    margin: 0px;
    height: 100vh;

    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 35px;
}

html{
    background-color: var(--bg-color);
}

html.dark-theme {
    background-color: var(--dark-bg-color);
}

.header {
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

span.header-text {
    font-size: 1.5em;
    color: var(--header-bg-color);
}

html.dark-theme span.header-text {
    color: var(--dark-header-bg-color);
}

.logo-wrapper {
    width: 100px;
    height: 100px;
    border-radius: 0.5em;
    overflow: hidden;
    box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 12px;
}

.logo-wrapper img{
    width: 100%;
    height: 100%;
}

form.login {
    width: 80%;
    max-width: 500px;
}

span.made-by-wrap {
    position: absolute;
    bottom: 5px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    font-weight: bold;
}

button.pw-show-btn {
    width: 55px;
    height: 30px;
    border: none;
    transition: color 0.2s ease;
    background-color: var(--pw-show-bg-color);
    color: white;
    border-radius: 0.3em;
    cursor: pointer;
}

html.dark-theme button.pw-show-btn {
    background-color: var(--dark-pw-show-bg-color);
}

button.pw-show-btn.visible{
    background-color: orangered;
}

button.pw-show-btn svg{
    width: 100%;
    height: 100%;
}

button.pw-show-btn span {
    width: 100%;
    height: 100%;
}

button.pw-show-btn .pw-locked{
    display: block;
}
button.pw-show-btn .pw-unlocked{
    display: none;
}

button.pw-show-btn.visible .pw-locked{
    display: none;
}
button.pw-show-btn.visible .pw-unlocked{
    display: block;
}

input {
    padding: 10px;
    font-size: 1em;
    border: none;
    background-color: white;
    border-radius: 0.5em;
    box-shadow: rgb(0 0 0 / 5%) 1.95px 1.95px 2.6px;
    width: 100%;
    color: var(--input-color);
    transition: box-shadow 0.2s ease;
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    transition: background-color 5000s ease-in-out 0s;
    -webkit-text-fill-color: #34bdeb !important;
    opacity:1;
}

input:focus-visible{
    border: none;
    outline: none;
    box-shadow: rgba(0, 0, 0, 0.315) 1.95px 1.95px 2.6px;
}

input::placeholder{
    color: var(--input-placeholder-color);
    font-size: 0.9em;
}

html.dark-theme input {
    background-color: #222222;
    box-shadow: rgb(0 0 0 / 78%) 0px 1px 2.6px;
    color: var(--dark-input-color);
}

html.dark-theme input::placeholder{
    color: var(--dark-input-placeholder-color);
}

.fields {
    width: 100%;
    margin: 40px 0px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pw-field {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.form-field {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

span.error-label {
    padding-left: 10px;
    font-size: 0.95em;
    color: orangered;
}

button.login-btn {
    cursor: pointer;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    padding: 10px;
    border-radius: 0.5em;
    background-color: var(--login-btn-bg-color);
    font-size: 1.1em;
    color: white;
    transition: background-color 0.2s ease;
    box-shadow: rgb(0 0 0 / 5%) 1.95px 1.95px 2.6px;
}

html.dark-theme button.login-btn {
    box-shadow: rgb(0 0 0 / 72%) 1.95px 1.95px 2.6px;
    background-color: var(--dark-login-btn-bg-color);
}

button.login-btn.error{
    animation: shakeOnErr .1s ease;
    background-color: #be0000 !important;
}

@keyframes shakeOnErr{
    0%{
        transform: translate(-10px);
    }
    50%{
        transform: translate(10px);
    }
    100%{
        transform: translate(0px);
    }
}

span.made-by {
    color: #df609f;
}

.made-by-link {
    color: #34bdeb;
    padding: 5px;
    transition: font-size 0.2s ease;
}

.made-by-link:hover{
    font-size: larger;
}

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>HsH Login</title>

    <link rel="apple-touch-icon" sizes="180x180" href="/assets/icons/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="/assets/icons/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/assets/icons/favicon-16x16.png">
    <link rel="manifest" href="/assets/hsh.webmanifest">
    <link rel="mask-icon" href="/assets/icons/safari-pinned-tab.svg" color="#5bbad5">
    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="theme-color" content="#ffffff">
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">

    <link rel="stylesheet" href="/pages/login/css/style.css">

    <form action="" class="login">

            Test

                <input type="text" lang="Username" name="username" class="username" id="username" placeholder="Username">

                    <input type="password" lang="Password" name="password" class="password" id="password" placeholder="Password">
                    <button class="pw-show-btn" type="button">

                            <svg viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
                                <path d="M9.76406 5.29519C10.4664 5.10724 11.2123 5 12 5C18.3636 5 22 12 22 12C22 12 21.171 13.5958 19.612 15.2635M4.34912 8.77822C2.8152 10.4307 2 12 2 12C2 12 5.63636 19 12 19C12.8021 19 13.5608 18.8888 14.2744 18.6944M11.5 14.9585C10.4158 14.7766 9.52883 14.0132 9.17071 13M12.5 9.04148C13.7563 9.25224 14.7478 10.2437 14.9585 11.5M3 3L21 21" stroke="#001A72" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
                            </svg>

                            <svg version="1.1" fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" xmlns:xlink="http://www.w3.org/1999/xlink" enable-background="new 0 0 512 512">
                                <g><g>
                                    <path d="m499.4,250.8c-51-86.3-143.6-140.4-243.4-140.4s-192.5,54.1-243.4,140.4c-2.1,3.1-2.1,7.3 5.32907e-15,10.4 51,86.3 143.6,140.4 243.4,140.4s192.5-54.1 243.4-140.4c2.1-3.1 2.1-7.3 0-10.4zm-243.4,130c-90.5,0-174.8-47.8-221.6-124.8 46.8-77 131.1-124.8 221.6-124.8s174.8,47.8 221.6,124.8c-46.8,77-131.1,124.8-221.6,124.8z"/>
                                    <path d="m256,162.4c-52,0-93.6,41.6-93.6,93.6 0,52 41.6,93.6 93.6,93.6s93.6-41.6 93.6-93.6c0-52-41.6-93.6-93.6-93.6zm0,166.4c-40.6,0-72.8-32.3-72.8-72.8s32.3-72.8 72.8-72.8 72.8,32.3 72.8,72.8-32.2,72.8-72.8,72.8z"/>
                                    <path d="m256,214.4v20.8c11.4,0 20.8,9.4 20.8,20.8s-9.4,20.8-20.8,20.8-20.8-9.4-20.8-20.8h-20.8c0,22.9 18.7,41.6 41.6,41.6 22.9,0 41.6-18.7 41.6-41.6s-18.7-41.6-41.6-41.6z"/>
                                </g></g>
                            </svg>

                    </button>

            <button type="submit" class="login-btn" lang="Login">Login</button>

    </form>

        test.hu

I have the same problem on other pages, where this exact same problem occours on any input field on mobile.


问:
Creating a LazyVGrid that "snakes" (each row has a rotation effect applied to it)
I am trying to create a grid within SwiftUI where the index "snakes" from left-to-right, right-to-left, and left-to-right (ad infinitum). The approach that I've been trying to implement is essentially applying rotationEffect to each row, but the LazyVGrid's GridItems cannot handle a rotation effect.

An example of how I am looking to lay out the array

Providing some rough code for my View, but I am having trouble figuring out if there is a way of extending GridItem or applying a row-based rotationEffect without implementing a bunch of separate ForEach statements that rely on index checks (which seems inefficient, especially as I am using a single array and would need to drag and drop between them.

```<code>struct ContentView: View {

    @StateObject private var game = GameDriver()

    let columns = [
        GridItem(.flexible()),
        GridItem(.flexible()),
        GridItem(.flexible()),
        GridItem(.flexible())
    ]

    var body: some View {

        LazyVGrid(columns: columns, spacing: 8) {

            ForEach(Array(game.hand.enumerated()), id: \.offset) { index, tile in
                 CardView(game: self.game, card: card)
                }
            }
        }

</code>```

I have tried to implement a rotationEffect on GridItem, but Type Grid Item does not have rotationEffect as a member, so I cannot affect the whole row. I have also tried implementing the rotationEffect within ForEach, but as expected, that only results in an individual card being flipped upside down, as opposed to the whole row as desired.

Body:
I am trying to create a grid within SwiftUI where the index "snakes" from left-to-right, right-to-left, and left-to-right (ad infinitum). The approach that I've been trying to implement is essentially applying rotationEffect to each row, but the LazyVGrid's GridItems cannot handle a rotation effect.

An example of how I am looking to lay out the array

Providing some rough code for my View, but I am having trouble figuring out if there is a way of extending GridItem or applying a row-based rotationEffect without implementing a bunch of separate ForEach statements that rely on index checks (which seems inefficient, especially as I am using a single array and would need to drag and drop between them.

struct ContentView: View {

    @StateObject private var game = GameDriver()

    let columns = [
        GridItem(.flexible()),
        GridItem(.flexible()),
        GridItem(.flexible()),
        GridItem(.flexible())
    ]

    var body: some View {

        LazyVGrid(columns: columns, spacing: 8) {

            ForEach(Array(game.hand.enumerated()), id: \.offset) { index, tile in
                 CardView(game: self.game, card: card)
                }
            }
        }

I have tried to implement a rotationEffect on GridItem, but Type Grid Item does not have rotationEffect as a member, so I cannot affect the whole row. I have also tried implementing the rotationEffect within ForEach, but as expected, that only results in an individual card being flipped upside down, as opposed to the whole row as desired.


问:
How to fix Java ProcessBuilder "Command Not Found" for Linux-based systems?
--- Specs ---

Operating System: Ubuntu-based Pop OS

OS Version: 22.04

Desktop Environment: default / GNOME

Used OS Shell(s): default / bash & sh

Programming Language: Java 8 / 17

Program Environment: all default IntelliJ IDEA 2022.3.1 (Community Edition), Build #IC-223.8214.52, built on December 20, 2022

Program JDK: manually installed Amazon Corretto 8 / 17, also tried in-built IntelliJ OpenJDK 16 & 17 to no avail.

--- Background (in case this is relevant) ---

I am working on a java photo editing automation program for which I   need to perform actions such as opening a photo editing software. I'd    like a java robot to press Super_L/Meta_L/Windows_L to open the Ubuntu   launcher, then type in the photo editing software name and confirm.

In order to achieve a press of the Super_L-key through java, I figured   out that I would have to temporarily assign the Meta_L-Key to my   Super_L-key using "xmodmap -e ...".

--- Problem Description ---

While I could successfully implement the rest,

I am severely struggling with executing the "xmodmap" shell-command using java.

I did not manually set any aliases or environmental variables regarding xmodmap.

Outside of java, it does work using bash, sh and "gnome-terminal -- xmodmap ..."
and the command exists in /usr/bin/ as "xmodmap".

I did try reading the /usr/bin folder of the executing java process to find "xmodmap" missing from the list.

I assumed "xmodmap" were a shell-builtin, but apparently I was wrong?

How can I invoke this command (and others like it)?

--- Code Chunk ---

```<code>    private void temporarilyAssignMetaLKeyToWindowsKey() {
        // xmodmap -e "keycode 133 = Meta_L"
        String cmd = "xmodmap -e \"keycode 133 = Meta_L\""; // does not work!
        //  cmd = "ls -alt /usr/bin |grep -i xm"; // works!
        try {
            // execute command
            ProcessBuilder processBuilder = new ProcessBuilder("/usr/bin/bash", "-c", cmd);
            processBuilder.inheritIO();
            System.out.println(processBuilder.command());
            Process process = processBuilder.start();

            // print command output
            InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream());
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            String output = null;
            while((output = bufferedReader.readLine()) != null ) {
                System.out.println(output);
            }

            // wait for command to finish
            process.waitFor();

            // close resources
            bufferedReader.close();
            process.destroy();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
</code>```

--- Produced Result ---

/usr/bin/bash: line 1: xmodmap: command not found

Edit:

Running "echo $XDG_SESSION_TYPE" in terminal returns "x11" (xorg).

Edit 2:

Added program environment.

Edit 3:

xmodmap before applying modifications:

xmodmap after applying modifications:

Edit 4:

Sudo-ing the command does not change the outcome:

```<code>String cmd = "sudo /usr/bin/xmodmap -e \"keycode 133 = Meta_L\"";
// ...
ProcessBuilder processBuilder = new ProcessBuilder("/usr/bin/bash", "-c", cmd); // /usr/bin/bash: line 1: sudo: command not found
ProcessBuilder processBuilder = new ProcessBuilder(cmd); // java.io.IOException: Cannot run program "sudo /usr/bin/xmodmap -e "keycode 133 = Meta_L"": error=2, No such file or directory
ProcessBuilder processBuilder = new ProcessBuilder("sudo /usr/bin/xmodmap", "-e", "keycode 133 = Meta_L"); // java.io.IOException: Cannot run program "sudo /usr/bin/xmodmap": error=2, No such file or directory
</code>```

Edit 5:

```<code>xmodmap -e "remove mod1 = Meta_L" && xmodmap -e "add mod4 = Meta_L" && xmodmap -e "remove mod4 = Super_L"

xmodmap -e "add mod4 = Super_L" && xmodmap -e "remove mod4 = Meta_L" && xmodmap -e "add mod1 = Meta_L" && exit
</code>```

these could also not be found, same error message

Thank you very much in advance!
Feel free to correct me (:

Body:
--- Specs ---

Operating System: Ubuntu-based Pop OS

OS Version: 22.04

Desktop Environment: default / GNOME

Used OS Shell(s): default / bash & sh

Programming Language: Java 8 / 17

Program Environment: all default IntelliJ IDEA 2022.3.1 (Community Edition), Build #IC-223.8214.52, built on December 20, 2022

Program JDK: manually installed Amazon Corretto 8 / 17, also tried in-built IntelliJ OpenJDK 16 & 17 to no avail.

--- Background (in case this is relevant) ---

I am working on a java photo editing automation program for which I   need to perform actions such as opening a photo editing software. I'd    like a java robot to press Super_L/Meta_L/Windows_L to open the Ubuntu   launcher, then type in the photo editing software name and confirm.

In order to achieve a press of the Super_L-key through java, I figured   out that I would have to temporarily assign the Meta_L-Key to my   Super_L-key using "xmodmap -e ...".

--- Problem Description ---

While I could successfully implement the rest,

I am severely struggling with executing the "xmodmap" shell-command using java.

I did not manually set any aliases or environmental variables regarding xmodmap.

Outside of java, it does work using bash, sh and "gnome-terminal -- xmodmap ..."
and the command exists in /usr/bin/ as "xmodmap".

I did try reading the /usr/bin folder of the executing java process to find "xmodmap" missing from the list.

I assumed "xmodmap" were a shell-builtin, but apparently I was wrong?

How can I invoke this command (and others like it)?

--- Code Chunk ---

    private void temporarilyAssignMetaLKeyToWindowsKey() {
        // xmodmap -e "keycode 133 = Meta_L"
        String cmd = "xmodmap -e \"keycode 133 = Meta_L\""; // does not work!
        //  cmd = "ls -alt /usr/bin |grep -i xm"; // works!
        try {
            // execute command
            ProcessBuilder processBuilder = new ProcessBuilder("/usr/bin/bash", "-c", cmd);
            processBuilder.inheritIO();
            System.out.println(processBuilder.command());
            Process process = processBuilder.start();

            // print command output
            InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream());
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            String output = null;
            while((output = bufferedReader.readLine()) != null ) {
                System.out.println(output);
            }

            // wait for command to finish
            process.waitFor();

            // close resources
            bufferedReader.close();
            process.destroy();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }

--- Produced Result ---

/usr/bin/bash: line 1: xmodmap: command not found

Edit:

Running "echo $XDG_SESSION_TYPE" in terminal returns "x11" (xorg).

Edit 2:

Added program environment.

Edit 3:

xmodmap before applying modifications:

xmodmap after applying modifications:

Edit 4:

Sudo-ing the command does not change the outcome:

String cmd = "sudo /usr/bin/xmodmap -e \"keycode 133 = Meta_L\"";
// ...
ProcessBuilder processBuilder = new ProcessBuilder("/usr/bin/bash", "-c", cmd); // /usr/bin/bash: line 1: sudo: command not found
ProcessBuilder processBuilder = new ProcessBuilder(cmd); // java.io.IOException: Cannot run program "sudo /usr/bin/xmodmap -e "keycode 133 = Meta_L"": error=2, No such file or directory
ProcessBuilder processBuilder = new ProcessBuilder("sudo /usr/bin/xmodmap", "-e", "keycode 133 = Meta_L"); // java.io.IOException: Cannot run program "sudo /usr/bin/xmodmap": error=2, No such file or directory

Edit 5:

xmodmap -e "remove mod1 = Meta_L" && xmodmap -e "add mod4 = Meta_L" && xmodmap -e "remove mod4 = Super_L"

xmodmap -e "add mod4 = Super_L" && xmodmap -e "remove mod4 = Meta_L" && xmodmap -e "add mod1 = Meta_L" && exit

these could also not be found, same error message

Thank you very much in advance!
Feel free to correct me (:


问:
How to clear GPU memory in tensorflow 2.0?
I am very new to tensorflow2.10.0. I am using GPU and having trouble to clear GPU memory using the command tf.keras.backend.clear_session(). I also run del model following the above command. After that, the model variable no longer exist, however the GPU memory usage remains unchanged as per nvidia-smi command. As expected, when I try to retrain a new model, I run into ResourceExhaustedError: Graph execution error:.

I wonder what am I missing here?


问:
Command 'pnpm build' returned non-zero exit status 1
I am trying to run testplan from this repo - https://github.com/morganstanley/testplan

but i am getting this error when installing ui, anyone knows what issue is? how to resolve it?

$ ./install-testplan-ui --dev
INFO:Installing Testplan UI dependencies...
INFO:Installing to path: /home/onionw/shadow/testplan/testplan/web_ui/testing
INFO:Enabling pre and post scripts...
INFO:Building Testplan UI...
Traceback (most recent call last):
File "./install-testplan-ui", line 136, in
install_and_build_ui(path=args.path, dev=args.dev, verbose=args.verbose)
File "./install-testplan-ui", line 124, in install_and_build_ui
subprocess.check_call(
File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
raise CalledProcessError(retcode, cmd)
**subprocess.CalledProcessError: Command 'pnpm build' returned non-zero exit status 1.
**

$ pnpm --version
7.21.0

$ node --version
v14.21.1


问:
error: parser: instruction expected x86 windows
Hi I'm writing some assembler code that displays a string and a current date-time. When I try to compile this code with

nasm -f win32 code.asm

i get the

code.asm:18: error: parser: instruction expected

This is my code

```<code>section .data
    message db "Test SURNAME Inf ", 0
    time_format db "%Y-%m-%d %H:0"', 0
    stdout dd 0

    ; Define the time structure
    struc SYSTEMTIME
        wYear dw ?
        wMonth dw ?
        wDayOfWeek dw ?
        wDay dw ?
        wHour dw ?
        wMinute dw ?
        wSecond dw ?
        wMilliseconds dw ?
    endstruc
    time SYSTEMTIME <>

    ; Define the date_time buffer
    date_time resb 30

; Declare the code segment
section .text

; Declare the external functions that will be used in the program
extern _GetStdHandle@4
extern _WriteFile@24
extern _GetLocalTime@4
extern _strftime@12
extern _ExitProcess@4

; Rest of the code goes here
</code>```

any help would be appreciated

Body:
Hi I'm writing some assembler code that displays a string and a current date-time. When I try to compile this code with

nasm -f win32 code.asm

i get the

code.asm:18: error: parser: instruction expected

This is my code

section .data
    message db "Test SURNAME Inf ", 0
    time_format db "%Y-%m-%d %H:0"', 0
    stdout dd 0

    ; Define the time structure
    struc SYSTEMTIME
        wYear dw ?
        wMonth dw ?
        wDayOfWeek dw ?
        wDay dw ?
        wHour dw ?
        wMinute dw ?
        wSecond dw ?
        wMilliseconds dw ?
    endstruc
    time SYSTEMTIME <>

    ; Define the date_time buffer
    date_time resb 30

; Declare the code segment
section .text

; Declare the external functions that will be used in the program
extern _GetStdHandle@4
extern _WriteFile@24
extern _GetLocalTime@4
extern _strftime@12
extern _ExitProcess@4

; Rest of the code goes here

any help would be appreciated


问:
consolidate multiple component isLoading states into a single loader?
I have a Next.js app with half a dozen components, each fetching data from Firestore.

I'm using useState in each component to setLoading to true before the await docs... and false after, then doing a simple if(loading) return <LoadingComponent/>; before returning the loaded content return.

As expected, I get a flickering of loaders across the page. I'd like to learn how to elegantly handle all the loading states with a single loader to rule them all.

My instinct is to pass an onLoading value up the tree from each component to the page component and do some debounced logic there to display the loader or the whole page, but... I defer to the experts before I set about building it out.

Here's my average component:

```<code>useEffect(() => {
  const getList = async () => {
    setLoading(true);
    const snap = await getDocs(query(collection(db, "featured")));
    // handle docs
    setLoading(false);
  };
  getList();
}, []);

if(loading){
  return <LoadingComponent/>
}

return data.length > 0 && <div>loaded content</div>
</code>```

Body:
I have a Next.js app with half a dozen components, each fetching data from Firestore.

I'm using useState in each component to setLoading to true before the await docs... and false after, then doing a simple if(loading) return <LoadingComponent/>; before returning the loaded content return.

As expected, I get a flickering of loaders across the page. I'd like to learn how to elegantly handle all the loading states with a single loader to rule them all.

My instinct is to pass an onLoading value up the tree from each component to the page component and do some debounced logic there to display the loader or the whole page, but... I defer to the experts before I set about building it out.

Here's my average component:

useEffect(() => {
  const getList = async () => {
    setLoading(true);
    const snap = await getDocs(query(collection(db, "featured")));
    // handle docs
    setLoading(false);
  };
  getList();
}, []);

if(loading){
  return <LoadingComponent/>
}

return data.length > 0 &&
loaded content


问:
Implementing a limited attempt system in C++
```<code>#include<iostream>
using namespace std;
int main()
{

    int rnd = 1 + (rand() % 99999);
    char comp;
    cout << "Introduzca el valor a comparar" << endl;

    cin >> comp;

    if (comp > rnd)
    {
        cout << ">";
    }
    else if (comp < rnd)
    {
        cout << "<";
    }
    else if (comp = rnd)
    {
        cout << "=";
    }
}
</code>```

So, in this C++ program I'm trying to get the user to guess a number, but I want them to have a limited number of tries at guessing (20). I have basically zero experience in C++ and I don't know how to implement this system.

Body:
#include<iostream>
using namespace std;
int main()
{

    int rnd = 1 + (rand() % 99999);
    char comp;
    cout << "Introduzca el valor a comparar" << endl;

    cin >> comp;

    if (comp > rnd)
    {
        cout << ">";
    }
    else if (comp < rnd)
    {
        cout << "<";
    }
    else if (comp = rnd)
    {
        cout << "=";
    }
}

So, in this C++ program I'm trying to get the user to guess a number, but I want them to have a limited number of tries at guessing (20). I have basically zero experience in C++ and I don't know how to implement this system.