问:
What are differences in fetching xml values using attributes and indices in SQL server
In SQL server, for XML datatype, to fetch a value from the xml column I came across two types of format like

```<code>Select xml_column.value('(/Node1/Node1.1[1]/Text)[8]', 'nvarchar(max)')
from myTable
</code>```

In this I have to change the query if any new Text node is added before this, e.g 8 to 9.

In another format to avoid this index dependency I have used

```<code>Select xml_column.value('(/Node1/Node1.1[@attributeX="val1"]/Text[@attributeY="val2"])[1]', 'nvarchar(max)')
from myTable
</code>```

In terms of performance will it make any difference in the second query if I fetch large data?

Also, given that the attributes in the XML nodes are one to two sentences long.

Body:
In SQL server, for XML datatype, to fetch a value from the xml column I came across two types of format like

Select xml_column.value('(/Node1/Node1.1[1]/Text)[8]', 'nvarchar(max)')
from myTable

In this I have to change the query if any new Text node is added before this, e.g 8 to 9.

In another format to avoid this index dependency I have used

Select xml_column.value('(/Node1/Node1.1[@attributeX="val1"]/Text[@attributeY="val2"])[1]', 'nvarchar(max)')
from myTable

In terms of performance will it make any difference in the second query if I fetch large data?

Also, given that the attributes in the XML nodes are one to two sentences long.


来源: stackexchange

问:
I am trying to get my collision detection to work but the codes I have put in won't let the collision function work
```<code>from turtle import Turtle, Screen

wn = Screen()
wn.bgcolor('lightblue')

spaceship = Turtle()
spaceship.color('red')
spaceship.penup()

import turtle

rocket = turtle.Turtle()
rocket.color('blue')
rocket.penup()
rocket.setposition(-250, -250)

speed = 8

def travel():
    spaceship.forward(speed)
    if spaceship.xcor() > 500:
        spaceship.goto(-500, 0)
    if spaceship.xcor() < -500:
        spaceship.goto(500, 0)
    elif spaceship.ycor() > 500:
        spaceship.goto(0, -500)
    elif spaceship.ycor() < -500:
        spaceship.goto(0, 500)

def rocket_spaceship():
    while True:
        rocket.setheading(rocket.towards(spaceship))
        rocket.forward(speed)
        wn.ontimer(travel, 3)

def is_collided_with(rocket_turtle, rocket_spaceship):
    return abs(rocket_turtle.xcor() - rocket_spaceship.xcor()) < 10 and abs(rocket_turtle.ycor() - rocket_spaceship.ycor()) < 10

def follow_rocket():
    follow.setheading(follow.towards(travel))
    follow.forward(min(follow.distance(travel), 8))

    if is_collided_with(follow, travel):
        print('Collision!')
        quitThis()
    else:
        playGround.ontimer(follow_rocket, 10)

wn.onkey(lambda: spaceship.setheading(90), 'Up')
wn.onkey(lambda: spaceship.setheading(180), 'Left')
wn.onkey(lambda: spaceship.setheading(0), 'Right')
wn.onkey(lambda: spaceship.setheading(270), 'Down')

wn.listen()
rocket_spaceship()
wn.mainloop()
</code>```

I can move the turtle but when they collide nothing happens it just keeps going and won't do the function I told it to do. I'm trying to turn this into a tag game but I can't seem to get the collision to work to end the game but it just keeps running forever and doesn't stop.

ContentLicense: CC BY-SA 4.0

Body:
from turtle import Turtle, Screen

wn = Screen()
wn.bgcolor('lightblue')

spaceship = Turtle()
spaceship.color('red')
spaceship.penup()

import turtle

rocket = turtle.Turtle()
rocket.color('blue')
rocket.penup()
rocket.setposition(-250, -250)

speed = 8

def travel():
    spaceship.forward(speed)
    if spaceship.xcor() > 500:
        spaceship.goto(-500, 0)
    if spaceship.xcor() < -500:
        spaceship.goto(500, 0)
    elif spaceship.ycor() > 500:
        spaceship.goto(0, -500)
    elif spaceship.ycor() < -500:
        spaceship.goto(0, 500)

def rocket_spaceship():
    while True:
        rocket.setheading(rocket.towards(spaceship))
        rocket.forward(speed)
        wn.ontimer(travel, 3)

def is_collided_with(rocket_turtle, rocket_spaceship):
    return abs(rocket_turtle.xcor() - rocket_spaceship.xcor()) < 10 and abs(rocket_turtle.ycor() - rocket_spaceship.ycor()) < 10

def follow_rocket():
    follow.setheading(follow.towards(travel))
    follow.forward(min(follow.distance(travel), 8))

    if is_collided_with(follow, travel):
        print('Collision!')
        quitThis()
    else:
        playGround.ontimer(follow_rocket, 10)

wn.onkey(lambda: spaceship.setheading(90), 'Up')
wn.onkey(lambda: spaceship.setheading(180), 'Left')
wn.onkey(lambda: spaceship.setheading(0), 'Right')
wn.onkey(lambda: spaceship.setheading(270), 'Down')

wn.listen()
rocket_spaceship()
wn.mainloop()

I can move the turtle but when they collide nothing happens it just keeps going and won't do the function I told it to do. I'm trying to turn this into a tag game but I can't seem to get the collision to work to end the game but it just keeps running forever and doesn't stop.


问:
How to use a release version of the std runtime library in gcc using -O0
I have some code for educational purpose where I intentionally make a standard library function go out of bounds.

```<code>/usr/src/debug/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:1221:
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT =
char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&;
size_type = long unsigned int]: Assertion '__pos <= size()' failed.
</code>```

This check is done in libstdc++, only in the debug version (see /usr/src/debug/...). If I compile my code using -O0 it will use the debug stdlibc++ and if I compile using -O1 or -O2 it doesn't. Is there a way to configure gcc to use -O0 and use the release version of the libstdc++

This is on GCC 12.2.0

Body:
I have some code for educational purpose where I intentionally make a standard library function go out of bounds.

/usr/src/debug/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:1221:
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference
std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT =
char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&;
size_type = long unsigned int]: Assertion '__pos <= size()' failed.

This check is done in libstdc++, only in the debug version (see /usr/src/debug/...). If I compile my code using -O0 it will use the debug stdlibc++ and if I compile using -O1 or -O2 it doesn't. Is there a way to configure gcc to use -O0 and use the release version of the libstdc++

This is on GCC 12.2.0


问:
should i use curly brackets when using arrow functions?
just a simple code for calculating average age of 'adult' array using reduce method.

```<code> const ageAvg = adult.reduce((acc, age) => {
    acc + age;
  }, 0);
  console.log(ageAvg / adult.length);
</code>```

im having a hard time figuring out what is happening behind the scene when i use curly braces for my arrow function content as in the example, cause when i do, ageAvg gives me NaN and when i dont use any braces at all for the acc + age it works totally fine.
i guess it has something to do with the 'this' keyword but i would like to understand exactly whats going on so

Body:
just a simple code for calculating average age of 'adult' array using reduce method.

 const ageAvg = adult.reduce((acc, age) => {
    acc + age;
  }, 0);
  console.log(ageAvg / adult.length);

im having a hard time figuring out what is happening behind the scene when i use curly braces for my arrow function content as in the example, cause when i do, ageAvg gives me NaN and when i dont use any braces at all for the acc + age it works totally fine.
i guess it has something to do with the 'this' keyword but i would like to understand exactly whats going on so


问:
wcstombs_s is undefiend (gcc, m1 mac)
I'm trying to make my own programming language and compiler for it. While creating lexical analyzer i have troubles with this function. Also i included stdlib.h and stdio.h. Platform what i use is m1 mac and vscode with gcc

There is code:

```<code>#define _CRT_SECURE_NO_WARNINGS
#include "Log.h"
namespace Log
{
    LOG getlog(wchar_t logfile[])
    {
        try
        {
            LOG struc;
            struc.stream = new (std::nothrow) std::ofstream;
            if (!struc.stream)
                throw ERROR_THROW(112);
            struc.stream->open(logfile);
            if (!(*(struc.stream)).is_open())
                throw ERROR_THROW(112);
            wcscpy(struc.logfile, logfile);
            return struc;
        }
        catch (Error::ERROR e)
        {
            Error::ErrorDisplay(e);
        }
    }

    void WriteLine(LOG log, char *c, ...)
    {
        for (char **c_ptr = &c; **c_ptr; c_ptr++)
        {
            *log.stream << *c_ptr;
        }
    }

    void WriteLine(LOG log, wchar_t *c, ...)
    {
        unsigned lineLength = 0;
        char *line = nullptr;
        unsigned int n = 0;

        for (wchar_t **c_ptr = &c; **c_ptr; c_ptr++)
        {
            lineLength = wcslen(*c_ptr);
            line = new char[lineLength + 1];
            wcstombs_s(&n, line, lineLength + 1u, *c_ptr, lineLength + 1u);
            *log.stream << line;
            delete[] line;
        }
    }

    void WriteLog(LOG log)
    {
        std::string line = "----Протокол------ ";
        time_t result = time(NULL);
        char str[26];
        ctime_s(str, sizeof str, &result);
        for (int i = 0; i < 26; i++)
            line += str[i];
        *log.stream << line;
    }

    void WriteParm(LOG log, Parm::PARM parm)
    {
        char in_text[PARM_MAX_SIZE];
        char out_text[PARM_MAX_SIZE];
        char log_text[PARM_MAX_SIZE];
        wcstombs(in_text, parm.in, PARM_MAX_SIZE);
        wcstombs(out_text, parm.out, PARM_MAX_SIZE);
        wcstombs(log_text, parm.log, PARM_MAX_SIZE);
        *log.stream << "---- Параметры ---- \n-in: " << in_text
                                << "\n-out: " << out_text
                                << "\n-log: " << log_text;
    }

    void WriteIn(LOG log, In::IN in)
    {
        *log.stream << "\n----Исходные данные------\nКол-во символов: " << (in.size < 0 ? 0 : in.size) << std::endl
                                << "Проигнорировано: " << (in.ignor < 0 ? 0 : in.ignor) << std::endl
                                << "Кол-во строк: " << (in.lines < 0 ? 0 : in.lines) << std::endl;
    }

    void WriteError(LOG log, Error::ERROR error)
    {
        *log.stream << "Ошибка " << error.id << ": " << error.message << ", Строка " << error.inext.line << ", Позиция " << error.inext.col << std::endl;
    }

    void Close(LOG log)
    {
        (*log.stream).close();
        delete log.stream;
    }
}
</code>```

And header file:

```<code>#pragma once
#include <fstream>
#include <iostream>
#include <cwchar>
#include <string>
#include <stdlib.h>
#include <stdio.h>

#include "In.h"
#include "Parm.h"
#include "Error.h"

namespace Log
{
    struct LOG
    {
        wchar_t logfile[PARM_MAX_SIZE];
        std::ofstream *stream;
    };

    static const LOG INITLOG{L"", NULL};
    LOG getlog(wchar_t logfile[]);
    void WriteLine(LOG log, char *c, ...);
    void WriteLine(LOG log, wchar_t *c, ...);
    void WriteLog(LOG log);
    void WriteParm(LOG log, Parm::PARM parm);
    void WriteIn(LOG log, In::IN in);
    void WriteError(LOG log, Error::ERROR error);
    void Close(LOG log);
}
</code>```

I tried to change include path and change versions of c++, std and compilers

Title: wcstombs_s is undefiend (gcc, m1 mac)

Body:
I'm trying to make my own programming language and compiler for it. While creating lexical analyzer i have troubles with this function. Also i included stdlib.h and stdio.h. Platform what i use is m1 mac and vscode with gcc

There is code:

#define _CRT_SECURE_NO_WARNINGS
#include "Log.h"
namespace Log
{
    LOG getlog(wchar_t logfile[])
    {
        try
        {
            LOG struc;
            struc.stream = new (std::nothrow) std::ofstream;
            if (!struc.stream)
                throw ERROR_THROW(112);
            struc.stream->open(logfile);
            if (!(*(struc.stream)).is_open())
                throw ERROR_THROW(112);
            wcscpy(struc.logfile, logfile);
            return struc;
        }
        catch (Error::ERROR e)
        {
            Error::ErrorDisplay(e);
        }
    }

    void WriteLine(LOG log, char *c, ...)
    {
        for (char **c_ptr = &c; **c_ptr; c_ptr++)
        {
            *log.stream << *c_ptr;
        }
    }

    void WriteLine(LOG log, wchar_t *c, ...)
    {
        unsigned lineLength = 0;
        char *line = nullptr;
        unsigned int n = 0;

        for (wchar_t **c_ptr = &c; **c_ptr; c_ptr++)
        {
            lineLength = wcslen(*c_ptr);
            line = new char[lineLength + 1];
            wcstombs_s(&n, line, lineLength + 1u, *c_ptr, lineLength + 1u);
            *log.stream << line;
            delete[] line;
        }
    }

    void WriteLog(LOG log)
    {
        std::string line = "----Протокол------ ";
        time_t result = time(NULL);
        char str[26];
        ctime_s(str, sizeof str, &result);
        for (int i = 0; i < 26; i++)
            line += str[i];
        *log.stream << line;
    }

    void WriteParm(LOG log, Parm::PARM parm)
    {
        char in_text[PARM_MAX_SIZE];
        char out_text[PARM_MAX_SIZE];
        char log_text[PARM_MAX_SIZE];
        wcstombs(in_text, parm.in, PARM_MAX_SIZE);
        wcstombs(out_text, parm.out, PARM_MAX_SIZE);
        wcstombs(log_text, parm.log, PARM_MAX_SIZE);
        *log.stream << "---- Параметры ---- \n-in: " << in_text
                                << "\n-out: " << out_text
                                << "\n-log: " << log_text;
    }

    void WriteIn(LOG log, In::IN in)
    {
        *log.stream << "\n----Исходные данные------\nКол-во символов: " << (in.size < 0 ? 0 : in.size) << std::endl
                                << "Проигнорировано: " << (in.ignor < 0 ? 0 : in.ignor) << std::endl
                                << "Кол-во строк: " << (in.lines < 0 ? 0 : in.lines) << std::endl;
    }

    void WriteError(LOG log, Error::ERROR error)
    {
        *log.stream << "Ошибка " << error.id << ": " << error.message << ", Строка " << error.inext.line << ", Позиция " << error.inext.col << std::endl;
    }

    void Close(LOG log)
    {
        (*log.stream).close();
        delete log.stream;
    }
}

And header file:

#pragma once
#include <fstream>
#include <iostream>
#include <cwchar>
#include <string>
#include <stdlib.h>
#include <stdio.h>

#include "In.h"
#include "Parm.h"
#include "Error.h"

namespace Log
{
    struct LOG
    {
        wchar_t logfile[PARM_MAX_SIZE];
        std::ofstream *stream;
    };

    static const LOG INITLOG{L"", NULL};
    LOG getlog(wchar_t logfile[]);
    void WriteLine(LOG log, char *c, ...);
    void WriteLine(LOG log, wchar_t *c, ...);
    void WriteLog(LOG log);
    void WriteParm(LOG log, Parm::PARM parm);
    void WriteIn(LOG log, In::IN in);
    void WriteError(LOG log, Error::ERROR error);
    void Close(LOG log);
}

I tried to change include path and change versions of c++, std and compilers


问:
Refreshing TreeView Tkinter
I want to refresh my treeview after updating/deleting records from DB, but it always shows me the same data unless the application closes. Any idea?

I'm showing the window as a Tk() and with .mainloop, for reference.

I've tried clearing the treeview with Treeview.delete and populating the treeview again, but with no results.

Title: Refreshing TreeView Tkinter


问:
How do I convert a PHP SOAP script to work in JavaScript
I've been trying (unsuccessfully) to work out how to write the following PHP code, as JavaScript:

```<code><?php
$api_key = "abc1234567890";
$loc="https://soap.somedomain.co.uk/edi/soapsr.pl";
$uri="https://soap.somedomain.co.uk/StockQuery"; # package
$client = new SoapClient(null, array('location' => $loc,
                                     'uri'      => $uri,
                                     'compression' => "SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5"
                                     ));

$stock_ids=array(1,6,15,16,167,169,170,171,172,173,175,176,5177,5178,5179,5180,5181);
$StkQtys = $client->stock_qty_array($api_key,$stock_ids);
echo var_dump($StkQtys);
unset($client);
exit;
?>
</code>```

I found a jquery.soap plugin, that sounds promising, but because of my lack of understanding, I'm struggling to work out how to use the parameters above in the correct way.

I'm not sure where I should put the '$loc' and '$uri' when using $.soap()
Also, how should I structure the data: {} object to include the required information?
I've tried the following, but no luck:

```<code><script>
function soap() {
  $.soap({
        loc: 'https://soap.somedomain.co.uk/edi/soapsr.pl',
    url: 'https://soap.somedomain.co.uk/StockQuery',
        compression: 'SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5'
    data: {
        stock_qty_array: { 'myAPIKey', {1,6,15,16,167,169,170,171,172,173,175,176,5177,5178,5179,5180,5181} }
    },
    success: function (soapResponse) {
                console.dir(soapResponse);
    },
    error: function (SOAPResponse) {
                console.dir(SOAPResponse);
    }
  });
}
</script>
</code>```

When I run my code, I get the error:
POST https://soap.somedomain.co.uk/StockQuery net::ERR_FAILED

Any advice would be greatly appreciated?

Thank you, Chris

Body:
I've been trying (unsuccessfully) to work out how to write the following PHP code, as JavaScript:

<?php
$api_key = "abc1234567890";
$loc="https://soap.somedomain.co.uk/edi/soapsr.pl";
$uri="https://soap.somedomain.co.uk/StockQuery"; # package
$client = new SoapClient(null, array('location' => $loc,
                                     'uri'      => $uri,
                                     'compression' => "SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5"
                                     ));

$stock_ids=array(1,6,15,16,167,169,170,171,172,173,175,176,5177,5178,5179,5180,5181);
$StkQtys = $client->stock_qty_array($api_key,$stock_ids);
echo var_dump($StkQtys);
unset($client);
exit;
?>

I found a jquery.soap plugin, that sounds promising, but because of my lack of understanding, I'm struggling to work out how to use the parameters above in the correct way.

I'm not sure where I should put the '$loc' and '$uri' when using $.soap()
Also, how should I structure the data: {} object to include the required information?
I've tried the following, but no luck:

When I run my code, I get the error:
POST https://soap.somedomain.co.uk/StockQuery net::ERR_FAILED

Any advice would be greatly appreciated?

Thank you, Chris


问:
Parallel Data Download from Snowflake to Databricks
I have a big table in Snowflake ( 10B records) , which I want to download in Databricks using Snowflakeconnector (spark.read.format("snowflake")). I am trying to apply parallel fetch by means of dividing the table using a date column. For running concurrently, I am using Databrick's concurrent Notebook mechanism. The split code looks something like this

```<code>val notebooks = Seq(
NotebookData("my_snowflake_table", 6000,Map("start_date" -> "2022-05-01", "end_date" -> "2022-08-01")),
    NotebookData("my_snowflake_table", 6000,Map("start_date" -> "2022-08-01", "end_date" -> "2022-11-01")),
    NotebookData("my_snowflake_table", 6000,Map("start_date" -> "2022-11-01", "end_date" -> "2022-12-01")))

// Run the notebooks in parallel
val res = parallelNotebooks(notebooks)

Await.result(res, 7200 seconds) // this is a blocking call.
res.value
</code>```

I was expecting horizontal scalability (by the means of autoscaling cluster) with this , however that doesn't seem to be the case. The time taken per split is lot more compared to when run alone. Each split takes around 15 minutes, but when done together, doesn't even complete even in an hour.

Is it because all the splits are running in the same driver, and therefore bandwidth of the driver node could be the bottleneck , also has compounding effect on the overall performance ?

Even more importantly, does this design make sense for how Dtabricks and Snowflake work together ? How else can we download data from Snowflake to Databricks in a faster way ?

Body:
I have a big table in Snowflake ( 10B records) , which I want to download in Databricks using Snowflakeconnector (spark.read.format("snowflake")). I am trying to apply parallel fetch by means of dividing the table using a date column. For running concurrently, I am using Databrick's concurrent Notebook mechanism. The split code looks something like this

val notebooks = Seq(
NotebookData("my_snowflake_table", 6000,Map("start_date" -> "2022-05-01", "end_date" -> "2022-08-01")),
    NotebookData("my_snowflake_table", 6000,Map("start_date" -> "2022-08-01", "end_date" -> "2022-11-01")),
    NotebookData("my_snowflake_table", 6000,Map("start_date" -> "2022-11-01", "end_date" -> "2022-12-01")))

// Run the notebooks in parallel
val res = parallelNotebooks(notebooks)

Await.result(res, 7200 seconds) // this is a blocking call.
res.value

I was expecting horizontal scalability (by the means of autoscaling cluster) with this , however that doesn't seem to be the case. The time taken per split is lot more compared to when run alone. Each split takes around 15 minutes, but when done together, doesn't even complete even in an hour.

Is it because all the splits are running in the same driver, and therefore bandwidth of the driver node could be the bottleneck , also has compounding effect on the overall performance ?

Even more importantly, does this design make sense for how Dtabricks and Snowflake work together ? How else can we download data from Snowflake to Databricks in a faster way ?


问:
QTreeView not updating after inserting new data in QAbstractItemModel with a QSortFilterProxyModel
I have a TreeView which is displaying items from an AbstractItemModel..
Now I wanted to add extra Filter functionality to my application, but somehow, the data is not visible in the TreeView (after calling newData()).
How does the interaction between the QAbstractItemModel and the QSortFilterProxyModel happens?
what should the QSortFilterProxyModel knows more the the setSource(QAbstractItemModel)

Here my code (copied from: https://stackoverflow.com/a/60910989/298487)

```<code>import logging
import sys
from PySide6 import QtCore, QtWidgets
from PySide6.QtCore import QSortFilterProxyModel

class DBObject:
    def __init__(self, name, parent, children=None):
        self.name = name
        self.parent = parent
        self.children = children or list()

    def __repr__(self):
        return f"name: {self.name}, parent: {self.parent.name if self.parent is not None else '-'}"

class Model(QtCore.QAbstractItemModel):
    def __init__(self, parent=None):
        super().__init__(parent)
        self._root = DBObject("root", None)

    def newData(self):
        items = ["foo", "bar", "baz"]
        for x in items:
            child = DBObject(x + "0", self._root)
            self._root.children.append(child)
            for y in items:
                child.children.append(DBObject(y + "1", child))

    def columnCount(self, parent=QtCore.QModelIndex()):
        return 1

    def rowCount(self, parent=QtCore.QModelIndex()):
        if not parent.isValid():
            return 1

        parentItem = parent.internalPointer()
        rowCount = len(parentItem.children)
        logging.info(f"rowCount({parentItem}): rowCount={rowCount}")
        return rowCount

    def parent(self, index):
        if not index.isValid():
            return QtCore.QModelIndex()

        item = index.internalPointer()
        parentItem = item.parent

        logging.info(f"parent({item}): parent={parentItem}")
        if parentItem is None:
            return QtCore.QModelIndex()
        else:
            if parentItem.parent is None:
                return self.createIndex(0, 0, parentItem)
            else:
                return self.createIndex(parentItem.parent.children.index(parentItem), 0, parentItem)

    def index(self, row, column, parent=QtCore.QModelIndex()):
        if not parent.isValid():
            if row != 0 or column != 0:
                return QtCore.QModelIndex()
            else:
                logging.info(f"index({row}, {column}, None): index={self._root}")
                return self.createIndex(0, 0, self._root)

        parentItem = parent.internalPointer()

        if 0 <= row < len(parentItem.children):
            logging.info(f"index({row}, {column}, {parentItem}): index={parentItem.children[row]}")
            return self.createIndex(row, column, parentItem.children[row])
        else:
            logging.info(f"index({row}, {column}, {parentItem}): index=None")
            return QtCore.QModelIndex()

    def data(self, index, role=QtCore.Qt.ItemDataRole.DisplayRole):
        if not index.isValid():
            return None

    item = index.internalPointer()

    if role == QtCore.Qt.ItemDataRole.DisplayRole:
        return item.name
    else:
        return None

    def flags(self, index):
        if not index.isValid():
            return QtCore.Qt.ItemFlag.NoItemFlags

        return (
            QtCore.Qt.ItemFlag.ItemIsEnabled
            | QtCore.Qt.ItemFlag.ItemIsSelectable)

class ProxyModel(QSortFilterProxyModel):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setFilterKeyColumn(0)
        self.setRecursiveFilteringEnabled(True)

class MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        self.setMinimumSize(640, 480)

        centralWidget = QtWidgets.QWidget(self)
        self.setCentralWidget(centralWidget)

        layout = QtWidgets.QVBoxLayout(centralWidget)

        self._treeView = QtWidgets.QTreeView(self)
        layout.addWidget(self._treeView)

        self._model = Model()
        self._proxyModel = ProxyModel()
        self._proxyModel.setSourceModel(self._model)
        # this line will not work
        self._treeView.setModel(self._proxyModel)
        # if i replace it with this line, it is working
        # but the filtering will not work
        self._treeView.setModel(self._model)

        self._proxyModel.setFilterFixedString("bar1")

        button = QtWidgets.QPushButton("Add")
        layout.addWidget(button)

        button.clicked.connect(self._Clicked)

    def _Clicked(self):
        self._model.newData()
        self._treeView.expandAll()

def main():
    app = QtWidgets.QApplication(sys.argv)

    mainWindow = MainWindow()
    mainWindow.show()
    app.exec()

if __name__ == "__main__":
    main()
</code>```

Body:
I have a TreeView which is displaying items from an AbstractItemModel..
Now I wanted to add extra Filter functionality to my application, but somehow, the data is not visible in the TreeView (after calling newData()).
How does the interaction between the QAbstractItemModel and the QSortFilterProxyModel happens?
what should the QSortFilterProxyModel knows more the the setSource(QAbstractItemModel)

Here my code (copied from: https://stackoverflow.com/a/60910989/298487)

import logging
import sys
from PySide6 import QtCore, QtWidgets
from PySide6.QtCore import QSortFilterProxyModel

class DBObject:
    def __init__(self, name, parent, children=None):
        self.name = name
        self.parent = parent
        self.children = children or list()

    def __repr__(self):
        return f"name: {self.name}, parent: {self.parent.name if self.parent is not None else '-'}"

class Model(QtCore.QAbstractItemModel):
    def __init__(self, parent=None):
        super().__init__(parent)
        self._root = DBObject("root", None)

    def newData(self):
        items = ["foo", "bar", "baz"]
        for x in items:
            child = DBObject(x + "0", self._root)
            self._root.children.append(child)
            for y in items:
                child.children.append(DBObject(y + "1", child))

    def columnCount(self, parent=QtCore.QModelIndex()):
        return 1

    def rowCount(self, parent=QtCore.QModelIndex()):
        if not parent.isValid():
            return 1

        parentItem = parent.internalPointer()
        rowCount = len(parentItem.children)
        logging.info(f"rowCount({parentItem}): rowCount={rowCount}")
        return rowCount

    def parent(self, index):
        if not index.isValid():
            return QtCore.QModelIndex()

        item = index.internalPointer()
        parentItem = item.parent

        logging.info(f"parent({item}): parent={parentItem}")
        if parentItem is None:
            return QtCore.QModelIndex()
        else:
            if parentItem.parent is None:
                return self.createIndex(0, 0, parentItem)
            else:
                return self.createIndex(parentItem.parent.children.index(parentItem), 0, parentItem)

    def index(self, row, column, parent=QtCore.QModelIndex()):
        if not parent.isValid():
            if row != 0 or column != 0:
                return QtCore.QModelIndex()
            else:
                logging.info(f"index({row}, {column}, None): index={self._root}")
                return self.createIndex(0, 0, self._root)

        parentItem = parent.internalPointer()

        if 0 <= row < len(parentItem.children):
            logging.info(f"index({row}, {column}, {parentItem}): index={parentItem.children[row]}")
            return self.createIndex(row, column, parentItem.children[row])
        else:
            logging.info(f"index({row}, {column}, {parentItem}): index=None")
            return QtCore.QModelIndex()

    def data(self, index, role=QtCore.Qt.ItemDataRole.DisplayRole):
        if not index.isValid():
            return None

    item = index.internalPointer()

    if role == QtCore.Qt.ItemDataRole.DisplayRole:
        return item.name
    else:
        return None

    def flags(self, index):
        if not index.isValid():
            return QtCore.Qt.ItemFlag.NoItemFlags

        return (
            QtCore.Qt.ItemFlag.ItemIsEnabled
            | QtCore.Qt.ItemFlag.ItemIsSelectable)

class ProxyModel(QSortFilterProxyModel):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setFilterKeyColumn(0)
        self.setRecursiveFilteringEnabled(True)

class MainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super().__init__()
        self.setMinimumSize(640, 480)

        centralWidget = QtWidgets.QWidget(self)
        self.setCentralWidget(centralWidget)

        layout = QtWidgets.QVBoxLayout(centralWidget)

        self._treeView = QtWidgets.QTreeView(self)
        layout.addWidget(self._treeView)

        self._model = Model()
        self._proxyModel = ProxyModel()
        self._proxyModel.setSourceModel(self._model)
        # this line will not work
        self._treeView.setModel(self._proxyModel)
        # if i replace it with this line, it is working
        # but the filtering will not work
        self._treeView.setModel(self._model)

        self._proxyModel.setFilterFixedString("bar1")

        button = QtWidgets.QPushButton("Add")
        layout.addWidget(button)

        button.clicked.connect(self._Clicked)

    def _Clicked(self):
        self._model.newData()
        self._treeView.expandAll()

def main():
    app = QtWidgets.QApplication(sys.argv)

    mainWindow = MainWindow()
    mainWindow.show()
    app.exec()

if __name__ == "__main__":
    main()


问:
How do I check if a connection is alive when using GStreamer?
We are using an ICE video streaming solution using GStreamer. But for some reason I can't find out how to detect if the receiver has suddenly vanished. GStreamer just keeps happily sending data to no recipient.

I already had thoughts about using webrtcbin's "connection-state" property but not sure if this will actually work if the client just quietly drops. Seems like it will just stay in connected state. Plus very unsure about the implementation.

Any help would be greatly appreciated.


问:
Firestore: Is it efficient to create a Firestore Collection per each user in your app?
I have developed a Daily Planner application that allows users to create an account, sign up and plan their schedule by the hour with tasks for each day.

I am using Firestore for the database and currently the way the app is structured is that there is a "day_packages" collection in Firestore. To simplify things, each document in the collection has an array of "tasks" and then a "timestamp" indicating the day it's for ("Thu-8-12-22") and a "user uid", which is specific to a user account. These two values give me a unique key, that will allow me to fetch and update specific days for specific users based on in app interactions.

However, as you can imagine, if a user makes a schedule for each day of the year, then that collection will have 365 documents for just that user. If you have a ton of users, then this collection will get very large over time I would think that querying by timestamp and user uid will start to take a performance impact.

One way to get around this that I was thinking about, would be to create a collection in the database for each user. The collection name would be the "user uid" and each document's ID in the collection will be the timestamp to uniquely identify them. That means that per year, the max amount of documents a collection could have for schedules per user, would be 365.

I was wondering if this is a correct way to use Firebase or if this is also inefficient? Is it wise to create a collection per-user? Should I just continue with how my data is currently set up or is this switch fine? Switching to collections per user would also allow easier querying as well.

Thank you!


问:
PANDAS: Stylize Dataframe
I have the following dataframe in pandas and I would like to modify it, as it is a dataframe of results, I would like that when having a sequence of 'BA' for example, it appears only once, just like merging in excel, how can I do it that?

This dataframe of mine is the result of a groupby, so how do I merge the values?

DataFrame

I would like it to remain like this:
In Excel

I do not know how to do it

Title: PANDAS: Stylize Dataframe


问:
OpenFaaS gateway and queue worker can't connect to nats
I have been having issues for more than a week trying to get OpenFaaS to start on my WSL instance using a K8S cluster deployed by Docker Desktop.

I keep on getting this from the gateway and queueworker pods:

```<code>OpenFaaS Gateway - Community Edition (CE)

Version: 0.25.2 Commit: bc2eeff4678407583faec982c1c7d1da915dd60c
Timeouts: read=5m2s write=5m2s  upstream=5m0s
Function provider: http://127.0.0.1:8081/

2022/12/05 16:08:53 Async enabled: Using NATS Streaming.
2022/12/05 16:08:53 Opening connection to nats://nats.openfaas.svc.cluster.local:4222
2022/12/05 16:08:53 Connect: nats://nats.openfaas.svc.cluster.local:4222
2022/12/05 16:08:55 dial tcp 10.101.241.144:4222: i/o timeout
</code>```

I have searched the openfaas website, github issues but nothing fixed my issue.
One of the things I tried is to set the NO_PROXY environment variable using export no_proxy=".svc,.svc.cluster.local" but that did not fix it.

Not sure what to do. Here are the pods:

```<code>NAME                                 READY   STATUS             RESTARTS       AGE
alertmanager-7c456f4cdd-n6r6q        1/1     Running            0              68m
basic-auth-plugin-589ff48889-b8wkp   1/1     Running            0              68m
gateway-5989d8f775-2k795             1/2     CrashLoopBackOff   10 (39s ago)   27m
nats-64d9444b95-rpfhr                1/1     Running            0              68m
prometheus-68584f9786-mp7t4          1/1     Running            0              68m
queue-worker-97bcf9fb-zgk6z          0/1     CrashLoopBackOff   18 (26s ago)   68m
</code>```

And the services:

```<code>NAME                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
alertmanager        ClusterIP   10.100.115.189   <none>        9093/TCP         69m
basic-auth-plugin   ClusterIP   10.105.160.116   <none>        8080/TCP         69m
gateway             ClusterIP   10.110.144.212   <none>        8080/TCP         69m
gateway-external    NodePort    10.103.2.255     <none>        8080:31112/TCP   69m
gateway-provider    ClusterIP   10.101.1.205     <none>        8081/TCP         69m
nats                ClusterIP   10.101.241.144   <none>        4222/TCP         69m
prometheus          ClusterIP   10.97.171.69     <none>        9090/TCP         69m
</code>```

The nats service has the 4222 endpoint enabled on TCP.

I have opened an issue on the faas-netes github repo but not getting any help. I just opened an issue on the main faas Github repo asking for help.

What could be causing this issue?

Body:
I have been having issues for more than a week trying to get OpenFaaS to start on my WSL instance using a K8S cluster deployed by Docker Desktop.

I keep on getting this from the gateway and queueworker pods:

OpenFaaS Gateway - Community Edition (CE)

Version: 0.25.2 Commit: bc2eeff4678407583faec982c1c7d1da915dd60c
Timeouts: read=5m2s write=5m2s  upstream=5m0s
Function provider: http://127.0.0.1:8081/

2022/12/05 16:08:53 Async enabled: Using NATS Streaming.
2022/12/05 16:08:53 Opening connection to nats://nats.openfaas.svc.cluster.local:4222
2022/12/05 16:08:53 Connect: nats://nats.openfaas.svc.cluster.local:4222
2022/12/05 16:08:55 dial tcp 10.101.241.144:4222: i/o timeout

I have searched the openfaas website, github issues but nothing fixed my issue.
One of the things I tried is to set the NO_PROXY environment variable using export no_proxy=".svc,.svc.cluster.local" but that did not fix it.

Not sure what to do. Here are the pods:

NAME                                 READY   STATUS             RESTARTS       AGE
alertmanager-7c456f4cdd-n6r6q        1/1     Running            0              68m
basic-auth-plugin-589ff48889-b8wkp   1/1     Running            0              68m
gateway-5989d8f775-2k795             1/2     CrashLoopBackOff   10 (39s ago)   27m
nats-64d9444b95-rpfhr                1/1     Running            0              68m
prometheus-68584f9786-mp7t4          1/1     Running            0              68m
queue-worker-97bcf9fb-zgk6z          0/1     CrashLoopBackOff   18 (26s ago)   68m

And the services:

NAME                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
alertmanager        ClusterIP   10.100.115.189   <none>        9093/TCP         69m
basic-auth-plugin   ClusterIP   10.105.160.116   <none>        8080/TCP         69m
gateway             ClusterIP   10.110.144.212   <none>        8080/TCP         69m
gateway-external    NodePort    10.103.2.255     <none>        8080:31112/TCP   69m
gateway-provider    ClusterIP   10.101.1.205     <none>        8081/TCP         69m
nats                ClusterIP   10.101.241.144   <none>        4222/TCP         69m
prometheus          ClusterIP   10.97.171.69     <none>        9090/TCP         69m

The nats service has the 4222 endpoint enabled on TCP.

I have opened an issue on the faas-netes github repo but not getting any help. I just opened an issue on the main faas Github repo asking for help.

What could be causing this issue?


问:
Add all .mp3 file in the array List from specific folder
```<code> private val listmp3 = ArrayList<String>()

  private fun loadmp3() {
        val YourFolderPath = Environment.getExternalStorageDirectory().path + "/ieltsTest/"
        val file = File(YourFolderPath)
        if (file.isDirectory) {
            val files = file.listFiles()
            if (files != null && files.size > 0) {
                for (f in files) {
                    if (f.isDirectory) {
                        loadmp3(f.absolutePath)
                    } else {
                        for (i in extensions.indices) {
                            if (f.absolutePath.endsWith(extensions[i])) {
                                listmp3.add(f.absolutePath)
                            }
                        }
                    }
                }
            }
        }

        Log.i("audioList", listmp3.toString())
    }
</code>```

Here, I want to list all the .mp3 in by the specific folder. I am trying to get list of the .mp3 folder. Can any body help me to get list of audio
thanks is advance............

Body:
 private val listmp3 = ArrayList<String>()

  private fun loadmp3() {
        val YourFolderPath = Environment.getExternalStorageDirectory().path + "/ieltsTest/"
        val file = File(YourFolderPath)
        if (file.isDirectory) {
            val files = file.listFiles()
            if (files != null && files.size > 0) {
                for (f in files) {
                    if (f.isDirectory) {
                        loadmp3(f.absolutePath)
                    } else {
                        for (i in extensions.indices) {
                            if (f.absolutePath.endsWith(extensions[i])) {
                                listmp3.add(f.absolutePath)
                            }
                        }
                    }
                }
            }
        }

        Log.i("audioList", listmp3.toString())
    }

Here, I want to list all the .mp3 in by the specific folder. I am trying to get list of the .mp3 folder. Can any body help me to get list of audio
thanks is advance............


问:
saving text on OK button with Yad
i am playing with YAD and want this command to save the edits to the text on the close

```<code>yad --text-info --editable --save --confirm-overwrite --show-uri --enable-spell --filename=editableFile.txt --width=400 --height=650
</code>```

is this possible?

Title: saving text on OK button with Yad

Body:
i am playing with YAD and want this command to save the edits to the text on the close

yad --text-info --editable --save --confirm-overwrite --show-uri --enable-spell --filename=editableFile.txt --width=400 --height=650

is this possible?


问:
Promises returns null
I'm getting some cars from another system.
getCar returns a promise. All works well but when I send multiple ids and one of them doesn't exist, I get a null entry in the array cars

[carObject, ..., null]

```<code>    const carPromises = cars.map(car=> getCar(car.id));
    const cars = await Promise.all(carPromises );
    console.log(`Car Data -> ${JSON.stringify(cars)}`);
</code>```
```<code>export const getCar = async (carId: number) => {
try {
    const response = await axiosInstance.get(`${baseUrl}/car/${carId});
    const car = response.data;
    return car;
} catch (err) {
   console.error(err);
}
</code>```

If there any way to just remove the null entries from the array or just ignore them somehow?

Title: Promises returns null

Body:
I'm getting some cars from another system.
getCar returns a promise. All works well but when I send multiple ids and one of them doesn't exist, I get a null entry in the array cars

[carObject, ..., null]

    const carPromises = cars.map(car=> getCar(car.id));
    const cars = await Promise.all(carPromises );
    console.log(`Car Data -> ${JSON.stringify(cars)}`);

export const getCar = async (carId: number) => {
try {
    const response = await axiosInstance.get(`${baseUrl}/car/${carId});
    const car = response.data;
    return car;
} catch (err) {
   console.error(err);
}

If there any way to just remove the null entries from the array or just ignore them somehow?


问:
Why mocking test mixing another way the fieldErrors when i run it "Run all test" and run individually?
```<code>package hu.progmasters.moovsmart.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import hu.progmasters.moovsmart.domain.Property;
import hu.progmasters.moovsmart.dto.PropertyDetails;
import hu.progmasters.moovsmart.exception.GlobalExceptionHandler;
import hu.progmasters.moovsmart.repository.PropertyRepository;
import hu.progmasters.moovsmart.service.PropertyService;
import hu.progmasters.moovsmart.validation.PropertyFormValidator;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.context.MessageSource;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.validateMockitoUsage;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

@ExtendWith(MockitoExtension.class)
public class PropertyControllerTest {

    private MockMvc mockMvc;

    @Mock
    private PropertyRepository propertyRepositoryMock;

    @Mock
    private PropertyService propertyServiceMock;

    @BeforeEach
    public void setUp() {
        PropertyFormValidator propertyFormValidator = new PropertyFormValidator(propertyRepositoryMock);

        PropertyController propertyController = new PropertyController(propertyServiceMock, propertyFormValidator);

        mockMvc = MockMvcBuilders.standaloneSetup(propertyController)
                .setControllerAdvice(new GlobalExceptionHandler(messageSource()))
                .build();
    }

    @AfterEach
    public void validate() {
        validateMockitoUsage();
    }

    @Test
    public void createPropertyTest() throws Exception {
        Property property = new Property();
        property.setId(1L);
        property.setName("TestName");
        property.setDescription("Test description");
        property.setNumberOfRooms(2);
        property.setPrice(2000);
        property.setAddress("Test address");
        property.setImageUrl("test_url");

        PropertyDetails propertyDetails = new PropertyDetails(property);

        this.mockMvc.perform(
                        post("/api/properties")
                                .contentType(MediaType.APPLICATION_JSON)
                                .content(asJsonString(propertyDetails))
                )
                .andExpect(status().is(201));

    }

    @Test
    public void createPropertyTestWithErrorsMessage() throws Exception {
        Property property = new Property();
        property.setId(1L);
        //white space name
        property.setName(" ");
        //below 100 characters
        property.setDescription("few");
        //zero rooms
        property.setNumberOfRooms(0);
        //price zero
        property.setPrice(0);
        property.setAddress("Test address");
        property.setImageUrl("test_url");

        PropertyDetails propertyDetails = new PropertyDetails(property);

        verifyNoInteractions(propertyServiceMock);

        this.mockMvc.perform(
                        post("/api/properties")
                                .contentType(MediaType.APPLICATION_JSON)
                                .content(asJsonString(propertyDetails))
                )
                .andExpect(status().is(400))
                .andExpect(content().contentType(MediaType.APPLICATION_JSON))
                .andExpect(jsonPath("$.fieldErrors", hasSize(4)))
                .andExpect(jsonPath("$.fieldErrors[0].field", is("name")))
                .andExpect(jsonPath("$.fieldErrors[0].message", is("Property name cannot be only whitespaces!")))
                .andExpect(jsonPath("$.fieldErrors[1].field", is("description")))
                .andExpect(jsonPath("$.fieldErrors[1].message", is("Description must be between 10 and 2000 characters!")))
                .andExpect(jsonPath("$.fieldErrors[2].field", is("numberOfRooms")))
                .andExpect(jsonPath("$.fieldErrors[2].message", is("Number of rooms must be between 1 and 12!")))
                .andExpect(jsonPath("$.fieldErrors[3].field", is("price")))
                .andExpect(jsonPath("$.fieldErrors[3].message", is("The price can't be zero or below!")));

    }

    private MessageSource messageSource() {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();

        messageSource.setBasename("messages");
        messageSource.setUseCodeAsDefaultMessage(true);

        return messageSource;
    }

    public static String asJsonString(final Object obj) {
        try {
            return new ObjectMapper().writeValueAsString(obj);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
</code>```

If i run individually just the method:

```<code>createPropertyTestWithErrorsMessage()
</code>```

I get this error:

```<code>java.lang.AssertionError: JSON path "$.fieldErrors[0].field"
Expected: is "name"
     but: was "description"
Expected :name
Actual   :description
<Click to see difference>

    at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
    at org.springframework.test.util.JsonPathExpectationsHelper.assertValue(JsonPathExpectationsHelper.java:74)
    at org.springframework.test.web.servlet.result.JsonPathResultMatchers.lambda$value$0(JsonPathResultMatchers.java:87)
    at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:212)
    at hu.progmasters.moovsmart.controller.PropertyControllerTest.createPropertyTestWithErrorsMessage(PropertyControllerTest.java:109)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Process finished with exit code 255
</code>```

But when i run the whole test class the error message is:

```<code>java.lang.AssertionError: JSON path "$.fieldErrors[0].field"
Expected: is "name"
     but: was "numberOfRooms"
Expected :name
Actual   :numberOfRooms
<Click to see difference>

    at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
    at org.springframework.test.util.JsonPathExpectationsHelper.assertValue(JsonPathExpectationsHelper.java:74)
    at org.springframework.test.web.servlet.result.JsonPathResultMatchers.lambda$value$0(JsonPathResultMatchers.java:87)
    at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:212)
    at hu.progmasters.moovsmart.controller.PropertyControllerTest.createPropertyTestWithErrorsMessage(PropertyControllerTest.java:109)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
</code>```

The indexing is mixed all the time, and i don't know why. Is there any way that the indexing always be in the same order?

I tried to make in the right order at first. But this not the right solution.

Body:
package hu.progmasters.moovsmart.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import hu.progmasters.moovsmart.domain.Property;
import hu.progmasters.moovsmart.dto.PropertyDetails;
import hu.progmasters.moovsmart.exception.GlobalExceptionHandler;
import hu.progmasters.moovsmart.repository.PropertyRepository;
import hu.progmasters.moovsmart.service.PropertyService;
import hu.progmasters.moovsmart.validation.PropertyFormValidator;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.context.MessageSource;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.validateMockitoUsage;
import static org.mockito.Mockito.verifyNoInteractions;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

@ExtendWith(MockitoExtension.class)
public class PropertyControllerTest {

    private MockMvc mockMvc;

    @Mock
    private PropertyRepository propertyRepositoryMock;

    @Mock
    private PropertyService propertyServiceMock;

    @BeforeEach
    public void setUp() {
        PropertyFormValidator propertyFormValidator = new PropertyFormValidator(propertyRepositoryMock);

        PropertyController propertyController = new PropertyController(propertyServiceMock, propertyFormValidator);

        mockMvc = MockMvcBuilders.standaloneSetup(propertyController)
                .setControllerAdvice(new GlobalExceptionHandler(messageSource()))
                .build();
    }

    @AfterEach
    public void validate() {
        validateMockitoUsage();
    }

    @Test
    public void createPropertyTest() throws Exception {
        Property property = new Property();
        property.setId(1L);
        property.setName("TestName");
        property.setDescription("Test description");
        property.setNumberOfRooms(2);
        property.setPrice(2000);
        property.setAddress("Test address");
        property.setImageUrl("test_url");

        PropertyDetails propertyDetails = new PropertyDetails(property);

        this.mockMvc.perform(
                        post("/api/properties")
                                .contentType(MediaType.APPLICATION_JSON)
                                .content(asJsonString(propertyDetails))
                )
                .andExpect(status().is(201));

    }

    @Test
    public void createPropertyTestWithErrorsMessage() throws Exception {
        Property property = new Property();
        property.setId(1L);
        //white space name
        property.setName(" ");
        //below 100 characters
        property.setDescription("few");
        //zero rooms
        property.setNumberOfRooms(0);
        //price zero
        property.setPrice(0);
        property.setAddress("Test address");
        property.setImageUrl("test_url");

        PropertyDetails propertyDetails = new PropertyDetails(property);

        verifyNoInteractions(propertyServiceMock);

        this.mockMvc.perform(
                        post("/api/properties")
                                .contentType(MediaType.APPLICATION_JSON)
                                .content(asJsonString(propertyDetails))
                )
                .andExpect(status().is(400))
                .andExpect(content().contentType(MediaType.APPLICATION_JSON))
                .andExpect(jsonPath("$.fieldErrors", hasSize(4)))
                .andExpect(jsonPath("$.fieldErrors[0].field", is("name")))
                .andExpect(jsonPath("$.fieldErrors[0].message", is("Property name cannot be only whitespaces!")))
                .andExpect(jsonPath("$.fieldErrors[1].field", is("description")))
                .andExpect(jsonPath("$.fieldErrors[1].message", is("Description must be between 10 and 2000 characters!")))
                .andExpect(jsonPath("$.fieldErrors[2].field", is("numberOfRooms")))
                .andExpect(jsonPath("$.fieldErrors[2].message", is("Number of rooms must be between 1 and 12!")))
                .andExpect(jsonPath("$.fieldErrors[3].field", is("price")))
                .andExpect(jsonPath("$.fieldErrors[3].message", is("The price can't be zero or below!")));

    }

    private MessageSource messageSource() {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();

        messageSource.setBasename("messages");
        messageSource.setUseCodeAsDefaultMessage(true);

        return messageSource;
    }

    public static String asJsonString(final Object obj) {
        try {
            return new ObjectMapper().writeValueAsString(obj);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}

If i run individually just the method:

createPropertyTestWithErrorsMessage()

I get this error:

java.lang.AssertionError: JSON path "$.fieldErrors[0].field"
Expected: is "name"
     but: was "description"
Expected :name
Actual   :description
<Click to see difference>

    at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
    at org.springframework.test.util.JsonPathExpectationsHelper.assertValue(JsonPathExpectationsHelper.java:74)
    at org.springframework.test.web.servlet.result.JsonPathResultMatchers.lambda$value$0(JsonPathResultMatchers.java:87)
    at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:212)
    at hu.progmasters.moovsmart.controller.PropertyControllerTest.createPropertyTestWithErrorsMessage(PropertyControllerTest.java:109)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

Process finished with exit code 255

But when i run the whole test class the error message is:

java.lang.AssertionError: JSON path "$.fieldErrors[0].field"
Expected: is "name"
     but: was "numberOfRooms"
Expected :name
Actual   :numberOfRooms
<Click to see difference>

    at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
    at org.springframework.test.util.JsonPathExpectationsHelper.assertValue(JsonPathExpectationsHelper.java:74)
    at org.springframework.test.web.servlet.result.JsonPathResultMatchers.lambda$value$0(JsonPathResultMatchers.java:87)
    at org.springframework.test.web.servlet.MockMvc$1.andExpect(MockMvc.java:212)
    at hu.progmasters.moovsmart.controller.PropertyControllerTest.createPropertyTestWithErrorsMessage(PropertyControllerTest.java:109)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
    at java.base/java.lang.reflect.Method.invoke(Method.java:577)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
    at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
    at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

The indexing is mixed all the time, and i don't know why. Is there any way that the indexing always be in the same order?

I tried to make in the right order at first. But this not the right solution.


问:
How can I align the left and right sides of the screens in harmony with all screens in a swiftui?
I want to make a top navigation bar compatible with all screens.
I want to leave 24 cm of space from left and right on each screen.
my code is like this:

```<code>struct NavigationBarView: View {
    var body: some View {
     HStack{
       GoldenTopBarUIView()
            Spacer()
       Image("mangaa")
                .resizable()
                .frame(width:79, height: 32.07, alignment: .center)
            Spacer()
       Button(action: {}, label: {
                ringIcon()
                })
       Button(action: {}, label: {
                MessageIcon()
               })
             }
            }
           }
</code>```

I want a space from the left like this, compatible with all screens
I want a space from the right like this, compatible with all screens

Body:
I want to make a top navigation bar compatible with all screens.
I want to leave 24 cm of space from left and right on each screen.
my code is like this:

struct NavigationBarView: View {
    var body: some View {
     HStack{
       GoldenTopBarUIView()
            Spacer()
       Image("mangaa")
                .resizable()
                .frame(width:79, height: 32.07, alignment: .center)
            Spacer()
       Button(action: {}, label: {
                ringIcon()
                })
       Button(action: {}, label: {
                MessageIcon()
               })
             }
            }
           }

I want a space from the left like this, compatible with all screens
I want a space from the right like this, compatible with all screens


问:
Initializing an extended generic property in TypeScript
I'm attempting to create a class with a generic parameter that extends type boolean. I've tried to make this generic parameter accessible at runtime by assigning it to a property like so:

```<code>class Example<T extends boolean> {
    foo: T = true;
}
</code>```

The base class declaration works, but the line initializing foo yields the error:

```<code>Type 'boolean' is not assignable to type 'T'.
  'boolean' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'boolean'.
</code>```

This doesn't make much sense to me. What other type could T be that extends but does not fall under true | false? Why does the possibility that it could be another type prevent it from being initialized as a boolean?

Body:
I'm attempting to create a class with a generic parameter that extends type boolean. I've tried to make this generic parameter accessible at runtime by assigning it to a property like so:

class Example<T extends boolean> {
    foo: T = true;
}

The base class declaration works, but the line initializing foo yields the error:

Type 'boolean' is not assignable to type 'T'.
  'boolean' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'boolean'.

This doesn't make much sense to me. What other type could T be that extends but does not fall under true | false? Why does the possibility that it could be another type prevent it from being initialized as a boolean?


问:
Meta Spark Studio not detecting a closed right eye but detecting a closed left
I'm trying to add a patch that makes a rectangle visible on a wink from either eye. It works perfectly for the left one but the right one refuses to work.

I've tried connecting the Right Eye Closed patch directly to Kira Visibility to no avail which pretty much rules out my or block being the issue. My best guess is it has something to do with the first three blocks but I have no idea honestly.
Full picture of patch


问:
C# .Net 6.0 German special characters are not saved properly on File
I am saving a Byte[] on a File. File is created successfully and all English characters are fine but all German special characters (ä, Ä, ö, Ö, ü, Ü, ß) are written wrong. The code is as below:

```<code>using (FileStream fs = File.Create(fileName))
{
    Byte[] betreffData = new UTF8Encoding(true).GetBytes("Subject: " + message.decSubject;
    fs.Write(betreffData, 0, betreffData.Length);
}
</code>```

Output on txt file is

Betreff: BersenbrÃ¼ck ./. Test GmbH

But the actual output should be

Betreff: Bersenbrßck ./. Test GmbH

How can I get the actual German characters too in output?

Body:
I am saving a Byte[] on a File. File is created successfully and all English characters are fine but all German special characters (ä, Ä, ö, Ö, ü, Ü, ß) are written wrong. The code is as below:

using (FileStream fs = File.Create(fileName))
{
    Byte[] betreffData = new UTF8Encoding(true).GetBytes("Subject: " + message.decSubject;
    fs.Write(betreffData, 0, betreffData.Length);
}

Output on txt file is

Betreff: BersenbrÃ¼ck ./. Test GmbH

But the actual output should be

Betreff: Bersenbrßck ./. Test GmbH

How can I get the actual German characters too in output?


问:
os.path.getmtime returning negative number only in Windows Server
I'm writing a python script in Windows server where I need the modified time of my file in a folder path.

```<code>filestamp = datetime.fromtimestamp(os.path.getmtime(path+filename))
</code>```

My code works fine locally but when I test in Windows Server, datetime.fromtimestamp returns

OSError : [Errno 22] Invalid argument

so when I print os.path.getmtime(path+filename), it returns -11623064500.963923

This is obviously wrong to convert to datetime and it only happens when in Windows Server.

I have seen answers multiplying / dividing the value by 1000, but it's no use. Especially when the value is negative.

Is there are alternate ways to get modified datetime of a file?

Body:
I'm writing a python script in Windows server where I need the modified time of my file in a folder path.

filestamp = datetime.fromtimestamp(os.path.getmtime(path+filename))

My code works fine locally but when I test in Windows Server, datetime.fromtimestamp returns

OSError : [Errno 22] Invalid argument

so when I print os.path.getmtime(path+filename), it returns -11623064500.963923

This is obviously wrong to convert to datetime and it only happens when in Windows Server.

I have seen answers multiplying / dividing the value by 1000, but it's no use. Especially when the value is negative.

Is there are alternate ways to get modified datetime of a file?


问:
Syntax error in module 'lambda_function': invalid syntax when changing lambda function to python from js
I create a lambda function with runtime setup Java scripts Node.js18.x and changed the runtime setup to python 3.9 and HandlerInfo to lambda_function.lambda_handler. I get an error message when I test this function.

Error message"errorMessage": "Syntax error in module 'lambda_function': invalid syntax (lambda_function.py, line 4)"

```<code>import time
import boto3

query = 'SELECT * FROM default.tb'
DATABASE = 'default'
output='s3://AWSDOC-EXAMPLE-BUCKET/'

def lambda_handler(event, context):
    query = "SELECT * FROM default.tb"
    client = boto3.client('athena')
    # Execution
    response = client.start_query_execution(
        QueryString=query,
        QueryExecutionContext={
            'Database': DATABASE
        },
        ResultConfiguration={
            'OutputLocation': output,
        }
    )
    return response
    return
</code>```

Line 4 is query = 'SELECT * FROM default.tb'

AWS reference file is here
https://aws.amazon.com/premiumsupport/knowledge-center/schedule-query-athena/

Why do I get this error message?

Body:
I create a lambda function with runtime setup Java scripts Node.js18.x and changed the runtime setup to python 3.9 and HandlerInfo to lambda_function.lambda_handler. I get an error message when I test this function.

Error message"errorMessage": "Syntax error in module 'lambda_function': invalid syntax (lambda_function.py, line 4)"

import time
import boto3

query = 'SELECT * FROM default.tb'
DATABASE = 'default'
output='s3://AWSDOC-EXAMPLE-BUCKET/'

def lambda_handler(event, context):
    query = "SELECT * FROM default.tb"
    client = boto3.client('athena')
    # Execution
    response = client.start_query_execution(
        QueryString=query,
        QueryExecutionContext={
            'Database': DATABASE
        },
        ResultConfiguration={
            'OutputLocation': output,
        }
    )
    return response
    return

Line 4 is query = 'SELECT * FROM default.tb'

AWS reference file is here
https://aws.amazon.com/premiumsupport/knowledge-center/schedule-query-athena/

Why do I get this error message?


问:
ResponseEntity function is supposed to take in an Object, send it to DAO, and return a Boolean, but isn't grabbing that first Object
I am attempting to implement a function that checks if an Object exists within a List of Objects by having a selected Object sent in and a Boolean sent out. Seems easy, right?

In my javascript service, everything starts out fine:

```<code>    function doesBookExist(book){
        return $http.get('http://localhost:8081/api/favoritebooks/checkBook', book)
</code>```

the Book goes in and is (presumably) sent to my java controller

```<code>    @GetMapping(value = "/checkBook", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<Boolean> checkBook(@RequestBody Book book){
        Boolean answer = bookService.doesBookExist(book);
        return new ResponseEntity<Boolean>(answer, HttpStatus.OK);
    }
</code>```

on looking over this code here, it appears that the Book object is not being picked up by the function, so either the problem is in the js service and it's not being sent correctly, or the code in the java controller is messing up in receiving the object.

Can anyone help me identify which is the source of the problem?

Body:
I am attempting to implement a function that checks if an Object exists within a List of Objects by having a selected Object sent in and a Boolean sent out. Seems easy, right?

In my javascript service, everything starts out fine:

    function doesBookExist(book){
        return $http.get('http://localhost:8081/api/favoritebooks/checkBook', book)

the Book goes in and is (presumably) sent to my java controller

    @GetMapping(value = "/checkBook", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<Boolean> checkBook(@RequestBody Book book){
        Boolean answer = bookService.doesBookExist(book);
        return new ResponseEntity<Boolean>(answer, HttpStatus.OK);
    }

on looking over this code here, it appears that the Book object is not being picked up by the function, so either the problem is in the js service and it's not being sent correctly, or the code in the java controller is messing up in receiving the object.

Can anyone help me identify which is the source of the problem?


问:
GA4: Why is the session count much lower when I select 'source' or 'source/medium' as dimension in rows
In the explore tab I am trying to look at the sessions by source or source/medium.

Without selecting any dimensions, I see 670k session over a selected time period.
total sessions

Wenn I select source I only see 2.7k sessions in the Totals. Same applies to source/medium.
sessions by source

Can anybody tell me what might be causing this?

I expect to see how the 670k sessions are distributed over the different sources in the report.


问:
JavaScript do wrong multiplication when the numbers are too larger || return round off of multiplication result
I am try to solve a problem of LEETCODE using JavaScript, the problem is Multiply Strings and the solution is:

```<code>const string = (num) => {
     return '' + num
 }

var multiply = function(num1, num2) {
    let result =  string(num1*num2)
    return result

};

console.log(multiply("123456789",
"987654321"))
</code>```

it should return  "121932631112635269"

but it returns 121932631112635260

Any Solution?

"123456789" * "987654321" should return "121932631112635269"

but it returns 121932631112635260

Body:
I am try to solve a problem of LEETCODE using JavaScript, the problem is Multiply Strings and the solution is:

const string = (num) => {
     return '' + num
 }

var multiply = function(num1, num2) {
    let result =  string(num1*num2)
    return result

};

console.log(multiply("123456789",
"987654321"))

it should return  "121932631112635269"

but it returns 121932631112635260

Any Solution?

"123456789" * "987654321" should return "121932631112635269"

but it returns 121932631112635260