问:
org.apache.hadoop.hive.ql.exec.UDF is deprecated
why hive3.x deprecate org.apache.hadoop.hive.ql.exec.UDF

then I use org.apache.hadoop.hive.ql.udf.generic.GenericUDF to deal join job
sql like

```<code>select
    dw_rk.STRDEREPEAT(',', t1.d_deptname, t2.d_deptname, t3.d_deptname) as d_deptname,
    dw_rk.STRDEREPEAT(',', t1.d_tabname, t2.d_tabname, t3.d_tabname) as d_tabname
from
    dw_rk.f_t_rk_jcxx t1
        LEFT join dw_rk.f_t_rk_hjxx t2 on t1.sfzhm = t2.sfzhm
        LEFT JOIN dw_rk.f_t_rk_dzxx t3 on t1.sfzhm = t3.sfzhm
</code>```

it means use a symbol to split cols,and return new union string

then
have an error in yarn

```<code>2022-12-09 15:22:54,852 ERROR [main] org.apache.hadoop.hive.ql.exec.MapJoinOperator: Unexpected exception from VectorMapJoinOperator : Error evaluating _col1
org.apache.hadoop.hive.ql.metadata.HiveException: Error evaluating _col1
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:149)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinBaseOperator.flushOutput(VectorMapJoinBaseOperator.java:254)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinBaseOperator.internalForward(VectorMapJoinBaseOperator.java:249)
    at org.apache.hadoop.hive.ql.exec.CommonJoinOperator.genAllOneUniqueJoinObject(CommonJoinOperator.java:848)
    at org.apache.hadoop.hive.ql.exec.CommonJoinOperator.checkAndGenObject(CommonJoinOperator.java:932)
    at org.apache.hadoop.hive.ql.exec.MapJoinOperator.process(MapJoinOperator.java:517)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinOperator.process(VectorMapJoinOperator.java:233)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:158)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.TableScanOperator.process(TableScanOperator.java:125)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapOperator.deliverVectorizedRowBatch(VectorMapOperator.java:812)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapOperator.process(VectorMapOperator.java:845)
    at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:154)
    at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
    at org.apache.hadoop.hive.ql.exec.mr.ExecMapRunner.run(ExecMapRunner.java:37)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:465)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:349)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:422)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1729)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:168)
Caused by: java.lang.NullPointerException
    at com.cestc.str.StrDerepeat.evaluate(StrDerepeat.java:33)
    at org.apache.hadoop.hive.ql.exec.vector.udf.VectorUDFAdaptor.setResult(VectorUDFAdaptor.java:190)
    at org.apache.hadoop.hive.ql.exec.vector.udf.VectorUDFAdaptor.evaluate(VectorUDFAdaptor.java:150)
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:146)
    ... 26 more
2022-12-09 15:22:54,853 ERROR [main] org.apache.hadoop.hive.ql.exec.mr.ExecMapper: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapOperator.process(VectorMapOperator.java:973)
    at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:154)
    at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
    at org.apache.hadoop.hive.ql.exec.mr.ExecMapRunner.run(ExecMapRunner.java:37)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:465)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:349)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:422)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1729)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:168)
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Unexpected exception from VectorMapJoinOperator : Error evaluating _col1
    at org.apache.hadoop.hive.ql.exec.MapJoinOperator.process(MapJoinOperator.java:530)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinOperator.process(VectorMapJoinOperator.java:233)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:158)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.TableScanOperator.process(TableScanOperator.java:125)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapOperator.deliverVectorizedRowBatch(VectorMapOperator.java:812)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapOperator.process(VectorMapOperator.java:845)
    ... 10 more
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Error evaluating _col1
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:149)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinBaseOperator.flushOutput(VectorMapJoinBaseOperator.java:254)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinBaseOperator.internalForward(VectorMapJoinBaseOperator.java:249)
    at org.apache.hadoop.hive.ql.exec.CommonJoinOperator.genAllOneUniqueJoinObject(CommonJoinOperator.java:848)
    at org.apache.hadoop.hive.ql.exec.CommonJoinOperator.checkAndGenObject(CommonJoinOperator.java:932)
    at org.apache.hadoop.hive.ql.exec.MapJoinOperator.process(MapJoinOperator.java:517)
    ... 19 more
Caused by: java.lang.NullPointerException
    at com.cestc.str.StrDerepeat.evaluate(StrDerepeat.java:33)
    at org.apache.hadoop.hive.ql.exec.vector.udf.VectorUDFAdaptor.setResult(VectorUDFAdaptor.java:190)
    at org.apache.hadoop.hive.ql.exec.vector.udf.VectorUDFAdaptor.evaluate(VectorUDFAdaptor.java:150)
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:146)
    ... 26 more
</code>```

I set
hive.vectorized.execution.enabled
and
hive.vectorized.execution.reduce.enabled
false alse wrong

then I take concat_ws() to 3 cols join into temp table,and take STRDEREPEAT to overwrite itself ,I success.
but I can`t know reason

Body:
why hive3.x deprecate org.apache.hadoop.hive.ql.exec.UDF

then I use org.apache.hadoop.hive.ql.udf.generic.GenericUDF to deal join job
sql like

select
    dw_rk.STRDEREPEAT(',', t1.d_deptname, t2.d_deptname, t3.d_deptname) as d_deptname,
    dw_rk.STRDEREPEAT(',', t1.d_tabname, t2.d_tabname, t3.d_tabname) as d_tabname
from
    dw_rk.f_t_rk_jcxx t1
        LEFT join dw_rk.f_t_rk_hjxx t2 on t1.sfzhm = t2.sfzhm
        LEFT JOIN dw_rk.f_t_rk_dzxx t3 on t1.sfzhm = t3.sfzhm

it means use a symbol to split cols,and return new union string

then
have an error in yarn

2022-12-09 15:22:54,852 ERROR [main] org.apache.hadoop.hive.ql.exec.MapJoinOperator: Unexpected exception from VectorMapJoinOperator : Error evaluating _col1
org.apache.hadoop.hive.ql.metadata.HiveException: Error evaluating _col1
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:149)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinBaseOperator.flushOutput(VectorMapJoinBaseOperator.java:254)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinBaseOperator.internalForward(VectorMapJoinBaseOperator.java:249)
    at org.apache.hadoop.hive.ql.exec.CommonJoinOperator.genAllOneUniqueJoinObject(CommonJoinOperator.java:848)
    at org.apache.hadoop.hive.ql.exec.CommonJoinOperator.checkAndGenObject(CommonJoinOperator.java:932)
    at org.apache.hadoop.hive.ql.exec.MapJoinOperator.process(MapJoinOperator.java:517)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinOperator.process(VectorMapJoinOperator.java:233)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:158)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.TableScanOperator.process(TableScanOperator.java:125)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapOperator.deliverVectorizedRowBatch(VectorMapOperator.java:812)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapOperator.process(VectorMapOperator.java:845)
    at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:154)
    at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
    at org.apache.hadoop.hive.ql.exec.mr.ExecMapRunner.run(ExecMapRunner.java:37)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:465)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:349)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:422)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1729)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:168)
Caused by: java.lang.NullPointerException
    at com.cestc.str.StrDerepeat.evaluate(StrDerepeat.java:33)
    at org.apache.hadoop.hive.ql.exec.vector.udf.VectorUDFAdaptor.setResult(VectorUDFAdaptor.java:190)
    at org.apache.hadoop.hive.ql.exec.vector.udf.VectorUDFAdaptor.evaluate(VectorUDFAdaptor.java:150)
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:146)
    ... 26 more
2022-12-09 15:22:54,853 ERROR [main] org.apache.hadoop.hive.ql.exec.mr.ExecMapper: org.apache.hadoop.hive.ql.metadata.HiveException: Hive Runtime Error while processing row
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapOperator.process(VectorMapOperator.java:973)
    at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.map(ExecMapper.java:154)
    at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:54)
    at org.apache.hadoop.hive.ql.exec.mr.ExecMapRunner.run(ExecMapRunner.java:37)
    at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:465)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:349)
    at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:422)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1729)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:168)
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Unexpected exception from VectorMapJoinOperator : Error evaluating _col1
    at org.apache.hadoop.hive.ql.exec.MapJoinOperator.process(MapJoinOperator.java:530)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinOperator.process(VectorMapJoinOperator.java:233)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:158)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.TableScanOperator.process(TableScanOperator.java:125)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapOperator.deliverVectorizedRowBatch(VectorMapOperator.java:812)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapOperator.process(VectorMapOperator.java:845)
    ... 10 more
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Error evaluating _col1
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:149)
    at org.apache.hadoop.hive.ql.exec.Operator.vectorForward(Operator.java:966)
    at org.apache.hadoop.hive.ql.exec.Operator.forward(Operator.java:939)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinBaseOperator.flushOutput(VectorMapJoinBaseOperator.java:254)
    at org.apache.hadoop.hive.ql.exec.vector.VectorMapJoinBaseOperator.internalForward(VectorMapJoinBaseOperator.java:249)
    at org.apache.hadoop.hive.ql.exec.CommonJoinOperator.genAllOneUniqueJoinObject(CommonJoinOperator.java:848)
    at org.apache.hadoop.hive.ql.exec.CommonJoinOperator.checkAndGenObject(CommonJoinOperator.java:932)
    at org.apache.hadoop.hive.ql.exec.MapJoinOperator.process(MapJoinOperator.java:517)
    ... 19 more
Caused by: java.lang.NullPointerException
    at com.cestc.str.StrDerepeat.evaluate(StrDerepeat.java:33)
    at org.apache.hadoop.hive.ql.exec.vector.udf.VectorUDFAdaptor.setResult(VectorUDFAdaptor.java:190)
    at org.apache.hadoop.hive.ql.exec.vector.udf.VectorUDFAdaptor.evaluate(VectorUDFAdaptor.java:150)
    at org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator.process(VectorSelectOperator.java:146)
    ... 26 more

I set
hive.vectorized.execution.enabled
and
hive.vectorized.execution.reduce.enabled
false alse wrong

then I take concat_ws() to 3 cols join into temp table,and take STRDEREPEAT to overwrite itself ,I success.
but I can`t know reason


来源: stackexchange

问:
Containers on different swarm nodes can't reach eachother
in short, I've got the problem that containers in a swarm can't reach containers that sit on another node. The worker node is in my home network, so not directly accessible externally.

Setup:

Manager node that is a publicly available server, let's give it the IP A.A.A.A

Worker node that is at home, behind a router, with the internal IP B.B.B.B and the router with public IP C.C.C.C

The worker can without a problem join the swarm, the manager can without problems allocate containers to that worker, so some sort of communication is established and working.
What is not working is, that containers on the manager can't reach containers on the worker and vice versa (but can reach containers on the same node)

docker node ls shows the worker node as Ready and Active. docker node inspect <NODE NAME> show the IP C.C.C.C under Status

minimal working example:

docker-compose

version: "3.8"
services:
  manager1:
    image: jwilder/whoami
    hostname: manager1
    deploy:
      placement:
        constraints:
          - node.role == manager
  manager2:
    image: jwilder/whoami
    hostname: manager2
    deploy:
      placement:
        constraints:
          - node.role == manager
  worker1:
    image: jwilder/whoami
    hostname: worker1
    deploy:
      placement:
        constraints:
          - node.role == worker
  worker2:
    image: jwilder/whoami
    hostname: worker2
    deploy:
      placement:
        constraints:
          - node.role == worker

```
<p>deploying with <code>docker stack deploy -c docker-compose.yml testing</code></p>
<p><code>docker network inspect testing_default -v</code> on manager shows</p>
<pre class="lang-js prettyprint-override"><code>"Peers": [
    {
        "Name": "f0de4150d01e",
        "IP": "A.A.A.A"
    }
],
"Services": {
    "testing_manager1": {
        "VIP": "10.0.25.5",
        "Ports": [],
        "LocalLBIndex": 21646,
        "Tasks": [
            {
                "Name": "testing_manager1.1.w6b2wufu96vk1jmtez9dtewr0",
                "EndpointID": "213b7182882e267f249edc52be57f6c56d83efafeba471639f2cbb9398854fe0",
                "EndpointIP": "10.0.25.6",
                "Info": {
                    "Host IP": "A.A.A.A"
                }
            }
        ]
    },
    "testing_manager2": {
        "VIP": "10.0.25.8",
        "Ports": [],
        "LocalLBIndex": 21645,
        "Tasks": [
            {
                "Name": "testing_manager2.1.5w51imw8toh81oyeruu48z2pr",
                "EndpointID": "41eeb9eaf97cd3f744873ccea9577332e24c799f61171c59447e084de9c829a4",
                "EndpointIP": "10.0.25.9",
                "Info": {
                    "Host IP": "A.A.A.A"
                }
            }
        ]
    }
}
</code>```

docker network inspect testing_default -v on worker shows

"Peers": [
    {
        "Name": "75fba815742b",
        "IP": "B.B.B.B"
    },
    {
        "Name": "f0de4150d01e",
        "IP": "A.A.A.A"
    }
],
"Services": {
    "testing_worker1": {
        "VIP": "10.0.25.10",
        "Ports": [],
        "LocalLBIndex": 293,
        "Tasks": [
            {
                "Name": "testing_worker1.1.ol4x1h560613l7e7yqv94sj68",
                "EndpointID": "3a9dc067b4a0e7e5d26fabdcb887b823f49bfad21fc0ec159edd8dd4f976b702",
                "EndpointIP": "10.0.25.11",
                "Info": {
                    "Host IP": "B.B.B.B"
                }
            }
        ]
    },
    "testing_worker2": {
        "VIP": "10.0.25.2",
        "Ports": [],
        "LocalLBIndex": 292,
        "Tasks": [
            {
                "Name": "testing_worker2.1.m2d5fwn83uxg9b7udakq1o41x",
                "EndpointID": "8317415fe2b0fa77d1195d33e91fa3354fcfd00af0bab5161c69038eb8fe38bb",
                "EndpointIP": "10.0.25.3",
                "Info": {
                    "Host IP": "B.B.B.B"
                }
            }
        ]
    }
}
```

So the worker sees the manager as a peer, but does not see the other services. What confuses me, is that the Host IP for worker services is B.B.B.B, which is the internal IP of the worker node (so a 192.168.x.x IP) instead of the external IP of my home network.

Attaching to one of the containers with docker exec -it <CONTAINER ID> /bin/sh and executing wget -qO- <ANOTHER CONTAINERS IP>:8000 returns fine for containers on the same node, but Host unreachable for containers on the other node. (Testing with the defined host names returns "bad address" for the ones on the other node)

Looking at the docs, it reads at https://docs.docker.com/engine/swarm/swarm-tutorial/#open-protocols-and-ports-between-the-hosts that there need to be some ports open.

I was under the impression that creating the swarm comes with a virtual network between the nodes (which kinda seems to be the case, as the services can get created without a problem, so there is a connection). But as it did not work like that, I tested it with just plain port forwarding, which resulted in the manager "sometimes" seeing the other services when inspecting the network, but the containers still can't reach eachother.

Am I supposed to spin up a VPN for the nodes to be inside the same network, or what am I missing?

ContentLicense: CC BY-SA 4.0

Body:
in short, I've got the problem that containers in a swarm can't reach containers that sit on another node. The worker node is in my home network, so not directly accessible externally.

Setup:

Manager node that is a publicly available server, let's give it the IP A.A.A.A

Worker node that is at home, behind a router, with the internal IP B.B.B.B and the router with public IP C.C.C.C

The worker can without a problem join the swarm, the manager can without problems allocate containers to that worker, so some sort of communication is established and working.
What is not working is, that containers on the manager can't reach containers on the worker and vice versa (but can reach containers on the same node)

docker node ls shows the worker node as Ready and Active. docker node inspect <NODE NAME> show the IP C.C.C.C under Status

minimal working example:

docker-compose

version: "3.8"
services:
  manager1:
    image: jwilder/whoami
    hostname: manager1
    deploy:
      placement:
        constraints:
          - node.role == manager
  manager2:
    image: jwilder/whoami
    hostname: manager2
    deploy:
      placement:
        constraints:
          - node.role == manager
  worker1:
    image: jwilder/whoami
    hostname: worker1
    deploy:
      placement:
        constraints:
          - node.role == worker
  worker2:
    image: jwilder/whoami
    hostname: worker2
    deploy:
      placement:
        constraints:
          - node.role == worker

deploying with docker stack deploy -c docker-compose.yml testing

docker network inspect testing_default -v on manager shows

"Peers": [
    {
        "Name": "f0de4150d01e",
        "IP": "A.A.A.A"
    }
],
"Services": {
    "testing_manager1": {
        "VIP": "10.0.25.5",
        "Ports": [],
        "LocalLBIndex": 21646,
        "Tasks": [
            {
                "Name": "testing_manager1.1.w6b2wufu96vk1jmtez9dtewr0",
                "EndpointID": "213b7182882e267f249edc52be57f6c56d83efafeba471639f2cbb9398854fe0",
                "EndpointIP": "10.0.25.6",
                "Info": {
                    "Host IP": "A.A.A.A"
                }
            }
        ]
    },
    "testing_manager2": {
        "VIP": "10.0.25.8",
        "Ports": [],
        "LocalLBIndex": 21645,
        "Tasks": [
            {
                "Name": "testing_manager2.1.5w51imw8toh81oyeruu48z2pr",
                "EndpointID": "41eeb9eaf97cd3f744873ccea9577332e24c799f61171c59447e084de9c829a4",
                "EndpointIP": "10.0.25.9",
                "Info": {
                    "Host IP": "A.A.A.A"
                }
            }
        ]
    }
}

docker network inspect testing_default -v on worker shows

"Peers": [
    {
        "Name": "75fba815742b",
        "IP": "B.B.B.B"
    },
    {
        "Name": "f0de4150d01e",
        "IP": "A.A.A.A"
    }
],
"Services": {
    "testing_worker1": {
        "VIP": "10.0.25.10",
        "Ports": [],
        "LocalLBIndex": 293,
        "Tasks": [
            {
                "Name": "testing_worker1.1.ol4x1h560613l7e7yqv94sj68",
                "EndpointID": "3a9dc067b4a0e7e5d26fabdcb887b823f49bfad21fc0ec159edd8dd4f976b702",
                "EndpointIP": "10.0.25.11",
                "Info": {
                    "Host IP": "B.B.B.B"
                }
            }
        ]
    },
    "testing_worker2": {
        "VIP": "10.0.25.2",
        "Ports": [],
        "LocalLBIndex": 292,
        "Tasks": [
            {
                "Name": "testing_worker2.1.m2d5fwn83uxg9b7udakq1o41x",
                "EndpointID": "8317415fe2b0fa77d1195d33e91fa3354fcfd00af0bab5161c69038eb8fe38bb",
                "EndpointIP": "10.0.25.3",
                "Info": {
                    "Host IP": "B.B.B.B"
                }
            }
        ]
    }
}

So the worker sees the manager as a peer, but does not see the other services. What confuses me, is that the Host IP for worker services is B.B.B.B, which is the internal IP of the worker node (so a 192.168.x.x IP) instead of the external IP of my home network.

Attaching to one of the containers with docker exec -it <CONTAINER ID> /bin/sh and executing wget -qO- <ANOTHER CONTAINERS IP>:8000 returns fine for containers on the same node, but Host unreachable for containers on the other node. (Testing with the defined host names returns "bad address" for the ones on the other node)

Looking at the docs, it reads at https://docs.docker.com/engine/swarm/swarm-tutorial/#open-protocols-and-ports-between-the-hosts that there need to be some ports open.

I was under the impression that creating the swarm comes with a virtual network between the nodes (which kinda seems to be the case, as the services can get created without a problem, so there is a connection). But as it did not work like that, I tested it with just plain port forwarding, which resulted in the manager "sometimes" seeing the other services when inspecting the network, but the containers still can't reach eachother.

Am I supposed to spin up a VPN for the nodes to be inside the same network, or what am I missing?


问:
How to add validation with error message in Select using react-hook-form
I am using react-hook-form for validating my form but not bale to set validation for my select dropdown

```<code>          <Form.Group>
              <Form.Select
                type="text"
                defaultValue={"default"}
                {...register("role", { required: true })}
              >
                <option value="default" disabled>
                  Select Role
                </option>
                <option value="UI Developer">UI Developer</option>
                <option value="Backend Developer">Backend Developer</option>
                <option value="Python Developer">Python Developer</option>
              </Form.Select>
              {errors.role && <span>Select Role</span>}
          </Form.Group>
</code>```

I tried using the min, max options but that did not work, also tried setting required: "select option" but this did not worked too

Body:
I am using react-hook-form for validating my form but not bale to set validation for my select dropdown

          <Form.Group>
              <Form.Select
                type="text"
                defaultValue={"default"}
                {...register("role", { required: true })}
              >
                <option value="default" disabled>
                  Select Role
                </option>
                <option value="UI Developer">UI Developer</option>
                <option value="Backend Developer">Backend Developer</option>
                <option value="Python Developer">Python Developer</option>
              </Form.Select>
              {errors.role && Select Role}
          </Form.Group>

I tried using the min, max options but that did not work, also tried setting required: "select option" but this did not worked too


问:
Python requests post reponse 400
I have no idea where is error. My response is 400 cuz of it:
"errors":{"data":["The data field is required."
but i am sending 'data':

```<code>data = "{'example': 'example'}"
url = f'http://localhost:5219/myApi'
payload = {'data': str(data).encode('utf-8')}
req = requests.post(url, data=payload)
print(req.content)
</code>```

response

```<code>b'{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-355ed090aff5fa10460587fe222edbbe-3b3927cf18b26b78-00","errors":{"data":["The data field is required."]}}'
</code>```

how can i repair that?

i tried changing formats and other things but it didn't work pls help me

this is c# code from api:

```<code>using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Bson;
using System.Text.Json.Nodes;

namespace spyware.Api.Controllers
{
    [Route("[controller]")]
    [ApiController]
    public class api : ControllerBase
    {
        [HttpPost]
        public void GetResponse(string data)
        {
            Console.WriteLine(JsonConvert.DeserializeObject(data.ToString()));
        }

    }
}
</code>```

Title: Python requests post reponse 400

Body:
I have no idea where is error. My response is 400 cuz of it:
"errors":{"data":["The data field is required."
but i am sending 'data':

data = "{'example': 'example'}"
url = f'http://localhost:5219/myApi'
payload = {'data': str(data).encode('utf-8')}
req = requests.post(url, data=payload)
print(req.content)

response

b'{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"00-355ed090aff5fa10460587fe222edbbe-3b3927cf18b26b78-00","errors":{"data":["The data field is required."]}}'

how can i repair that?

i tried changing formats and other things but it didn't work pls help me

this is c# code from api:

using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Bson;
using System.Text.Json.Nodes;

namespace spyware.Api.Controllers
{
    [Route("[controller]")]
    [ApiController]
    public class api : ControllerBase
    {
        [HttpPost]
        public void GetResponse(string data)
        {
            Console.WriteLine(JsonConvert.DeserializeObject(data.ToString()));
        }

    }
}


问:
The plugins `downloads_path_provider_28, flutter_qr_code_scaner` use a deprecated version of the Android embedding
The plugins downloads_path_provider_28, flutter_qr_code_scaner use a deprecated version of the Android embedding.

The plugins downloads_path_provider_28, flutter_qr_code_scaner use a deprecated version of the Android embedding.


问:
In Entity Framework i want to use roslyn analyzer and find the places where lazy loading might occur on some huge tables. Any idea on how to achieve?
In Entity Framework i want to use roslyn analyzer and find the places where lazy loading might occur on some huge tables. Any idea on how to achieve?

I am trying to achieve and give warning while running the solution if a code is written in such a way that will trigger lazy loading on certain huge tables.


问:
How to navigate from a different page on a different tab using CupertinoTabBar?
I have 4 tabs and for each tab I have a page, I use CupertinoTabScaffold to build my tabs:

```<code> Widget build(BuildContext context) {
   return CupertinoTabScaffold(
       controller: controller,
       backgroundColor: Colors.black87,
       tabBar: CupertinoTabBar(
         iconSize: 30,
         currentIndex: currentIndex,
         onTap: (index) => setState(() => currentIndex = index),
         items: const [
           BottomNavigationBarItem(icon: Icon(Icons.home, size: 25)),
           BottomNavigationBarItem(icon: Icon(Icons.store, size: 25,)),
           BottomNavigationBarItem(icon: Icon(Icons.shopping_bag, size: 25)),
           BottomNavigationBarItem(icon: Icon(Icons.person, size: 25)),
         ],
       ),
       tabBuilder: (BuildContext context, int index) {
         switch (index) {
           case 0:
             return CupertinoTabView(
               navigatorKey: navigatorKeyList[index],
               builder: (BuildContext context) {
                 return CupertinoPageScaffold(
                   resizeToAvoidBottomInset: false,
                   child: HomePage(),
                 );
               },
             );
           case 1:
             return CupertinoTabView(
               navigatorKey: navigatorKeyList[index],
               builder: (BuildContext context) {
                 return CupertinoPageScaffold(
                   resizeToAvoidBottomInset: false,
                   child: CatalogPage(),
                 );
               },
             );
           case 2:
             return CupertinoTabView(
               navigatorKey: navigatorKeyList[index],
               builder: (BuildContext context) {
                 return CupertinoPageScaffold(
                   resizeToAvoidBottomInset: false,
                   child: ShoppingBag(),
                 );
               },
             );
           case 3:
             return CupertinoTabView(
               navigatorKey: navigatorKeyList[index],
               builder: (BuildContext context) {
                 return CupertinoPageScaffold(
                   resizeToAvoidBottomInset: false,
                   child: UserProfileScaffold(),
                 );
               },
             );
           default:
             return CupertinoTabView(
               builder: (BuildContext context) {
                 return CupertinoPageScaffold(
                   resizeToAvoidBottomInset: false,
                   child: HomePage(),
                 );
               },
             );
         }
       });
 }
</code>```

I want to switch between tabs when I use Navigator.push, not just push to the page, like in material BottomNavigationBar.

Edited

Here is an example of what my Navigator.push should look like:

```<code>ElevatedButton(onPressed: () async {
            SharedPreferences pref = await SharedPreferences.getInstance();
            await pref.clear();
            Navigator.of(context).pushAndRemoveUntil(
                MaterialPageRoute(
                    builder: (context) => CupertinoBottomNavBarPage(tab: 0)),
                    (route) => false);
          },
            child: const Text('logout'))
</code>```

Body:
I have 4 tabs and for each tab I have a page, I use CupertinoTabScaffold to build my tabs:

 Widget build(BuildContext context) {
   return CupertinoTabScaffold(
       controller: controller,
       backgroundColor: Colors.black87,
       tabBar: CupertinoTabBar(
         iconSize: 30,
         currentIndex: currentIndex,
         onTap: (index) => setState(() => currentIndex = index),
         items: const [
           BottomNavigationBarItem(icon: Icon(Icons.home, size: 25)),
           BottomNavigationBarItem(icon: Icon(Icons.store, size: 25,)),
           BottomNavigationBarItem(icon: Icon(Icons.shopping_bag, size: 25)),
           BottomNavigationBarItem(icon: Icon(Icons.person, size: 25)),
         ],
       ),
       tabBuilder: (BuildContext context, int index) {
         switch (index) {
           case 0:
             return CupertinoTabView(
               navigatorKey: navigatorKeyList[index],
               builder: (BuildContext context) {
                 return CupertinoPageScaffold(
                   resizeToAvoidBottomInset: false,
                   child: HomePage(),
                 );
               },
             );
           case 1:
             return CupertinoTabView(
               navigatorKey: navigatorKeyList[index],
               builder: (BuildContext context) {
                 return CupertinoPageScaffold(
                   resizeToAvoidBottomInset: false,
                   child: CatalogPage(),
                 );
               },
             );
           case 2:
             return CupertinoTabView(
               navigatorKey: navigatorKeyList[index],
               builder: (BuildContext context) {
                 return CupertinoPageScaffold(
                   resizeToAvoidBottomInset: false,
                   child: ShoppingBag(),
                 );
               },
             );
           case 3:
             return CupertinoTabView(
               navigatorKey: navigatorKeyList[index],
               builder: (BuildContext context) {
                 return CupertinoPageScaffold(
                   resizeToAvoidBottomInset: false,
                   child: UserProfileScaffold(),
                 );
               },
             );
           default:
             return CupertinoTabView(
               builder: (BuildContext context) {
                 return CupertinoPageScaffold(
                   resizeToAvoidBottomInset: false,
                   child: HomePage(),
                 );
               },
             );
         }
       });
 }

I want to switch between tabs when I use Navigator.push, not just push to the page, like in material BottomNavigationBar.

Edited

Here is an example of what my Navigator.push should look like:

ElevatedButton(onPressed: () async {
            SharedPreferences pref = await SharedPreferences.getInstance();
            await pref.clear();
            Navigator.of(context).pushAndRemoveUntil(
                MaterialPageRoute(
                    builder: (context) => CupertinoBottomNavBarPage(tab: 0)),
                    (route) => false);
          },
            child: const Text('logout'))


问:
Docker Swarm to encrypt password in application.properties as docker-compose?
In a Spring Boot app, I am just trying to encrypt passwords used in the docker-compose.yml and application.properties.yml files. But I am not sure if Docker Swarm is a proper option for me because I share the app with the customer who will run the app via the commands that I provide (e.g. docker-compose using Dockerfile in the project).

So, my questions are:

1. Is Docker Swarm is a proper option for me to encrypt password in docker-compose.yml and application.properties.yml files?

2. How can I encrypt the passwords, can you basically explain some steps?


问:
Updating data in a csv after editing in a GUI
I'm displaying already available data from csv file in a GUI.
If I update some values in the GUI, i want them to be updated in the csv file as well.

```<code> def onClickedSaveReturn(self):
        """closes GUI and returns to calling (main) GUI"""

        df_general = Clean.get_GeneralData()

        # First of all, read general data so that pre-/intra- and postoperative share these
        df_subj = {k: '' for k in Content.extract_saved_data(self.date).keys()}  # create empty dictionary
        df_subj['ID'] = General.read_current_subj().id[0]
        df_subj['PID'] = df_general['PID_ORBIS'][0]
        df_subj['Gender'] = df_general['Gender'][0]
        df_subj['Diagnosis_preop'] = df_general['diagnosis'][0]

        # Now extract teh changed data from the GUI
        df_subj["First_Diagnosed_preop"] = self.lineEditFirstDiagnosed.text()
        df_subj['Admission_preop'] = self.lineEditAdmNeurIndCheck.text()
        df_subj['Dismissal_preop'] = self.DismNeurIndCheckLabel.text()

.
.
.

subj_id = General.read_current_subj().id[0] # reads data from current_subj (saved in ./tmp)
        df = General.import_dataframe('{}.csv'.format(self.date), separator_csv=',')
        if df.shape[1] == 1:
            df = General.import_dataframe('{}.csv'.format(self.date), separator_csv=';')

        idx2replace = df.index[df['ID'] == subj_id][0]
        df_subj = df.iloc[idx2replace, :]
        df = df.replace(['nan', ''], [np.nan, np.nan])
        #df.to_csv(os.path.join(FILEDIR, "preoperative.csv"), index=False)

</code>```

If i run this code including the line
"df.to_csv(os.path.join(FILEDIR, "preoperative.csv"), index=False)", all data in the csv file (except the columns "ID", "PID", "Gender" "Diagnosis_preop")

So I want all the data i definied in df_subj to replace the data in csv.
I have no idea why my code isn't working ..

Thank you guys!

Body:
I'm displaying already available data from csv file in a GUI.
If I update some values in the GUI, i want them to be updated in the csv file as well.

 def onClickedSaveReturn(self):
        """closes GUI and returns to calling (main) GUI"""

        df_general = Clean.get_GeneralData()

        # First of all, read general data so that pre-/intra- and postoperative share these
        df_subj = {k: '' for k in Content.extract_saved_data(self.date).keys()}  # create empty dictionary
        df_subj['ID'] = General.read_current_subj().id[0]
        df_subj['PID'] = df_general['PID_ORBIS'][0]
        df_subj['Gender'] = df_general['Gender'][0]
        df_subj['Diagnosis_preop'] = df_general['diagnosis'][0]

        # Now extract teh changed data from the GUI
        df_subj["First_Diagnosed_preop"] = self.lineEditFirstDiagnosed.text()
        df_subj['Admission_preop'] = self.lineEditAdmNeurIndCheck.text()
        df_subj['Dismissal_preop'] = self.DismNeurIndCheckLabel.text()

.
.
.

subj_id = General.read_current_subj().id[0] # reads data from current_subj (saved in ./tmp)
        df = General.import_dataframe('{}.csv'.format(self.date), separator_csv=',')
        if df.shape[1] == 1:
            df = General.import_dataframe('{}.csv'.format(self.date), separator_csv=';')

        idx2replace = df.index[df['ID'] == subj_id][0]
        df_subj = df.iloc[idx2replace, :]
        df = df.replace(['nan', ''], [np.nan, np.nan])
        #df.to_csv(os.path.join(FILEDIR, "preoperative.csv"), index=False)

If i run this code including the line
"df.to_csv(os.path.join(FILEDIR, "preoperative.csv"), index=False)", all data in the csv file (except the columns "ID", "PID", "Gender" "Diagnosis_preop")

So I want all the data i definied in df_subj to replace the data in csv.
I have no idea why my code isn't working ..

Thank you guys!


问:
getServerSideProps pass Undefined value
Sticker.ts

```<code>import React from "react";
import Image from "next/image";

import {GetServerSideProps, InferGetServerSidePropsType } from 'next';
import Product from "models/Product";
import currencyFormatter from "lib/currencyFormatter";
import mongoose from "mongoose";
import handler from "pages/api/pincode";

// const Sticker = (props: any) => {
const Sticker = ({products}) => {
  // const products = JSON.parse((props?.products));
  console.log("list of product  "+ products)
  return (
    <div>
      <section className="text-gray-600 body-font">
        <div className="container px-5 py-24 mx-auto">
          <div className="flex flex-wrap -m-4 justify-centr">
            {/* {products?.map((dt: any, idx: number) =>  */}
                {/* <div className="lg:w-1/4 md:w-1/2 p-4 w-full" key={idx}> */}
                <div className="lg:w-1/4 md:w-1/2 p-4 w-full" >
                {/* <a href={`./product/${dt?.category}/${dt?.id}`} className="block relative h-68 rounded overflow-hidden"> */}
                <a href="./product/{category}/slug[jhbjh]" className="block relative h-68 rounded overflow-hidden">
                    <Image
                        alt="ecommerce"
                        className="object-cover cursor-pointer object-center  w-full h-full block"
                        src="https://m.media-amazon.com/images/I/61SFAM62ucL._SL1280_.jpg"
                        width="100"
                        height="100"
                    />
                </a>
                <div className="mt-4">
                    <h3 className="text-gray-500 text-xs tracking-widest title-font mb-1">
                    Home Decor
                    </h3>
                    <h2 className="text-gray-900 title-font text-lg font-medium">
                        Paper Plane Design Quote and Motivational Posters 12X18
                    </h2>
                    <p className="mt-1">{currencyFormatter(179)}</p>
                </div>
                </div>
            {/* )} */}
          </div>
        </div>
      </section>
    </div>
  );
};

export async function getServerSideProps(context) {
  if(!mongoose.connections[0].readyState){
     await mongoose.connect(process.env.MONGO_URI)
  }

  let products =  await Product.find()

  return {
    // props: { products },
    props: { products : JSON.parse(JSON.stringify(products)) },

  }
}

export default Sticker;

</code>```

_app.tsx

```<code>import React, { useEffect, useState } from 'react'
import { NextUIProvider, useSSR } from '@nextui-org/react';

import '../styles/globals.css'
import Navbar from '../modules/body/Navbar';
import Footer from '../modules/body/Footer';
import theme from "../themes";
import { AppProps } from 'next/app';
// import SideNavbar from '../mainComponent/SideNavbar'

function MyApp({ Component, pageProps }: AppProps) {
  const [cart, setCart] = useState<object>({})
  const [subTotal, setSubTotal] = useState<number>(0)
  const { isBrowser } = useSSR();
  useEffect(() => {
    try {
      if (localStorage.getItem("cart")) {
        setCart(JSON.parse(localStorage.getItem("cart") || ""))
        saveCart(JSON.parse(localStorage.getItem("cart") || ""))
      }
    } catch (error) {
      console.log(error);
      localStorage.clear()
    }
  }, [])

  const saveCart = (myCart: object) => {
    localStorage.setItem("cart", JSON.stringify(myCart))
    // let keys = Object.keys(myCart);
    const subt = Object.values(myCart).reduce((acc, curr) => acc + curr?.price * curr?.qty,0);
    setSubTotal(subt)
  }

  const addToCart = (itemCode, qty, price, name, size, variant) => {
    let newCart = cart;
    if (itemCode in cart) {
      newCart[itemCode].qty = cart[itemCode].qty + qty
    }
    else {
      newCart[itemCode] = { qty: 1, price, name, size, variant }
    }
    setCart(newCart)
    saveCart(newCart)
  }

  const removeFromCart = (itemCode, qty, price, name, size, variant) => {
    let newCart = JSON.parse(JSON.stringify(cart));
    if (itemCode in cart) {
      newCart[itemCode].qty = cart[itemCode].qty - qty
    }
    if (newCart[itemCode]["qty"] <= 0) {
      delete newCart[itemCode]
    }
    setCart(newCart)
    saveCart(newCart)
  }

  const clearCart = () => {
    setCart({})
    saveCart({})
  }

  return isBrowser && (
    <NextUIProvider theme={theme}>
      <Navbar key={subTotal} cart={cart} addToCart={addToCart} removeFromCart={removeFromCart}
        clearCart={clearCart} subTotal={subTotal} />

      {/* <SideNavbar /> */}

      <Component cart={cart} addToCart={addToCart} removeFromCart={removeFromCart}
        clearCart={clearCart} subTotal={subTotal} {...pageProps} />
      <Footer />
    </NextUIProvider>
  )
}

export default MyApp

</code>```

I tried every method posted on the browser but still it shows undefined. If you help me to find out the solution of this problem then i will be very happy and feel blessed with this coding environment. please solve this as soon as possible. My whole project is stucked because of this error.

Title: getServerSideProps pass Undefined value

Body:
Sticker.ts

import React from "react";
import Image from "next/image";

import {GetServerSideProps, InferGetServerSidePropsType } from 'next';
import Product from "models/Product";
import currencyFormatter from "lib/currencyFormatter";
import mongoose from "mongoose";
import handler from "pages/api/pincode";

// const Sticker = (props: any) => {
const Sticker = ({products}) => {
  // const products = JSON.parse((props?.products));
  console.log("list of product  "+ products)
  return (

            {/* {products?.map((dt: any, idx: number) =>  */}
                {/*
 */}

                {/* <a href={`./product/${dt?.category}/${dt?.id}`} className="block relative h-68 rounded overflow-hidden"> */}

                    <Image
                        alt="ecommerce"
                        className="object-cover cursor-pointer object-center  w-full h-full block"
                        src="https://m.media-amazon.com/images/I/61SFAM62ucL._SL1280_.jpg"
                        width="100"
                        height="100"
                    />

                    Home Decor

                        Paper Plane Design Quote and Motivational Posters 12X18

{currencyFormatter(179)}

            {/* )} */}

  );
};

export async function getServerSideProps(context) {
  if(!mongoose.connections[0].readyState){
     await mongoose.connect(process.env.MONGO_URI)
  }

  let products =  await Product.find()

  return {
    // props: { products },
    props: { products : JSON.parse(JSON.stringify(products)) },

  }
}

export default Sticker;

_app.tsx

import React, { useEffect, useState } from 'react'
import { NextUIProvider, useSSR } from '@nextui-org/react';

import '../styles/globals.css'
import Navbar from '../modules/body/Navbar';
import Footer from '../modules/body/Footer';
import theme from "../themes";
import { AppProps } from 'next/app';
// import SideNavbar from '../mainComponent/SideNavbar'

function MyApp({ Component, pageProps }: AppProps) {
  const [cart, setCart] = useState<object>({})
  const [subTotal, setSubTotal] = useState<number>(0)
  const { isBrowser } = useSSR();
  useEffect(() => {
    try {
      if (localStorage.getItem("cart")) {
        setCart(JSON.parse(localStorage.getItem("cart") || ""))
        saveCart(JSON.parse(localStorage.getItem("cart") || ""))
      }
    } catch (error) {
      console.log(error);
      localStorage.clear()
    }
  }, [])

  const saveCart = (myCart: object) => {
    localStorage.setItem("cart", JSON.stringify(myCart))
    // let keys = Object.keys(myCart);
    const subt = Object.values(myCart).reduce((acc, curr) => acc + curr?.price * curr?.qty,0);
    setSubTotal(subt)
  }

  const addToCart = (itemCode, qty, price, name, size, variant) => {
    let newCart = cart;
    if (itemCode in cart) {
      newCart[itemCode].qty = cart[itemCode].qty + qty
    }
    else {
      newCart[itemCode] = { qty: 1, price, name, size, variant }
    }
    setCart(newCart)
    saveCart(newCart)
  }

  const removeFromCart = (itemCode, qty, price, name, size, variant) => {
    let newCart = JSON.parse(JSON.stringify(cart));
    if (itemCode in cart) {
      newCart[itemCode].qty = cart[itemCode].qty - qty
    }
    if (newCart[itemCode]["qty"] <= 0) {
      delete newCart[itemCode]
    }
    setCart(newCart)
    saveCart(newCart)
  }

  const clearCart = () => {
    setCart({})
    saveCart({})
  }

  return isBrowser && (
    <NextUIProvider theme={theme}>
      <Navbar key={subTotal} cart={cart} addToCart={addToCart} removeFromCart={removeFromCart}
        clearCart={clearCart} subTotal={subTotal} />

      {/* <SideNavbar /> */}

      <Component cart={cart} addToCart={addToCart} removeFromCart={removeFromCart}
        clearCart={clearCart} subTotal={subTotal} {...pageProps} />

    </NextUIProvider>
  )
}

export default MyApp

I tried every method posted on the browser but still it shows undefined. If you help me to find out the solution of this problem then i will be very happy and feel blessed with this coding environment. please solve this as soon as possible. My whole project is stucked because of this error.


问:
Using sleep with Tkinter
I'm trying to create a game with the Tkinter window, and I am currently trying to figure out how to get a text box to have different texts, one after another without pressing a button. You are meant to go through the north corridoor, and than keep going down the hallway.

I tried to use time.sleep(), and it didn't work. I also tried Tkiner's after function and that didn't work either. The text box just went to the last one that was there. Italics is where I think the problem is.

from tkinter import *
import sys
from time import time, sleep
global lobbyreturn
lobbyreturn = 0
global hello
hello = 0

*def empty_L():
    global hello
    if hello == 1:
        L.delete(1.0, END)
        shrek()
    elif hello == 2:
        L.delete(1.0, END)
        shrek2()
    elif hello == 3:
        L.delete(1.0, END)
        shrek3()
def shrek():
    global hello
    hello = 2
    L.insert(END, """You pull on the door, trying to escape the hallway.
A deep voice laughs from behind the door, saying:""")
    L.after(8, empty_L())
def shrek2():
    global hello
    hello = 3
    L.insert(END, "Why are you here?!")
    L.after(5, empty_L())
def shrek3():
    global hello
    hello = 4
    L.insert(END, "Leave now, before I take you out myself!!")
    L.after(5, hallway1pt3())*
def leave():
    window.destroy()
    sys.exit()
def name():
    global b2
    global b3
    b1.destroy()
    b.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """Hello, Mark.
The Algreen is your personal space cruise.
Would you like some coffee?""")
    L.config(state=DISABLED)
    b2 = Button(window, text="Yes please.", command=lambda : coffeemachine1())
    b2.place(relx=0.5, rely=0.7, anchor="c")
    b3 = Button(window, text="No thank you.", command=lambda : lobby())
    b3.place(relx=0.5, rely=0.8, anchor="c")
def whatyouwantfromme():
    b1.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """What I want from you is your name.
Please tell me what it is.
I promise it will help you.""")
    L.config(state=DISABLED)
def coffeemachine1():
    global b2
    global b3
    global b4
    global b5
    b2.destroy()
    b3.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """This is the coffee machine.
It will revitalise your health, stamina and mana.
Having coffee whilst all stats are full will boost them by 10%.""")
    L.config(state=DISABLED)
    b4 = Button(window, text="Have a cup.", command=lambda : coffeet())
    b4.place(relx=0.5, rely=0.7, anchor="c")
    b5 = Button(window, text="Leave the room.", command=lambda : lobby1())
    b5.place(relx=0.5, rely=0.8, anchor="c")
def coffeet():
    global b4
    global b5
    b4.destroy()
    b5.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """You drink the coffee.
A powerful wave of energy flows through you as you feel revitalised.""")
    L.config(state=DISABLED)
    lobby()
def lobby():
    global b2
    global b3
    global b6
    global b7
    global b8
    global b9
    global b10
    global b11
    global b12
    global b13
    global b14
    global b15
    global b16
    global b17
    global b18
    global b19
    global lobbyreturn
    if lobbyreturn == 1:
        b14.destroy()
        b15.destroy()
        L.config(state=NORMAL)
        L.delete(1.0, END)
        L.insert(END, """Welcome back to the lobby.
Where would you like to go?""")
        L.config(state=DISABLED)
        b6 = Button(window, text="Go North.", command=lambda : hallway1())
        b6.place(relx=0.5, rely=0.7, anchor="c")
        b7 = Button(window, text="Go North East.", command=lambda : hallway2())
        b7.place(relx=0.3, rely=0.7, anchor="c")
        b8 = Button(window, text="Go North West.", command=lambda : CaptainsCabin1())
        b8.place(relx=0.7, rely=0.7, anchor="c")
        b9 = Button(window, text="Go West.", command=lambda : hallway3())
        b9.place(relx=0.7, rely=0.8, anchor="c")
        b10 = Button(window, text="Go South West.", command=lambda : Jamesroom())
        b10.place(relx=0.5, rely=0.9, anchor="c")
        b11 = Button(window, text="Go South.", command=lambda : yourroom())
        b11.place(relx=0.5, rely=0.8, anchor="c")
        b12 = Button(window, text="Go South East.", command=lambda : hallway4())
        b12.place(relx=0.3, rely=0.9, anchor="c")
        b13 = Button(window, text="Go East.", command=lambda : mainhall())
        b13.place(relx=0.7, rely=0.7, anchor="c")
    elif lobbyreturn == 2:
        b16.destroy()
        b17.destroy()
        L.config(state=NORMAL)
        L.delete(1.0, END)
        L.insert(END, """Welcome back to the lobby.
Where would you like to go?""")
        L.config(state=DISABLED)
        b6 = Button(window, text="Go North.", command=lambda : hallway1())
        b6.place(relx=0.3, rely=0.8, anchor="c")
        b7 = Button(window, text="Go North East.", command=lambda : hallway2())
        b7.place(relx=0.3, rely=0.7, anchor="c")
        b8 = Button(window, text="Go North West.", command=lambda : CaptainsCabin1())
        b8.place(relx=0.3, rely=0.9, anchor="c")
        b9 = Button(window, text="Go West.", command=lambda : hallway3())
        b9.place(relx=0.7, rely=0.8, anchor="c")
        b10 = Button(window, text="Go South West.", command=lambda : Jamesroom())
        b10.place(relx=0.5, rely=0.9, anchor="c")
        b11 = Button(window, text="Go South.", command=lambda : yourroom())
        b11.place(relx=0.5, rely=0.8, anchor="c")
        b12 = Button(window, text="Go South East.", command=lambda : hallway4())
        b12.place(relx=0.5, rely=0.7, anchor="c")
        b13 = Button(window, text="Go East.", command=lambda : mainhall())
        b13.place(relx=0.7, rely=0.7, anchor="c")
    elif lobbyreturn == 3:
        b18.destroy()
        b19.destroy()
        L.config(state=NORMAL)
        L.delete(1.0, END)
        L.insert(END, """Welcome back to the lobby.
Where would you like to go?""")
        L.config(state=DISABLED)
        b6 = Button(window, text="Go North.", command=lambda : hallway1())
        b6.place(relx=0.3, rely=0.8, anchor="c")
        b7 = Button(window, text="Go North East.", command=lambda : hallway2())
        b7.place(relx=0.3, rely=0.7, anchor="c")
        b8 = Button(window, text="Go North West.", command=lambda : CaptainsCabin1())
        b8.place(relx=0.3, rely=0.9, anchor="c")
        b9 = Button(window, text="Go West.", command=lambda : hallway3())
        b9.place(relx=0.7, rely=0.8, anchor="c")
        b10 = Button(window, text="Go South West.", command=lambda : Jamesroom())
        b10.place(relx=0.5, rely=0.9, anchor="c")
        b11 = Button(window, text="Go South.", command=lambda : yourroom())
        b11.place(relx=0.5, rely=0.8, anchor="c")
        b12 = Button(window, text="Go South East.", command=lambda : hallway4())
        b12.place(relx=0.5, rely=0.7, anchor="c")
        b13 = Button(window, text="Go East.", command=lambda : mainhall())
        b13.place(relx=0.7, rely=0.7, anchor="c")
    elif lobbyreturn == 4:
        b20.destroy()
        b21.destroy()
        L.config(state=NORMAL)
        L.delete(1.0, END)
        L.insert(END, """Welcome back to the lobby.
Where would you like to go?""")
        L.config(state=DISABLED)
        b6 = Button(window, text="Go North.", command=lambda : hallway1())
        b6.place(relx=0.3, rely=0.8, anchor="c")
        b7 = Button(window, text="Go North East.", command=lambda : hallway2())
        b7.place(relx=0.3, rely=0.7, anchor="c")
        b8 = Button(window, text="Go North West.", command=lambda : CaptainsCabin1())
        b8.place(relx=0.3, rely=0.9, anchor="c")
        b9 = Button(window, text="Go West.", command=lambda : hallway3())
        b9.place(relx=0.7, rely=0.8, anchor="c")
        b10 = Button(window, text="Go South West.", command=lambda : Jamesroom())
        b10.place(relx=0.5, rely=0.9, anchor="c")
        b11 = Button(window, text="Go South.", command=lambda : yourroom())
        b11.place(relx=0.5, rely=0.8, anchor="c")
        b12 = Button(window, text="Go South East.", command=lambda : hallway4())
        b12.place(relx=0.5, rely=0.7, anchor="c")
        b13 = Button(window, text="Go East.", command=lambda : mainhall())
        b13.place(relx=0.7, rely=0.7, anchor="c")
    elif lobbyreturn == 5:
        b22.destroy()
        b23.destroy()
        L.config(state=NORMAL)
        L.delete(1.0, END)
        L.insert(END, """Welcome back to the lobby.
Where would you like to go?""")
        L.config(state=DISABLED)
        b6 = Button(window, text="Go North.", command=lambda : hallway1())
        b6.place(relx=0.3, rely=0.8, anchor="c")
        b7 = Button(window, text="Go North East.", command=lambda : hallway2())
        b7.place(relx=0.3, rely=0.7, anchor="c")
        b8 = Button(window, text="Go North West.", command=lambda : CaptainsCabin1())
        b8.place(relx=0.3, rely=0.9, anchor="c")
        b9 = Button(window, text="Go West.", command=lambda : hallway3())
        b9.place(relx=0.7, rely=0.8, anchor="c")
        b10 = Button(window, text="Go South West.", command=lambda : Jamesroom())
        b10.place(relx=0.5, rely=0.9, anchor="c")
        b11 = Button(window, text="Go South.", command=lambda : yourroom())
        b11.place(relx=0.5, rely=0.8, anchor="c")
        b12 = Button(window, text="Go South East.", command=lambda : hallway4())
        b12.place(relx=0.5, rely=0.7, anchor="c")
        b13 = Button(window, text="Go East.", command=lambda : mainhall())
        b13.place(relx=0.7, rely=0.7, anchor="c")
    elif lobbyreturn == 6:
        b24.destroy()
        b25.destroy()
        L.config(state=NORMAL)
        L.delete(1.0, END)
        L.insert(END, """Welcome back to the lobby.
Where would you like to go?""")
        L.config(state=DISABLED)
        b6 = Button(window, text="Go North.", command=lambda : hallway1())
        b6.place(relx=0.3, rely=0.8, anchor="c")
        b7 = Button(window, text="Go North East.", command=lambda : hallway2())
        b7.place(relx=0.3, rely=0.7, anchor="c")
        b8 = Button(window, text="Go North West.", command=lambda : CaptainsCabin1())
        b8.place(relx=0.3, rely=0.9, anchor="c")
        b9 = Button(window, text="Go West.", command=lambda : hallway3())
        b9.place(relx=0.7, rely=0.8, anchor="c")
        b10 = Button(window, text="Go South West.", command=lambda : Jamesroom())
        b10.place(relx=0.5, rely=0.9, anchor="c")
        b11 = Button(window, text="Go South.", command=lambda : yourroom())
        b11.place(relx=0.5, rely=0.8, anchor="c")
        b12 = Button(window, text="Go South East.", command=lambda : hallway4())
        b12.place(relx=0.5, rely=0.7, anchor="c")
        b13 = Button(window, text="Go East.", command=lambda : mainhall())
        b13.place(relx=0.7, rely=0.7, anchor="c")
    elif lobbyreturn == 7:
        b26.destroy()
        b27.destroy()
        L.config(state=NORMAL)
        L.delete(1.0, END)
        L.insert(END, """Welcome back to the lobby.
Where would you like to go?""")
        L.config(state=DISABLED)
        b6 = Button(window, text="Go North.", command=lambda : hallway1())
        b6.place(relx=0.3, rely=0.8, anchor="c")
        b7 = Button(window, text="Go North East.", command=lambda : hallway2())
        b7.place(relx=0.3, rely=0.7, anchor="c")
        b8 = Button(window, text="Go North West.", command=lambda : CaptainsCabin1())
        b8.place(relx=0.3, rely=0.9, anchor="c")
        b9 = Button(window, text="Go West.", command=lambda : hallway3())
        b9.place(relx=0.7, rely=0.8, anchor="c")
        b10 = Button(window, text="Go South West.", command=lambda : Jamesroom())
        b10.place(relx=0.5, rely=0.9, anchor="c")
        b11 = Button(window, text="Go South.", command=lambda : yourroom())
        b11.place(relx=0.5, rely=0.8, anchor="c")
        b12 = Button(window, text="Go South East.", command=lambda : hallway4())
        b12.place(relx=0.5, rely=0.7, anchor="c")
        b13 = Button(window, text="Go East.", command=lambda : mainhall())
        b13.place(relx=0.7, rely=0.7, anchor="c")
    elif lobbyreturn == 8:
        b28.destroy()
        b29.destroy()
        L.config(state=NORMAL)
        L.delete(1.0, END)
        L.insert(END, """Welcome back to the lobby.
Where would you like to go?""")
        L.config(state=DISABLED)
        b6 = Button(window, text="Go North.", command=lambda : hallway1())
        b6.place(relx=0.3, rely=0.8, anchor="c")
        b7 = Button(window, text="Go North East.", command=lambda : hallway2())
        b7.place(relx=0.3, rely=0.7, anchor="c")
        b8 = Button(window, text="Go North West.", command=lambda : CaptainsCabin1())
        b8.place(relx=0.3, rely=0.9, anchor="c")
        b9 = Button(window, text="Go West.", command=lambda : hallway3())
        b9.place(relx=0.7, rely=0.8, anchor="c")
        b10 = Button(window, text="Go South West.", command=lambda : Jamesroom())
        b10.place(relx=0.5, rely=0.9, anchor="c")
        b11 = Button(window, text="Go South.", command=lambda : yourroom())
        b11.place(relx=0.5, rely=0.8, anchor="c")
        b12 = Button(window, text="Go South East.", command=lambda : hallway4())
        b12.place(relx=0.5, rely=0.7, anchor="c")
        b13 = Button(window, text="Go East.", command=lambda : mainhall())
        b13.place(relx=0.7, rely=0.7, anchor="c")
    else:
        b3.destroy()
        b2.destroy()
        L.config(state=NORMAL)
        L.delete(1.0, END)
        L.insert(END, """Welcome to the lobby.
Here you will find the pathways to the rest of the ship.
Where wuld you like to go?""")
        L.config(state=DISABLED)
        b6 = Button(window, text="Go North.", command=lambda : hallway1())
        b6.place(relx=0.3, rely=0.8, anchor="c")
        b7 = Button(window, text="Go North East.", command=lambda : hallway2())
        b7.place(relx=0.3, rely=0.7, anchor="c")
        b8 = Button(window, text="Go North West.", command=lambda : CaptainsCabin1())
        b8.place(relx=0.3, rely=0.9, anchor="c")
        b9 = Button(window, text="Go West.", command=lambda : hallway3())
        b9.place(relx=0.7, rely=0.8, anchor="c")
        b10 = Button(window, text="Go South West.", command=lambda : Jamesroom())
        b10.place(relx=0.5, rely=0.9, anchor="c")
        b11 = Button(window, text="Go South.", command=lambda : yourroom())
        b11.place(relx=0.5, rely=0.8, anchor="c")
        b12 = Button(window, text="Go South East.", command=lambda : hallway4())
        b12.place(relx=0.5, rely=0.7, anchor="c")
        b13 = Button(window, text="Go East.", command=lambda : mainhall())
        b13.place(relx=0.7, rely=0.7, anchor="c")
def hallway1():
    global b6
    global b7
    global b8
    global b9
    global b10
    global b11
    global b12
    global b13
    global b14
    global b15
    global lobbyreturn
    lobbyreturn = 1
    b6.destroy()
    b7.destroy()
    b8.destroy()
    b9.destroy()
    b10.destroy()
    b11.destroy()
    b12.destroy()
    b13.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """This is one of the thousands of hallways on the Algreen.
There seems to be no exit for miles.
Will you keep walking or go back?""")
    L.config(state=DISABLED)
    b14 = Button(window, text="Go back.", command=lambda : lobby())
    b14.place(relx=0.5, rely=0.7, anchor="c")
    b15 = Button(window, text="Go down the long hallway.", command=lambda : hallway1pt2())
    b15.place(relx=0.5, rely=0.8, anchor="c")
*def hallway1pt2():
global b14
global b15
global hello
hello = 1
b14.destroy()
b15.destroy()
L.config(state=NORMAL)
L.delete(1.0, END)
L.insert(END, """You begin to walk forwards, as you hear a loud thud behind you.
You run back towards the door, trying to figure out what just happened.""")
L.after(10, empty_L())
b30 = Button(window, text="Run in the opposite direction. Not my problem.", command=lambda : hallway1pt3())*
    b30.place(relx=0.5, rely=0.7, anchor="c")
    b31 = Button(window, text="Bang on the door. I want to leave this place.", command=lambda : bangondoor())
    b31.place(relx=0.5, rely=0.8, anchor="c")
def hallway1pt3():
    global b30
    global b31
    L.delete(1.0, END)
    L.insert(END, """What would you like to do.
Follow the instructions, or keep banging on the door?""")
    b30 = Button(window, text="Run in the opposite direction. Not my problem.", command=lambda : hallway1pt3())
    b30.place(relx=0.5, rely=0.7, anchor="c")
    b31 = Button(window, text="Keep banging. I want it to kill me now.", command=lambda : bangondoor())
    b31.place(relx=0.5, rely=0.8, anchor="c")
def hallway2():
    global b6
    global b7
    global b8
    global b9
    global b10
    global b11
    global b12
    global b13
    global b16
    global b17
    global lobbyreturn
    lobbyreturn = 2
    b6.destroy()
    b7.destroy()
    b8.destroy()
    b9.destroy()
    b10.destroy()
    b11.destroy()
    b12.destroy()
    b13.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """This is one of the thousands of hallways on the Algreen.
The hallways seem to be quite small. There is an exit at the end.
Will you keep walking or go back?""")
    L.config(state=DISABLED)
    b16 = Button(window, text="Go back.", command=lambda : lobby())
    b16.place(relx=0.5, rely=0.7, anchor="c")
    b17 = Button(window, text="Go down the hallway to the exit.", command=lambda : hallway2pt2())
    b17.place(relx=0.5, rely=0.8, anchor="c")
def hallway3():
    global b6
    global b7
    global b8
    global b9
    global b10
    global b11
    global b12
    global b13
    global b20
    global b21
    global lobbyreturn
    lobbyreturn = 4
    b6.destroy()
    b7.destroy()
    b8.destroy()
    b9.destroy()
    b10.destroy()
    b11.destroy()
    b12.destroy()
    b13.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """A blank hallway.
Will you keep going?""")
    L.config(state=DISABLED)
    b20 = Button(window, text="Keep going.", command=lambda : hallway3pt2())
    b20.place(relx=0.5, rely=0.7, anchor="c")
    b21 = Button(window, text="Go back to the lobby.", command=lambda : lobby())
    b21.place(relx=0.5, rely=0.8, anchor="c")
def hallway4():
    global b6
    global b7
    global b8
    global b9
    global b10
    global b11
    global b12
    global b13
    global b26
    global b27
    global lobbyreturn
    lobbyreturn = 7
    b6.destroy()
    b7.destroy()
    b8.destroy()
    b9.destroy()
    b10.destroy()
    b11.destroy()
    b12.destroy()
    b13.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """An exciting-looking room.
There is an automatic walker on the floor.
Will you stand on it?""")
    L.config(state=DISABLED)
    b26 = Button(window, text="Leave. I like excercise.", command=lambda : lobby())
    b26.place(relx=0.5, rely=0.7, anchor="c")
    b27 = Button(window, text="Yeah, I'll step on it.", command=lambda : hallway4pt2())
    b27.place(relx=0.5, rely=0.8, anchor="c")
def CaptainsCabin1():
    global b6
    global b7
    global b8
    global b9
    global b10
    global b11
    global b12
    global b13
    global b18
    global b19
    global lobbyreturn
    lobbyreturn = 3
    b6.destroy()
    b7.destroy()
    b8.destroy()
    b9.destroy()
    b10.destroy()
    b11.destroy()
    b12.destroy()
    b13.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """This is the Captains Cabin.
He doesn't seem to be here at the moment.""")
    L.config(state=DISABLED)
    b18 = Button(window, text="Have a look around.", command=lambda : CaptainsCabin2())
    b18.place(relx=0.5, rely=0.7, anchor="c")
    b19 = Button(window, text="Leave the room. I shouldn't go through his stuff.", command=lambda : lobby())
    b19.place(relx=0.5, rely=0.8, anchor="c")
def Jamesroom():
    global b6
    global b7
    global b8
    global b9
    global b10
    global b11
    global b12
    global b13
    global b22
    global b23
    global lobbyreturn
    lobbyreturn = 5
    b6.destroy()
    b7.destroy()
    b8.destroy()
    b9.destroy()
    b10.destroy()
    b11.destroy()
    b12.destroy()
    b13.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """This is your friend, James' room.
He said you could borrow his blaster ealier.""")
    L.config(state=DISABLED)
    b22 = Button(window, text="Find the blaster.", command=lambda : GetBlaster())
    b22.place(relx=0.5, rely=0.7, anchor="c")
    b23 = Button(window, text="Leave the room. I won't need his blaster!", command=lambda : lobby())
    b23.place(relx=0.5, rely=0.8, anchor="c")
def yourroom():
    global b6
    global b7
    global b8
    global b9
    global b10
    global b11
    global b12
    global b13
    global b24
    global b25
    global lobbyreturn
    lobbyreturn = 6
    b6.destroy()
    b7.destroy()
    b8.destroy()
    b9.destroy()
    b10.destroy()
    b11.destroy()
    b12.destroy()
    b13.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """This is your room.
There are loads of things for you to take in here.""")
    L.config(state=DISABLED)
    b24 = Button(window, text="Take a look around.", command=lambda : yourroompt2())
    b24.place(relx=0.5, rely=0.7, anchor="c")
    b25 = Button(window, text="Leave. I don't need anything right now.", command=lambda : lobby())
    b25.place(relx=0.5, rely=0.8, anchor="c")
def mainhall():
    global b6
    global b7
    global b8
    global b9
    global b10
    global b11
    global b12
    global b13
    global b28
    global b29
    global lobbyreturn
    lobbyreturn = 8
    b6.destroy()
    b7.destroy()
    b8.destroy()
    b9.destroy()
    b10.destroy()
    b11.destroy()
    b12.destroy()
    b13.destroy()
    L.config(state=NORMAL)
    L.delete(1.0, END)
    L.insert(END, """This is the main hall.
There are loads of things for you to do in here.""")
    L.config(state=DISABLED)
    b28 = Button(window, text="Explore the room.", command=lambda : mainhallpt2())
    b28.place(relx=0.5, rely=0.7, anchor="c")
    b29 = Button(window, text="Leave the room. Too much for me too handle at the moment.", command=lambda : lobby())
    b29.place(relx=0.5, rely=0.8, anchor="c")

window = Tk()
window.title("The Algreen")
window.config(width=500, height=300)
window.config(bg='lightblue')
Label(window, bg='lightblue', text="The Algreen", font=("Arial", 20)).place(relx=0.5, rely=0.15, anchor="s")
L = Text(window, font=("Arial", 13))
L.place(relx=0.5, rely=0.15, anchor="n", relwidth=1, relheight=0.4)
L.insert(END, """Welcome to the Algreen.
My name is Aria.
What is yours?""")
L.config(state=DISABLED)
Button(window, text="Quit", command=lambda : leave()).place(relx=1, rely=1, anchor="se")
b = Button(window, text="My name is Mark.", command=lambda : name())
b.place(relx=0.5, rely=0.7, anchor="c")
b1 = Button(window, text="What do you want from me?", command=lambda : whatyouwantfromme())
b1.place(relx=0.5, rely= 0.8, anchor="c")

window.mainloop()
```

Title: Using sleep with Tkinter


问:
Entity Framework Core 6.0.7 initialized 'DatabaseContext' using provider 'Npgsql.EntityFrameworkCore.PostgreSQL:6.0.7' with options: None
Why EF logs the error when connecting to the database and how to fix that? What does "using provider with none" means?

```<code>Entity Framework Core 6.0.7 initialized 'DatabaseContext' using provider 'Npgsql.EntityFrameworkCore.PostgreSQL:6.0.7' with options: None
</code>```

Connection strings

```<code>host=dbserver.cloud;port=30726;database=xxxx;user id=xxxxx;password=xxxxxxx;sslmode=Require;Trust Server Certificate=true;Timeout=3
</code>```

Body:
Why EF logs the error when connecting to the database and how to fix that? What does "using provider with none" means?

Entity Framework Core 6.0.7 initialized 'DatabaseContext' using provider 'Npgsql.EntityFrameworkCore.PostgreSQL:6.0.7' with options: None

Connection strings

host=dbserver.cloud;port=30726;database=xxxx;user id=xxxxx;password=xxxxxxx;sslmode=Require;Trust Server Certificate=true;Timeout=3


问:
bash: syntax error near unexpected token `
I am trying to make an alias to call my linter before commit to git.

I have a bash issue and i don't understand where is the issue.

Pre-requisits to test :

pip install sqlfluff

go on git test project where you have no SQL files inside.

checkout -b 'test_branch'

create a dummy .SQL file (ex select * from test group by 1,2,3)

create aliases and source ~/.bashrc if you put aliases in it.

Use SQLlint "write a commit comment"

Alias issues:

```<code>alias lint="git add . && git diff HEAD --name-only --diff-filter=d | grep '.*.sql$' | xargs sqlfluff lint --dialect bigquery"

alias SQLlint="f() {branch=$(git rev-parse --abbrev-ref HEAD); lint && git add . && git commit -m "$1" && git push -u origin $branch;};f"
</code>```

Error:

bash: syntax error near unexpected token `{branch=test_branch'

It is based on this blog article:
https://www.emgoto.com/magic-command/

Thank you for your time.

Body:
I am trying to make an alias to call my linter before commit to git.

I have a bash issue and i don't understand where is the issue.

Pre-requisits to test :

pip install sqlfluff

go on git test project where you have no SQL files inside.

checkout -b 'test_branch'

create a dummy .SQL file (ex select * from test group by 1,2,3)

create aliases and source ~/.bashrc if you put aliases in it.

Use SQLlint "write a commit comment"

Alias issues:

alias lint="git add . && git diff HEAD --name-only --diff-filter=d | grep '.*.sql$' | xargs sqlfluff lint --dialect bigquery"

alias SQLlint="f() {branch=$(git rev-parse --abbrev-ref HEAD); lint && git add . && git commit -m "$1" && git push -u origin $branch;};f"

Error:

bash: syntax error near unexpected token `{branch=test_branch'

It is based on this blog article:
https://www.emgoto.com/magic-command/

Thank you for your time.


问:
Get Cards by idList from Trello using trello-node-api in Nodejs
I just started with trello api (because cheerio can't crawl data from trello board). I've read through their documentation here but there doesn't seem to be any specific instructions on filtering out tags belonging to a certain list

My aim is to get and display cards in a list by day of the week.
I can only get all the cards in the list. But don't know how to add a condition.

```<code>`
const TrelloSchedule = require('trello-node-api')

const trello = new TrelloSchedule()
trello.setApiKey('###')
trello.setOauthToken('###')
trello.board
 .searchCards('###')
 .then(function (response) {
   console.log(response)
  })
  .catch(function (error) {
   console.log(error)
  })
`
</code>```

Body:
I just started with trello api (because cheerio can't crawl data from trello board). I've read through their documentation here but there doesn't seem to be any specific instructions on filtering out tags belonging to a certain list

My aim is to get and display cards in a list by day of the week.
I can only get all the cards in the list. But don't know how to add a condition.

`
const TrelloSchedule = require('trello-node-api')

const trello = new TrelloSchedule()
trello.setApiKey('###')
trello.setOauthToken('###')
trello.board
 .searchCards('###')
 .then(function (response) {
   console.log(response)
  })
  .catch(function (error) {
   console.log(error)
  })
`


问:
Can I use Java 17 record with Cassandra table?

I know that final class cannot be used for Hibernate Entity, but can it be used for cassandra?

@Table("custom_table")
public record MyTable(
  @PrimaryKey @Column("id") String id,
  @Column("options") Options options) {

}
```


问:
Insert Events with Changed Status Only using Logstash
I'm inserting data into elasticsearch (Index A) every minute for the healthcheck of some endpoints. I want to read the index A every minute for the last events it received and if the state changes of any endpoint (from healthy to unhealthy or unhealthy to healthy) then insert that event into Index B.
How would I achieve that and if possible can someone provide a sample code please. I tried elasticsearch filter plugin but couldn't get the desired result.

I tried elasticsearch filter plugin but couldn't get the desired result.


问:
How to unlock a locked python file using "filelock" library?
I wrote a python code after referencing from a suggestion on SO.

Code -

```<code>from filelock import FileLock

with FileLock("zipy.py"):  print("Lock acquired.")
</code>```

After this my "zipy.py" got vanished from the editor. I assume it got locked. How to unlock the same?

Tried to lock the file Expecting the file to show locked setting and ask for a password but instead the file got vanished.

Body:
I wrote a python code after referencing from a suggestion on SO.

Code -

from filelock import FileLock

with FileLock("zipy.py"):  print("Lock acquired.")

After this my "zipy.py" got vanished from the editor. I assume it got locked. How to unlock the same?

Tried to lock the file Expecting the file to show locked setting and ask for a password but instead the file got vanished.


问:
Pusher: How to get channel subscription count in pusher in controller?
How can I get the number of subscriptions in a channel in pusher? It is in the backend and in the Laravel controller

I did not find documentation on Laravel and controller.


问:
Frequently updating UICollectionView's data leads to laggy scrolling
I have a UICollectionView that updates its data about every 1 second. An incoming websocket event triggers the update. When I scroll down the collection view I clearly note a lag every time the update happens.

The stack is:

Combine Publishers for sending data

UICollectionViewCompositionalLayout for UI

UICollectionViewDiffableDataSource as UICollectionView's data source

One ViewModel instance per cell that hold the data

E.g. one of the cell's update handlers look like this:

```<code>viewModel.titleSubject
   .sink { [weak self] title in
                guard let _ = self?.dataSource?.snapshot().indexOfSection(0) else { return }
                let itemIDs = self?.dataSource?.snapshot().itemIdentifiers(inSection: 0)
                if let header = itemIDs?.first as? HeaderCellViewModel {
                    guard header.text != title else { return }
                    header.text = title
                    if var snapshot = self?.dataSource?.snapshot() {
                        snapshot.reloadItems([header])
                        self?.dataSource?.apply(snapshot)
                    }
                }
            }
   .store(in: &cancelBag)
</code>```

I trigger the subject without doing any Thread/Queue work myself:

```<code>titleSubject.send("Hey, I'm a new title")
</code>```

How could I improve the update stack, so I don't get laggy scrolling?

Body:
I have a UICollectionView that updates its data about every 1 second. An incoming websocket event triggers the update. When I scroll down the collection view I clearly note a lag every time the update happens.

The stack is:

Combine Publishers for sending data

UICollectionViewCompositionalLayout for UI

UICollectionViewDiffableDataSource as UICollectionView's data source

One ViewModel instance per cell that hold the data

E.g. one of the cell's update handlers look like this:

viewModel.titleSubject
   .sink { [weak self] title in
                guard let _ = self?.dataSource?.snapshot().indexOfSection(0) else { return }
                let itemIDs = self?.dataSource?.snapshot().itemIdentifiers(inSection: 0)
                if let header = itemIDs?.first as? HeaderCellViewModel {
                    guard header.text != title else { return }
                    header.text = title
                    if var snapshot = self?.dataSource?.snapshot() {
                        snapshot.reloadItems([header])
                        self?.dataSource?.apply(snapshot)
                    }
                }
            }
   .store(in: &cancelBag)

I trigger the subject without doing any Thread/Queue work myself:

titleSubject.send("Hey, I'm a new title")

How could I improve the update stack, so I don't get laggy scrolling?


问:
Azure Monitor: how collect \Hyper-V Hypervisor Logical Processor\% Total Run Time metrics in Data Collection Rule?
I have started using "new" version of Azure Monitor (Data collection Rule).

At old version Azure Monitor I collected  metrics fom on-premise Hyper-V (for example: \Hyper-V Hypervisor Logical Processor% Total Run Time).

Now, when I have started using "new" Azure Monitor,
I can't collect this hyper-v metrics, because
they aren't in list of metrics at Data Collection Rule.

When I write and add "\Hyper-V Hypervisor Logical Processor% Total Run Time" as Custom, Data Collection Rule still don't collect anything?

Can you help me?

How I can collect metrics from on-premise hyper-v by "new" Azure Monitor (with Data Collection Rules)?

Thank you


问:
how to use DateTimePicker (MUI) with YupValidation and restrict startdate to come after enddate and enddate come before startdate?
This is my Current code:

```<code>import { useForm, Controller } from "react-hook-form";
import { yupResolver } from "@hookform/resolvers/yup";
import { DateTimePicker } from "@mui/x-date-pickers";
</code>```
```<code>const schema = Yup.object({
  startDate: Yup.date().required("startDate is required"),
  endDate: Yup.date().required("endDate is required"),
});
</code>```
```<code>const {
    register,
    control,
    formState: { errors },
    handleSubmit,
    reset,
    watch,
  } = useForm({
    defaultValues: {
      startDate: "",
      endDate: "",
    },
    mode: "all",
    resolver: yupResolver(schema),
  });

</code>```
```<code> const onSubmit = (data: any) => {
    data.startDate = new Date(data.startDate).toISOString();
    data.endDate = new Date(data.endDate).toISOString();
  };

</code>```
```<code><div className="grid grid-cols-4 ml-10 mr-56">
        <div>
          <Controller
            name="startDate"
            control={control}
            render={({ field: { onChange, value } }) => (
              <DateTimePicker
                disablePast
                id="startDate"
                label=" Start Date"
                placeholder="Start Date"
                value={value}
                onChange={onChange}
                renderInput={(params) => <TextField {...params} />}
              />
            )}
          />
        </div>
        <div>
          <Controller
            name="endDate"
            control={control}
            render={({ field: { onChange, value } }) => (
              <DateTimePicker
                disablePast
                label=" End Date"
                id="endDate"
                placeholder="End Date"
                value={value}
                onChange={onChange}
                renderInput={(params) => <TextField {...params} />}
              />
            )}
          />
        </div>
      </div>
</code>```

start & end date

(right now the validaiton works i just want to restrict the user from selecting end date before start date and vice versa)

right now i can choose date before the start date in the end date so how can i dont allow it(its important for me to make the dateformat UTC)
how can i solve this problem?

i tried to change it to textField
and date picker
tried to use dayjs but didnt work so i dont know what to do
cause i need validation too
(right now the validaiton works i just want to restrict the user from selecting end date before start date and vice versa)

Body:
This is my Current code:

import { useForm, Controller } from "react-hook-form";
import { yupResolver } from "@hookform/resolvers/yup";
import { DateTimePicker } from "@mui/x-date-pickers";

const schema = Yup.object({
  startDate: Yup.date().required("startDate is required"),
  endDate: Yup.date().required("endDate is required"),
});

const {
    register,
    control,
    formState: { errors },
    handleSubmit,
    reset,
    watch,
  } = useForm({
    defaultValues: {
      startDate: "",
      endDate: "",
    },
    mode: "all",
    resolver: yupResolver(schema),
  });

 const onSubmit = (data: any) => {
    data.startDate = new Date(data.startDate).toISOString();
    data.endDate = new Date(data.endDate).toISOString();
  };

          <Controller
            name="startDate"
            control={control}
            render={({ field: { onChange, value } }) => (
              <DateTimePicker
                disablePast
                id="startDate"
                label=" Start Date"
                placeholder="Start Date"
                value={value}
                onChange={onChange}
                renderInput={(params) => <TextField {...params} />}
              />
            )}
          />

          <Controller
            name="endDate"
            control={control}
            render={({ field: { onChange, value } }) => (
              <DateTimePicker
                disablePast
                label=" End Date"
                id="endDate"
                placeholder="End Date"
                value={value}
                onChange={onChange}
                renderInput={(params) => <TextField {...params} />}
              />
            )}
          />

start & end date

(right now the validaiton works i just want to restrict the user from selecting end date before start date and vice versa)

right now i can choose date before the start date in the end date so how can i dont allow it(its important for me to make the dateformat UTC)
how can i solve this problem?

i tried to change it to textField
and date picker
tried to use dayjs but didnt work so i dont know what to do
cause i need validation too
(right now the validaiton works i just want to restrict the user from selecting end date before start date and vice versa)