问:
Unusual GC memory usage
I am using Tomcat 10 and Java 17 on Windows. I have -xmx set at 1GB.

I activated native memory debug and I can see that GC is taking about 9 GB of memory. Here is the full output for jcmd PID VM.native_memory :

```<code>     Native Memory Tracking:

     (Omitting categories weighting less than 1KB)

     Total: reserved=12037466KB, committed=10529414KB
              Java Heap (reserved=1048576KB, committed=881664KB)
                        (mmap: reserved=1048576KB, committed=881664KB)

                  Class (reserved=1049958KB, committed=7846KB)
                        (classes #11096)
                        (  instance classes #10222, array classes #874)
                        (malloc=1382KB #33141)
                        (mmap: reserved=1048576KB, committed=6464KB)
                        (  Metadata:   )
                        (    reserved=57344KB, committed=55104KB)
                        (    used=54882KB)
                        (    waste=222KB =0.40%)
                        (  Class space:)
                        (    reserved=1048576KB, committed=6464KB)
                        (    used=6163KB)
                        (    waste=301KB =4.65%)

                 Thread (reserved=93410KB, committed=5578KB)
                        (thread #91)
                        (stack: reserved=93184KB, committed=5352KB)
                        (malloc=121KB #558)
                        (arena=105KB #180)

                   Code (reserved=251223KB, committed=48443KB)
                        (malloc=3479KB #13870)
                        (mmap: reserved=247744KB, committed=44964KB)

                     GC (reserved=9484143KB, committed=9477967KB)
                        (malloc=9412015KB #1204531)
                        (mmap: reserved=72128KB, committed=65952KB)

               Compiler (reserved=675KB, committed=675KB)
                        (malloc=510KB #820)
                        (arena=165KB #5)

               Internal (reserved=1359KB, committed=1359KB)
                        (malloc=1295KB #22480)
                        (mmap: reserved=64KB, committed=64KB)

                  Other (reserved=367KB, committed=367KB)
                        (malloc=367KB #69)

                 Symbol (reserved=11951KB, committed=11951KB)
                        (malloc=10185KB #305552)
                        (arena=1766KB #1)

    Native Memory Tracking (reserved=25251KB, committed=25251KB)
                        (malloc=396KB #5669)
                        (tracking overhead=24855KB)

     Shared class space (reserved=12096KB, committed=12096KB)
                        (mmap: reserved=12096KB, committed=12096KB)

            Arena Chunk (reserved=315KB, committed=315KB)
                        (malloc=315KB)

                Tracing (reserved=32KB, committed=32KB)
                        (arena=32KB #1)

                Logging (reserved=5KB, committed=5KB)
                        (malloc=5KB #216)

              Arguments (reserved=3KB, committed=3KB)
                        (malloc=3KB #92)

                 Module (reserved=399KB, committed=399KB)
                        (malloc=399KB #2322)

              Safepoint (reserved=8KB, committed=8KB)
                        (mmap: reserved=8KB, committed=8KB)

        Synchronization (reserved=79KB, committed=79KB)
                        (malloc=79KB #849)

         Serviceability (reserved=1KB, committed=1KB)
                        (malloc=1KB #14)

              Metaspace (reserved=57614KB, committed=55374KB)
                        (malloc=270KB #236)
                        (mmap: reserved=57344KB, committed=55104KB)

   String Deduplication (reserved=1KB, committed=1KB)
                        (malloc=1KB #8)
</code>```

From this, I understand that GC process requires 9 times more memory  than my application memory. (9 GB compared with 1 GB app max heap). Am I miss something?

Title: Unusual GC memory usage

Body:
I am using Tomcat 10 and Java 17 on Windows. I have -xmx set at 1GB.

I activated native memory debug and I can see that GC is taking about 9 GB of memory. Here is the full output for jcmd PID VM.native_memory :

     Native Memory Tracking:

     (Omitting categories weighting less than 1KB)

     Total: reserved=12037466KB, committed=10529414KB
              Java Heap (reserved=1048576KB, committed=881664KB)
                        (mmap: reserved=1048576KB, committed=881664KB)

                  Class (reserved=1049958KB, committed=7846KB)
                        (classes #11096)
                        (  instance classes #10222, array classes #874)
                        (malloc=1382KB #33141)
                        (mmap: reserved=1048576KB, committed=6464KB)
                        (  Metadata:   )
                        (    reserved=57344KB, committed=55104KB)
                        (    used=54882KB)
                        (    waste=222KB =0.40%)
                        (  Class space:)
                        (    reserved=1048576KB, committed=6464KB)
                        (    used=6163KB)
                        (    waste=301KB =4.65%)

                 Thread (reserved=93410KB, committed=5578KB)
                        (thread #91)
                        (stack: reserved=93184KB, committed=5352KB)
                        (malloc=121KB #558)
                        (arena=105KB #180)

                   Code (reserved=251223KB, committed=48443KB)
                        (malloc=3479KB #13870)
                        (mmap: reserved=247744KB, committed=44964KB)

                     GC (reserved=9484143KB, committed=9477967KB)
                        (malloc=9412015KB #1204531)
                        (mmap: reserved=72128KB, committed=65952KB)

               Compiler (reserved=675KB, committed=675KB)
                        (malloc=510KB #820)
                        (arena=165KB #5)

               Internal (reserved=1359KB, committed=1359KB)
                        (malloc=1295KB #22480)
                        (mmap: reserved=64KB, committed=64KB)

                  Other (reserved=367KB, committed=367KB)
                        (malloc=367KB #69)

                 Symbol (reserved=11951KB, committed=11951KB)
                        (malloc=10185KB #305552)
                        (arena=1766KB #1)

    Native Memory Tracking (reserved=25251KB, committed=25251KB)
                        (malloc=396KB #5669)
                        (tracking overhead=24855KB)

     Shared class space (reserved=12096KB, committed=12096KB)
                        (mmap: reserved=12096KB, committed=12096KB)

            Arena Chunk (reserved=315KB, committed=315KB)
                        (malloc=315KB)

                Tracing (reserved=32KB, committed=32KB)
                        (arena=32KB #1)

                Logging (reserved=5KB, committed=5KB)
                        (malloc=5KB #216)

              Arguments (reserved=3KB, committed=3KB)
                        (malloc=3KB #92)

                 Module (reserved=399KB, committed=399KB)
                        (malloc=399KB #2322)

              Safepoint (reserved=8KB, committed=8KB)
                        (mmap: reserved=8KB, committed=8KB)

        Synchronization (reserved=79KB, committed=79KB)
                        (malloc=79KB #849)

         Serviceability (reserved=1KB, committed=1KB)
                        (malloc=1KB #14)

              Metaspace (reserved=57614KB, committed=55374KB)
                        (malloc=270KB #236)
                        (mmap: reserved=57344KB, committed=55104KB)

   String Deduplication (reserved=1KB, committed=1KB)
                        (malloc=1KB #8)

From this, I understand that GC process requires 9 times more memory  than my application memory. (9 GB compared with 1 GB app max heap). Am I miss something?


来源: stackexchange

问:
How to use Threejs to create a boundary for the Mesh load by fbxloador
The created boundary's scale and rotation are totally different with the import fbxmodel.

Hi, I have loaded a fbx model into the scene by fbxLoador.

```<code>const addFbxModel = (modelName: string, position: Vector3) => {
  const fbxLoader = new FBXLoader();
  fbxLoader.load(
    `../../src/assets/models/${modelName}.fbx`,
    (fbxObject: Object3D) => {
      fbxObject.position.set(position.x, position.y, position.z);
      console.log(fbxObject.scale);
      fbxObject.scale.set(0.01, 0.01, 0.01);
      const material = new MeshBasicMaterial({ color: 0x008080 });
      fbxObject.traverse((object) => {
        if (object instanceof Mesh) {
          object.material = material;
        }
      });
      scene.add(fbxObject);

      updateRenderer();
      updateCamera();
      render();
    },
    (xhr) => {
      console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
    },
    (error) => {
      console.log(error);
    }
  );
};
</code>```

And now i want to add a click function on this model which will highlight it by showing it's boundary box.

```<code>const onclick = (event: MouseEvent) => {
  event.preventDefault();
  if (renderBox.value) {
    const mouse = new Vector2();
    mouse.x = (event.offsetX / renderBox.value.clientWidth) * 2 - 1;
    mouse.y = -(event.offsetY / renderBox.value.clientHeight) * 2 + 1;

    raycaster.setFromCamera(mouse, camera);
    const intersects = raycaster.intersectObjects(scene.children, true);
    if (intersects.length > 0) {
      const intersect = intersects[0];
      const object = intersect.object;
      createBoundary(object);
    }
  }
};
</code>```
```<code>const createBoundary = (object: Object3D) => {
  if (object instanceof Mesh) {
    console.log(object.geometry, object.scale, object.rotation);
    const edges = new EdgesGeometry(object.geometry);

    const material = new LineBasicMaterial({ color: 0xffffff });
    const wireframe = new LineSegments(edges, material);

    wireframe.scale.copy(object.scale);
    wireframe.rotation.copy(object.rotation);
    console.log(wireframe.scale);

    scene.add(wireframe);
  }
};
</code>```

But now the boundary's scale and rotation are totally different with the fbxmodel.

And also the boundary is too complex, is it possible to create one only include the outline and the top point.

Thank you. :)

ContentLicense: CC BY-SA 4.0

Body:
The created boundary's scale and rotation are totally different with the import fbxmodel.

Hi, I have loaded a fbx model into the scene by fbxLoador.

const addFbxModel = (modelName: string, position: Vector3) => {
  const fbxLoader = new FBXLoader();
  fbxLoader.load(
    `../../src/assets/models/${modelName}.fbx`,
    (fbxObject: Object3D) => {
      fbxObject.position.set(position.x, position.y, position.z);
      console.log(fbxObject.scale);
      fbxObject.scale.set(0.01, 0.01, 0.01);
      const material = new MeshBasicMaterial({ color: 0x008080 });
      fbxObject.traverse((object) => {
        if (object instanceof Mesh) {
          object.material = material;
        }
      });
      scene.add(fbxObject);

      updateRenderer();
      updateCamera();
      render();
    },
    (xhr) => {
      console.log((xhr.loaded / xhr.total) * 100 + "% loaded");
    },
    (error) => {
      console.log(error);
    }
  );
};

And now i want to add a click function on this model which will highlight it by showing it's boundary box.

const onclick = (event: MouseEvent) => {
  event.preventDefault();
  if (renderBox.value) {
    const mouse = new Vector2();
    mouse.x = (event.offsetX / renderBox.value.clientWidth) * 2 - 1;
    mouse.y = -(event.offsetY / renderBox.value.clientHeight) * 2 + 1;

    raycaster.setFromCamera(mouse, camera);
    const intersects = raycaster.intersectObjects(scene.children, true);
    if (intersects.length > 0) {
      const intersect = intersects[0];
      const object = intersect.object;
      createBoundary(object);
    }
  }
};

const createBoundary = (object: Object3D) => {
  if (object instanceof Mesh) {
    console.log(object.geometry, object.scale, object.rotation);
    const edges = new EdgesGeometry(object.geometry);

    const material = new LineBasicMaterial({ color: 0xffffff });
    const wireframe = new LineSegments(edges, material);

    wireframe.scale.copy(object.scale);
    wireframe.rotation.copy(object.rotation);
    console.log(wireframe.scale);

    scene.add(wireframe);
  }
};

But now the boundary's scale and rotation are totally different with the fbxmodel.

And also the boundary is too complex, is it possible to create one only include the outline and the top point.

Thank you. :)


问:
How to wire queries in Nebula explorer workflow properly
I am using NebulaGraph Explorer Workflow to create DAG pipelines on NebulaGraph today.

I am creating a DAG with three tasks like this:

```<code> ┌──────────────────────────────────────────┐
 │                                          │
 │  MATCH ()-[e]->()                        │
 │  WITH e LIMIT 10000                      │
 │  WITH e AS e                             │
 │      WHERE e.goals > 10                  │
 │      AND toFloat(e.goals)/e.caps > 0.2   │
 │  RETURN src(e), dst(e)                   │
 │          │                               │
 └──────────┼───────────────────────────────┘
            │
            ▼
 ┌──────────────────────────────────┐
 │                                  │
 │  MATCH (v0)-[:belongto]-(v1)     │
 │  WHERE id(v0) == ${src}          │ # here I mapped src(e) from last task into ${src}
 │  RETURN id(v0), id(v1)           │
 │           │        │             │
 └───────────┼────────┼─────────────┘
             │        │
  ┌──────────▼────────▼────────────┐
  │                                │
  │ Betweenness Centrality         │
  │                                │
  │                                │
  └────────────────────────────────┘
</code>```

While it failed in the second task:

```<code>Process exited with status 1
/root/nebula-analytics-3.3.0-centos7.x86_64/3rd/mpich/bin/mpiexec.hydra -n 1 -hosts 192.168.8.237 /root/nebula-analytics-3.3.0-centos7.x86_64/bin/exec_ngql --ngql=MATCH (v0)-[:belongto]-(v1)
WHERE id(v0) == "Álvaro Morata","Romelu Lukaku","Neymar","Naïm Sliti","Mehdi Taremi","Mario Götze","Kylian Mbappé","Kasper Dolberg","Jordan Morris","Joel Campbell","Ivan Perišić","Enner Valencia (captain","Christian Eriksen","Alphonso Davies","Ali Assadalla","Akram Afif","İlkay Gündoğan","Youssef En-Nesyri","Serge Gnabry","Sardar Azmoun","Richarlison","Raúl Jiménez","Mohammed Muntari","Almoez Ali","Memphis Depay","Marcus Rashford","Luis Suárez","Lucas Cavallini","Leroy Sané","Karl Toko Ekambi","Hirving Lozano","Haris Seferovic","Hakim Ziyech","Gareth Bale (captain","Gabriel Jesus","Dušan Tadić (captain","Christian Pulisic","Bruno Fernandes","Andrej Kramarić","Aleksandar Mitrović","Aaron Ramsey","Thomas Partey","Robert Lewandowski (captain","Raheem Sterling","Lionel Messi (captain","Kwon Chang-hoon","Junior Hoilett","Hassan Al-Haydos (captain","Cristiano Ronaldo (captain","André Silva","André Ayew (captain","Alireza Jahanbakhsh","Ángel Di María","Wahbi Khazri","Vincent Aboubakar (captain","Thomas Müller","Takumi Minamino","Leon Goretzka","Krzysztof Piątek","Karim Benzema","Jordan Ayew","Harry Kane (captain","Ferran Torres","Cyle Larin","Arkadiusz Milik","Antoine Griezmann","Xherdan Shaqiri","Son Heung-min (captain","Salem Al-Dawsari","Olivier Giroud","Michy Batshuayi","Lautaro Martínez","Kevin De Bruyne","Karim Ansarifard","Jonathan David","Hwang Ui-jo","Eric Maxim Choupo-Moting","Edinson Cavani","Eden Hazard (captain"
RETURN id(v0), id(v1) --threads=1 --datasource_user=root --datasink_hdfs_url=hdfs://192.168.8.168:9000/ll_test/analytics/1999/tasks/query_2/ --datasource_graphd=192.168.8.131:9669 --datasource_space=fifa_2020 --datasource_graphd_timeout=60000
I20230109 02:52:37.758909 2224521 base.hpp:179] thread support level provided by MPI:
I20230109 02:52:37.759177 2224521 base.hpp:182] MPI_THREAD_MULTIPLE
I20230109 02:52:37.759189 2224521 base.hpp:215] threads: 1
I20230109 02:52:37.759192 2224521 base.hpp:216] sockets: 2
I20230109 02:52:37.759194 2224521 base.hpp:217] partitions: 1
I20230109 02:52:37.759402 2224521 license.cc:519] [part-0]Signature validation started
I20230109 02:52:37.759697 2224521 license.cc:547] [part-0]Signature validation succeed
I20230109 02:52:37.759745 2224521 license.cc:717] [part-0][License] Trial license detected, hardware checking is skipped.
I20230109 02:52:37.759830 2224521 license.cc:623] [part-0]The number of cpus of the current machine is 4
I20230109 02:52:37.759858 2224521 license.cc:253] [License] Expiration timestamp in UTC: 4826275199
I20230109 02:52:37.759866 2224521 license.cc:259] [License] Timezone difference: 0 seconds
I20230109 02:52:37.759869 2224521 license.cc:263] [License] Expiration timestamp in local time zone: 4826275199
I20230109 02:52:37.759872 2224521 license.cc:607] [part-0][License] Expiration check passed
I20230109 02:52:37.810142 2224521 exec_ngql.cc:52] stmt:MATCH (v0)-[:belongto]-(v1)
WHERE id(v0) == "Álvaro Morata","Romelu Lukaku","Neymar","Naïm Sliti","Mehdi Taremi","Mario Götze","Kylian Mbappé","Kasper Dolberg","Jordan Morris","Joel Campbell","Ivan Perišić","Enner Valencia (captain","Christian Eriksen","Alphonso Davies","Ali Assadalla","Akram Afif","İlkay Gündoğan","Youssef En-Nesyri","Serge Gnabry","Sardar Azmoun","Richarlison","Raúl Jiménez","Mohammed Muntari","Almoez Ali","Memphis Depay","Marcus Rashford","Luis Suárez","Lucas Cavallini","Leroy Sané","Karl Toko Ekambi","Hirving Lozano","Haris Seferovic","Hakim Ziyech","Gareth Bale (captain","Gabriel Jesus","Dušan Tadić (captain","Christian Pulisic","Bruno Fernandes","Andrej Kramarić","Aleksandar Mitrović","Aaron Ramsey","Thomas Partey","Robert Lewandowski (captain","Raheem Sterling","Lionel Messi (captain","Kwon Chang-hoon","Junior Hoilett","Hassan Al-Haydos (captain","Cristiano Ronaldo (captain","André Silva","André Ayew (captain","Alireza Jahanbakhsh","Ángel Di María","Wahbi Khazri","Vincent Aboubakar (captain","Thomas Müller","Takumi Minamino","Leon Goretzka","Krzysztof Piątek","Karim Benzema","Jordan Ayew","Harry Kane (captain","Ferran Torres","Cyle Larin","Arkadiusz Milik","Antoine Griezmann","Xherdan Shaqiri","Son Heung-min (captain","Salem Al-Dawsari","Olivier Giroud","Michy Batshuayi","Lautaro Martínez","Kevin De Bruyne","Karim Ansarifard","Jonathan David","Hwang Ui-jo","Eric Maxim Choupo-Moting","Edinson Cavani","Eden Hazard (captain"
RETURN id(v0), id(v1)
I20230109 02:52:37.810698 2224521 exec_ngql.cc:55] session execute failed, statment: MATCH (v0)-[:belongto]-(v1)
WHERE id(v0) == "Álvaro Morata","Romelu Lukaku","Neymar","Naïm Sliti","Mehdi Taremi","Mario Götze","Kylian Mbappé","Kasper Dolberg","Jordan Morris","Joel Campbell","Ivan Perišić","Enner Valencia (captain","Christian Eriksen","Alphonso Davies","Ali Assadalla","Akram Afif","İlkay Gündoğan","Youssef En-Nesyri","Serge Gnabry","Sardar Azmoun","Richarlison","Raúl Jiménez","Mohammed Muntari","Almoez Ali","Memphis Depay","Marcus Rashford","Luis Suárez","Lucas Cavallini","Leroy Sané","Karl Toko Ekambi","Hirving Lozano","Haris Seferovic","Hakim Ziyech","Gareth Bale (captain","Gabriel Jesus","Dušan Tadić (captain","Christian Pulisic","Bruno Fernandes","Andrej Kramarić","Aleksandar Mitrović","Aaron Ramsey","Thomas Partey","Robert Lewandowski (captain","Raheem Sterling","Lionel Messi (captain","Kwon Chang-hoon","Junior Hoilett","Hassan Al-Haydos (captain","Cristiano Ronaldo (captain","André Silva","André Ayew (captain","Alireza Jahanbakhsh","Ángel Di María","Wahbi Khazri","Vincent Aboubakar (captain","Thomas Müller","Takumi Minamino","Leon Goretzka","Krzysztof Piątek","Karim Benzema","Jordan Ayew","Harry Kane (captain","Ferran Torres","Cyle Larin","Arkadiusz Milik","Antoine Griezmann","Xherdan Shaqiri","Son Heung-min (captain","Salem Al-Dawsari","Olivier Giroud","Michy Batshuayi","Lautaro Martínez","Kevin De Bruyne","Karim Ansarifard","Jonathan David","Hwang Ui-jo","Eric Maxim Choupo-Moting","Edinson Cavani","Eden Hazard (captain"
RETURN id(v0), id(v1)
errorCode: -1004, errorMsg: SyntaxError: syntax error near `E id(v0)'
</code>```

I am following the docs chapter 4, while it seems something went wrong anyway.

I tried to use the GO clause instead of MATCH in the second task, but it complained of similar errors.

Could anyone help answer at where I could be wrong?

Body:
I am using NebulaGraph Explorer Workflow to create DAG pipelines on NebulaGraph today.

I am creating a DAG with three tasks like this:

 ┌──────────────────────────────────────────┐
 │                                          │
 │  MATCH ()-[e]->()                        │
 │  WITH e LIMIT 10000                      │
 │  WITH e AS e                             │
 │      WHERE e.goals > 10                  │
 │      AND toFloat(e.goals)/e.caps > 0.2   │
 │  RETURN src(e), dst(e)                   │
 │          │                               │
 └──────────┼───────────────────────────────┘
            │
            ▼
 ┌──────────────────────────────────┐
 │                                  │
 │  MATCH (v0)-[:belongto]-(v1)     │
 │  WHERE id(v0) == ${src}          │ # here I mapped src(e) from last task into ${src}
 │  RETURN id(v0), id(v1)           │
 │           │        │             │
 └───────────┼────────┼─────────────┘
             │        │
  ┌──────────▼────────▼────────────┐
  │                                │
  │ Betweenness Centrality         │
  │                                │
  │                                │
  └────────────────────────────────┘

While it failed in the second task:

Process exited with status 1
/root/nebula-analytics-3.3.0-centos7.x86_64/3rd/mpich/bin/mpiexec.hydra -n 1 -hosts 192.168.8.237 /root/nebula-analytics-3.3.0-centos7.x86_64/bin/exec_ngql --ngql=MATCH (v0)-[:belongto]-(v1)
WHERE id(v0) == "Álvaro Morata","Romelu Lukaku","Neymar","Naïm Sliti","Mehdi Taremi","Mario Götze","Kylian Mbappé","Kasper Dolberg","Jordan Morris","Joel Campbell","Ivan Perišić","Enner Valencia (captain","Christian Eriksen","Alphonso Davies","Ali Assadalla","Akram Afif","İlkay Gündoğan","Youssef En-Nesyri","Serge Gnabry","Sardar Azmoun","Richarlison","Raúl Jiménez","Mohammed Muntari","Almoez Ali","Memphis Depay","Marcus Rashford","Luis Suárez","Lucas Cavallini","Leroy Sané","Karl Toko Ekambi","Hirving Lozano","Haris Seferovic","Hakim Ziyech","Gareth Bale (captain","Gabriel Jesus","Dušan Tadić (captain","Christian Pulisic","Bruno Fernandes","Andrej Kramarić","Aleksandar Mitrović","Aaron Ramsey","Thomas Partey","Robert Lewandowski (captain","Raheem Sterling","Lionel Messi (captain","Kwon Chang-hoon","Junior Hoilett","Hassan Al-Haydos (captain","Cristiano Ronaldo (captain","André Silva","André Ayew (captain","Alireza Jahanbakhsh","Ángel Di María","Wahbi Khazri","Vincent Aboubakar (captain","Thomas Müller","Takumi Minamino","Leon Goretzka","Krzysztof Piątek","Karim Benzema","Jordan Ayew","Harry Kane (captain","Ferran Torres","Cyle Larin","Arkadiusz Milik","Antoine Griezmann","Xherdan Shaqiri","Son Heung-min (captain","Salem Al-Dawsari","Olivier Giroud","Michy Batshuayi","Lautaro Martínez","Kevin De Bruyne","Karim Ansarifard","Jonathan David","Hwang Ui-jo","Eric Maxim Choupo-Moting","Edinson Cavani","Eden Hazard (captain"
RETURN id(v0), id(v1) --threads=1 --datasource_user=root --datasink_hdfs_url=hdfs://192.168.8.168:9000/ll_test/analytics/1999/tasks/query_2/ --datasource_graphd=192.168.8.131:9669 --datasource_space=fifa_2020 --datasource_graphd_timeout=60000
I20230109 02:52:37.758909 2224521 base.hpp:179] thread support level provided by MPI:
I20230109 02:52:37.759177 2224521 base.hpp:182] MPI_THREAD_MULTIPLE
I20230109 02:52:37.759189 2224521 base.hpp:215] threads: 1
I20230109 02:52:37.759192 2224521 base.hpp:216] sockets: 2
I20230109 02:52:37.759194 2224521 base.hpp:217] partitions: 1
I20230109 02:52:37.759402 2224521 license.cc:519] [part-0]Signature validation started
I20230109 02:52:37.759697 2224521 license.cc:547] [part-0]Signature validation succeed
I20230109 02:52:37.759745 2224521 license.cc:717] [part-0][License] Trial license detected, hardware checking is skipped.
I20230109 02:52:37.759830 2224521 license.cc:623] [part-0]The number of cpus of the current machine is 4
I20230109 02:52:37.759858 2224521 license.cc:253] [License] Expiration timestamp in UTC: 4826275199
I20230109 02:52:37.759866 2224521 license.cc:259] [License] Timezone difference: 0 seconds
I20230109 02:52:37.759869 2224521 license.cc:263] [License] Expiration timestamp in local time zone: 4826275199
I20230109 02:52:37.759872 2224521 license.cc:607] [part-0][License] Expiration check passed
I20230109 02:52:37.810142 2224521 exec_ngql.cc:52] stmt:MATCH (v0)-[:belongto]-(v1)
WHERE id(v0) == "Álvaro Morata","Romelu Lukaku","Neymar","Naïm Sliti","Mehdi Taremi","Mario Götze","Kylian Mbappé","Kasper Dolberg","Jordan Morris","Joel Campbell","Ivan Perišić","Enner Valencia (captain","Christian Eriksen","Alphonso Davies","Ali Assadalla","Akram Afif","İlkay Gündoğan","Youssef En-Nesyri","Serge Gnabry","Sardar Azmoun","Richarlison","Raúl Jiménez","Mohammed Muntari","Almoez Ali","Memphis Depay","Marcus Rashford","Luis Suárez","Lucas Cavallini","Leroy Sané","Karl Toko Ekambi","Hirving Lozano","Haris Seferovic","Hakim Ziyech","Gareth Bale (captain","Gabriel Jesus","Dušan Tadić (captain","Christian Pulisic","Bruno Fernandes","Andrej Kramarić","Aleksandar Mitrović","Aaron Ramsey","Thomas Partey","Robert Lewandowski (captain","Raheem Sterling","Lionel Messi (captain","Kwon Chang-hoon","Junior Hoilett","Hassan Al-Haydos (captain","Cristiano Ronaldo (captain","André Silva","André Ayew (captain","Alireza Jahanbakhsh","Ángel Di María","Wahbi Khazri","Vincent Aboubakar (captain","Thomas Müller","Takumi Minamino","Leon Goretzka","Krzysztof Piątek","Karim Benzema","Jordan Ayew","Harry Kane (captain","Ferran Torres","Cyle Larin","Arkadiusz Milik","Antoine Griezmann","Xherdan Shaqiri","Son Heung-min (captain","Salem Al-Dawsari","Olivier Giroud","Michy Batshuayi","Lautaro Martínez","Kevin De Bruyne","Karim Ansarifard","Jonathan David","Hwang Ui-jo","Eric Maxim Choupo-Moting","Edinson Cavani","Eden Hazard (captain"
RETURN id(v0), id(v1)
I20230109 02:52:37.810698 2224521 exec_ngql.cc:55] session execute failed, statment: MATCH (v0)-[:belongto]-(v1)
WHERE id(v0) == "Álvaro Morata","Romelu Lukaku","Neymar","Naïm Sliti","Mehdi Taremi","Mario Götze","Kylian Mbappé","Kasper Dolberg","Jordan Morris","Joel Campbell","Ivan Perišić","Enner Valencia (captain","Christian Eriksen","Alphonso Davies","Ali Assadalla","Akram Afif","İlkay Gündoğan","Youssef En-Nesyri","Serge Gnabry","Sardar Azmoun","Richarlison","Raúl Jiménez","Mohammed Muntari","Almoez Ali","Memphis Depay","Marcus Rashford","Luis Suárez","Lucas Cavallini","Leroy Sané","Karl Toko Ekambi","Hirving Lozano","Haris Seferovic","Hakim Ziyech","Gareth Bale (captain","Gabriel Jesus","Dušan Tadić (captain","Christian Pulisic","Bruno Fernandes","Andrej Kramarić","Aleksandar Mitrović","Aaron Ramsey","Thomas Partey","Robert Lewandowski (captain","Raheem Sterling","Lionel Messi (captain","Kwon Chang-hoon","Junior Hoilett","Hassan Al-Haydos (captain","Cristiano Ronaldo (captain","André Silva","André Ayew (captain","Alireza Jahanbakhsh","Ángel Di María","Wahbi Khazri","Vincent Aboubakar (captain","Thomas Müller","Takumi Minamino","Leon Goretzka","Krzysztof Piątek","Karim Benzema","Jordan Ayew","Harry Kane (captain","Ferran Torres","Cyle Larin","Arkadiusz Milik","Antoine Griezmann","Xherdan Shaqiri","Son Heung-min (captain","Salem Al-Dawsari","Olivier Giroud","Michy Batshuayi","Lautaro Martínez","Kevin De Bruyne","Karim Ansarifard","Jonathan David","Hwang Ui-jo","Eric Maxim Choupo-Moting","Edinson Cavani","Eden Hazard (captain"
RETURN id(v0), id(v1)
errorCode: -1004, errorMsg: SyntaxError: syntax error near `E id(v0)'

I am following the docs chapter 4, while it seems something went wrong anyway.

I tried to use the GO clause instead of MATCH in the second task, but it complained of similar errors.

Could anyone help answer at where I could be wrong?


问:
Start a container in interactive shell in docker compose
My scenario is that I have a bunch of next.js apps. I start all of them in production mode (yarn start) by docker compose up. The docker-compose file looks like below

```<code>version: '3'
services:
  website:
    ...
  admin:
    ...
  website-api:
    ...
  admin-api:
    ...
</code>```

When I'm coding a service, I'd like to re-run the container of that service in an interactive shell, so I could run whatever commands I needed (eg. yarn dev or running test). And keep other services in production

Is there any way I can archive that?

I read about using another docker-compose.overwrite.yml for development. But in my case, I only need one service run in development and keep others in production. So this solution is not fit for me.

Need help!

Body:
My scenario is that I have a bunch of next.js apps. I start all of them in production mode (yarn start) by docker compose up. The docker-compose file looks like below

version: '3'
services:
  website:
    ...
  admin:
    ...
  website-api:
    ...
  admin-api:
    ...

When I'm coding a service, I'd like to re-run the container of that service in an interactive shell, so I could run whatever commands I needed (eg. yarn dev or running test). And keep other services in production

Is there any way I can archive that?

I read about using another docker-compose.overwrite.yml for development. But in my case, I only need one service run in development and keep others in production. So this solution is not fit for me.

Need help!


问:
Automatically importing UnityEngine in generated MessagePack resolvers
I'm trying to start using MessagePack in my Unity project. I've followed the instructions to generate resolvers using mpc through the provided Unity editor plugin, since my project needs to be AOT.

It works, but if my classes contain members of Unity types e.g. Vector3, the generated code doesn't recognize them unless I manually import UnityEngine in the generated file.

That's fine, but it makes me wonder if I'm missing something or rather, is there a way to tell the generator to add certain imports automatically?


问:
Radio Switch Button not working if its required and user click submit before select anything
I have php form like this

First, user need to select Type of individual.

if user do not select anything and click submit button, a required message will show. actually my form work if user doing straight forward.

The problem is when user do not select type individiual and click submit, message apair. but when user select  individual, the radio button dont change to blue. the radio button should change to whatever user select.

but if user select company, the button can change to blue
scenario:

User do not select type individual, then click submit, required message apair

User then select company (radio button change to blue), but if user select individu (radio button dont change, but the hide/show function still work, it not change to blue only, blue color just for remark if user select that button)

$( document ).ready(function( $ ) {
      $("#smart-form-register").validate({
        rules : {
                type_of_individual: {
                    required : true,
                },
                 type_sfaff: {
                    required : true,
                },
                },

        });

    });
    $( "#radio-one" ).change(function() {
        var ind = $('#radio-one').val();

        $("#type_staff").show();
        $("#non_individual").hide();
        $("#staff").hide();
    });

    $( "#radio-two" ).change(function() {
        var non = $('#radio-two').val();
        $("#individual").hide();
        $("#non_individual").show();
        $("#staff").hide();
        $("#type_staff").hide();
         $("#radio-three").prop('checked', false);
          $("#radio-four").prop('checked', false);
    });
    //IF STAFF
    $( "#radio-three" ).change(function() {
        var staff1 = $('#radio-three').val();
        $("#staff").show();
        $("#individual").show();

    });
    //IF NON
    $( "#radio-four" ).change(function() {
        var nonstaff = $('#radio-four').val();
        $("#staff").hide();
        $("#individual").show();

    });```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.switch-field {
        display: flex;
        margin-bottom: 36px;
        overflow: hidden;
    }

    .switch-field input {
        position: absolute !important;
        clip: rect(0, 0, 0, 0);
        height: 1px;
        width: 1px;
        border: 0;
        overflow: hidden;
    }

    .switch-field label {
      /*  background-color: #e4e4e4;
        color: rgba(0, 0, 0, 0.6);
        font-size: 14px;
        line-height: 1;
        text-align: center;
        padding: 8px 16px;
        margin-right: -1px;
        border: 1px solid rgba(0, 0, 0, 0.2);
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
        transition: all 0.1s ease-in-out;*/

        padding: 6px;
        margin: 10px 17px 15px 0;
        font-size: 16px;
        background: #fff;
        color: #0e4e91;
        border: solid 2px #0e4e91;
        border-radius: 5px;
        min-width: 150px;
        text-align: center;
        transition: all 0.1s ease-in-out;
        margin-right: -1px;
    }

    .switch-field label:hover {
        cursor: pointer;
        /*background-color: #204184;
        box-shadow: none;
        border: solid 2px #204184;
        color: #fff;*/
    }

    .switch-field input:checked + label {
        background-color: #204184;
        box-shadow: none;
        border: solid 2px #204184;
        color: #fff;
    }

    .switch-field label:first-of-type {
        border-radius: 4px 0 0 4px;
    }

    .switch-field label:last-of-type {
        border-radius: 0 4px 4px 0;
    }
     .switch-field label.error {
        position:absolute;
          display: inline-block;
        max-width: 100%;

        font-weight: 700;
        font-size: 16px;
        background: #fff;
        color: #e82c0c !important;
        border: 0px !important;
        border-radius: 5px;
        min-width: 150px;
        margin-top: 60px!important;
    padding: 0 1px!important;
    line-height: 15px!important;

    }
    .switch-field label[for=switch_right] {
background-color: red !important;
}</code>```

<form id="smart-form-register">
  Individual Type

  <input type="radio" id="radio-one" name="type_of_individual" value="1" required="">
  Individual

  <input type="radio" id="radio-two" name="type_of_individual" value="0"  required >
  Company

  Staff Type

  <input type="radio" id="radio-three" name="type_of_staff" value="1" required="">
  Staff

  <input type="radio" id="radio-four" name="type_of_staff" value="0"  required >
  Non Staff

  Fullname *
  <input type="text" class="form-control" id="fullname" name="fullname"  maxlength="255" >

  Company Name *
  <input type="text" class="form-control" id="company_name" name="company_name"  maxlength="255" >

  Staff ID *
  <input type="text" class="form-control" id="staff_id" name="staff_id"  maxlength="255" >

 <button type="submit" name="singlebutton" class="btn btn-primary  btn-sm " id="register" >Submit</button></form>```

Body:
I have php form like this

First, user need to select Type of individual.

if user do not select anything and click submit button, a required message will show. actually my form work if user doing straight forward.

The problem is when user do not select type individiual and click submit, message apair. but when user select  individual, the radio button dont change to blue. the radio button should change to whatever user select.

but if user select company, the button can change to blue
scenario:

User do not select type individual, then click submit, required message apair

User then select company (radio button change to blue), but if user select individu (radio button dont change, but the hide/show function still work, it not change to blue only, blue color just for remark if user select that button)

$( document ).ready(function( $ ) {
      $("#smart-form-register").validate({
        rules : {
                type_of_individual: {
                    required : true,
                },
                 type_sfaff: {
                    required : true,
                },
                },

        });

    });
    $( "#radio-one" ).change(function() {
        var ind = $('#radio-one').val();

        $("#type_staff").show();
        $("#non_individual").hide();
        $("#staff").hide();
    });

    $( "#radio-two" ).change(function() {
        var non = $('#radio-two').val();
        $("#individual").hide();
        $("#non_individual").show();
        $("#staff").hide();
        $("#type_staff").hide();
         $("#radio-three").prop('checked', false);
          $("#radio-four").prop('checked', false);
    });
    //IF STAFF
    $( "#radio-three" ).change(function() {
        var staff1 = $('#radio-three').val();
        $("#staff").show();
        $("#individual").show();

    });
    //IF NON
    $( "#radio-four" ).change(function() {
        var nonstaff = $('#radio-four').val();
        $("#staff").hide();
        $("#individual").show();

    });

.switch-field {
        display: flex;
        margin-bottom: 36px;
        overflow: hidden;
    }

    .switch-field input {
        position: absolute !important;
        clip: rect(0, 0, 0, 0);
        height: 1px;
        width: 1px;
        border: 0;
        overflow: hidden;
    }

    .switch-field label {
      /*  background-color: #e4e4e4;
        color: rgba(0, 0, 0, 0.6);
        font-size: 14px;
        line-height: 1;
        text-align: center;
        padding: 8px 16px;
        margin-right: -1px;
        border: 1px solid rgba(0, 0, 0, 0.2);
        box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px rgba(255, 255, 255, 0.1);
        transition: all 0.1s ease-in-out;*/

        padding: 6px;
        margin: 10px 17px 15px 0;
        font-size: 16px;
        background: #fff;
        color: #0e4e91;
        border: solid 2px #0e4e91;
        border-radius: 5px;
        min-width: 150px;
        text-align: center;
        transition: all 0.1s ease-in-out;
        margin-right: -1px;
    }

    .switch-field label:hover {
        cursor: pointer;
        /*background-color: #204184;
        box-shadow: none;
        border: solid 2px #204184;
        color: #fff;*/
    }

    .switch-field input:checked + label {
        background-color: #204184;
        box-shadow: none;
        border: solid 2px #204184;
        color: #fff;
    }

    .switch-field label:first-of-type {
        border-radius: 4px 0 0 4px;
    }

    .switch-field label:last-of-type {
        border-radius: 0 4px 4px 0;
    }
     .switch-field label.error {
        position:absolute;
          display: inline-block;
        max-width: 100%;

        font-weight: 700;
        font-size: 16px;
        background: #fff;
        color: #e82c0c !important;
        border: 0px !important;
        border-radius: 5px;
        min-width: 150px;
        margin-top: 60px!important;
    padding: 0 1px!important;
    line-height: 15px!important;

    }
    .switch-field label[for=switch_right] {
background-color: red !important;
}

<form id="smart-form-register">
  Individual Type

  <input type="radio" id="radio-one" name="type_of_individual" value="1" required="">
  Individual

  <input type="radio" id="radio-two" name="type_of_individual" value="0"  required >
  Company

  Staff Type

  <input type="radio" id="radio-three" name="type_of_staff" value="1" required="">
  Staff

  <input type="radio" id="radio-four" name="type_of_staff" value="0"  required >
  Non Staff

  Fullname *
  <input type="text" class="form-control" id="fullname" name="fullname"  maxlength="255" >

  Company Name *
  <input type="text" class="form-control" id="company_name" name="company_name"  maxlength="255" >

  Staff ID *
  <input type="text" class="form-control" id="staff_id" name="staff_id"  maxlength="255" >

 <button type="submit" name="singlebutton" class="btn btn-primary  btn-sm " id="register" >Submit</button></form>


问:
How to build a docker image for arm(aarch)?
I want to use a centos7.6 docker image, but I can't find centos7.6(arm) in docker hub.

Is there a way to build centos7.6 docker image match to arm(I am working on centos x86_64)? Thanks!


问:
Using subprocess to run a Python script with shell=True
I have a Python script foo.py that I want to invoke with a second Python script using the subprocess module. The code in foo.py is provided by a user, and it could be malicious. I have set some security features in place (e.g., resource limits, change UID) prior to running the code to minimize the damage that the user can do.

I'd like to invoke the script with shell=True kwarg in the subprocess.run command because I am setting resource limits at the UID level. It seems like these limits do not apply if I do not add this kwarg. My code looks something like this:

```<code>import os
import subprocess

def enable_extra_security() -> None:
  # set a different user ID for security reasons
  os.setuid(1234)

  # limit CPU time usage
  resource.setrlimit(resource.RLIMIT_CPU, (5, 5))

  # limit file size creation
  resource.setrlimit(resource.RLIMIT_FSIZE, (100_000, 100_000))

  # prevent forking
  resource.setrlimit(resource.RLIMIT_NPROC, (5, 5))

if __name__ == '__main__':
  # this script is run as root.

  pid = os.fork()

  if pid == 0:
   # child process
   enable_extra_security()
   res = subprocess.run(['/usr/bin/python', 'foo.py'], shell=True, capture_output=True)
   # ...
   # child does some processing based on the returncode and output.
   # ...
  else:
    # parent process
    os.waitpid(pid, 0)

  # ...
  # ...

</code>```

When I invoke enable_extra_security(), it only applies the additional security features to the child process. Specifically, the limits are only imposed on user ID 1234, which is only set for the child process. If I run subprocess.run without shell=True, the security features vanish. Unfortunately, the code above does not work: the subprocess.run command will actually just start a Python console and hang (i.e., it does not seem to pass in "foo.py" as an argument).

Interestingly, the code does work for C and C++ code (if I were to replace /usr/bin/python with /usr/bin/gcc and instead put a .c or .cpp file, it would work just fine). Why is this happening, and how can I solve my problem?

Body:
I have a Python script foo.py that I want to invoke with a second Python script using the subprocess module. The code in foo.py is provided by a user, and it could be malicious. I have set some security features in place (e.g., resource limits, change UID) prior to running the code to minimize the damage that the user can do.

I'd like to invoke the script with shell=True kwarg in the subprocess.run command because I am setting resource limits at the UID level. It seems like these limits do not apply if I do not add this kwarg. My code looks something like this:

import os
import subprocess

def enable_extra_security() -> None:
  # set a different user ID for security reasons
  os.setuid(1234)

  # limit CPU time usage
  resource.setrlimit(resource.RLIMIT_CPU, (5, 5))

  # limit file size creation
  resource.setrlimit(resource.RLIMIT_FSIZE, (100_000, 100_000))

  # prevent forking
  resource.setrlimit(resource.RLIMIT_NPROC, (5, 5))

if __name__ == '__main__':
  # this script is run as root.

  pid = os.fork()

  if pid == 0:
   # child process
   enable_extra_security()
   res = subprocess.run(['/usr/bin/python', 'foo.py'], shell=True, capture_output=True)
   # ...
   # child does some processing based on the returncode and output.
   # ...
  else:
    # parent process
    os.waitpid(pid, 0)

  # ...
  # ...

When I invoke enable_extra_security(), it only applies the additional security features to the child process. Specifically, the limits are only imposed on user ID 1234, which is only set for the child process. If I run subprocess.run without shell=True, the security features vanish. Unfortunately, the code above does not work: the subprocess.run command will actually just start a Python console and hang (i.e., it does not seem to pass in "foo.py" as an argument).

Interestingly, the code does work for C and C++ code (if I were to replace /usr/bin/python with /usr/bin/gcc and instead put a .c or .cpp file, it would work just fine). Why is this happening, and how can I solve my problem?


问:
How to strip a special character from multiple columns at once in python dataframe
I am trying to strip a special character from all columns in a data frame at the same time. it seems to work when using the iloc function on a single columns but when I try to use select multiple columns it doesn't seem to work.</p>
```<code>df.iloc[:,1:10] = df.iloc[:,1:10].str.strip('%')
</code>```

Body:
I am trying to strip a special character from all columns in a data frame at the same time. it seems to work when using the iloc function on a single columns but when I try to use select multiple columns it doesn't seem to work.

df.iloc[:,1:10] = df.iloc[:,1:10].str.strip('%')


问:
R html widget: annoying return symbols
I'm converting an R DT table to an html widget.

The widgets have the annoying carriage return symbols. Example of carriage return issue:

The dataframe is all_p_22

My code:

```<code>library(htmlwidgets)
library(DT)

tab10a <- datatable(all_p_22,
                    filter = 'top',
                    options = list(
                      dom = "Bfrtip",
                      pageLength = 120,
                      autoWidth = TRUE,
                      buttons = c("csv","excel")),
                    rownames = FALSE,
                    caption = htmltools::tags$caption(style = 'caption-side: top; text-align: center; color:black; font-size:150%;',
                                                      'Table 10a: Overall Legislative Assembly result by party'),
                    class = 'cell-border stripe',
                    extensions = c("Buttons","Responsive"))

tab10a1 <- tab10a %>%
  formatRound("Sum Votes",
              digits = 0,
              interval = 3,
              mark = ",") %>%
  formatRound("Per cent",
              digits = 2,
              mark = ",")

saveWidget(tab10a1,"tab10a.html")
</code>```

Tried minor fixes such as removing buttons but had no effect.

Title: R html widget: annoying return symbols

Body:
I'm converting an R DT table to an html widget.

The widgets have the annoying carriage return symbols. Example of carriage return issue:

The dataframe is all_p_22

My code:

library(htmlwidgets)
library(DT)

tab10a <- datatable(all_p_22,
                    filter = 'top',
                    options = list(
                      dom = "Bfrtip",
                      pageLength = 120,
                      autoWidth = TRUE,
                      buttons = c("csv","excel")),
                    rownames = FALSE,
                    caption = htmltools::tags$caption(style = 'caption-side: top; text-align: center; color:black; font-size:150%;',
                                                      'Table 10a: Overall Legislative Assembly result by party'),
                    class = 'cell-border stripe',
                    extensions = c("Buttons","Responsive"))

tab10a1 <- tab10a %>%
  formatRound("Sum Votes",
              digits = 0,
              interval = 3,
              mark = ",") %>%
  formatRound("Per cent",
              digits = 2,
              mark = ",")

saveWidget(tab10a1,"tab10a.html")

Tried minor fixes such as removing buttons but had no effect.


问:
Python: how to pipe to a background process using subprocess.*?
I am trying to have Python execute an external program (which continues to run in the background) and write arbitrary data to the program's STDIN.  The program will read STDIN in non-blocking mode and act upon it.

Here's a toy example (ex.py) of the to-be-executed program:
`

```<code>import fcntl, os, sys, time

orig_fl = fcntl.fcntl(sys.stdin, fcntl.F_GETFL)
fcntl.fcntl(sys.stdin, fcntl.F_SETFL, orig_fl | os.O_NONBLOCK)

i = 0
while True:
    for line in sys.stdin:
        try:
            i = int(line)
        except:
            pass
    print(i)
    time.sleep(1)
    i += 1
</code>```

Here's my driver program:

```<code>import os, random, subprocess, time

command = ['/usr/bin/python3', './ex.py']
proc = subprocess.Popen(command, stdin=subprocess.PIPE)

for i in range(100):
    new_base = 100 * (i + 10)
    print('drive.py setting new_base to', new_base)
    proc.communicate(str(new_base).encode())
    time.sleep(5)
</code>```

I get this:

```<code>drive.py setting new_base to 1000
1000
1001
1002
1003
1004
1005
1006
1007
[...]
</code>```

... whereas I expect something like:

```<code>drive.py setting new_base to 1000
1000
1001
1002
1003
1004
1005
drive.py setting new_base to 1100
1100
1101
[...]
</code>```

So proc.communicate() is blocking or something.

(My "real" executed program is in C and uses fork(), exec(), pipe(), etc., and I could do that here I suppose, but it's not the Python way.)

Any ideas?  Thanks!

Body:
I am trying to have Python execute an external program (which continues to run in the background) and write arbitrary data to the program's STDIN.  The program will read STDIN in non-blocking mode and act upon it.

Here's a toy example (ex.py) of the to-be-executed program:
`

import fcntl, os, sys, time

orig_fl = fcntl.fcntl(sys.stdin, fcntl.F_GETFL)
fcntl.fcntl(sys.stdin, fcntl.F_SETFL, orig_fl | os.O_NONBLOCK)

i = 0
while True:
    for line in sys.stdin:
        try:
            i = int(line)
        except:
            pass
    print(i)
    time.sleep(1)
    i += 1

Here's my driver program:

import os, random, subprocess, time

command = ['/usr/bin/python3', './ex.py']
proc = subprocess.Popen(command, stdin=subprocess.PIPE)

for i in range(100):
    new_base = 100 * (i + 10)
    print('drive.py setting new_base to', new_base)
    proc.communicate(str(new_base).encode())
    time.sleep(5)

I get this:

drive.py setting new_base to 1000
1000
1001
1002
1003
1004
1005
1006
1007
[...]

... whereas I expect something like:

drive.py setting new_base to 1000
1000
1001
1002
1003
1004
1005
drive.py setting new_base to 1100
1100
1101
[...]

So proc.communicate() is blocking or something.

(My "real" executed program is in C and uses fork(), exec(), pipe(), etc., and I could do that here I suppose, but it's not the Python way.)

Any ideas?  Thanks!


问:
Does a VS project that targets netstandard2.0 need to install the NetStandard.Library nuget package?
Does a VS project that targets netstandard2.0 need to install the NetStandard.Library nuget package?

This MS doc says " The most common way to target netstandard is by referencing this metapackage."

My project does NOT reference the package, but DOES target netstardard using

 <TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>

And everything works ok.  But who knows, I might be missing something that only comprehensive testing would reveal.


问:
Redisson-spring-boot-starter library fails to start the application
i am using Redisson-spring-boot-starter 3.17.0 and spring-boot version 2.7.1 below is my pom file , the application fails to start with the below dependencies.

I tried playing around with different versions but still same failure. Tried adding spring-data-26 and spring-session-data-redis along with redisson-spring-boot-starter dint help. Replaced the redisson spring boot starter dependency with just redisson, but that gave cacheManager bean not found error.

i am implementing Rate limiting using bucket4j and redis referring this implementation: https://www.freecodecamp.org/news/rate-limiting-with-bucket4j-and-redis/

```<code><revision>0.0.0-SNAPSHOT</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
<mapstruct.version>1.4.2.Final</mapstruct.version>
<micrometer.version>1.10.1</micrometer.version>
<h2.version>2.1.210</h2.version>
<jose4j.version>0.7.10</jose4j.version>
<junit-jupiter.version>5.8.1</junit-jupiter.version>
<springdoc.version>1.6.6</springdoc.version>
<log4j2.version>2.17.1</log4j2.version>
<spring-boot-starter-security.version>2.6.3</spring-boot-starter-security.version>
<!--Official plugins-->
<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
<maven-failsafe-plugin-version>${maven-surefire-plugin.version}</maven-failsafe-plugin-version>
<git-commit-id-plugin.version>5.0.0</git-commit-id-plugin.version>
<jacoco-plugin-version>0.8.7</jacoco-plugin-version>
<spotless.version>2.20.2</spotless.version>
<exists-maven-plugin.version>0.6.0</exists-maven-plugin.version>
<google-java-format.version>1.13.0</google-java-format.version>
<wagon-ssh-external.version>3.5.1</wagon-ssh-external.version>
<bucket4j.version>0.5.2</bucket4j.version>   </properties>   <dependencies>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
    </exclusion>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-logging</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-configuration-processor</artifactId>
  <optional>true</optional>
</dependency>
<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-registry-prometheus</artifactId>
  <version>${micrometer.version}</version>
</dependency>
<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>org.springdoc</groupId>
  <artifactId>springdoc-openapi-ui</artifactId>
  <version>${springdoc.version}</version>
</dependency>
<dependency>
  <groupId>org.springdoc</groupId>
  <artifactId>springdoc-openapi-webmvc-core</artifactId>
  <version>${springdoc.version}</version>
</dependency>
<dependency>
  <groupId>org.springdoc</groupId>
  <artifactId>springdoc-openapi-data-rest</artifactId>
  <version>${springdoc.version}</version>
</dependency>
<dependency>
  <groupId>org.mapstruct</groupId>
  <artifactId>mapstruct</artifactId>
  <version>${mapstruct.version}</version>
</dependency>
<dependency>
  <groupId>org.mapstruct</groupId>
  <artifactId>mapstruct-processor</artifactId>
  <version>${mapstruct.version}</version>
  <optional>true</optional>
</dependency>
<dependency>
  <groupId>org.bitbucket.b_c</groupId>
  <artifactId>jose4j</artifactId>
  <version>${jose4j.version}</version>
</dependency>
<!-- Configuring Spring Boot to use Log4j2 -->
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.junit.jupiter</groupId>
  <artifactId>junit-jupiter-engine</artifactId>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.h2database</groupId>
  <artifactId>h2</artifactId>
  <version>${h2.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
  <version>${spring-boot-starter-security.version}</version>
</dependency>
<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
  <groupId>org.redisson</groupId>
  <artifactId>redisson-spring-boot-starter</artifactId>
  <version>3.17.0</version>
</dependency>

<!-- Bucket4J starter = Bucket4J + JCache -->
<dependency>
  <groupId>com.giffing.bucket4j.spring.boot.starter</groupId>
  <artifactId>bucket4j-spring-boot-starter</artifactId>
  <version>0.5.2</version>
</dependency>   </dependencies>
</code>```

Body:
i am using Redisson-spring-boot-starter 3.17.0 and spring-boot version 2.7.1 below is my pom file , the application fails to start with the below dependencies.

I tried playing around with different versions but still same failure. Tried adding spring-data-26 and spring-session-data-redis along with redisson-spring-boot-starter dint help. Replaced the redisson spring boot starter dependency with just redisson, but that gave cacheManager bean not found error.

i am implementing Rate limiting using bucket4j and redis referring this implementation: https://www.freecodecamp.org/news/rate-limiting-with-bucket4j-and-redis/

<revision>0.0.0-SNAPSHOT</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
<mapstruct.version>1.4.2.Final</mapstruct.version>
<micrometer.version>1.10.1</micrometer.version>

2.1.210

<jose4j.version>0.7.10</jose4j.version>
<junit-jupiter.version>5.8.1</junit-jupiter.version>
<springdoc.version>1.6.6</springdoc.version>
<log4j2.version>2.17.1</log4j2.version>
<spring-boot-starter-security.version>2.6.3</spring-boot-starter-security.version>

<maven-surefire-plugin.version>3.0.0-M5</maven-surefire-plugin.version>
<maven-failsafe-plugin-version>${maven-surefire-plugin.version}</maven-failsafe-plugin-version>
<git-commit-id-plugin.version>5.0.0</git-commit-id-plugin.version>
<jacoco-plugin-version>0.8.7</jacoco-plugin-version>
<spotless.version>2.20.2</spotless.version>
<exists-maven-plugin.version>0.6.0</exists-maven-plugin.version>
<google-java-format.version>1.13.0</google-java-format.version>
<wagon-ssh-external.version>3.5.1</wagon-ssh-external.version>
<bucket4j.version>0.5.2</bucket4j.version>   </properties>   <dependencies>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <exclusions>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-tomcat</artifactId>
    </exclusion>
    <exclusion>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-logging</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-configuration-processor</artifactId>
  <optional>true</optional>
</dependency>
<dependency>
  <groupId>io.micrometer</groupId>
  <artifactId>micrometer-registry-prometheus</artifactId>
  <version>${micrometer.version}</version>
</dependency>
<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>org.springdoc</groupId>
  <artifactId>springdoc-openapi-ui</artifactId>
  <version>${springdoc.version}</version>
</dependency>
<dependency>
  <groupId>org.springdoc</groupId>
  <artifactId>springdoc-openapi-webmvc-core</artifactId>
  <version>${springdoc.version}</version>
</dependency>
<dependency>
  <groupId>org.springdoc</groupId>
  <artifactId>springdoc-openapi-data-rest</artifactId>
  <version>${springdoc.version}</version>
</dependency>
<dependency>
  <groupId>org.mapstruct</groupId>
  <artifactId>mapstruct</artifactId>
  <version>${mapstruct.version}</version>
</dependency>
<dependency>
  <groupId>org.mapstruct</groupId>
  <artifactId>mapstruct-processor</artifactId>
  <version>${mapstruct.version}</version>
  <optional>true</optional>
</dependency>
<dependency>
  <groupId>org.bitbucket.b_c</groupId>
  <artifactId>jose4j</artifactId>
  <version>${jose4j.version}</version>
</dependency>

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-test</artifactId>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.junit.jupiter</groupId>
  <artifactId>junit-jupiter-engine</artifactId>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>com.h2database</groupId>
  <artifactId>h2</artifactId>
  <version>${h2.version}</version>
  <scope>test</scope>
</dependency>
<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-security</artifactId>
  <version>${spring-boot-starter-security.version}</version>
</dependency>
<dependency>
  <groupId>org.apache.commons</groupId>
  <artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
  <groupId>org.redisson</groupId>
  <artifactId>redisson-spring-boot-starter</artifactId>
  <version>3.17.0</version>
</dependency>

<dependency>
  <groupId>com.giffing.bucket4j.spring.boot.starter</groupId>
  <artifactId>bucket4j-spring-boot-starter</artifactId>
  <version>0.5.2</version>
</dependency>   </dependencies>


问:
SDL.h: No such file or directory, SDL_image.h: No such file or directory VS Code
I am struggling with compiling my program using SDL and SDL_image libraries with MinGW. When I try to build my program I always get these errors. I've already tried two methods: manually install (this one showed me same errors but I was able to compile my program using MakeFile but the problem is I'm not getting any errors messages even if I have them), vcpkg tool (I did everything as in the tutorial but this time program does not build at all and shows same thing).

Addition to the first method: In my project I have 3 files which are actually parts of program written by me (main.cpp,RenderWindow.hpp header file,renderwindow.cpp source file that desribes header). And as I've already mentioned I have a MakeFile which contains this:

```<code>output: main.o renderwindow.o
    g++ -Isrc/include -Lsrc/lib main.o renderwindow.o -o output -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
main.o: main.cpp
    g++ -Isrc/include -Lsrc/lib -c main.cpp -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
renderwindow.o: renderwindow.cpp
    g++ -Isrc/include -Lsrc/lib -c renderwindow.cpp -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
clean:
    rm *.o output
</code>```

Also I have two dll files (SDL2.dll,SDL2_image.dll) in my workspace. Everything is building but if I have errors I don't even know that because nothing shows up in terminal and I have to manually look for them and it's not ok.

Addition to the second method: I decided to install SDL and SDL_image using vcpkg. I've installed libraries successfully with vcpkg, I have a CMakeLists.txt that looks like this:

```<code>type herecmake_minimum_required(VERSION 3.0.0)
project(game VERSION 0.1.0)

INCLUDE_DIRECTORIES(
    D:/D/vcpkg/vcpkg/installed/x64-windows/include
)

LINK_DIRECTORIES(
    D:/D/vcpkg/vcpkg/installed/x64-windows/lib,
    D:/D/vcpkg/vcpkg/installed/x64-windows/lib/manual-link
)

add_executable(game main.cpp)

TARGET_LINK_LIBRARIES(game
    SDL2 SDL2_image
)

</code>```

I have automatically generated build folder with all Cmake things as well but still getting "SDL.h: No such file or directory".

I searched the internet for a solution to this problem but nothing helped and I assume from what I've already found that this problem is related to linker stuff.

P.S. I have the latest MinGW,SDL/SDL_image and VS Code versions.

Body:
I am struggling with compiling my program using SDL and SDL_image libraries with MinGW. When I try to build my program I always get these errors. I've already tried two methods: manually install (this one showed me same errors but I was able to compile my program using MakeFile but the problem is I'm not getting any errors messages even if I have them), vcpkg tool (I did everything as in the tutorial but this time program does not build at all and shows same thing).

Addition to the first method: In my project I have 3 files which are actually parts of program written by me (main.cpp,RenderWindow.hpp header file,renderwindow.cpp source file that desribes header). And as I've already mentioned I have a MakeFile which contains this:

output: main.o renderwindow.o
    g++ -Isrc/include -Lsrc/lib main.o renderwindow.o -o output -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
main.o: main.cpp
    g++ -Isrc/include -Lsrc/lib -c main.cpp -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
renderwindow.o: renderwindow.cpp
    g++ -Isrc/include -Lsrc/lib -c renderwindow.cpp -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
clean:
    rm *.o output

Also I have two dll files (SDL2.dll,SDL2_image.dll) in my workspace. Everything is building but if I have errors I don't even know that because nothing shows up in terminal and I have to manually look for them and it's not ok.

Addition to the second method: I decided to install SDL and SDL_image using vcpkg. I've installed libraries successfully with vcpkg, I have a CMakeLists.txt that looks like this:

type herecmake_minimum_required(VERSION 3.0.0)
project(game VERSION 0.1.0)

INCLUDE_DIRECTORIES(
    D:/D/vcpkg/vcpkg/installed/x64-windows/include
)

LINK_DIRECTORIES(
    D:/D/vcpkg/vcpkg/installed/x64-windows/lib,
    D:/D/vcpkg/vcpkg/installed/x64-windows/lib/manual-link
)

add_executable(game main.cpp)

TARGET_LINK_LIBRARIES(game
    SDL2 SDL2_image
)

I have automatically generated build folder with all Cmake things as well but still getting "SDL.h: No such file or directory".

I searched the internet for a solution to this problem but nothing helped and I assume from what I've already found that this problem is related to linker stuff.

P.S. I have the latest MinGW,SDL/SDL_image and VS Code versions.


问:
Python asyncio await on future seems to be blocking
I'm trying to use the below code to implement async data waiting process. Basic idea is a future is passed into wait_on_data, another function set_status will set the result for this future.

The problem is when I ran the code, it seems like await fut doesn't suspend task, it always reached the timeout limit, and set_status couldn't run concurrently to set the result.
Is this because of GIL? If it is, what can I do alternatively to achieve this?

```<code>    def set_status(fut):
        print("set future")
        fut.set_result((True, True))

    async def wait_on_data(fut):
        try:
            async with asyncio.timeout(10):
                print("waiting for future")
                await fut
                return fut.result()
        except TimeoutError:
            print("timeout for future")
            return (False, False)

    async def main():
        fut = asyncio.get_running_loop().create_future()
        result = await wait_on_data(fut)
        await asyncio.get_event_loop().run_in_executor(set_status(fut))

        assert result == True, True
</code>```

Body:
I'm trying to use the below code to implement async data waiting process. Basic idea is a future is passed into wait_on_data, another function set_status will set the result for this future.

The problem is when I ran the code, it seems like await fut doesn't suspend task, it always reached the timeout limit, and set_status couldn't run concurrently to set the result.
Is this because of GIL? If it is, what can I do alternatively to achieve this?

    def set_status(fut):
        print("set future")
        fut.set_result((True, True))

    async def wait_on_data(fut):
        try:
            async with asyncio.timeout(10):
                print("waiting for future")
                await fut
                return fut.result()
        except TimeoutError:
            print("timeout for future")
            return (False, False)

    async def main():
        fut = asyncio.get_running_loop().create_future()
        result = await wait_on_data(fut)
        await asyncio.get_event_loop().run_in_executor(set_status(fut))

        assert result == True, True


问:
C# System.NotImplementedException: NModbus4 error "function code 28 is not supported" with function WriteSingleCoil()
When I use NModbus4 in C#, the shared library is the program running into the function WriteSingleCoil().System.NotImplementedException:"function code 28 is not supported"

I wanted to use the NModbus4 shared library to control the solenoid switch through the IO module, but I was troubled by the occasional error when the program ran to the WriteSingleCoil () function: System.NotImplementedException:"function code 28 is not supported" .sometimes it didn't.


问:
Serializing custom model fields in TokenObtainPairSerializer
Im using djangorestframework-simplejwt. I want to make TokenObtainPairView take in first_name, last_name, phone_number and email to authenticate instead of the default username and password, so that I can instead make a /register endpoint that will both register and login in a single request. (For reference this is the urlpattern typically used with TokenObtainPairView typically

path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
```
<p>I've been able to make this work with writing normal serializer fields like below</p>
<pre class="lang-py prettyprint-override"><code>class MyTokenObtainPairSerializer(TokenObtainPairSerializer):

    first_name = serializers.CharField()
    last_name = serializers.CharField()
    email = serializers.EmailField()

class MyTokenObtainPairView(TokenObtainPairView):
    serializer_class = MyTokenObtainPairSerializer
</code>```

Is there a way to use ModelSerializer to do this instead? e.g something like this (the below doesn't work)

class MyTokenObtainPairSerializer(TokenObtainPairSerializer, ModelSerializer):

    class Meta:
        model = User
        fields = ['first_name', 'last_name', 'email']

```

Body:
Im using djangorestframework-simplejwt. I want to make TokenObtainPairView take in first_name, last_name, phone_number and email to authenticate instead of the default username and password, so that I can instead make a /register endpoint that will both register and login in a single request. (For reference this is the urlpattern typically used with TokenObtainPairView typically

path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),

I've been able to make this work with writing normal serializer fields like below

class MyTokenObtainPairSerializer(TokenObtainPairSerializer):

    first_name = serializers.CharField()
    last_name = serializers.CharField()
    email = serializers.EmailField()

class MyTokenObtainPairView(TokenObtainPairView):
    serializer_class = MyTokenObtainPairSerializer

Is there a way to use ModelSerializer to do this instead? e.g something like this (the below doesn't work)

class MyTokenObtainPairSerializer(TokenObtainPairSerializer, ModelSerializer):

    class Meta:
        model = User
        fields = ['first_name', 'last_name', 'email']


问:
I cannot deploy my website even though firebase is installed
I am trying to download firebase, but even after I run:

npm install -g firebase-tools
```
<p>I get:</p>
<blockquote>
<p>zsh: command not found: firebase</p>
</blockquote>
<p>when trying: <code>firebase -v</code></p>
<p>could it have something to do with:</p>
<pre class="lang-none prettyprint-override"><code>npm WARN deprecated har-validator@5.1.3: this library is no longer supported
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
</code>```

Body:
I am trying to download firebase, but even after I run:

npm install -g firebase-tools

I get:

zsh: command not found: firebase

when trying: firebase -v

could it have something to do with:

npm WARN deprecated har-validator@5.1.3: this library is no longer supported
npm WARN deprecated debug@4.1.1: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142


问:
SheetJS generated excel workbook size is too large
I am using xlsx to prepare the excel workbook through AWS lambda. I need to read the workbook from S3 and add the multiple sheets. I am using below code to read the excel workbook from S3 but final workbook size is too large.

xlsx.read(buffer, { cellStyles: true })

If I remove cellStyles: true then it is generating workbook with correct size but it removes the formatting (date, number, cell width etc)

I am writing workbook to S3 with ContentType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet


问:
Changing the class of SendSweetAlert 'Ok' button in Rshiny to 'btn-danger'
I am trying to change the SendSweetAlert 'OK' button class to 'btn-danger' but unable to do so. I am doing this by passing the parameter 'confirmButtonClass' as 'btn-danger' but it is not working.
How can I accomplish this?
Thanks for the help.

```<code>library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  tags$h1("Click the button to open the alert"),
  actionButton(
    inputId = "sw_html",
    label = "Sweet alert with plot"
  )
)

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

  observeEvent(input$sw_html, {
    show_alert(
      title = "Yay a plot!",
      text = tags$div(
        plotOutput(outputId = "plot"),
        sliderInput(
          inputId = "clusters",
          label = "Number of clusters",
          min = 2, max = 6, value = 3, width = "100%"
        )
      ),
      html = TRUE,
      width = "80%",
      confirmButtonClass='btn-danger'
    )
  })

  output$plot <- renderPlot({
    plot(Sepal.Width ~ Sepal.Length,
         data = iris, col = Species,
         pch = 20, cex = 2)
    points(kmeans(iris[, 1:2], input$clusters)$centers,
           pch = 4, cex = 4, lwd = 4)
  })
}

if (interactive())
  shinyApp(ui, server) ```

```

Body:
I am trying to change the SendSweetAlert 'OK' button class to 'btn-danger' but unable to do so. I am doing this by passing the parameter 'confirmButtonClass' as 'btn-danger' but it is not working.
How can I accomplish this?
Thanks for the help.

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  tags$h1("Click the button to open the alert"),
  actionButton(
    inputId = "sw_html",
    label = "Sweet alert with plot"
  )
)

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

  observeEvent(input$sw_html, {
    show_alert(
      title = "Yay a plot!",
      text = tags$div(
        plotOutput(outputId = "plot"),
        sliderInput(
          inputId = "clusters",
          label = "Number of clusters",
          min = 2, max = 6, value = 3, width = "100%"
        )
      ),
      html = TRUE,
      width = "80%",
      confirmButtonClass='btn-danger'
    )
  })

  output$plot <- renderPlot({
    plot(Sepal.Width ~ Sepal.Length,
         data = iris, col = Species,
         pch = 20, cex = 2)
    points(kmeans(iris[, 1:2], input$clusters)$centers,
           pch = 4, cex = 4, lwd = 4)
  })
}

if (interactive())
  shinyApp(ui, server) ```


问:
Ziggy error: 'blok' parameter is required for route 'blok.update'
i'm using inertia js with laravel 9 for my web app, while i want update it show error "Ziggy error: 'blok' parameter is required for route 'blok.update'."

my route :

```<code>Route::resource('blok', BlokController::class)
    ->only(['index', 'store', 'update', 'destroy'])
    ->middleware(['auth', 'verified']);
</code>```

Controller :

```<code>public function update(Request $request, $id)
    {
        //

        Validator::make($request->all(), [
            'id_kebun' => ['required'],
            'nama_blok' => ['required'],

        ])->validate();

        Blok::find($id)->update($request->all());
        return redirect()->route('blok.index');
    //

    }
</code>```

and my view :

```<code>const { petaks } = usePage().props;

    const { data, setData, put, patch, processing, reset, errors } = useForm({
        nama_blok_petak: petaks.nama_blok_petak || "",
        kelas_lahan: petaks.kelas_lahan || "",
    });

    function handleSubmit(e) {
        e.preventDefault();
        put(route("petak.update", petaks.id));
    }
</code>```

i'm expect solved my problem with parameter update not defined at router

Body:
i'm using inertia js with laravel 9 for my web app, while i want update it show error "Ziggy error: 'blok' parameter is required for route 'blok.update'."

my route :

Route::resource('blok', BlokController::class)
    ->only(['index', 'store', 'update', 'destroy'])
    ->middleware(['auth', 'verified']);

Controller :

public function update(Request $request, $id)
    {
        //

        Validator::make($request->all(), [
            'id_kebun' => ['required'],
            'nama_blok' => ['required'],

        ])->validate();

        Blok::find($id)->update($request->all());
        return redirect()->route('blok.index');
    //

    }

and my view :

const { petaks } = usePage().props;

    const { data, setData, put, patch, processing, reset, errors } = useForm({
        nama_blok_petak: petaks.nama_blok_petak || "",
        kelas_lahan: petaks.kelas_lahan || "",
    });

    function handleSubmit(e) {
        e.preventDefault();
        put(route("petak.update", petaks.id));
    }

i'm expect solved my problem with parameter update not defined at router


问:
C# to VB net : " float* "
Dears,

Can I convert this code to VB net ?

float* temp = (float*)pixel;
float temp2 = *temp;

Thank you ~.

tried to use intPrt,
auto convertor,
all failed..

Title: C# to VB net : " float* "


问:
Wininet error and crash in ntdll (RtlpWaitOnCriticalSection)
I tried to call HttpSendRequest in a new thread, and most of the time the code works fine, recently found the same crash on two systems: windows10 enterprise, windwos 7 professional.

code like this (critical code):

```<code>#include <iostream>
#include <windows.h>
#include <wininet.h>
#include <map>
#include <vector>

#pragma comment(lib, "Wininet.lib")

bool HttpRequest(std::wstring url,
                 const std::string& send,
                 std::string& recv,
                 int& status) {
  std::wstring header(L"QUA:xxxxxxxx\r\nTTO:xxxxxxxx\r\n");
  std::map<std::wstring, std::wstring> rsp_header;
  std::string body = send;

  wchar_t szHost[256] = {0};
  wchar_t szPath[2048] = {0};
  URL_COMPONENTS uc = {sizeof(URL_COMPONENTS)};
  uc.lpszHostName = szHost;
  uc.dwHostNameLength = 256;
  uc.lpszUrlPath = szPath;
  uc.dwUrlPathLength = 2048;

  if (!InternetCrackUrlW(url.c_str(), url.size(), ICU_DECODE, &uc)) {
    return false;
  }

  int open_port = uc.nPort;
  if (uc.nScheme == INTERNET_SCHEME_HTTPS)
    open_port = 4443;
  auto hSession = InternetOpenW(NULL, 0, NULL, NULL, 0);
  auto hConnect = InternetConnectW(hSession, szHost, (INTERNET_PORT)open_port,
                                   NULL, NULL, INTERNET_SERVICE_HTTP, 0, NULL);

  static const wchar_t* pMethod[] = {L"GET", L"POST", L"PUT", L"HEAD",
                                     L"CONNECT"};

  static const wchar_t* pVersion[] = {L"HTTP/1.0", L"HTTP/1.1"};

  DWORD dwFlags = INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_NO_CACHE_WRITE;

  auto hRequest = HttpOpenRequestW(hConnect, pMethod[1], szPath, pVersion[1],
                                   NULL, NULL, dwFlags, NULL);

  unsigned int realDataLen = body.size();
  unsigned int realHeaderLen = header.size();
  auto pOptinalData = &send[0];
  auto pHeaderdata = &header[0];

  HttpSendRequestW(hRequest, pHeaderdata, realHeaderLen, (void*)pOptinalData,
                   realDataLen);

  InternetCloseHandle(hRequest);
  InternetCloseHandle(hConnect);
  InternetCloseHandle(hSession);

  return true;
}

DWORD WINAPI Run(LPVOID) {
  std::string send = "empty";
  std::string recv = "";
  int status = 0;
  std::wstring url = L"http://127.0.0.1:8080";

  auto rtn = HttpRequest(url, send, recv, status);
  std::cout << rtn << " last error:" << ::GetLastError() << "status:" << status
            << std::endl;
}

int main() {
  auto handle = CreateThread(NULL, 0, Run, NULL, 0, NULL);
  WaitForSingleObject(handle, INFINITE);
  return 0;
}
</code>```

with error:
0x77E8F563 (ntdll.dll)
0xC0000005: Access violation writing location 0x00000014.

crash stack trace:

```<code>ntdll.dll!RtlpWaitOnCriticalSection()
ntdll.dll!RtlpEnterCriticalSectionContended()
ntdll.dll!_RtlEnterCriticalSection@4()
wininet.dll!CSocket::InitializeSocket()
wininet.dll!CSocket::Connect_Start(classCFsm_SocketConnect *)
wininet.dll!CFsm_SocketConnect::RunSM()
wininet.dll!CFsm::Run()
wininet.dll!DoFsm()
wininet.dll!CSocket::Connect()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::OpenConnection_Fsm(classCFsm_OpenConnection *)
wininet.dll!CFsm_OpenConnection::RunSM()
wininet.dll!CFsm::Run()
wininet.dll!DoFsm()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::OpenConnection()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::MakeConnection_Fsm()
wininet.dll!CFsm_MakeConnection::RunSM()
wininet.dll!CFsm::Run()
wininet.dll!DoFsm()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::MakeConnection()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::SendRequest_Fsm(classCFsm_SendRequest *) wininet.dll!CFsm_SendRequest::RunSM()
wininet.dll!CFsm::Run()
wininet.dll!DoFsm()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::HttpSendRequest_Start(classCFsm_HttpSendRequest *)
wininet.dll!CFsm_HttpSendRequest::RunSM()
wininet.dll!CFsm::Run()
wininet.dll!CFsm::RunWorkItem()
wininet.dll!FailFastThreadPoolCallback<&CFsm::RunWorkItemWrapper>()
ntdll.dll!TppSimplepExecuteCallback()
ntdll.dll!TppWorkerThread()
kernel32.dll!761afa29()
</code>```

There are a lot of codes. What aspects should I check.
Could you give me some advice?

The code runs normally on 99.9% of the devices.

Body:
I tried to call HttpSendRequest in a new thread, and most of the time the code works fine, recently found the same crash on two systems: windows10 enterprise, windwos 7 professional.

code like this (critical code):

#include <iostream>
#include <windows.h>
#include <wininet.h>
#include <map>
#include <vector>

#pragma comment(lib, "Wininet.lib")

bool HttpRequest(std::wstring url,
                 const std::string& send,
                 std::string& recv,
                 int& status) {
  std::wstring header(L"QUA:xxxxxxxx\r\nTTO:xxxxxxxx\r\n");
  std::map<std::wstring, std::wstring> rsp_header;
  std::string body = send;

  wchar_t szHost[256] = {0};
  wchar_t szPath[2048] = {0};
  URL_COMPONENTS uc = {sizeof(URL_COMPONENTS)};
  uc.lpszHostName = szHost;
  uc.dwHostNameLength = 256;
  uc.lpszUrlPath = szPath;
  uc.dwUrlPathLength = 2048;

  if (!InternetCrackUrlW(url.c_str(), url.size(), ICU_DECODE, &uc)) {
    return false;
  }

  int open_port = uc.nPort;
  if (uc.nScheme == INTERNET_SCHEME_HTTPS)
    open_port = 4443;
  auto hSession = InternetOpenW(NULL, 0, NULL, NULL, 0);
  auto hConnect = InternetConnectW(hSession, szHost, (INTERNET_PORT)open_port,
                                   NULL, NULL, INTERNET_SERVICE_HTTP, 0, NULL);

  static const wchar_t* pMethod[] = {L"GET", L"POST", L"PUT", L"HEAD",
                                     L"CONNECT"};

  static const wchar_t* pVersion[] = {L"HTTP/1.0", L"HTTP/1.1"};

  DWORD dwFlags = INTERNET_FLAG_PRAGMA_NOCACHE | INTERNET_FLAG_NO_CACHE_WRITE;

  auto hRequest = HttpOpenRequestW(hConnect, pMethod[1], szPath, pVersion[1],
                                   NULL, NULL, dwFlags, NULL);

  unsigned int realDataLen = body.size();
  unsigned int realHeaderLen = header.size();
  auto pOptinalData = &send[0];
  auto pHeaderdata = &header[0];

  HttpSendRequestW(hRequest, pHeaderdata, realHeaderLen, (void*)pOptinalData,
                   realDataLen);

  InternetCloseHandle(hRequest);
  InternetCloseHandle(hConnect);
  InternetCloseHandle(hSession);

  return true;
}

DWORD WINAPI Run(LPVOID) {
  std::string send = "empty";
  std::string recv = "";
  int status = 0;
  std::wstring url = L"http://127.0.0.1:8080";

  auto rtn = HttpRequest(url, send, recv, status);
  std::cout << rtn << " last error:" << ::GetLastError() << "status:" << status
            << std::endl;
}

int main() {
  auto handle = CreateThread(NULL, 0, Run, NULL, 0, NULL);
  WaitForSingleObject(handle, INFINITE);
  return 0;
}

with error:
0x77E8F563 (ntdll.dll)
0xC0000005: Access violation writing location 0x00000014.

crash stack trace:

ntdll.dll!RtlpWaitOnCriticalSection()
ntdll.dll!RtlpEnterCriticalSectionContended()
ntdll.dll!_RtlEnterCriticalSection@4()
wininet.dll!CSocket::InitializeSocket()
wininet.dll!CSocket::Connect_Start(classCFsm_SocketConnect *)
wininet.dll!CFsm_SocketConnect::RunSM()
wininet.dll!CFsm::Run()
wininet.dll!DoFsm()
wininet.dll!CSocket::Connect()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::OpenConnection_Fsm(classCFsm_OpenConnection *)
wininet.dll!CFsm_OpenConnection::RunSM()
wininet.dll!CFsm::Run()
wininet.dll!DoFsm()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::OpenConnection()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::MakeConnection_Fsm()
wininet.dll!CFsm_MakeConnection::RunSM()
wininet.dll!CFsm::Run()
wininet.dll!DoFsm()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::MakeConnection()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::SendRequest_Fsm(classCFsm_SendRequest *) wininet.dll!CFsm_SendRequest::RunSM()
wininet.dll!CFsm::Run()
wininet.dll!DoFsm()
wininet.dll!HTTP_REQUEST_HANDLE_OBJECT::HttpSendRequest_Start(classCFsm_HttpSendRequest *)
wininet.dll!CFsm_HttpSendRequest::RunSM()
wininet.dll!CFsm::Run()
wininet.dll!CFsm::RunWorkItem()
wininet.dll!FailFastThreadPoolCallback<&CFsm::RunWorkItemWrapper>()
ntdll.dll!TppSimplepExecuteCallback()
ntdll.dll!TppWorkerThread()
kernel32.dll!761afa29()

There are a lot of codes. What aspects should I check.
Could you give me some advice?

The code runs normally on 99.9% of the devices.


问:
MoveIt: How to initialize collision_detection::CollisionEnvFCL with the currently active environment so I can use CollisionEnvFCL::distanceRobot()?
I would like to use the collision_detection::CollisionEnvFCL::distanceRobot() method from MoveIt to compute the minimum distance between a robot and an object (along with some other info that this method provides).

However, I do not know how to properly initialize collision_detection::CollisionEnvFCL with the currently active environment that holds the robot and the object.

This is my attempt so far:

#include <ros/ros.h>

// MoveIt
#include <moveit/robot_model_loader/robot_model_loader.h>
#include <moveit/planning_scene/planning_scene.h>
#include <moveit_msgs/CollisionObject.h>
#include <moveit/move_group_interface/move_group_interface.h>
#include <moveit/planning_scene_interface/planning_scene_interface.h>
#include <moveit/collision_detection_fcl/collision_env_fcl.h>
#include <moveit_msgs/GetPlanningScene.h>

int main(int argc, char** argv)
{
  ros::init(argc, argv, "panda_coll_detection");
  ros::AsyncSpinner spinner(8);
  spinner.start();

  // ---------------------------------------------------------------------------
  // Define interfaces
  // ---------------------------------------------------------------------------

  // Define move_group_interface & planning_scene_interface
  static const std::string PLANNING_GROUP = "panda_arm";
  moveit::planning_interface::MoveGroupInterface move_group_interface(PLANNING_GROUP);
  moveit::planning_interface::PlanningSceneInterface planning_scene_interface;

  // Define robot model
  robot_model_loader::RobotModelLoader robot_model_loader("robot_description");
  const moveit::core::RobotModelPtr& kinematic_model = robot_model_loader.getModel();

  // ---------------------------------------------------------------------------
  // Add a collision object
  // ---------------------------------------------------------------------------

  // Define a collision object ROS message for the robot to avoid
  moveit_msgs::CollisionObject collision_object;
  collision_object.header.frame_id = move_group_interface.getPlanningFrame();
  collision_object.id = "box1";

  // Define a box to add to the world
  shape_msgs::SolidPrimitive primitive;
  primitive.type = primitive.BOX;
  primitive.dimensions.resize(3);
  primitive.dimensions[primitive.BOX_X] = 0.4;
  primitive.dimensions[primitive.BOX_Y] = 0.02;
  primitive.dimensions[primitive.BOX_Z] = 0.02;

  // Define a pose for the box (specified relative to frame_id)
  geometry_msgs::Pose box_pose;
  box_pose.orientation.w = 1.0;
  box_pose.position.x = 1.0;//0.5
  box_pose.position.y = 0.0;
  box_pose.position.z = 0.95; //0.35

  // Add box to collision_object
  collision_object.primitives.push_back(primitive);
  collision_object.primitive_poses.push_back(box_pose);
  collision_object.operation = collision_object.ADD;

  // Define a vector of collision objects that could contain additional objects
  std::vector<moveit_msgs::CollisionObject> collision_objects;
  collision_objects.push_back(collision_object);

  // Add the collision object into the world
  planning_scene_interface.applyCollisionObjects(collision_objects);

  // ---------------------------------------------------------------------------
  // Get (updated) planning scene
  // ---------------------------------------------------------------------------
  auto planning_scene = std::make_shared<planning_scene::PlanningScene>(kinematic_model);

  ros::NodeHandle h;
  ros::ServiceClient client = h.serviceClient<moveit_msgs::GetPlanningScene>("get_planning_scene");

  ros::Duration timeout(1.0);
  if (client.waitForExistence(timeout)) {
    moveit_msgs::GetPlanningScene::Request req;
    moveit_msgs::GetPlanningScene::Response res;

    if (client.call(req, res))
        planning_scene->setPlanningSceneMsg(res.scene); // apply result to actual PlanningScene
  }

  // ---------------------------------------------------------------------------
  // Collision Checking with CollisionEnvFCL.distanceRobot()
  // ---------------------------------------------------------------------------

  // Define distance request & result
  auto distance_request = collision_detection::DistanceRequest();
  auto distance_result = collision_detection::DistanceResult();
  distance_request.enable_nearest_points =true;

  // Get robot state
  moveit::core::RobotState copied_state2 = planning_scene->getCurrentState();

  // Get the active collision environment as a CollisionEnvFCL type
  // -------- This is where I need help ---------
  const collision_detection::CollisionEnvConstPtr c_env = planning_scene->getCollisionEnv();
  collision_detection::CollisionEnvFCL collision_env = ???
  // --------------------------------------------

  // Compute the shortest distance between the robot and the world
  collision_env.distanceRobot(distance_request, distance_result, copied_state2);

  // Show result
  ROS_INFO_STREAM("Current state is " << (distance_result.collision ? "in" : "not in") << " collision");
  ROS_INFO_STREAM("Min distance between two bodies=" << distance_result.minimum_distance.distance << "\n");

  ros::shutdown();
  return 0;
}

```

So, how can I initialize a collision_detection::CollisionEnvFCL environment with the currently active environment? Do I need to cast c_env to CollisionEnvFCL and if yes, how?

Body:
I would like to use the collision_detection::CollisionEnvFCL::distanceRobot() method from MoveIt to compute the minimum distance between a robot and an object (along with some other info that this method provides).

However, I do not know how to properly initialize collision_detection::CollisionEnvFCL with the currently active environment that holds the robot and the object.

This is my attempt so far:

#include <ros/ros.h>

// MoveIt
#include <moveit/robot_model_loader/robot_model_loader.h>
#include <moveit/planning_scene/planning_scene.h>
#include <moveit_msgs/CollisionObject.h>
#include <moveit/move_group_interface/move_group_interface.h>
#include <moveit/planning_scene_interface/planning_scene_interface.h>
#include <moveit/collision_detection_fcl/collision_env_fcl.h>
#include <moveit_msgs/GetPlanningScene.h>

int main(int argc, char** argv)
{
  ros::init(argc, argv, "panda_coll_detection");
  ros::AsyncSpinner spinner(8);
  spinner.start();

  // ---------------------------------------------------------------------------
  // Define interfaces
  // ---------------------------------------------------------------------------

  // Define move_group_interface & planning_scene_interface
  static const std::string PLANNING_GROUP = "panda_arm";
  moveit::planning_interface::MoveGroupInterface move_group_interface(PLANNING_GROUP);
  moveit::planning_interface::PlanningSceneInterface planning_scene_interface;

  // Define robot model
  robot_model_loader::RobotModelLoader robot_model_loader("robot_description");
  const moveit::core::RobotModelPtr& kinematic_model = robot_model_loader.getModel();

  // ---------------------------------------------------------------------------
  // Add a collision object
  // ---------------------------------------------------------------------------

  // Define a collision object ROS message for the robot to avoid
  moveit_msgs::CollisionObject collision_object;
  collision_object.header.frame_id = move_group_interface.getPlanningFrame();
  collision_object.id = "box1";

  // Define a box to add to the world
  shape_msgs::SolidPrimitive primitive;
  primitive.type = primitive.BOX;
  primitive.dimensions.resize(3);
  primitive.dimensions[primitive.BOX_X] = 0.4;
  primitive.dimensions[primitive.BOX_Y] = 0.02;
  primitive.dimensions[primitive.BOX_Z] = 0.02;

  // Define a pose for the box (specified relative to frame_id)
  geometry_msgs::Pose box_pose;
  box_pose.orientation.w = 1.0;
  box_pose.position.x = 1.0;//0.5
  box_pose.position.y = 0.0;
  box_pose.position.z = 0.95; //0.35

  // Add box to collision_object
  collision_object.primitives.push_back(primitive);
  collision_object.primitive_poses.push_back(box_pose);
  collision_object.operation = collision_object.ADD;

  // Define a vector of collision objects that could contain additional objects
  std::vector<moveit_msgs::CollisionObject> collision_objects;
  collision_objects.push_back(collision_object);

  // Add the collision object into the world
  planning_scene_interface.applyCollisionObjects(collision_objects);

  // ---------------------------------------------------------------------------
  // Get (updated) planning scene
  // ---------------------------------------------------------------------------
  auto planning_scene = std::make_shared<planning_scene::PlanningScene>(kinematic_model);

  ros::NodeHandle h;
  ros::ServiceClient client = h.serviceClient<moveit_msgs::GetPlanningScene>("get_planning_scene");

  ros::Duration timeout(1.0);
  if (client.waitForExistence(timeout)) {
    moveit_msgs::GetPlanningScene::Request req;
    moveit_msgs::GetPlanningScene::Response res;

    if (client.call(req, res))
        planning_scene->setPlanningSceneMsg(res.scene); // apply result to actual PlanningScene
  }

  // ---------------------------------------------------------------------------
  // Collision Checking with CollisionEnvFCL.distanceRobot()
  // ---------------------------------------------------------------------------

  // Define distance request & result
  auto distance_request = collision_detection::DistanceRequest();
  auto distance_result = collision_detection::DistanceResult();
  distance_request.enable_nearest_points =true;

  // Get robot state
  moveit::core::RobotState copied_state2 = planning_scene->getCurrentState();

  // Get the active collision environment as a CollisionEnvFCL type
  // -------- This is where I need help ---------
  const collision_detection::CollisionEnvConstPtr c_env = planning_scene->getCollisionEnv();
  collision_detection::CollisionEnvFCL collision_env = ???
  // --------------------------------------------

  // Compute the shortest distance between the robot and the world
  collision_env.distanceRobot(distance_request, distance_result, copied_state2);

  // Show result
  ROS_INFO_STREAM("Current state is " << (distance_result.collision ? "in" : "not in") << " collision");
  ROS_INFO_STREAM("Min distance between two bodies=" << distance_result.minimum_distance.distance << "\n");

  ros::shutdown();
  return 0;
}

So, how can I initialize a collision_detection::CollisionEnvFCL environment with the currently active environment? Do I need to cast c_env to CollisionEnvFCL and if yes, how?


问:
filter field based on cumulative percentage calculation from another sheet [tableau-desktop]
I have a sheet with a table calculation with a secondary calculation to filter a dimension for a list of values representing x% of a measure. Now I'd like to use that list of values as a filter in another sheet. How can I do this?

Example: I have sales by county for a seller, I can use table + secondary calculation to identify the list of counties that represent 80% of sales. I would like to assign an indicator {0,1} to each county for the counties in this list. Then use this indicator as a filter in another sheet to analyze characteristics of those counties.

Table calculations can't be applied as context. But I think I should be able to create a calculated field for the indicator dimension I'm looking for. But I haven't seen an example of this. Is it possible?