问:
Is there a way I can make my webview scrolling smoother?
```<code>            PageView(
              scrollDirection: Axis.horizontal,
              children: [
               StatefulPageview(  //Displays vertical pageview
                        articles: state.articles,
                        currentPage: currentStare);

               ArticleWebView(  //Displays webview
                      url: 'www.google.com',
                    );
              ],
            );
</code>```

Here I have nested Pageview. Outer one that scrolls horizontally and an inner one that scrolls vertically. The inner pageview works fine but when I swipe right and on the WebView that has to scroll vertically as well, even the slightest horizontal movement scrolls back to the inner Pageview.So i can not basically scroll smoothly inside webview widget.
I even tried creating custom scroll physics to make it work like this.

```<code>      class StickyPageViewScrollPhysics extends PageScrollPhysics {
         const StickyPageViewScrollPhysics({ScrollPhysics? parent})
          : super(parent: parent);

       @override
       StickyPageViewScrollPhysics applyTo(ScrollPhysics? ancestor) {
        return StickyPageViewScrollPhysics(parent: buildParent(ancestor)!);
        }

      @override
       SpringDescription get spring => const SpringDescription(
      mass: 100,
      stiffness: 1000,
      damping: 10.0,
    );
    }
</code>```

But it does not seem to work. Does anyone have an idea how can I solve this ?

Body:
            PageView(
              scrollDirection: Axis.horizontal,
              children: [
               StatefulPageview(  //Displays vertical pageview
                        articles: state.articles,
                        currentPage: currentStare);

               ArticleWebView(  //Displays webview
                      url: 'www.google.com',
                    );
              ],
            );

Here I have nested Pageview. Outer one that scrolls horizontally and an inner one that scrolls vertically. The inner pageview works fine but when I swipe right and on the WebView that has to scroll vertically as well, even the slightest horizontal movement scrolls back to the inner Pageview.So i can not basically scroll smoothly inside webview widget.
I even tried creating custom scroll physics to make it work like this.

      class StickyPageViewScrollPhysics extends PageScrollPhysics {
         const StickyPageViewScrollPhysics({ScrollPhysics? parent})
          : super(parent: parent);

       @override
       StickyPageViewScrollPhysics applyTo(ScrollPhysics? ancestor) {
        return StickyPageViewScrollPhysics(parent: buildParent(ancestor)!);
        }

      @override
       SpringDescription get spring => const SpringDescription(
      mass: 100,
      stiffness: 1000,
      damping: 10.0,
    );
    }

But it does not seem to work. Does anyone have an idea how can I solve this ?


来源: stackexchange

问:
How to create a feature wise Data Catalog in AWS?
I have a CSV files stored on a s3 data lake. I need to create a data catalog where I can see all the features from all CSV files and then name of the table each feature belongs to. Basically this is ML use case, I am downlaoding alot of data sets and ingesting them into S3 Lake. Then after analyzing them carefully I figure out business value features.
e.g.
Feature_Name | Table_Name| Location | Classification
Feature-1    |  Table-1  | Location | (Link)
Feature-2    |  Table-1  | Location | (Link)
Feature-3    |  Table-1  | Location | (Link)
Feature-1    |  Table-2  | Location | (Link)
Feature-2    |  Table-2  | Location | (Link)
Feature-1    |  Table-3  | Location | (Link)

I tried AWS Glue crawler to crawl all the tables from the S3 bucket. It gave me the data catalog having Name of the tables and their locations. I want feature names also with the table names to see the everything in a big picture.

ContentLicense: CC BY-SA 4.0


问:
Spring JPA, Thymeleaf - Bind Form List to Entity with EmbeddedId (OneToMany; ManyToOne)
I have created a Thymeleaf form which has a field that accepts multiple values. I am attempting to map this list of fields to a JPA entity, but I keep getting the following error:

```<code>default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.List' for property 'equipmentExerciseList'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'myproject.model.EquipmentExercise' for property 'equipmentExerciseList[0]': no matching editors or conversion strategy found
</code>```

I am following this tutorial, and a difference I see is that one of my entities has an embedded id, so I figure that must be causing my issues.

Basically, I want to insert a new exercise into the database, with the exercise containing a list of required equipment. The required equipment must be chosen from a list existing in the database.

Tables

I have an entity, Exercise, which logically can be performed with multiple props/pieces of equipment. Similarly, the pieces of equipment can be associated with multiple exercises. I have created a join table to handle this relationship, and I also have a third table which controls the equipment that can be selected:

Code

Entities

Exercise.java

```<code>@Data
@Entity
@Table(name = "Exercise")
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
public class Exercise implements Serializable {

    @Id
    @Column(name = "exercise_name")
    private String exerciseName;

    // Others removed for brevity

    @OneToMany(mappedBy = "exercise")
    private List<EquipmentExercise> equipmentExerciseList;
}
</code>```

EquipmentExercise.java

```<code>@Getter
@Setter
@Entity
@Table(name = "EquipmentExercise")
@ToString
public class EquipmentExercise implements Serializable {

    @EmbeddedId
    EquipmentExerciseId equipmentExerciseId;

    @ManyToOne
    @MapsId("exerciseName")
    @JoinColumn(name = "exercise_name")
    Exercise exercise;

    @ManyToOne
    @MapsId("equipmentName")
    @JoinColumn(name = "equipment_name")
    Equipment equipment;

}
</code>```

EquipmentExerciseId.java

```<code>@Embeddable
@Getter
@Setter
@EqualsAndHashCode
@ToString
public class EquipmentExerciseId implements Serializable {

    @Column(name = "equipment_name")
    String equipmentName;

    @Column(name = "exercise_name")
    String exercise_name;
}
</code>```

Equipment.java

```<code>@Entity
@Table(name = "Equipment")
@Getter
@Setter
@EqualsAndHashCode
public class Equipment {

    @Id
    @Column(name = "equipment_name")
    String equipmentName;

    @OneToMany(mappedBy = "equipment", cascade = CascadeType.ALL)
    private List<EquipmentExercise> equipmentExerciseList;

}
</code>```

Attempted Solution 1

At first I retrieved a list of potential props from the Equipment table and used that to populate the options on the Thymeleaf form:

Controller

```<code> @GetMapping("/stretch")
    public String addStretch(Model model){
        List<Equipment> availableEquipmentList = equipmentService.findAllEquipment();
        EquipmentExercise equipmentExercise = new EquipmentExercise();

        model.addAttribute("exercise", new Exercise());
        model.addAttribute("availableEquipmentList", availableEquipmentList);
        model.addAttribute("EquipmentExercise", equipmentExercise);

        return "/add";
}
</code>```

Thymeleaf Form

```<code> <div class="mb-3">
    <label for="exercise.equipmentExerciseList" class="form-label">Prop(s)</label>
    <select th:field="${exercise.equipmentExerciseList}" class="form-control" multiple="multiple" name = "exercise.equipmentExerciseList">
       <th:block th:each="equipment : ${availableEquipmentList}">
               <option th:text="${equipment.equipmentName}" th:value="${equipment.equipmentName}" />
       </th:block>
    </select>
</div>
</code>```

but I got the error from above.

Attempted Solution 2

I did some digging here and discovered that the error probably is arising because the program did not know how to convert from Equipment to EquipmentExercise. So, I tried using an EquipmentExercise object instead of the Equipment object in the form, but I am still effectively getting the same error, just with a different object as the source of the error.

```<code> @GetMapping("/stretch")
    public String addStretch(Model model){
        List<EquipmentExercise> availableEquipmentList;

        EquipmentExercise equipmentExercise = new EquipmentExercise();
        EquipmentExerciseId equipmentExerciseId = new EquipmentExerciseId();
        equipmentExercise.setEquipmentName = "Test";
        equipmentExercise.setEquipmentExerciseId(equipmentExerciseId);
        availableEquipmentList.add(equipmentExercise);

        model.addAttribute("exercise", new Exercise());
        model.addAttribute("availableEquipmentList", availableEquipmentList);

        return "/add";
}
</code>```

Thymeleaf Form

```<code> <div class="mb-3">
    <label for="exercise.equipmentList" class="form-label">Prop(s)</label>
    <select th:field="${exercise.equipmentList}" class="form-control" multiple="multiple" name = "exercise.equipmentList"  >
       <th:block th:each="equipmentExercise : ${equipmentExerciseList}">
           <option th:text="${equipmentExercise.getEquipmentExerciseId().getEquipmentName()}" th:value="${equipmentExercise}" />
       </th:block>
    </select>
</div>
</code>```

Error

```<code>Field error in object 'exercise' on field 'equipmentExerciseList': rejected value [EquipmentExercise(equipmentExerciseId=EquipmentExerciseId(equipmentName=Test, exerciseName=null), exercise=null, equipment=null)]; codes [typeMismatch.exercise.equipmentExerciselist,typeMismatch.equipmentExerciseList,typeMismatch.java.util.List,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [exercise.equipmentExerciseList,equipmentExerciseList]; arguments []; default message [equipmentExerciseList]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.List' for property 'propList'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'myproject.model.EquipmentExercise' for property 'equipmentExerciseList[0]': no matching editors or conversion strategy found]
</code>```

Update

I have confirmed my suspicion that the issue stems from the composite id, but I do not yet have a solution.

To confirm, I found this similar question, where one of the answers explains that the th:value is supposed to map to a primary key, which Spring then uses behind the scenes to generate the requested object. I am guessing that the th:values I've provided are too ambiguous (due to the composite key) for Spring to map correctly.

I looked into a custom converter, and was able to get Spring to generate an Exercise object using this, but understandably, the values the other fields in my EquipmentExercise class didn't map

```<code>@Data
@Entity
@Table(name = "Exercise")
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
public class Exercise implements Serializable {

    @Id
    @Column(name = "exercise_name")
    private String exerciseName;

    // Others removed for brevity

    @OneToMany(mappedBy = "exercise")
    private List<EquipmentExercise> equipmentExerciseList;
}
</code>```0

Body:
I have created a Thymeleaf form which has a field that accepts multiple values. I am attempting to map this list of fields to a JPA entity, but I keep getting the following error:

default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.List' for property 'equipmentExerciseList'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'myproject.model.EquipmentExercise' for property 'equipmentExerciseList[0]': no matching editors or conversion strategy found

I am following this tutorial, and a difference I see is that one of my entities has an embedded id, so I figure that must be causing my issues.

Basically, I want to insert a new exercise into the database, with the exercise containing a list of required equipment. The required equipment must be chosen from a list existing in the database.

Tables

I have an entity, Exercise, which logically can be performed with multiple props/pieces of equipment. Similarly, the pieces of equipment can be associated with multiple exercises. I have created a join table to handle this relationship, and I also have a third table which controls the equipment that can be selected:

Code

Entities

Exercise.java

@Data
@Entity
@Table(name = "Exercise")
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
public class Exercise implements Serializable {

    @Id
    @Column(name = "exercise_name")
    private String exerciseName;

    // Others removed for brevity

    @OneToMany(mappedBy = "exercise")
    private List<EquipmentExercise> equipmentExerciseList;
}

EquipmentExercise.java

@Getter
@Setter
@Entity
@Table(name = "EquipmentExercise")
@ToString
public class EquipmentExercise implements Serializable {

    @EmbeddedId
    EquipmentExerciseId equipmentExerciseId;

    @ManyToOne
    @MapsId("exerciseName")
    @JoinColumn(name = "exercise_name")
    Exercise exercise;

    @ManyToOne
    @MapsId("equipmentName")
    @JoinColumn(name = "equipment_name")
    Equipment equipment;

}

EquipmentExerciseId.java

@Embeddable
@Getter
@Setter
@EqualsAndHashCode
@ToString
public class EquipmentExerciseId implements Serializable {

    @Column(name = "equipment_name")
    String equipmentName;

    @Column(name = "exercise_name")
    String exercise_name;
}

Equipment.java

@Entity
@Table(name = "Equipment")
@Getter
@Setter
@EqualsAndHashCode
public class Equipment {

    @Id
    @Column(name = "equipment_name")
    String equipmentName;

    @OneToMany(mappedBy = "equipment", cascade = CascadeType.ALL)
    private List<EquipmentExercise> equipmentExerciseList;

}

Attempted Solution 1

At first I retrieved a list of potential props from the Equipment table and used that to populate the options on the Thymeleaf form:

Controller

 @GetMapping("/stretch")
    public String addStretch(Model model){
        List<Equipment> availableEquipmentList = equipmentService.findAllEquipment();
        EquipmentExercise equipmentExercise = new EquipmentExercise();

        model.addAttribute("exercise", new Exercise());
        model.addAttribute("availableEquipmentList", availableEquipmentList);
        model.addAttribute("EquipmentExercise", equipmentExercise);

        return "/add";
}

Thymeleaf Form

    Prop(s)
    <select th:field="${exercise.equipmentExerciseList}" class="form-control" multiple="multiple" name = "exercise.equipmentExerciseList">

               <option th:text="${equipment.equipmentName}" th:value="${equipment.equipmentName}" />

    </select>

but I got the error from above.

Attempted Solution 2

I did some digging here and discovered that the error probably is arising because the program did not know how to convert from Equipment to EquipmentExercise. So, I tried using an EquipmentExercise object instead of the Equipment object in the form, but I am still effectively getting the same error, just with a different object as the source of the error.

 @GetMapping("/stretch")
    public String addStretch(Model model){
        List<EquipmentExercise> availableEquipmentList;

        EquipmentExercise equipmentExercise = new EquipmentExercise();
        EquipmentExerciseId equipmentExerciseId = new EquipmentExerciseId();
        equipmentExercise.setEquipmentName = "Test";
        equipmentExercise.setEquipmentExerciseId(equipmentExerciseId);
        availableEquipmentList.add(equipmentExercise);

        model.addAttribute("exercise", new Exercise());
        model.addAttribute("availableEquipmentList", availableEquipmentList);

        return "/add";
}

Thymeleaf Form

    Prop(s)
    <select th:field="${exercise.equipmentList}" class="form-control" multiple="multiple" name = "exercise.equipmentList"  >

           <option th:text="${equipmentExercise.getEquipmentExerciseId().getEquipmentName()}" th:value="${equipmentExercise}" />

    </select>

Error

Field error in object 'exercise' on field 'equipmentExerciseList': rejected value [EquipmentExercise(equipmentExerciseId=EquipmentExerciseId(equipmentName=Test, exerciseName=null), exercise=null, equipment=null)]; codes [typeMismatch.exercise.equipmentExerciselist,typeMismatch.equipmentExerciseList,typeMismatch.java.util.List,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [exercise.equipmentExerciseList,equipmentExerciseList]; arguments []; default message [equipmentExerciseList]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.List' for property 'propList'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'myproject.model.EquipmentExercise' for property 'equipmentExerciseList[0]': no matching editors or conversion strategy found]

Update

I have confirmed my suspicion that the issue stems from the composite id, but I do not yet have a solution.

To confirm, I found this similar question, where one of the answers explains that the th:value is supposed to map to a primary key, which Spring then uses behind the scenes to generate the requested object. I am guessing that the th:values I've provided are too ambiguous (due to the composite key) for Spring to map correctly.

I looked into a custom converter, and was able to get Spring to generate an Exercise object using this, but understandably, the values the other fields in my EquipmentExercise class didn't map

@Override
public EquipmentExercise convert(String equipmentName){

    EquipmentExercise equipmentExercise = new EquipmentExercise();
    EquipmentExerciseId equipmentExerciseId = new EquipmentExerciseId();
    equipmentExerciseId.setEquipmentName(equipmentName);
    equipmentExercise.setEquipmentExerciseId(equipmentExerciseId);

    return equipmentExercise;
}


问:
Offset.Clear crashes excel when try to run in change mode
I'm trying to clear a cell in worksheet change mode in VBA.

However, when I try to clear cell which is just a number Excel crashes and stops working.

I am trying to clear "5" when I deleted "asd" Cell.

If IsEmpty(Target.value) Then
    'Target.Offset(0, 3).Validation.Delete
    Target.Offset(0, 3).Clear
```
<p>It gives me the error "Range of Object worksheet Failed"</p>
<p>Full Code:</p>
<pre class="lang-vb prettyprint-override"><code>Private Sub Worksheet_Change(ByVal Target As Range)
    Dim i As Range
    Set i = Range("A1:A1000")
    Dim b As Range
    Set b = Range("b1:b1000")
    Dim t As Range

    If Not Intersect(Target, i) Is Nothing Then
        Debug.Print "-"
        Debug.Print "Start"
        Debug.Print "****************"

        Set t = Target
        mak1 t
    End If

    If Not Intersect(Target, b) Is Nothing Then
        Set t = Target
        mak2 t
        Range("D3").Clear
    End If

    If IsEmpty(Target.value) Then
        Debug.Print Target.Address.Offset(0, 3)

        'Target.Offset(0, 3).Validation.Delete
        Target.Offset(0, 3).Activate
    End If
End Sub
</code>```

Body:
I'm trying to clear a cell in worksheet change mode in VBA.

However, when I try to clear cell which is just a number Excel crashes and stops working.

I am trying to clear "5" when I deleted "asd" Cell.

If IsEmpty(Target.value) Then
    'Target.Offset(0, 3).Validation.Delete
    Target.Offset(0, 3).Clear

It gives me the error "Range of Object worksheet Failed"

Full Code:

Private Sub Worksheet_Change(ByVal Target As Range)
    Dim i As Range
    Set i = Range("A1:A1000")
    Dim b As Range
    Set b = Range("b1:b1000")
    Dim t As Range

    If Not Intersect(Target, i) Is Nothing Then
        Debug.Print "-"
        Debug.Print "Start"
        Debug.Print "****************"

        Set t = Target
        mak1 t
    End If

    If Not Intersect(Target, b) Is Nothing Then
        Set t = Target
        mak2 t
        Range("D3").Clear
    End If

    If IsEmpty(Target.value) Then
        Debug.Print Target.Address.Offset(0, 3)

        'Target.Offset(0, 3).Validation.Delete
        Target.Offset(0, 3).Activate
    End If
End Sub


问:
Plotting each iteration of Kmeans
So I have created a K-means algorithm from scratch and what I want to do is to plot each iteration. So if the K-means runs 5 times I want 5 plots so you can visualize how the centroids and the clusters change. And i'm stuck on how to even start this proccess. Would I store all the clusters and centroids with each iteration to a list? I tried doing that but it gets so confusing to later plot and run a for loop through the list.

If the question is confusing let me know and i'll try to explain it better.

This is my code I have so far to plot the centroids and clusters.

```<code>    for i, cluster in enumerate(clusters):
        cluster = np.array(cluster)
        plt.scatter(cluster[:, 0], cluster[:, 1], c=colors[i])
    for center in centers:
        plt.scatter(center[0], center[1], c="k", marker="x", s=100)
    plt.title("Iteration {}".format(k))
    plt.show()
</code>```

Now all this does is just plot the final result, since the variable clusters and centers are the returns of my Kmeans function. Any ideas? Thanks in advance.

Title: Plotting each iteration of Kmeans

Body:
So I have created a K-means algorithm from scratch and what I want to do is to plot each iteration. So if the K-means runs 5 times I want 5 plots so you can visualize how the centroids and the clusters change. And i'm stuck on how to even start this proccess. Would I store all the clusters and centroids with each iteration to a list? I tried doing that but it gets so confusing to later plot and run a for loop through the list.

If the question is confusing let me know and i'll try to explain it better.

This is my code I have so far to plot the centroids and clusters.

    for i, cluster in enumerate(clusters):
        cluster = np.array(cluster)
        plt.scatter(cluster[:, 0], cluster[:, 1], c=colors[i])
    for center in centers:
        plt.scatter(center[0], center[1], c="k", marker="x", s=100)
    plt.title("Iteration {}".format(k))
    plt.show()

Now all this does is just plot the final result, since the variable clusters and centers are the returns of my Kmeans function. Any ideas? Thanks in advance.


问:
High precision binary multiplication
Assume I want to multiply 1.1 and 1.4 in binary. I store them as 11/10 and 14/10 respectively. The result is 1.54 which I must store as 154/100. But I have 4 bits to store numerator that is why I must cut the result down to 15/10 so 15 would fit my memory limitations.

I could use double memory buffer to temporarily store 154 in 8 bits and then repeatedly divide it by 10 until it would fit, but it would be slow to calculate partial products and then have long division to divide it by 10. I also could cut multipliers so their product would fit but this causes major loss of accuracy. So seems like I need something else to multiply numbers like that, and I cannot find the solution.

Which ways can be used to solve this memory+accuracy problem?

Title: High precision binary multiplication


问:
Python - instaPy - login throwing errors
Getting these errors when trying to use InstaPy to login  - Any idea what is wrong with my code? Feel like this is a problem with instaPy though.

```<code>INFO [2023-01-08 17:54:41] [john]  Session started!
INFO [2023-01-08 17:54:45] [john]  - Cookie file not found, creating cookie...
WARNING [2023-01-08 17:54:56] [john]  Login A/B test detected! Trying another string...
WARNING [2023-01-08 17:55:01] [john]  Could not pass the login A/B test. Trying last string...
</code>```
```<code>
ERROR [2023-01-08 17:55:06] [john]  Login A/B test failed!
    b"Message: Unable to locate element: //div[text()='Log In']\nStacktrace:\nWebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:186:5\nNoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:398:5\nelement.find/</<@chrome://remote/content/marionette/element.js:300:16\n"
</code>```
```<code>selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //a[text()='Log in']
</code>```
```<code>CRITICAL [2023-01-08 17:55:06] [johnpurves2022]  Unable to login to Instagram! You will find more information in the logs above.
</code>```

Here is my code

```<code>from instapy import InstaPy

session = InstaPy(username="john", password="Support!", headless_browser=False, want_check_browser=False)
session.login()
</code>```

Body:
Getting these errors when trying to use InstaPy to login  - Any idea what is wrong with my code? Feel like this is a problem with instaPy though.

INFO [2023-01-08 17:54:41] [john]  Session started!
INFO [2023-01-08 17:54:45] [john]  - Cookie file not found, creating cookie...
WARNING [2023-01-08 17:54:56] [john]  Login A/B test detected! Trying another string...
WARNING [2023-01-08 17:55:01] [john]  Could not pass the login A/B test. Trying last string...

ERROR [2023-01-08 17:55:06] [john]  Login A/B test failed!
    b"Message: Unable to locate element: //div[text()='Log In']\nStacktrace:\nWebDriverError@chrome://remote/content/shared/webdriver/Errors.jsm:186:5\nNoSuchElementError@chrome://remote/content/shared/webdriver/Errors.jsm:398:5\nelement.find/</<@chrome://remote/content/marionette/element.js:300:16\n"

selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //a[text()='Log in']

CRITICAL [2023-01-08 17:55:06] [johnpurves2022]  Unable to login to Instagram! You will find more information in the logs above.

Here is my code

from instapy import InstaPy

session = InstaPy(username="john", password="Support!", headless_browser=False, want_check_browser=False)
session.login()


问:
CS50 - filter (more confortable) - edges filter makes the image all black except for pixels along the edge or corners
Here is my function:

void edges(int height, int width, RGBTRIPLE image[height][width])
{
    int Gx[3][3] = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}};
    int Gy[3][3] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};

    RGBTRIPLE temp[height][width];

    for(int i = 0; i < height; i++) {
        for(int j = 0; j < width; j++) {

            double gxred = 0, gxgreen = 0, gxblue = 0;
            double gyred = 0, gygreen = 0, gyblue = 0;
            double red = 0, green = 0, blue = 0;

            for(int a = -1; a <= 1; a++) {
                for(int b = -1; b <=1; b++) {

                    if(a+i >= 0 && a+i < height && b+j >= 0 && b+j < width) {
                        gxred += Gx[a+1][b+1] * image[i][j].rgbtRed;
                        gxgreen += Gx[a+1][b+1] * image[i][j].rgbtGreen;
                        gxblue += Gx[a+1][b+1] * image[i][j].rgbtBlue;

                        gyred += Gy[a+1][b+1] * image[i][j].rgbtRed;
                        gygreen += Gy[a+1][b+1] * image[i][j].rgbtGreen;
                        gyblue += Gy[a+1][b+1] * image[i][j].rgbtBlue;
                    }

                }
            }

            red = sqrt(((gxred*gxred) + (gyred*gyred)));
            if(red > 255)
                red = 255;
            green = sqrt(((gxgreen*gxgreen) + (gygreen*gygreen)));
            if(green > 255)
                green = 255;
            blue = sqrt(((gxblue*gxblue) + (gyblue*gyblue)));
            if(blue > 255)
                blue = 255;

            temp[i][j].rgbtRed = red;
            temp[i][j].rgbtGreen = green;
            temp[i][j].rgbtBlue = blue;

        }
    }

    // image = temp
    for(int i = 0; i < height; i++) {
        for(int j = 0; j < width; j++) {
            image[i][j].rgbtRed = temp[i][j].rgbtRed;
            image[i][j].rgbtGreen = temp[i][j].rgbtGreen;
            image[i][j].rgbtBlue = temp[i][j].rgbtBlue;
        }
    }

    return;
}
```

As the title says this code makes all pixels black except for the corners and edges, I have  tried to debug it using debug50 but since the images are too big I cant reach the middle pixels with the debugger, already watched some youtube tutorials and saw other people's code but I really can't tell what Im doing wrong.

Body:
Here is my function:

void edges(int height, int width, RGBTRIPLE image[height][width])
{
    int Gx[3][3] = {{-1, 0, 1}, {-2, 0, 2}, {-1, 0, 1}};
    int Gy[3][3] = {{-1, -2, -1}, {0, 0, 0}, {1, 2, 1}};

    RGBTRIPLE temp[height][width];

    for(int i = 0; i < height; i++) {
        for(int j = 0; j < width; j++) {

            double gxred = 0, gxgreen = 0, gxblue = 0;
            double gyred = 0, gygreen = 0, gyblue = 0;
            double red = 0, green = 0, blue = 0;

            for(int a = -1; a <= 1; a++) {
                for(int b = -1; b <=1; b++) {

                    if(a+i >= 0 && a+i < height && b+j >= 0 && b+j < width) {
                        gxred += Gx[a+1][b+1] * image[i][j].rgbtRed;
                        gxgreen += Gx[a+1][b+1] * image[i][j].rgbtGreen;
                        gxblue += Gx[a+1][b+1] * image[i][j].rgbtBlue;

                        gyred += Gy[a+1][b+1] * image[i][j].rgbtRed;
                        gygreen += Gy[a+1][b+1] * image[i][j].rgbtGreen;
                        gyblue += Gy[a+1][b+1] * image[i][j].rgbtBlue;
                    }

                }
            }

            red = sqrt(((gxred*gxred) + (gyred*gyred)));
            if(red > 255)
                red = 255;
            green = sqrt(((gxgreen*gxgreen) + (gygreen*gygreen)));
            if(green > 255)
                green = 255;
            blue = sqrt(((gxblue*gxblue) + (gyblue*gyblue)));
            if(blue > 255)
                blue = 255;

            temp[i][j].rgbtRed = red;
            temp[i][j].rgbtGreen = green;
            temp[i][j].rgbtBlue = blue;

        }
    }

    // image = temp
    for(int i = 0; i < height; i++) {
        for(int j = 0; j < width; j++) {
            image[i][j].rgbtRed = temp[i][j].rgbtRed;
            image[i][j].rgbtGreen = temp[i][j].rgbtGreen;
            image[i][j].rgbtBlue = temp[i][j].rgbtBlue;
        }
    }

    return;
}

As the title says this code makes all pixels black except for the corners and edges, I have  tried to debug it using debug50 but since the images are too big I cant reach the middle pixels with the debugger, already watched some youtube tutorials and saw other people's code but I really can't tell what Im doing wrong.


问:
HTML not showing - commented in console
My HTML doesnt dhow on the page : it seems to be commented out when I check the console, but I have no idea why.

I am coding in php and using wampserver. I tried to restart the server but to no avail.
Note : when I try to view other PHP projects I had worked on, or even previous versions of the same project, it works fine.
If I echo something in php above the !doctype, it gets commented out as well.

If anyone already encountered this problem or would be available to help, I would greatly appreciate it, thank you.

Title: HTML not showing - commented in console


问:
Qt 6.4.2 / PySide 6.4.2 window move() not working on Ubuntu Wayland
The example below creates a window in the upper left corner and ignores the move() function on Ubuntu Wayland 22.04.1 or 22.10 with all updates installed. It works on Ubuntu X11, Windows 10 and other desktops.

Pyside 6.4.2 testcase (installed via PIP):

from PySide6.QtWidgets import QApplication, QMainWindow
import sys

app = QApplication(sys.argv)
mainwindow = QMainWindow()

# Window move does not work on Ubuntu Wayland, works on X11:
mainwindow.move(1000, 600)

mainwindow.show()
app.exec()
```
<p>Qt 6.4.2 C++ testcase:</p>
```#include <QApplication>
#include <QWidget>int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWidget w = QWidget();

    w.setWindowTitle("Window Move");
    w.setFixedSize(300, 200);

    // Window move does not work on Ubuntu Wayland, works on X11
    w.move(1000, 600);

    w.show();
    return a.exec();
}
```

Reproducible with PySide2.

What could be the reason for a difference between Windows and Linux?

Updates:

PYSIDE-2190 issue confirmed by PySide developers.

QTBUG-110119 confirmed by Qt window developers, not willing to investigate further.

The reason why the quality of the Qt documentation is below our expectation is that the Qt developers confirmed this issue on Wayland and are ignoring the request to update the documentation.

Body:
The example below creates a window in the upper left corner and ignores the move() function on Ubuntu Wayland 22.04.1 or 22.10 with all updates installed. It works on Ubuntu X11, Windows 10 and other desktops.

Pyside 6.4.2 testcase (installed via PIP):

from PySide6.QtWidgets import QApplication, QMainWindow
import sys

app = QApplication(sys.argv)
mainwindow = QMainWindow()

# Window move does not work on Ubuntu Wayland, works on X11:
mainwindow.move(1000, 600)

mainwindow.show()
app.exec()

Qt 6.4.2 C++ testcase:

#include <QApplication>
#include <QWidget>int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWidget w = QWidget();

    w.setWindowTitle("Window Move");
    w.setFixedSize(300, 200);

    // Window move does not work on Ubuntu Wayland, works on X11
    w.move(1000, 600);

    w.show();
    return a.exec();
}

Reproducible with PySide2.

What could be the reason for a difference between Windows and Linux?

Updates:

PYSIDE-2190 issue confirmed by PySide developers.

QTBUG-110119 confirmed by Qt window developers, not willing to investigate further.

The reason why the quality of the Qt documentation is below our expectation is that the Qt developers confirmed this issue on Wayland and are ignoring the request to update the documentation.


问:
how to filter beacon frames by its security type
I'm trying to write a python script using (Scapy) to sniff the network that automatically detects rogue access points and launch DoS attack on it, but I can't filter the beacon frames to get the frames with open security?

How can I write this script or how can I filter the frames by its security type?

As I mentioned before I couldn't filter the frames by the security type.


问:
Text Hydration error when using SwiperSlide
I'm using the swiper.js, but when I use SwiperSlide I get the following error

```<code>Unhandled Runtime Error
Error: Text content does not match server-rendered HTML.
</code>```

This only occurs when using SwiperSlide.

```<code>import styled from "styled-components";
import { Swiper, SwiperSlide } from "swiper/react";
import { Autoplay } from "swiper";
import "swiper/css/autoplay";

function Courses() {
  const courseList = [
    {
      courseImage: "/images/header-v2.png",
      courseTag: ["Python", "#4AB2FF"],
      courseDescription:
        "simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s",
    },
    {
      courseImage: "/images/html-header.png",
      courseTag: ["HTML", "#F06529"],
      courseDescription:
        "simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s",
    },
    {
      courseImage: "/images/profile/profile-background2.png",
      courseTag: ["CSS", "#FAB9A8"],
      courseDescription:
        "simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s",
    },
    {
      courseImage: "/images/profile/profile-background.png",
      courseTag: ["JavaScript", "#EFB701"],
      courseDescription:
        "simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s",
    },
  ];

  return (
    <div>
      <Swiper
        loop={true}
        autoplay={{
          enabled: true,
          delay: 1,
        }}
        speed={8000}
        allowTouchMove={false}
        width={1500}
        breakpoints={{
          320: {
            slidesPerView: 1,
          },
          768: {
            slidesPerView: 2,
          },
          1024: {
            slidesPerView: 3,
          },
          1440: {
            slidesPerView: 3,
          },
        }}
        modules={[Autoplay]}
        className="swiper-wrapper"
      >
        {courseList.map((course, index) => (
          <SwiperSlide key={index}>
            <div className="course">
              <img src={course.courseImage} />
              <p className="description">{course.courseDescription}</p>
              <p
                className="tag"
                style={{ backgroundColor: course.courseTag[1] }}
              >
                {course.courseTag[0]}
              </p>
            </div>
          </SwiperSlide>
        ))}
      </Swiper>
     </div>
  );
}

export default Courses;
</code>```

I'm using SwiperSlide like this in other components, but this one gives me the hydration error. I've removed pieces of the code one by one and I can confirm that the hydration error only occurs when I'm using SwiperSlide.

What could be the cause?

Body:
I'm using the swiper.js, but when I use SwiperSlide I get the following error

Unhandled Runtime Error
Error: Text content does not match server-rendered HTML.

This only occurs when using SwiperSlide.

import styled from "styled-components";
import { Swiper, SwiperSlide } from "swiper/react";
import { Autoplay } from "swiper";
import "swiper/css/autoplay";

function Courses() {
  const courseList = [
    {
      courseImage: "/images/header-v2.png",
      courseTag: ["Python", "#4AB2FF"],
      courseDescription:
        "simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s",
    },
    {
      courseImage: "/images/html-header.png",
      courseTag: ["HTML", "#F06529"],
      courseDescription:
        "simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s",
    },
    {
      courseImage: "/images/profile/profile-background2.png",
      courseTag: ["CSS", "#FAB9A8"],
      courseDescription:
        "simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s",
    },
    {
      courseImage: "/images/profile/profile-background.png",
      courseTag: ["JavaScript", "#EFB701"],
      courseDescription:
        "simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s",
    },
  ];

  return (

      <Swiper
        loop={true}
        autoplay={{
          enabled: true,
          delay: 1,
        }}
        speed={8000}
        allowTouchMove={false}
        width={1500}
        breakpoints={{
          320: {
            slidesPerView: 1,
          },
          768: {
            slidesPerView: 2,
          },
          1024: {
            slidesPerView: 3,
          },
          1440: {
            slidesPerView: 3,
          },
        }}
        modules={[Autoplay]}
        className="swiper-wrapper"
      >
        {courseList.map((course, index) => (
          <SwiperSlide key={index}>

{course.courseDescription}

                {course.courseTag[0]}

          </SwiperSlide>
        ))}
      </Swiper>

  );
}

export default Courses;

I'm using SwiperSlide like this in other components, but this one gives me the hydration error. I've removed pieces of the code one by one and I can confirm that the hydration error only occurs when I'm using SwiperSlide.

What could be the cause?


问:
Handling an oauth callback request by nginx
I decide to add authentication to my dummy web app by using github's oauth2 service. I already have a nginx acting as reverse proxy so I decided to try to use him to handle authentication. What I am trying to get is to make nginx to ask for auth token by performing a POST request with the code value and return the github's json reply. I am totally new to nginx and I am not getting how to do that in the right way.

Here is the nginx's conf relevant part:

```<code>location /login {
  return 301 https://github.com/login/oauth/authorize?client_id=myclientidcode;
}

location /callback {
  proxy_method POST;
  proxy_set_header Accept application/json;
  proxy_pass https://github.com/login/oauth/access_token?client_id=myclientidcode&redirect_uri=http://myapp.net:8000/callback&client_secret=myclientsecretcode&code=$arg_code;
}
</code>```

As request hit the login location, client is redirected to the callback location and there a 502 error is returned. Nginx log reports this:

```<code>2023/01/08 16:10:13 [error] 28#28: *3 no resolver defined to resolve github.com, client: 172.17.0.1, server: localhost, request: "GET /callback?code=somecodeigotback HTTP/1.1", host: "myapp.net:8000"
172.17.0.1 - - [08/Jan/2023:16:10:13 +0000] "GET /callback?code=somecodeigotback HTTP/1.1" 502 559 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/80.0.3987.87 Chrome/80.0.3987.87 Safari/537.36" "-"
</code>```

The webapp runs in a minikube cluster. TIA.

Body:
I decide to add authentication to my dummy web app by using github's oauth2 service. I already have a nginx acting as reverse proxy so I decided to try to use him to handle authentication. What I am trying to get is to make nginx to ask for auth token by performing a POST request with the code value and return the github's json reply. I am totally new to nginx and I am not getting how to do that in the right way.

Here is the nginx's conf relevant part:

location /login {
  return 301 https://github.com/login/oauth/authorize?client_id=myclientidcode;
}

location /callback {
  proxy_method POST;
  proxy_set_header Accept application/json;
  proxy_pass https://github.com/login/oauth/access_token?client_id=myclientidcode&redirect_uri=http://myapp.net:8000/callback&client_secret=myclientsecretcode&code=$arg_code;
}

As request hit the login location, client is redirected to the callback location and there a 502 error is returned. Nginx log reports this:

2023/01/08 16:10:13 [error] 28#28: *3 no resolver defined to resolve github.com, client: 172.17.0.1, server: localhost, request: "GET /callback?code=somecodeigotback HTTP/1.1", host: "myapp.net:8000"
172.17.0.1 - - [08/Jan/2023:16:10:13 +0000] "GET /callback?code=somecodeigotback HTTP/1.1" 502 559 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/80.0.3987.87 Chrome/80.0.3987.87 Safari/537.36" "-"

The webapp runs in a minikube cluster. TIA.


问:
React native app getting closed trying to call RNReactNativeGetMusicFiles.getAll
I am tryingto develop a music player as a part of learning, and i am using the plugin "react-native-get-music-files" and I linked manually, Finally I am trying to load all music files in my device, and when i press the button app is getting closed, no error in the console.</p>
```<code>import { useEffect } from "react";
import { View, Text, Button } from "react-native"
import MusicFiles from 'react-native-get-music-files';

const MusicFilesList = () => {

    const loadMusicfiles = () => {
        MusicFiles.getAll({
            blured: true, // works only when 'cover' is set to true
            artist: true,
            duration: true, //default : true
            cover: false, //default : true,
            genre: true,
            title: true,
            cover: true,
            minimumSongDuration: 10000, // get songs bigger than 10000 miliseconds duration,
            fields: ['title', 'albumTitle', 'genre', 'lyrics', 'artwork', 'duration'] // for iOs Version
        }).then(tracks => {
            // do your stuff...
            console.log("Files : ", tracks);
        }).catch(error => {
            // catch the error
            console.log("Error occured while retriving the audio files! ", error);
        })
    }

    return <View>
        <Button title="Load Music Files" onPress={loadMusicfiles} />
    </View>
}

export default MusicFilesList;
</code>```

Body:
I am tryingto develop a music player as a part of learning, and i am using the plugin "react-native-get-music-files" and I linked manually, Finally I am trying to load all music files in my device, and when i press the button app is getting closed, no error in the console.

import { useEffect } from "react";
import { View, Text, Button } from "react-native"
import MusicFiles from 'react-native-get-music-files';

const MusicFilesList = () => {

    const loadMusicfiles = () => {
        MusicFiles.getAll({
            blured: true, // works only when 'cover' is set to true
            artist: true,
            duration: true, //default : true
            cover: false, //default : true,
            genre: true,
            title: true,
            cover: true,
            minimumSongDuration: 10000, // get songs bigger than 10000 miliseconds duration,
            fields: ['title', 'albumTitle', 'genre', 'lyrics', 'artwork', 'duration'] // for iOs Version
        }).then(tracks => {
            // do your stuff...
            console.log("Files : ", tracks);
        }).catch(error => {
            // catch the error
            console.log("Error occured while retriving the audio files! ", error);
        })
    }

    return <View>
        <Button title="Load Music Files" onPress={loadMusicfiles} />
    </View>
}

export default MusicFilesList;


问:
SvelteKit Audio Visualizer with AudioContext / createMediaElementSource
I wrote this audio visualizer in Svelte. And it works - but only on the first run. As soon as the source of the player is changed and it should play, I get the following error and the visualizer is not visible anymore:

DOMException: Failed to execute 'createMediaElementSource' on 'AudioContext': HTMLMediaElement already connected previously to a different MediaElementSourceNode.

I am basically aware that the error is probably that the const audioCtx = new AudioContext(); const source = audioCtx.createMediaElementSource(audioElement); is executed every time in the function and it should better be executed before. But I have already tried a few things to separate it out and pass the arguments to the function, but without success. Can anyone help me?

```<code><script>
    import { Plyr } from 'svelte-plyr';
    import NewTrackStore from '../../Store.js';
    let track;
    let audioElement;
    let canvas;
    let container;
    let player;
    let eventsToEmit = ['play'];

    NewTrackStore.subscribe((data) => {
      console.log(data);
      track = data;

      // restart player
      if (player) {
        player.source = {
    type: 'audio',
    title: track.title,
    sources: [{
      src: track.track.file,
      type: 'audio/mp3'
    },],
  };
  player.play();
      }
    });

    const startVisualizer = async () => {
     // Create AudioContext and MediaElementAudioSourceNode
        const audioCtx = new AudioContext();
        const source = audioCtx.createMediaElementSource(audioElement);

        // Create analyser and connect audio graph
        const analyser = audioCtx.createAnalyser();
        source.connect(analyser);
        analyser.connect(audioCtx.destination);

        // Set up analyser
        analyser.fftSize = 512;
        const buffer = new Uint8Array(analyser.frequencyBinCount);
        analyser.maxDecibels = -20;
        analyser.minDecibels = -80;

        // Get canvas context and set canvas dimensions to match container div
      const canvasCtx = canvas.getContext('2d');
      canvas.width = container.offsetWidth;
      canvas.height = container.offsetHeight;

      // Set canvas fill style
      canvasCtx.fillStyle = 'white';

      // Set up rendering variables
      const w = canvas.offsetWidth;
      const h = canvas.offsetHeight;

      // Start rendering
      audioCtx.resume().then(() => {
        requestAnimationFrame(render);
      });

      function render() {
        requestAnimationFrame(render);

        analyser.getByteFrequencyData(buffer);

        let x = 0;

        canvasCtx.clearRect(0, 0, w, h);

        for (let i = 0; i < buffer.length; ++i) {
          const y = buffer[i] / 255 * h;
          const width = w / analyser.frequencyBinCount;

          canvasCtx.fillRect(x, h - y, width, y);

          x += width;
        }
      }

  };

  let paused = true;
</script>

<svelte:head>
  <link rel="stylesheet" href="/css/plyr.css">
</svelte:head>
<div id="visualizer-container" bind:this={container}>
  <canvas bind:this={canvas}></canvas>
</div>

<Plyr eventsToEmit={eventsToEmit} bind:player={player}  on:play={startVisualizer} >
  <audio
    bind:this={audioElement}
    controls
    crossOrigin="anonymous"
  >
  <source src={track.track.file} type="audio/mp3" />
  </audio>
</Plyr>
</code>```

I tried to put the

```<code>const audioCtx = new AudioContext();
const source = audioCtx.createMediaElementSource(audioElement);
</code>```

outside of the function, with and without onMount and tried to pass the audioCtx and source as parameters.

Body:
I wrote this audio visualizer in Svelte. And it works - but only on the first run. As soon as the source of the player is changed and it should play, I get the following error and the visualizer is not visible anymore:

DOMException: Failed to execute 'createMediaElementSource' on 'AudioContext': HTMLMediaElement already connected previously to a different MediaElementSourceNode.

I am basically aware that the error is probably that the const audioCtx = new AudioContext(); const source = audioCtx.createMediaElementSource(audioElement); is executed every time in the function and it should better be executed before. But I have already tried a few things to separate it out and pass the arguments to the function, but without success. Can anyone help me?

<svelte:head>
  <link rel="stylesheet" href="/css/plyr.css">
</svelte:head>

  <canvas bind:this={canvas}></canvas>

<Plyr eventsToEmit={eventsToEmit} bind:player={player}  on:play={startVisualizer} >
  <audio
    bind:this={audioElement}
    controls
    crossOrigin="anonymous"
  >
  <source src={track.track.file} type="audio/mp3" />
  </audio>
</Plyr>

I tried to put the

const audioCtx = new AudioContext();
const source = audioCtx.createMediaElementSource(audioElement);

outside of the function, with and without onMount and tried to pass the audioCtx and source as parameters.


问:
Qt6 QClipboard doesn't put anything in the clipboard (Linux)
I've been trying to get a simple app to work on Linux using QClipboard to copy some information to the system clipboard.  The code that does the copy to clipboard is very simple:

        qDebug() << "Copying to clipboard:" << result;
        QClipboard *clipboard = QGuiApplication::clipboard();
        qDebug() << "Existing content (to be overwritten):" << clipboard->text(QClipboard::Clipboard);
        clipboard->setText(result, QClipboard::Clipboard);
        qDebug() << "Clipboard contents:" << clipboard->text(QClipboard::Clipboard);
```
<p>When it runs, the printed clipboard contents before <code>setText</code> show the existing contents of the clipboard and the printed clipboard contents after <code>setText</code> show the text that should have been copied to the clipboard. All looks okay.  However, nothing is in the clipboard.  If I run the same thing again, the existing clipboard contents is shown as empty:</p>
```$ ./output/linux/digraph # Then type "VE" and click "Copy to Clipboard"
Copying to clipboard: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"
Existing content (to be overwritten): "Manually copied to clipboard"
Clipboard contents: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"

# But clipboard is empty!

$ ./output/linux/digraph # Then type "VE" and click "Copy to Clipboard"
Copying to clipboard: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"
Existing content (to be overwritten): ""
Clipboard contents: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"

# Clipboard still empty!

$ ./output/linux/digraph # Then type "VE" and click "Copy to Clipboard"
Copying to clipboard: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"
Existing content (to be overwritten): ""
Clipboard contents: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"

# Clipboard still empty!
```

Is there something else I need to do to make the written clipboard contents be visible to other applications and to persist after the application quits?

The full source code of the application is here: https://github.com/abudden/digraph ; it works on Windows (but uses the Windows API to do the copy as I found QClipboard worked but was unreliable) and is arguably a bit pointless on Linux with Compose Key type features, but someone asked me if I could make it work on Linux, so I'm trying.

Body:
I've been trying to get a simple app to work on Linux using QClipboard to copy some information to the system clipboard.  The code that does the copy to clipboard is very simple:

        qDebug() << "Copying to clipboard:" << result;
        QClipboard *clipboard = QGuiApplication::clipboard();
        qDebug() << "Existing content (to be overwritten):" << clipboard->text(QClipboard::Clipboard);
        clipboard->setText(result, QClipboard::Clipboard);
        qDebug() << "Clipboard contents:" << clipboard->text(QClipboard::Clipboard);

When it runs, the printed clipboard contents before setText show the existing contents of the clipboard and the printed clipboard contents after setText show the text that should have been copied to the clipboard. All looks okay.  However, nothing is in the clipboard.  If I run the same thing again, the existing clipboard contents is shown as empty:

$ ./output/linux/digraph # Then type "VE" and click "Copy to Clipboard"
Copying to clipboard: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"
Existing content (to be overwritten): "Manually copied to clipboard"
Clipboard contents: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"

# But clipboard is empty!

$ ./output/linux/digraph # Then type "VE" and click "Copy to Clipboard"
Copying to clipboard: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"
Existing content (to be overwritten): ""
Clipboard contents: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"

# Clipboard still empty!

$ ./output/linux/digraph # Then type "VE" and click "Copy to Clipboard"
Copying to clipboard: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"
Existing content (to be overwritten): ""
Clipboard contents: "Version: v1.0.3-15-4700916fe26d\nCompiled 8th January 2023"

# Clipboard still empty!

Is there something else I need to do to make the written clipboard contents be visible to other applications and to persist after the application quits?

The full source code of the application is here: https://github.com/abudden/digraph ; it works on Windows (but uses the Windows API to do the copy as I found QClipboard worked but was unreliable) and is arguably a bit pointless on Linux with Compose Key type features, but someone asked me if I could make it work on Linux, so I'm trying.


问:
comparing groups of patients (allowing the user to choose the variable(s) by which grouping the data)
```<code>TD <- thyroid

library(readxl)
library(shiny)
library(ggplot2)
library(shinythemes)
library(DT)

ui <-shinyUI(fluidPage(pageWithSidebar(
  headerPanel("Test App"),
  sidebarPanel(
    selectInput("xaxis", "Choose a x variable", choices = names(TD)),
    selectInput("T4", "T4 Rate", choices = c("All","0 - 80","80 - 140","> 140")),
    selectInput("T3", "T4 Rate", choices = c("All","0 - 80","80 - 140","> 140")),
    selectInput("TSH", "T4 Rate", choices = c("All","0 - 80","80 - 140","> 140")),

    actionButton("goButton","Update")
  ),
  mainPanel(
    tabsetPanel(
      tabPanel('Plot1', plotOutput("plot1")),
      tabPanel('Plot2', plotOutput("plot2"))
    ))
)
))

server <- shinyServer(function(input,output, session){

  data1 <- reactive({
    if(input$T4 == "All"){
      TD
    }
    else if(input$T4 == "0 - 80"){
      TD[which(TD$T4 >= 0 & TD$T4 < 80),]

    }
    else if(input$T4 == "80 - 140"){
      TD[which(TD$T4 >= 80 & TD$T4 < 140),]

    }
    else{
      TD[which(TD$T4 >= 140),]

    }
  })

  x_var<- eventReactive(input$goButton, {
    input$xaxis
  })

  output$plot1 <- renderPlot({
    x <- x_var()

    p <- ggplot() + geom_bar(aes(x=TD[[x]], fill = TD$ThryroidClass))
    p  #+
      #theme(plot.title = element_text(hjust = 0.5, size=20))
  })
  output$plot2 <- renderPlot({
    x <- x_var()

    p <- ggplot() + geom_bar(aes(x=data1[[x]], fill = TD$ThryroidClass))
    p  #+
      #theme(plot.title = element_text(hjust = 0.5, size=20))
  })
})

shinyApp(ui,server)

</code>```

I m working on the thyroid dataset
i wanna compare groups of patients which are probably sick from thyroid based on the T4 rate.
THis is why i have created a subset of my original according to that rate.
i have done 2 plos, the one with the whole dataset works perfectly,  but the second with the sub set five me the followinf error : Error[object object]
How can i handle this please??

Body:
TD <- thyroid

library(readxl)
library(shiny)
library(ggplot2)
library(shinythemes)
library(DT)

ui <-shinyUI(fluidPage(pageWithSidebar(
  headerPanel("Test App"),
  sidebarPanel(
    selectInput("xaxis", "Choose a x variable", choices = names(TD)),
    selectInput("T4", "T4 Rate", choices = c("All","0 - 80","80 - 140","> 140")),
    selectInput("T3", "T4 Rate", choices = c("All","0 - 80","80 - 140","> 140")),
    selectInput("TSH", "T4 Rate", choices = c("All","0 - 80","80 - 140","> 140")),

    actionButton("goButton","Update")
  ),
  mainPanel(
    tabsetPanel(
      tabPanel('Plot1', plotOutput("plot1")),
      tabPanel('Plot2', plotOutput("plot2"))
    ))
)
))

server <- shinyServer(function(input,output, session){

  data1 <- reactive({
    if(input$T4 == "All"){
      TD
    }
    else if(input$T4 == "0 - 80"){
      TD[which(TD$T4 >= 0 & TD$T4 < 80),]

    }
    else if(input$T4 == "80 - 140"){
      TD[which(TD$T4 >= 80 & TD$T4 < 140),]

    }
    else{
      TD[which(TD$T4 >= 140),]

    }
  })

  x_var<- eventReactive(input$goButton, {
    input$xaxis
  })

  output$plot1 <- renderPlot({
    x <- x_var()

    p <- ggplot() + geom_bar(aes(x=TD[[x]], fill = TD$ThryroidClass))
    p  #+
      #theme(plot.title = element_text(hjust = 0.5, size=20))
  })
  output$plot2 <- renderPlot({
    x <- x_var()

    p <- ggplot() + geom_bar(aes(x=data1[[x]], fill = TD$ThryroidClass))
    p  #+
      #theme(plot.title = element_text(hjust = 0.5, size=20))
  })
})

shinyApp(ui,server)

I m working on the thyroid dataset
i wanna compare groups of patients which are probably sick from thyroid based on the T4 rate.
THis is why i have created a subset of my original according to that rate.
i have done 2 plos, the one with the whole dataset works perfectly,  but the second with the sub set five me the followinf error : Error[object object]
How can i handle this please??


问:
Keras class weights for nested output
I have a network in keras with 2 Conv2d layers and 3 dense layers. The input is image-like data and I want to perform object detection with a yolo-like algorithm, meaning I divide the image into boxes of pixels and look for one object per box. The output has the shape

```<code>5*5*13
</code>```

Where the 5*5 correspond to the different boxes and the 13 correspond to 13 different classes.
The inner tensor with 13 values will always have one value equal to 1 and all others equal to 0. The background class will have a 1 in the first location and 0 elsewhere, this class is by far the most common (~95%).
When training the network just guesses class 1 everytime, so I obtain [1,0,...] always, which achieves an accuracy of about 95% (who would have guessed). I wanted to add class weights but the keras model.fit(..., class_weight=cl_weights) throws the following error:

```<code>ValueError: `class_weight` not supported for 3+ dimensional targets.
</code>```

where I tried the following class weights:

```<code>cl_weights= {0: 0.015, 1 : 0.985,2: 0.985,3: 0.985,4: 0.985,5: 0.985,6: 0.985
               ,7: 0.985,8: 0.985,9: 0.985,10: 0.985,11: 0.985,12: 0.985}
</code>```

I cant change anything about the dataset, atleast nothing that I am aware of, as the data is just structured like that. Thats why I was hoping there might be some workaround to the class_weights issue

Title: Keras class weights for nested output

Body:
I have a network in keras with 2 Conv2d layers and 3 dense layers. The input is image-like data and I want to perform object detection with a yolo-like algorithm, meaning I divide the image into boxes of pixels and look for one object per box. The output has the shape

5*5*13

Where the 5*5 correspond to the different boxes and the 13 correspond to 13 different classes.
The inner tensor with 13 values will always have one value equal to 1 and all others equal to 0. The background class will have a 1 in the first location and 0 elsewhere, this class is by far the most common (~95%).
When training the network just guesses class 1 everytime, so I obtain [1,0,...] always, which achieves an accuracy of about 95% (who would have guessed). I wanted to add class weights but the keras model.fit(..., class_weight=cl_weights) throws the following error:

ValueError: `class_weight` not supported for 3+ dimensional targets.

where I tried the following class weights:

cl_weights= {0: 0.015, 1 : 0.985,2: 0.985,3: 0.985,4: 0.985,5: 0.985,6: 0.985
               ,7: 0.985,8: 0.985,9: 0.985,10: 0.985,11: 0.985,12: 0.985}

I cant change anything about the dataset, atleast nothing that I am aware of, as the data is just structured like that. Thats why I was hoping there might be some workaround to the class_weights issue


问:
Can parameters depend on a parameter in a loop invariant in ada?

Please can you tell me whether or not the parameters (in or out or in out) and the depends clause, are correct for the rest of the program.

Question: I am unsure if the loop invariant can 'use' a parameter in order to make it an in parameter (or initialise one to make it an out).

For example if this line was missing Aux : Integer := X; would x be made an in parameter here:

Loop Invariant (Z = X + Aux - Y) ?

Also does Z depend on X because of the loop invariant? I am just unsure if the loop invariant works like pre and post conditions or if it is actually part of the program where parameters can be used etc..

Here is the ads file:

```<code>pragma SPARK MODE;
procedure Myproc (X : in Integer; Y : in Integer; Z : out Integer)
with Depends => (Z => (Y,Z)),
     Post => (Z = X - Y);
</code>```

here is the adb file:

```<code>pragma SPARK MODE;
procedure Myproc (X : in Integer; Y : in Integer; Z : out Integer) is
    Aux : Integer := X;
begin
    Z := Y;
    loop
        pragma Loop Invariant (Z = X + Aux - Y);
        exit when Aux = 0;
        Aux := Aux - 1;
        Z := Z - 2;
    end loop;
end Myproc;
</code>```

I tried in Gnat studio and am now unsure

Body:
Please can you tell me whether or not the parameters (in or out or in out) and the depends clause, are correct for the rest of the program.

Question: I am unsure if the loop invariant can 'use' a parameter in order to make it an in parameter (or initialise one to make it an out).

For example if this line was missing Aux : Integer := X; would x be made an in parameter here:

Loop Invariant (Z = X + Aux - Y) ?

Also does Z depend on X because of the loop invariant? I am just unsure if the loop invariant works like pre and post conditions or if it is actually part of the program where parameters can be used etc..

Here is the ads file:

pragma SPARK MODE;
procedure Myproc (X : in Integer; Y : in Integer; Z : out Integer)
with Depends => (Z => (Y,Z)),
     Post => (Z = X - Y);

here is the adb file:

pragma SPARK MODE;
procedure Myproc (X : in Integer; Y : in Integer; Z : out Integer) is
    Aux : Integer := X;
begin
    Z := Y;
    loop
        pragma Loop Invariant (Z = X + Aux - Y);
        exit when Aux = 0;
        Aux := Aux - 1;
        Z := Z - 2;
    end loop;
end Myproc;

I tried in Gnat studio and am now unsure


问:
docker-compose does not run in gitlab CICD after pull image
I have a project and I use redis in this project.

This is my .gitlab-cu.yml

```<code>image: node:latest

stages:
  - build
  - deploy

build:
  image: docker:stable
  services:
    - docker:dind
  stage: build
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - docker build --pull -t "$DOCKER_IMAGE" .
    - docker push "$DOCKER_IMAGE"

deploy:
  stage: deploy
  services:
    - redis:latest
  script:
    - ssh $SSH_PRIVATE_KEY $USER_NAME@$HOST_NAME docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - ssh $SSH_PRIVATE_KEY $USER_NAME@$HOST_NAME
      docker run --name=$CI_PROJECT_NAME --restart=always --network="host" -v "/app/storage:/src/storage" -d $DOCKER_IMAGE
    - ssh -o StrictHostKeyChecking=no -i $SSH_PRIVATE_KEY $USER_NAME@$HOST_NAME docker compose up
</code>```

And this my docker-compose.yml:

```<code>version: "3.2"

services:
  redis:
    image: redis:latest
    volumes:
      - redisdata:/data/
    command: --port 6379
    ports:
      - "6379:6379"
    expose:
      - "6379"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
volumes:
  redisdata:
</code>```

everything is OK, but last line not work for me:

```<code>- ssh -o StrictHostKeyChecking=no -i $SSH_PRIVATE_KEY $USER_NAME@$HOST_NAME docker compose up
</code>```

So, my redis image not running in this container

Note: I want 1 container with 2 images contains my project and redis

My redis image not running

So, my redis image not running in this container

Note: I want 1 container with 2 images contains my project and redis

Body:
I have a project and I use redis in this project.

This is my .gitlab-cu.yml

image: node:latest

stages:
  - build
  - deploy

build:
  image: docker:stable
  services:
    - docker:dind
  stage: build
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - docker build --pull -t "$DOCKER_IMAGE" .
    - docker push "$DOCKER_IMAGE"

deploy:
  stage: deploy
  services:
    - redis:latest
  script:
    - ssh $SSH_PRIVATE_KEY $USER_NAME@$HOST_NAME docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
    - ssh $SSH_PRIVATE_KEY $USER_NAME@$HOST_NAME
      docker run --name=$CI_PROJECT_NAME --restart=always --network="host" -v "/app/storage:/src/storage" -d $DOCKER_IMAGE
    - ssh -o StrictHostKeyChecking=no -i $SSH_PRIVATE_KEY $USER_NAME@$HOST_NAME docker compose up

And this my docker-compose.yml:

version: "3.2"

services:
  redis:
    image: redis:latest
    volumes:
      - redisdata:/data/
    command: --port 6379
    ports:
      - "6379:6379"
    expose:
      - "6379"
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
volumes:
  redisdata:

everything is OK, but last line not work for me:

- ssh -o StrictHostKeyChecking=no -i $SSH_PRIVATE_KEY $USER_NAME@$HOST_NAME docker compose up

So, my redis image not running in this container

Note: I want 1 container with 2 images contains my project and redis

My redis image not running

So, my redis image not running in this container

Note: I want 1 container with 2 images contains my project and redis


问:
How to instantiate an object complying with zod schema defined
In my React project, I have integrated the zod library, like so:

const schema = z.object({
  id: z.string().optional(),
  name: z.string().min(1, "Name is required"),
  country: z.string().min(1, "Country is required")
});

type Customer = z.infer<typeof schema>;
```

I am trying to instantiate an object of the type Customer.

In one of my components, I try to use the type in this manner:

I can't figure out what the right syntax would be for this:
const [customer, setCustomer] = useState(new Customer());

The error I get on that new Customer() syntax is: 'Customer' only refers to a type, but is being used as a value here.ts(2693)

I figured I could maybe declare a class of the Customer type, but that didn't work either.

Got any ideas, please?

Body:
In my React project, I have integrated the zod library, like so:

const schema = z.object({
  id: z.string().optional(),
  name: z.string().min(1, "Name is required"),
  country: z.string().min(1, "Country is required")
});

type Customer = z.infer<typeof schema>;

I am trying to instantiate an object of the type Customer.

In one of my components, I try to use the type in this manner:

I can't figure out what the right syntax would be for this:
const [customer, setCustomer] = useState(new Customer());

The error I get on that new Customer() syntax is: 'Customer' only refers to a type, but is being used as a value here.ts(2693)

I figured I could maybe declare a class of the Customer type, but that didn't work either.

Got any ideas, please?


问:
How to check if a model is an intermediate model
Taking the example in the docs, I'm trying to check if a model is an intermediate model.

from django.db import models

class Person(models.Model):
    name = models.CharField(max_length=128)

    def __str__(self):
        return self.name

class Group(models.Model):
    name = models.CharField(max_length=128)
    members = models.ManyToManyField(Person, through='Membership')

    def __str__(self):
        return self.name

class Membership(models.Model):
    person = models.ForeignKey(Person, on_delete=models.CASCADE)
    group = models.ForeignKey(Group, on_delete=models.CASCADE)
    date_joined = models.DateField()
    invite_reason = models.CharField(max_length=64)

```
<p>So a function like this, that takes a model as input and returns true if the model is an intermediate model and false otherwise.</p>
<pre class="lang-py prettyprint-override"><code>def is_intermediate(model):
    pass

# is_intermediate(Person) -> False
# is_intermediate(Group) -> False
# is_intermediate(Membership) -> True
</code>```

I believe Django REST Framework has a way of doing this with the has_through_model attribute. Looking at that, I wrote this:

def is_intermediate(model):
    for field in model._meta.get_fields():
        if field.is_relation:
            for related_field in field.related_model._meta.get_fields():
                through = getattr(related_field.remote_field, "through", None)
                if through and not through._meta.auto_created and through == model._meta.model:
                    return True
    return False
```

And it works. But to me, this sounds entirely inefficient. Is there a more performant way of finding if a model is intermediate?

Body:
Taking the example in the docs, I'm trying to check if a model is an intermediate model.

from django.db import models

class Person(models.Model):
    name = models.CharField(max_length=128)

    def __str__(self):
        return self.name

class Group(models.Model):
    name = models.CharField(max_length=128)
    members = models.ManyToManyField(Person, through='Membership')

    def __str__(self):
        return self.name

class Membership(models.Model):
    person = models.ForeignKey(Person, on_delete=models.CASCADE)
    group = models.ForeignKey(Group, on_delete=models.CASCADE)
    date_joined = models.DateField()
    invite_reason = models.CharField(max_length=64)

So a function like this, that takes a model as input and returns true if the model is an intermediate model and false otherwise.

def is_intermediate(model):
    pass

# is_intermediate(Person) -> False
# is_intermediate(Group) -> False
# is_intermediate(Membership) -> True

I believe Django REST Framework has a way of doing this with the has_through_model attribute. Looking at that, I wrote this:

def is_intermediate(model):
    for field in model._meta.get_fields():
        if field.is_relation:
            for related_field in field.related_model._meta.get_fields():
                through = getattr(related_field.remote_field, "through", None)
                if through and not through._meta.auto_created and through == model._meta.model:
                    return True
    return False

And it works. But to me, this sounds entirely inefficient. Is there a more performant way of finding if a model is intermediate?


问:
Vuetify v-autocomplete is not displayed at all, is not rendered, nothing is displayed
I have this code:

```<code><template>
  <div>
    <v-autocomplete
        label="Autocomplete"
        :items="['California', 'Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming']"
    ></v-autocomplete>
  </div>
</template>

<script>
export default {
name: "TestPage"
}
</script>

<style scoped>

</style>
</code>```

Nothing is displayed on that page (only Home and Footer. When I view its HTML, I get this:

What am I doing wrong?

The vuetify is in my dependencies, in package.json:

```<code>
 "devDependencies": {
    ...
    "@nuxtjs/vuetify": "^1.12.3",
    ...
</code>```

Body:
I have this code:

<template>

    <v-autocomplete
        label="Autocomplete"
        :items="['California', 'Colorado', 'Florida', 'Georgia', 'Texas', 'Wyoming']"
    ></v-autocomplete>

</template>

Nothing is displayed on that page (only Home and Footer. When I view its HTML, I get this:

What am I doing wrong?

The vuetify is in my dependencies, in package.json:

 "devDependencies": {
    ...
    "@nuxtjs/vuetify": "^1.12.3",
    ...


问:
Legend text are not showing for the legend position as 'bottom' for google chart
I am using google chart to draw a line chart, The chart is drawing properly but the legend text at the bottom is not showing and the VAxis ticks also.


问:
Firebase Analytics API StatusRunTimeException with XdsInitializationException
My problem - when start runReportRequest catched exeptions: StatusRunTimeException, XdsInitializationException. It is problem exist only when start jar-file, and when start in IDE that's ok and problem doesn't exist. Full log error:

янв. 08, 2023 8:49:41 PM io.grpc.internal.ManagedChannelImpl$NameResolverListener handleErrorInSyncContext
WARNING: [Channel<1>: (analyticsdata.googleapis.com:443)] Failed to resolve name. status=Status{code=UNAVAILABLE, description=Failed to initialize xDS, cause=io.grpc.xds.XdsInitializationException: Cannot find bootstrap configuration
Environment variables searched:

GRPC_XDS_BOOTSTRAP

GRPC_XDS_BOOTSTRAP_CONFIG

`Java System Properties searched:

io.grpc.xds.bootstrap

io.grpc.xds.bootstrapConfig
at io.grpc.xds.BootstrapperImpl.bootstrap(BootstrapperImpl.java:110)
at io.grpc.xds.SharedXdsClientPoolProvider.getOrCreate(SharedXdsClientPoolProvider.java:87)
at io.grpc.xds.XdsNameResolver.start(XdsNameResolver.java:179)
at io.grpc.internal.ManagedChannelImpl.exitIdleMode(ManagedChannelImpl.java:418)
at io.grpc.internal.ManagedChannelImpl$RealChannel$2.run(ManagedChannelImpl.java:981)
at io.grpc.SynchronizationContext.drain(SynchronizationContext.java:95)
at io.grpc.SynchronizationContext.execute(SynchronizationContext.java:127)
at io.grpc.internal.ManagedChannelImpl$RealChannel.newCall(ManagedChannelImpl.java:978)
at com.google.api.gax.grpc.GrpcChannelUUIDInterceptor.interceptCall(GrpcChannelUUIDInterceptor.java:52)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
at com.google.api.gax.grpc.GrpcHeaderInterceptor.interceptCall(GrpcHeaderInterceptor.java:80)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
at com.google.api.gax.grpc.GrpcMetadataHandlerInterceptor.interceptCall(GrpcMetadataHandlerInterceptor.java:54)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
at io.grpc.internal.ManagedChannelImpl.newCall(ManagedChannelImpl.java:920)
at io.grpc.internal.ForwardingManagedChannel.newCall(ForwardingManagedChannel.java:63)
at com.google.api.gax.grpc.ChannelPool$AffinityChannel.newCall(ChannelPool.java:514)
at com.google.api.gax.grpc.ChannelPool.newCall(ChannelPool.java:143)
at com.google.api.gax.grpc.GrpcClientCalls.newCall(GrpcClientCalls.java:99)
at com.google.api.gax.grpc.GrpcDirectCallable.futureCall(GrpcDirectCallable.java:60)
at com.google.api.gax.grpc.GrpcUnaryRequestParamCallable.futureCall(GrpcUnaryRequestParamCallable.java:65)
at com.google.api.gax.grpc.GrpcExceptionCallable.futureCall(GrpcExceptionCallable.java:64)
at com.google.api.gax.rpc.AttemptCallable.call(AttemptCallable.java:87)
at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:63)
at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:41)
at com.google.api.gax.tracing.TracedUnaryCallable.futureCall(TracedUnaryCallable.java:75)
at com.google.api.gax.rpc.UnaryCallable$1.futureCall(UnaryCallable.java:126)
at com.google.api.gax.rpc.UnaryCallable.futureCall(UnaryCallable.java:87)
at com.google.api.gax.rpc.UnaryCallable.call(UnaryCallable.java:112)
at com.google.analytics.data.v1beta.BetaAnalyticsDataClient.runRealtimeReport(BetaAnalyticsDataClient.java:672)
at ru.vkcleanlite.ApplicationKt.getRealtimeReport(Application.kt:87)
at ru.vkcleanlite.ApplicationKt$startRequests$1.run(Application.kt:135)
}
com.google.api.gax.rpc.UnavailableException: io.grpc.StatusRuntimeException: UNAVAILABLE: Failed to initialize xDS`

Initialization:

```<code>BetaAnalyticsDataClient.create().use { analyticsData ->
        val request = RunRealtimeReportRequest.newBuilder()
            .setProperty("properties/$propertyId")
            .addDimensions(Dimension.newBuilder().setName("city"))
            .addMetrics(Metric.newBuilder().setName("activeUsers"))
            .build()

        val response = analyticsData.runRealtimeReport(request)
    }
</code>```

How, I see, need add environment variables GRPC_XDS_BOOTSTRAP GRPC_XDS_BOOTSTRAP_CONFIG, but where get this is files? Official guide shared links on Git, where source link unsaffed, browser denied. But in this time, I'm not sure, what problem in environment variable, because in IDE that's all work, and in quick start (offical firebase guide for GA4) not contains information about settings for grps-connection. Pehraps, my research incorrect and problem another. For now updated grpc, but it not fixed problem. How it fixed? Thanks!

Body:
My problem - when start runReportRequest catched exeptions: StatusRunTimeException, XdsInitializationException. It is problem exist only when start jar-file, and when start in IDE that's ok and problem doesn't exist. Full log error:

янв. 08, 2023 8:49:41 PM io.grpc.internal.ManagedChannelImpl$NameResolverListener handleErrorInSyncContext
WARNING: [Channel<1>: (analyticsdata.googleapis.com:443)] Failed to resolve name. status=Status{code=UNAVAILABLE, description=Failed to initialize xDS, cause=io.grpc.xds.XdsInitializationException: Cannot find bootstrap configuration
Environment variables searched:

GRPC_XDS_BOOTSTRAP

GRPC_XDS_BOOTSTRAP_CONFIG

`Java System Properties searched:

io.grpc.xds.bootstrap

io.grpc.xds.bootstrapConfig
at io.grpc.xds.BootstrapperImpl.bootstrap(BootstrapperImpl.java:110)
at io.grpc.xds.SharedXdsClientPoolProvider.getOrCreate(SharedXdsClientPoolProvider.java:87)
at io.grpc.xds.XdsNameResolver.start(XdsNameResolver.java:179)
at io.grpc.internal.ManagedChannelImpl.exitIdleMode(ManagedChannelImpl.java:418)
at io.grpc.internal.ManagedChannelImpl$RealChannel$2.run(ManagedChannelImpl.java:981)
at io.grpc.SynchronizationContext.drain(SynchronizationContext.java:95)
at io.grpc.SynchronizationContext.execute(SynchronizationContext.java:127)
at io.grpc.internal.ManagedChannelImpl$RealChannel.newCall(ManagedChannelImpl.java:978)
at com.google.api.gax.grpc.GrpcChannelUUIDInterceptor.interceptCall(GrpcChannelUUIDInterceptor.java:52)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
at com.google.api.gax.grpc.GrpcHeaderInterceptor.interceptCall(GrpcHeaderInterceptor.java:80)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
at com.google.api.gax.grpc.GrpcMetadataHandlerInterceptor.interceptCall(GrpcMetadataHandlerInterceptor.java:54)
at io.grpc.ClientInterceptors$InterceptorChannel.newCall(ClientInterceptors.java:156)
at io.grpc.internal.ManagedChannelImpl.newCall(ManagedChannelImpl.java:920)
at io.grpc.internal.ForwardingManagedChannel.newCall(ForwardingManagedChannel.java:63)
at com.google.api.gax.grpc.ChannelPool$AffinityChannel.newCall(ChannelPool.java:514)
at com.google.api.gax.grpc.ChannelPool.newCall(ChannelPool.java:143)
at com.google.api.gax.grpc.GrpcClientCalls.newCall(GrpcClientCalls.java:99)
at com.google.api.gax.grpc.GrpcDirectCallable.futureCall(GrpcDirectCallable.java:60)
at com.google.api.gax.grpc.GrpcUnaryRequestParamCallable.futureCall(GrpcUnaryRequestParamCallable.java:65)
at com.google.api.gax.grpc.GrpcExceptionCallable.futureCall(GrpcExceptionCallable.java:64)
at com.google.api.gax.rpc.AttemptCallable.call(AttemptCallable.java:87)
at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:63)
at com.google.api.gax.rpc.RetryingCallable.futureCall(RetryingCallable.java:41)
at com.google.api.gax.tracing.TracedUnaryCallable.futureCall(TracedUnaryCallable.java:75)
at com.google.api.gax.rpc.UnaryCallable$1.futureCall(UnaryCallable.java:126)
at com.google.api.gax.rpc.UnaryCallable.futureCall(UnaryCallable.java:87)
at com.google.api.gax.rpc.UnaryCallable.call(UnaryCallable.java:112)
at com.google.analytics.data.v1beta.BetaAnalyticsDataClient.runRealtimeReport(BetaAnalyticsDataClient.java:672)
at ru.vkcleanlite.ApplicationKt.getRealtimeReport(Application.kt:87)
at ru.vkcleanlite.ApplicationKt$startRequests$1.run(Application.kt:135)
}
com.google.api.gax.rpc.UnavailableException: io.grpc.StatusRuntimeException: UNAVAILABLE: Failed to initialize xDS`

Initialization:

BetaAnalyticsDataClient.create().use { analyticsData ->
        val request = RunRealtimeReportRequest.newBuilder()
            .setProperty("properties/$propertyId")
            .addDimensions(Dimension.newBuilder().setName("city"))
            .addMetrics(Metric.newBuilder().setName("activeUsers"))
            .build()

        val response = analyticsData.runRealtimeReport(request)
    }

How, I see, need add environment variables GRPC_XDS_BOOTSTRAP GRPC_XDS_BOOTSTRAP_CONFIG, but where get this is files? Official guide shared links on Git, where source link unsaffed, browser denied. But in this time, I'm not sure, what problem in environment variable, because in IDE that's all work, and in quick start (offical firebase guide for GA4) not contains information about settings for grps-connection. Pehraps, my research incorrect and problem another. For now updated grpc, but it not fixed problem. How it fixed? Thanks!


问:
How do I put a camera on a separate window without lag?
The current way I'm doing it works, but is really heavy on performance, and I'd like to reduce the lag as much as possible.

Basically I'm copying the pixels of said FlxCamera onto an FlxSprite, and then I'm rendering that FlxSprite's pixels to a normal Sprite (openfl.display.Sprite), which then gets put onto the window. The lag doesn't seem to be coming from putting the camera onto an FlxSprite, it seems to be coming from putting the FlxSprite onto the Sprite (this is all in the update function btw). Is there a better way to put the FlxSprite onto the Sprite without having to copy the pixels every single frame? Or possibly a better way of copying the pixels that lags less?

This is the current code for it (just the FlxSprite to Sprite part):

```<code>notesSprite.graphics.clear();
notesSprite.graphics.beginBitmapFill(cameraSprite.pixels, new Matrix());
notesSprite.graphics.drawRect(0, 0, cameraSprite.pixels.width, cameraSprite.pixels.height);
notesSprite.graphics.endFill();
</code>```

I've tried removing endFill(), nothing changed. I've tried removing drawRect() from update and only calling it once but that made the Sprite empty. I've scrolled through all the functions and variables to see if there was another way, but it didn't seem like it.

running clear() does seem to reduce the lag a lot, but considering I have a really good pc and it's still bringing me down to 60 fps, I wanna make sure the game is playable on other people's pcs that may or may not be as good. I've yet to test this on a worse pc (I'm gonna send a build to my friend soon so he can test it), but seeing as I'm working with a rhythm game I wanna make sure that the fps stays at 60 or higher constantly.

Body:
The current way I'm doing it works, but is really heavy on performance, and I'd like to reduce the lag as much as possible.

Basically I'm copying the pixels of said FlxCamera onto an FlxSprite, and then I'm rendering that FlxSprite's pixels to a normal Sprite (openfl.display.Sprite), which then gets put onto the window. The lag doesn't seem to be coming from putting the camera onto an FlxSprite, it seems to be coming from putting the FlxSprite onto the Sprite (this is all in the update function btw). Is there a better way to put the FlxSprite onto the Sprite without having to copy the pixels every single frame? Or possibly a better way of copying the pixels that lags less?

This is the current code for it (just the FlxSprite to Sprite part):

notesSprite.graphics.clear();
notesSprite.graphics.beginBitmapFill(cameraSprite.pixels, new Matrix());
notesSprite.graphics.drawRect(0, 0, cameraSprite.pixels.width, cameraSprite.pixels.height);
notesSprite.graphics.endFill();

I've tried removing endFill(), nothing changed. I've tried removing drawRect() from update and only calling it once but that made the Sprite empty. I've scrolled through all the functions and variables to see if there was another way, but it didn't seem like it.

running clear() does seem to reduce the lag a lot, but considering I have a really good pc and it's still bringing me down to 60 fps, I wanna make sure the game is playable on other people's pcs that may or may not be as good. I've yet to test this on a worse pc (I'm gonna send a build to my friend soon so he can test it), but seeing as I'm working with a rhythm game I wanna make sure that the fps stays at 60 or higher constantly.


问:
Not able to insert records from one table to another table using Pyspark SQL in AWS Glue job
I am unable to insert records from one table to another table using Pyspark SQL in AWS Glue job. Its not prompting any error as well..

Table1 name : details_info

```<code>spark.sql('select count(*) from details_info').show();

count: 50000
</code>```

Table2 name : goals_info

```<code>spark.sql('select count(*) from goals_info').show();

count: 0
</code>```

I am trying to insert data from "details_info" table to "goals_info" table with below querie

```<code>spark.sql("INSERT INTO goals_info SELECT * FROM details_info")

I am expecting the count of goals_info as 50000 but it is showing me as 0 after
executing above sql statement

spark.sql('select count(*) from goals_info').show();
count: 0
</code>```

code block is executing with out throwing any error but data is not inserting as count is showing as 0. Could anybody help me understand what might be the reason?

I even tried with write.insertInto() pyspark method , but the count is still showing a zero

```<code> view_df = spark.table("details_info")
 view_df.write.insertInto("goals_info")
</code>```

Body:
I am unable to insert records from one table to another table using Pyspark SQL in AWS Glue job. Its not prompting any error as well..

Table1 name : details_info

spark.sql('select count(*) from details_info').show();

count: 50000

Table2 name : goals_info

spark.sql('select count(*) from goals_info').show();

count: 0

I am trying to insert data from "details_info" table to "goals_info" table with below querie

spark.sql("INSERT INTO goals_info SELECT * FROM details_info")

I am expecting the count of goals_info as 50000 but it is showing me as 0 after
executing above sql statement

spark.sql('select count(*) from goals_info').show();
count: 0

code block is executing with out throwing any error but data is not inserting as count is showing as 0. Could anybody help me understand what might be the reason?

I even tried with write.insertInto() pyspark method , but the count is still showing a zero

 view_df = spark.table("details_info")
 view_df.write.insertInto("goals_info")


问:
Fixing includes with Bazel
I am trying to fix includes with a local copy of openssl with bazel 5.0 on Mac using the clang compiler.

The file structure is as follows.

```<code>WORKSPACE
external
  openssl
    libcrypto.a
    libssl.a
    include
      openssl
        conf.h
        .
        .
        .
</code>```

Whenever I build openssl or anything dependent on it like https://github.com/nelhage/rules_boost. I get errors like the following.

```<code>In file included from external/com_github_nelhage_rules_boost/src/build_asio_ssl.cpp:1:
In file included from external/boost/boost/asio/ssl/impl/src.hpp:22:
In file included from external/boost/boost/asio/ssl/impl/context.ipp:24:
In file included from external/boost/boost/asio/ssl/context.hpp:23:
In file included from external/boost/boost/asio/ssl/context_base.hpp:19:
external/boost/boost/asio/ssl/detail/openssl_types.hpp:23:10: fatal error: 'openssl/conf.h' file not found
#include <openssl/conf.h>
</code>```

or

```<code>In file included from contrib/epee/src/network_throttle-detail.cpp:58:
In file included from ./contrib/epee/include/net/abstract_tcp_server2.h:49:
In file included from external/boost/boost/asio/ssl.hpp:18:
In file included from external/boost/boost/asio/ssl/context.hpp:23:
In file included from external/boost/boost/asio/ssl/context_base.hpp:19:
In file included from external/boost/boost/asio/ssl/detail/openssl_types.hpp:23:
external/openssl/include/openssl/conf.h:19:11: fatal error: 'openssl/macros.h' file not found
# include <openssl/macros.h>
</code>```

I am curious what other people have done to fix this sort of thing. I have tried adding includes = ["external/openssl/include/openssl"] and includes = ["include/openssl"] to the cc_library rule for openssl. I have also tried strip_include_prefix = "include/openssl" from C++ / Bazel: How to include angle <> bracket system headers?.

Title: Fixing includes with Bazel

Body:
I am trying to fix includes with a local copy of openssl with bazel 5.0 on Mac using the clang compiler.

The file structure is as follows.

WORKSPACE
external
  openssl
    libcrypto.a
    libssl.a
    include
      openssl
        conf.h
        .
        .
        .

Whenever I build openssl or anything dependent on it like https://github.com/nelhage/rules_boost. I get errors like the following.

In file included from external/com_github_nelhage_rules_boost/src/build_asio_ssl.cpp:1:
In file included from external/boost/boost/asio/ssl/impl/src.hpp:22:
In file included from external/boost/boost/asio/ssl/impl/context.ipp:24:
In file included from external/boost/boost/asio/ssl/context.hpp:23:
In file included from external/boost/boost/asio/ssl/context_base.hpp:19:
external/boost/boost/asio/ssl/detail/openssl_types.hpp:23:10: fatal error: 'openssl/conf.h' file not found
#include <openssl/conf.h>

or

In file included from contrib/epee/src/network_throttle-detail.cpp:58:
In file included from ./contrib/epee/include/net/abstract_tcp_server2.h:49:
In file included from external/boost/boost/asio/ssl.hpp:18:
In file included from external/boost/boost/asio/ssl/context.hpp:23:
In file included from external/boost/boost/asio/ssl/context_base.hpp:19:
In file included from external/boost/boost/asio/ssl/detail/openssl_types.hpp:23:
external/openssl/include/openssl/conf.h:19:11: fatal error: 'openssl/macros.h' file not found
# include <openssl/macros.h>

I am curious what other people have done to fix this sort of thing. I have tried adding includes = ["external/openssl/include/openssl"] and includes = ["include/openssl"] to the cc_library rule for openssl. I have also tried strip_include_prefix = "include/openssl" from C++ / Bazel: How to include angle <> bracket system headers?.


问:
Assistance with NGINX and Regex Rustexp Parsing with Vector VRL in YAML .yml Format
I am attempting to parse an unfiltered & unformatted generic NGINX access log using Vector VRL. I need am looking for a couple of examples and a push in the right direction, my first attempt using VRL syntax syntax but I have experience with basic regex and Sumo Logic (other logging systems).

Here is an example when I mean generic basic NGINX access log: (sourced from Digital Ocean's blog)

47.29.201.179 - - [28/Feb/2019:13:17:10 +0000] "GET /?p=1 HTTP/2.0" 200 5316 "https://domain1.com/?p=1" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" "2.75"

My goal is to parse and transform the log into the following below JSON presentation format, or at least in JSON so I can then use JQ to interpret the log with the below. But you can see an idea of the fields I am looking to parse with the message key names:

```<code>{
"file": "X",
"host": "X",
"message": "<MESSAGE> \"GET .."",
"nginx": {
"agent": "X",
"client": "X",
"method": "GET",
"path": "/",
"protocol": "HTTP/1.1",
"request": "GET / HTTP/1.1",
"server": "X", <---- Attempting to add this field here by extracting client IP from the log
"size": X,
"status": 200,
"timestamp": "YYYY-MM-DDTHH:MM:SSZ"
},
"source_type": "file",
"timestamp": "YYYY-MM-DDTHH:MM:SS.<unixtimestamp>Z"
}
</code>```

Please also note I am additionally trying to nest nginx as nested JSON within the formatted log.

VRL has a ton of functions available but I am not sure on my best choice going forward, should I use the Regex parse_regex as well as parse_nginx_log, in which order and any other transforms? I saw you can also use Multiple parsing strategies but unsure how to achieve this, especially in yml.

I started testing with an example transform configuration below (I am strictly attempting to achieve this in YAML .yml), but not having much look thus far:

```<code>transforms:
  parse-nginx:
    inputs:
      - nginx
    type: remap
    source: |
      .nginx = parse_nginx_log!(.message,"combined")
      .nginx = parse_regex!(.message, r'^(?P<server>\d+\.\d+\.\d+\.\d+)
    #.nginx = parse_json!(.message) # sets `.` to an array of objects
    #.nginx = parse_syslog(.message) ??
    #.nginx = parse_common_log(.message) ??
</code>```

Additionally, to test the configuration would you suggest this is the best approach?

sudo vector --config-yaml <path>/nginx-vector-config.yml

Any help much appreciated...
TYIA!

Body:
I am attempting to parse an unfiltered & unformatted generic NGINX access log using Vector VRL. I need am looking for a couple of examples and a push in the right direction, my first attempt using VRL syntax syntax but I have experience with basic regex and Sumo Logic (other logging systems).

Here is an example when I mean generic basic NGINX access log: (sourced from Digital Ocean's blog)

47.29.201.179 - - [28/Feb/2019:13:17:10 +0000] "GET /?p=1 HTTP/2.0" 200 5316 "https://domain1.com/?p=1" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" "2.75"

My goal is to parse and transform the log into the following below JSON presentation format, or at least in JSON so I can then use JQ to interpret the log with the below. But you can see an idea of the fields I am looking to parse with the message key names:

{
"file": "X",
"host": "X",
"message": "<MESSAGE> \"GET .."",
"nginx": {
"agent": "X",
"client": "X",
"method": "GET",
"path": "/",
"protocol": "HTTP/1.1",
"request": "GET / HTTP/1.1",
"server": "X", <---- Attempting to add this field here by extracting client IP from the log
"size": X,
"status": 200,
"timestamp": "YYYY-MM-DDTHH:MM:SSZ"
},
"source_type": "file",
"timestamp": "YYYY-MM-DDTHH:MM:SS.<unixtimestamp>Z"
}

Please also note I am additionally trying to nest nginx as nested JSON within the formatted log.

VRL has a ton of functions available but I am not sure on my best choice going forward, should I use the Regex parse_regex as well as parse_nginx_log, in which order and any other transforms? I saw you can also use Multiple parsing strategies but unsure how to achieve this, especially in yml.

I started testing with an example transform configuration below (I am strictly attempting to achieve this in YAML .yml), but not having much look thus far:

transforms:
  parse-nginx:
    inputs:
      - nginx
    type: remap
    source: |
      .nginx = parse_nginx_log!(.message,"combined")
      .nginx = parse_regex!(.message, r'^(?P<server>\d+\.\d+\.\d+\.\d+)
    #.nginx = parse_json!(.message) # sets `.` to an array of objects
    #.nginx = parse_syslog(.message) ??
    #.nginx = parse_common_log(.message) ??

Additionally, to test the configuration would you suggest this is the best approach?

sudo vector --config-yaml <path>/nginx-vector-config.yml

Any help much appreciated...
TYIA!


问:
why doing std::move twice before passing to move constructor/assignment and after?
I have been reading this book: C++ High Performance and one example I encountered regarding move assignment was:

(as member function)

```<code>auto set_title(std::string && s){
    title_ = std::move(s);
}
</code>```

however unless the s variable is coming out of an equation as an rvalue reference, we also have to call
set_title(std::move(variable_name))

in order to trigger the set_title using the rvalue signature.

I did check other places like cppreference and indeed the move inside the function definition seems to be a common behavior.

I am particularly interested/confused about the std::move of the assignment in the function, since the variable is already parsed as a rvalue reference, why doing std::move again?

Thanks!

Body:
I have been reading this book: C++ High Performance and one example I encountered regarding move assignment was:

(as member function)

auto set_title(std::string && s){
    title_ = std::move(s);
}

however unless the s variable is coming out of an equation as an rvalue reference, we also have to call
set_title(std::move(variable_name))

in order to trigger the set_title using the rvalue signature.

I did check other places like cppreference and indeed the move inside the function definition seems to be a common behavior.

I am particularly interested/confused about the std::move of the assignment in the function, since the variable is already parsed as a rvalue reference, why doing std::move again?

Thanks!