问:
A threejs mesh needs to build boxes based on different orientations, coords and dimensions in React but the boxes are not stacked on eachother
I am creating a pallet stacked with boxes based around json data. This data contains the coordinates, height, width and length. Now I can build the pallet, but the boxes do not stack well on top of each other and the boxes on position.z that start at 0 do not fall evenly either. I've already tried different things with offset but then the boxes collapse and don't stack neatly on top of each other. Hopefully someone will see what's wrong.

I tried to calculate the position of the boxes with offset and then take the result into account and subtract it from my current position

Example of the pallet with the gaps between the boxes

```<code>
import React, { Suspense } from 'react';
import { Canvas, extend, useThree } from '@react-three/fiber';
import { OrbitControls, Edges, } from "@react-three/drei";
import { Physics } from "@react-three/cannon";
import * as THREE from 'three';
import { MeshLine, MeshLineMaterial } from 'three.meshline';

import data from './data.json';

const json = data;
const obj = (json);

extend({ MeshLine, MeshLineMaterial })

let orientations = [];

for (let i = 0; i < obj.value.boxes.length; i++) {
    let orientation = obj.value.boxes[i].box.orientation;
    orientations.push(orientation);
}

console.log(orientations);

function Orientations() {
    //F00S90T00 = Front == Front && Side == Top && Top == Side
    if (orientations.includes("F00S90T00")) {
      return [0, Math.PI / 2, 0];
    }
     //F90S00T00 = Front == Side && Side == Front && Top == Top
    if (orientations.includes("F90S00T00")) {
       return [Math.PI / 2, 0, 0];
    }
    //F00S00T90 = Front == Top && Side == Side && Top == Front
    if (orientations.includes("F00S00T90")) {
        return [0, 0, Math.PI / 2];
    }
    //F90S90T00 = Front == Top && Side == Front && Top == Side
    if (orientations.includes("F90S90T00")) {
        return [Math.PI / 2, Math.PI / 2, 0];
    }
    //F90S00T90 = Front == Side && Side == Top && Top == Front
    if (orientations.includes("F90S00T90")) {
        return [Math.PI / 2, 0, Math.PI / 2];
    }
    //Default
    if (orientations.includes("F00S00T00")) {
        return [0, 0, 0];
    }
}

const value = Orientations();
console.log(value);

const offsets = obj.value.boxes.map(boxData => {
    let offset = new THREE.Vector3(boxData.position.x / 10, boxData.position.y / 10, 0);
    for (let i = boxData.stackingIndex + 1; i < obj.value.boxes.length; i++) {
        const otherBoxData = obj.value.boxes[i];
        if (otherBoxData.stackingIndex === boxData.stackingIndex + 1) {
            offset.z += otherBoxData.box.height / 10;
        }
    }
    return offset;
});

function Boxes() {

    return (
    <mesh rotation={[-Math.PI / 2, 0, 0]}>
        {obj.value.boxes.map((box, index) => (
            <mesh key={index} rotation={value} position={[
                box.position.x / 100,
                box.position.y / 100,
                box.position.z / 100 - offsets[index].z / 100
            ]}>
                <boxGeometry attach="geometry"
                    args={[box.box.width / 100,
                    box.box.height / 100,
                    box.box.length / 100
                    ]} />
                <Edges />
                <meshPhysicalMaterial
                    color="#c19a6c"
                    attach="material"
                    clearcoat={1}
                    reflectivity={1}
                    side={useThree.DoubleSide}
                />
            </mesh>
        ))}
        </mesh>
)}

function App() {
    return (
        <Canvas style={{ width: '100vw', height: '79vh', display: 'block' }}
            shadows
            camera={{ position: [10, 10, 10] }}>
            <OrbitControls />
            <ambientLight />
            <Suspense>
                <pointLight position={[0, 0, 0]} />
                <mesh rotation={[-Math.PI / 2, 0, 0]} position={[2, -2.2, -5]}>
                    <planeBufferGeometry args={[8, 12]} />
                    <meshStandardMaterial attach="material" color="brown" />
                </mesh>
                <Boxes />
            </Suspense>
            <Physics>
            </Physics>
        </Canvas>
    );
}

export default App;
</code>```

data

```<code>{
  "contentType": null,
  "serializerSettings": null,
  "statusCode": null,
  "value": {
    "pallet": {
      "height": 144,
      "width": 800,
      "length": 1200,
      "type": "Euro",
      "unit": "Millimetre"
    },
    "boxes": [
      {
        "position": {
          "z": 0.0000,
          "x": 405.0000,
          "y": 0.0000
        },
        "box": {
          "height": 326.0000,
          "width": 395.0000,
          "length": 232.0000,
          "unit": "Millimetre",
          "orientation": "F90S00T00",
          "reference": "test1"
        },
        "blockReference": "0",
        "weight": 10.1000,
        "stackingIndex": 0,
        "bottom": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "top": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "left": {
          "position": {
            "x": 0.0000,
            "y": 0.0000
          },
          "width": 232.0000,
          "length": 326.0000,
          "surface": 75632.00000000
        },
        "front": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 326.0000,
          "surface": 128770.00000000
        }
      },
      {
        "position": {
          "z": 0.0000,
          "x": 405.0000,
          "y": 322.6667
        },
        "box": {
          "height": 326.0000,
          "width": 395.0000,
          "length": 232.0000,
          "unit": "Millimetre",
          "orientation": "F90S00T00",
          "reference": "test1"
        },
        "blockReference": "0",
        "weight": 10.1000,
        "stackingIndex": 0,
        "bottom": {
          "position": {
            "x": 405.0000,
            "y": 322.6667
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "top": {
          "position": {
            "x": 405.0000,
            "y": 322.6667
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "left": {
          "position": {
            "x": 322.6667,
            "y": 0.0000
          },
          "width": 232.0000,
          "length": 326.0000,
          "surface": 75632.00000000
        },
        "front": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 326.0000,
          "surface": 128770.00000000
        }
      },
      {
        "position": {
          "z": 0.0000,
          "x": 405.0000,
          "y": 645.3334
        },
        "box": {
          "height": 326.0000,
          "width": 395.0000,
          "length": 232.0000,
          "unit": "Millimetre",
          "orientation": "F90S00T00",
          "reference": "test1"
        },
        "blockReference": "0",
        "weight": 10.1000,
        "stackingIndex": 0,
        "bottom": {
          "position": {
            "x": 405.0000,
            "y": 645.3334
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "top": {
          "position": {
            "x": 405.0000,
            "y": 645.3334
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "left": {
          "position": {
            "x": 645.3334,
            "y": 0.0000
          },
          "width": 232.0000,
          "length": 326.0000,
          "surface": 75632.00000000
        },
        "front": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 326.0000,
          "surface": 128770.00000000
        }
      },
      {
        "position": {
          "z": 0.0000,
          "x": 405.0000,
          "y": 968.0001
        },
        "box": {
          "height": 326.0000,
          "width": 395.0000,
          "length": 232.0000,
          "unit": "Millimetre",
          "orientation": "F90S00T00",
          "reference": "test1"
        },
        "blockReference": "0",
        "weight": 10.1000,
        "stackingIndex": 0,
        "bottom": {
          "position": {
            "x": 405.0000,
            "y": 968.0001
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "top": {
          "position": {
            "x": 405.0000,
            "y": 968.0001
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "left": {
          "position": {
            "x": 968.0001,
            "y": 0.0000
          },
          "width": 232.0000,
          "length": 326.0000,
          "surface": 75632.00000000
        },
        "front": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 326.0000,
          "surface": 128770.00000000
        }
      },
      {
        "position": {
          "z": 326.0000,
          "x": 395.0000,
          "y": 0.0000
        },
        "box": {
          "height": 245.0000,
          "width": 185.0000,
          "length": 285.0000,
          "unit": "Millimetre",
          "orientation": "F00S00T00",
          "reference": "test2"
        },
        "blockReference": "1",
        "weight": 6.1000,
        "stackingIndex": 1,
        "bottom": {
          "position": {
            "x": 395.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "top": {
          "position": {
            "x": 395.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "left": {
          "position": {
            "x": 0.0000,
            "y": 326.0000
          },
          "width": 285.0000,
          "length": 245.0000,
          "surface": 69825.00000000
        },
        "front": {
          "position": {
            "x": 395.0000,
            "y": 326.0000
          },
          "width": 185.0000,
          "length": 245.0000,
          "surface": 45325.00000000
        }
      },
      {
        "position": {
          "z": 326.0000,
          "x": 615.0000,
          "y": 0.0000
        },
        "box": {
          "height": 245.0000,
          "width": 185.0000,
          "length": 285.0000,
          "unit": "Millimetre",
          "orientation": "F00S00T00",
          "reference": "test2"
        },
        "blockReference": "1",
        "weight": 6.1000,
        "stackingIndex": 1,
        "bottom": {
          "position": {
            "x": 615.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "top": {
          "position": {
            "x": 615.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "left": {
          "position": {
            "x": 0.0000,
            "y": 326.0000
          },
          "width": 285.0000,
          "length": 245.0000,
          "surface": 69825.00000000
        },
        "front": {
          "position": {
            "x": 615.0000,
            "y": 326.0000
          },
          "width": 185.0000,
          "length": 245.0000,
          "surface": 45325.00000000
        }
      },
      {
        "position": {
          "z": 571.0000,
          "x": 395.0000,
          "y": 0.0000
        },
        "box": {
          "height": 245.0000,
          "width": 185.0000,
          "length": 285.0000,
          "unit": "Millimetre",
          "orientation": "F00S00T00",
          "reference": "test2"
        },
        "blockReference": "2",
        "weight": 6.1000,
        "stackingIndex": 2,
        "bottom": {
          "position": {
            "x": 395.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "top": {
          "position": {
            "x": 395.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "left": {
          "position": {
            "x": 0.0000,
            "y": 571.0000
          },
          "width": 285.0000,
          "length": 245.0000,
          "surface": 69825.00000000
        },
        "front": {
          "position": {
            "x": 395.0000,
            "y": 571.0000
          },
          "width": 185.0000,
          "length": 245.0000,
          "surface": 45325.00000000
        }
      },
      {
        "position": {
          "z": 571.0000,
          "x": 580.0000,
          "y": 0.0000
        },
        "box": {
          "height": 245.0000,
          "width": 185.0000,
          "length": 285.0000,
          "unit": "Millimetre",
          "orientation": "F00S00T00",
          "reference": "test2"
        },
        "blockReference": "2",
        "weight": 6.1000,
        "stackingIndex": 2,
        "bottom": {
          "position": {
            "x": 580.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "top": {
          "position": {
            "x": 580.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "left": {
          "position": {
            "x": 0.0000,
            "y": 571.0000
          },
          "width": 285.0000,
          "length": 245.0000,
          "surface": 69825.00000000
        },
        "front": {
          "position": {
            "x": 580.0000,
            "y": 571.0000
          },
          "width": 185.0000,
          "length": 245.0000,
          "surface": 45325.00000000
        }
      }
    ],
    "maxStackHeight": null,
    "products": [
      {
        "sku": "test1",
        "quantity": 4
      },
      {
        "sku": "test2",
        "quantity": 4
      }
    ]
  }
}

</code>```

Body:
I am creating a pallet stacked with boxes based around json data. This data contains the coordinates, height, width and length. Now I can build the pallet, but the boxes do not stack well on top of each other and the boxes on position.z that start at 0 do not fall evenly either. I've already tried different things with offset but then the boxes collapse and don't stack neatly on top of each other. Hopefully someone will see what's wrong.

I tried to calculate the position of the boxes with offset and then take the result into account and subtract it from my current position

Example of the pallet with the gaps between the boxes

import React, { Suspense } from 'react';
import { Canvas, extend, useThree } from '@react-three/fiber';
import { OrbitControls, Edges, } from "@react-three/drei";
import { Physics } from "@react-three/cannon";
import * as THREE from 'three';
import { MeshLine, MeshLineMaterial } from 'three.meshline';

import data from './data.json';

const json = data;
const obj = (json);

extend({ MeshLine, MeshLineMaterial })

let orientations = [];

for (let i = 0; i < obj.value.boxes.length; i++) {
    let orientation = obj.value.boxes[i].box.orientation;
    orientations.push(orientation);
}

console.log(orientations);

function Orientations() {
    //F00S90T00 = Front == Front && Side == Top && Top == Side
    if (orientations.includes("F00S90T00")) {
      return [0, Math.PI / 2, 0];
    }
     //F90S00T00 = Front == Side && Side == Front && Top == Top
    if (orientations.includes("F90S00T00")) {
       return [Math.PI / 2, 0, 0];
    }
    //F00S00T90 = Front == Top && Side == Side && Top == Front
    if (orientations.includes("F00S00T90")) {
        return [0, 0, Math.PI / 2];
    }
    //F90S90T00 = Front == Top && Side == Front && Top == Side
    if (orientations.includes("F90S90T00")) {
        return [Math.PI / 2, Math.PI / 2, 0];
    }
    //F90S00T90 = Front == Side && Side == Top && Top == Front
    if (orientations.includes("F90S00T90")) {
        return [Math.PI / 2, 0, Math.PI / 2];
    }
    //Default
    if (orientations.includes("F00S00T00")) {
        return [0, 0, 0];
    }
}

const value = Orientations();
console.log(value);

const offsets = obj.value.boxes.map(boxData => {
    let offset = new THREE.Vector3(boxData.position.x / 10, boxData.position.y / 10, 0);
    for (let i = boxData.stackingIndex + 1; i < obj.value.boxes.length; i++) {
        const otherBoxData = obj.value.boxes[i];
        if (otherBoxData.stackingIndex === boxData.stackingIndex + 1) {
            offset.z += otherBoxData.box.height / 10;
        }
    }
    return offset;
});

function Boxes() {

    return (
    <mesh rotation={[-Math.PI / 2, 0, 0]}>
        {obj.value.boxes.map((box, index) => (
            <mesh key={index} rotation={value} position={[
                box.position.x / 100,
                box.position.y / 100,
                box.position.z / 100 - offsets[index].z / 100
            ]}>
                <boxGeometry attach="geometry"
                    args={[box.box.width / 100,
                    box.box.height / 100,
                    box.box.length / 100
                    ]} />
                <Edges />
                <meshPhysicalMaterial
                    color="#c19a6c"
                    attach="material"
                    clearcoat={1}
                    reflectivity={1}
                    side={useThree.DoubleSide}
                />
            </mesh>
        ))}
        </mesh>
)}

function App() {
    return (
        <Canvas style={{ width: '100vw', height: '79vh', display: 'block' }}
            shadows
            camera={{ position: [10, 10, 10] }}>
            <OrbitControls />
            <ambientLight />
            <Suspense>
                <pointLight position={[0, 0, 0]} />
                <mesh rotation={[-Math.PI / 2, 0, 0]} position={[2, -2.2, -5]}>
                    <planeBufferGeometry args={[8, 12]} />
                    <meshStandardMaterial attach="material" color="brown" />
                </mesh>
                <Boxes />
            </Suspense>
            <Physics>
            </Physics>
        </Canvas>
    );
}

export default App;

data

{
  "contentType": null,
  "serializerSettings": null,
  "statusCode": null,
  "value": {
    "pallet": {
      "height": 144,
      "width": 800,
      "length": 1200,
      "type": "Euro",
      "unit": "Millimetre"
    },
    "boxes": [
      {
        "position": {
          "z": 0.0000,
          "x": 405.0000,
          "y": 0.0000
        },
        "box": {
          "height": 326.0000,
          "width": 395.0000,
          "length": 232.0000,
          "unit": "Millimetre",
          "orientation": "F90S00T00",
          "reference": "test1"
        },
        "blockReference": "0",
        "weight": 10.1000,
        "stackingIndex": 0,
        "bottom": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "top": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "left": {
          "position": {
            "x": 0.0000,
            "y": 0.0000
          },
          "width": 232.0000,
          "length": 326.0000,
          "surface": 75632.00000000
        },
        "front": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 326.0000,
          "surface": 128770.00000000
        }
      },
      {
        "position": {
          "z": 0.0000,
          "x": 405.0000,
          "y": 322.6667
        },
        "box": {
          "height": 326.0000,
          "width": 395.0000,
          "length": 232.0000,
          "unit": "Millimetre",
          "orientation": "F90S00T00",
          "reference": "test1"
        },
        "blockReference": "0",
        "weight": 10.1000,
        "stackingIndex": 0,
        "bottom": {
          "position": {
            "x": 405.0000,
            "y": 322.6667
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "top": {
          "position": {
            "x": 405.0000,
            "y": 322.6667
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "left": {
          "position": {
            "x": 322.6667,
            "y": 0.0000
          },
          "width": 232.0000,
          "length": 326.0000,
          "surface": 75632.00000000
        },
        "front": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 326.0000,
          "surface": 128770.00000000
        }
      },
      {
        "position": {
          "z": 0.0000,
          "x": 405.0000,
          "y": 645.3334
        },
        "box": {
          "height": 326.0000,
          "width": 395.0000,
          "length": 232.0000,
          "unit": "Millimetre",
          "orientation": "F90S00T00",
          "reference": "test1"
        },
        "blockReference": "0",
        "weight": 10.1000,
        "stackingIndex": 0,
        "bottom": {
          "position": {
            "x": 405.0000,
            "y": 645.3334
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "top": {
          "position": {
            "x": 405.0000,
            "y": 645.3334
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "left": {
          "position": {
            "x": 645.3334,
            "y": 0.0000
          },
          "width": 232.0000,
          "length": 326.0000,
          "surface": 75632.00000000
        },
        "front": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 326.0000,
          "surface": 128770.00000000
        }
      },
      {
        "position": {
          "z": 0.0000,
          "x": 405.0000,
          "y": 968.0001
        },
        "box": {
          "height": 326.0000,
          "width": 395.0000,
          "length": 232.0000,
          "unit": "Millimetre",
          "orientation": "F90S00T00",
          "reference": "test1"
        },
        "blockReference": "0",
        "weight": 10.1000,
        "stackingIndex": 0,
        "bottom": {
          "position": {
            "x": 405.0000,
            "y": 968.0001
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "top": {
          "position": {
            "x": 405.0000,
            "y": 968.0001
          },
          "width": 395.0000,
          "length": 232.0000,
          "surface": 91640.00000000
        },
        "left": {
          "position": {
            "x": 968.0001,
            "y": 0.0000
          },
          "width": 232.0000,
          "length": 326.0000,
          "surface": 75632.00000000
        },
        "front": {
          "position": {
            "x": 405.0000,
            "y": 0.0000
          },
          "width": 395.0000,
          "length": 326.0000,
          "surface": 128770.00000000
        }
      },
      {
        "position": {
          "z": 326.0000,
          "x": 395.0000,
          "y": 0.0000
        },
        "box": {
          "height": 245.0000,
          "width": 185.0000,
          "length": 285.0000,
          "unit": "Millimetre",
          "orientation": "F00S00T00",
          "reference": "test2"
        },
        "blockReference": "1",
        "weight": 6.1000,
        "stackingIndex": 1,
        "bottom": {
          "position": {
            "x": 395.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "top": {
          "position": {
            "x": 395.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "left": {
          "position": {
            "x": 0.0000,
            "y": 326.0000
          },
          "width": 285.0000,
          "length": 245.0000,
          "surface": 69825.00000000
        },
        "front": {
          "position": {
            "x": 395.0000,
            "y": 326.0000
          },
          "width": 185.0000,
          "length": 245.0000,
          "surface": 45325.00000000
        }
      },
      {
        "position": {
          "z": 326.0000,
          "x": 615.0000,
          "y": 0.0000
        },
        "box": {
          "height": 245.0000,
          "width": 185.0000,
          "length": 285.0000,
          "unit": "Millimetre",
          "orientation": "F00S00T00",
          "reference": "test2"
        },
        "blockReference": "1",
        "weight": 6.1000,
        "stackingIndex": 1,
        "bottom": {
          "position": {
            "x": 615.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "top": {
          "position": {
            "x": 615.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "left": {
          "position": {
            "x": 0.0000,
            "y": 326.0000
          },
          "width": 285.0000,
          "length": 245.0000,
          "surface": 69825.00000000
        },
        "front": {
          "position": {
            "x": 615.0000,
            "y": 326.0000
          },
          "width": 185.0000,
          "length": 245.0000,
          "surface": 45325.00000000
        }
      },
      {
        "position": {
          "z": 571.0000,
          "x": 395.0000,
          "y": 0.0000
        },
        "box": {
          "height": 245.0000,
          "width": 185.0000,
          "length": 285.0000,
          "unit": "Millimetre",
          "orientation": "F00S00T00",
          "reference": "test2"
        },
        "blockReference": "2",
        "weight": 6.1000,
        "stackingIndex": 2,
        "bottom": {
          "position": {
            "x": 395.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "top": {
          "position": {
            "x": 395.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "left": {
          "position": {
            "x": 0.0000,
            "y": 571.0000
          },
          "width": 285.0000,
          "length": 245.0000,
          "surface": 69825.00000000
        },
        "front": {
          "position": {
            "x": 395.0000,
            "y": 571.0000
          },
          "width": 185.0000,
          "length": 245.0000,
          "surface": 45325.00000000
        }
      },
      {
        "position": {
          "z": 571.0000,
          "x": 580.0000,
          "y": 0.0000
        },
        "box": {
          "height": 245.0000,
          "width": 185.0000,
          "length": 285.0000,
          "unit": "Millimetre",
          "orientation": "F00S00T00",
          "reference": "test2"
        },
        "blockReference": "2",
        "weight": 6.1000,
        "stackingIndex": 2,
        "bottom": {
          "position": {
            "x": 580.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "top": {
          "position": {
            "x": 580.0000,
            "y": 0.0000
          },
          "width": 185.0000,
          "length": 285.0000,
          "surface": 52725.00000000
        },
        "left": {
          "position": {
            "x": 0.0000,
            "y": 571.0000
          },
          "width": 285.0000,
          "length": 245.0000,
          "surface": 69825.00000000
        },
        "front": {
          "position": {
            "x": 580.0000,
            "y": 571.0000
          },
          "width": 185.0000,
          "length": 245.0000,
          "surface": 45325.00000000
        }
      }
    ],
    "maxStackHeight": null,
    "products": [
      {
        "sku": "test1",
        "quantity": 4
      },
      {
        "sku": "test2",
        "quantity": 4
      }
    ]
  }
}


来源: stackexchange

问:
can`t write to a file with root
Please help me to understand why I can`t write to a file</p>
```<code>[root@192.168.1.11 ~]# echo "Hello World" >file.txt

-bash: 1.txt: Permission denied

[root@192.168.1.11 ~]# ls -lah file.txt

-rw-r--r-- 1 root root 7 May  8 14:57 file.txt

[root@192.168.1.11 ~]# id

uid=0(root) gid=0(root) groups=0(root)
</code>```

ContentLicense: CC BY-SA 4.0

Title: can`t write to a file with root

Body:
Please help me to understand why I can`t write to a file

[root@192.168.1.11 ~]# echo "Hello World" >file.txt

-bash: 1.txt: Permission denied

[root@192.168.1.11 ~]# ls -lah file.txt

-rw-r--r-- 1 root root 7 May  8 14:57 file.txt

[root@192.168.1.11 ~]# id

uid=0(root) gid=0(root) groups=0(root)


问:
Mongo DB crash by a peak of the CPU
I have a virtual machine running several Node JS projects and a local instance of Mongo DB.
The virtual Machine has only 2 GB of RAM. And I'm monitoring the database with the free monitoring provided by mongo DB

The problem occurs randomly, the CPU usage by Mongo DB goes high, and it overcomes the 2GB Ram and crashes. And the error on the logs (which is attached at the end), points to admin.$cmd what appear in other warnings before without another impact. This issue can not happen for a week, and suddenly happens a day 6am when nobody is calling the server. I suspect some internal MongoDB usage.

```<code></code>```

Does anyone have a TIP on why the CPU usage peaks appear or how to avoid them? I could always upgrade the VM or use MongoDB atlas but has no sense that this happens in a VM in which traffic is almost unexisting

```<code>
{"t":{"$date":"2023-01-11T07:32:53.117+00:00"},"s":"I",  "c":"COMMAND",  "id":23099,   "ctx":"PeriodicTaskRunner","msg":"Task finished","attr":{"taskName":"DBConnectionPool-cleaner","durationMillis":1437}}

{"t":{"$date":"2023-01-11T07:32:35.867+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn29","msg":"Slow query","attr":{"type":"command","ns":"admin.$cmd","command":{"ismaster":1,"$db":"admin"},"numYields":0,"reslen":304,"locks":{},"remote":"127.0.0.1:53792","protocol":"op_msg","durationMillis":43549}}

{"t":{"$date":"2023-01-11T07:31:52.574+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"LogicalSessionCacheReap","msg":"Slow query","attr":{"type":"command","ns":"config.transactions","command":{"find":"transactions","filter":{"lastWriteDate":{"$lt":{"$date":"2023-01-11T06:58:42.761Z"}}},"projection":{"_id":1},"sort":{"_id":1},"readConcern":{},"$db":"config"},"planSummary":"EOF","keysExamined":0,"docsExamined":0,"cursorExhausted":true,"numYields":0,"nreturned":0,"queryExecutionEngine":"classic","reslen":108,"locks":{"FeatureCompatibilityVersion":{"acquireCount":{"r":3}},"ReplicationStateTransition":{"acquireCount":{"w":1}},"Global":{"acquireCount":{"r":3}},"Mutex":{"acquireCount":{"r":2}}},"readConcern":{"provenance":"implicitDefault"},"storage":{},"protocol":"op_msg","durationMillis":109845}}
</code>```

Title: Mongo DB crash by a peak of the CPU

Body:
I have a virtual machine running several Node JS projects and a local instance of Mongo DB.
The virtual Machine has only 2 GB of RAM. And I'm monitoring the database with the free monitoring provided by mongo DB

The problem occurs randomly, the CPU usage by Mongo DB goes high, and it overcomes the 2GB Ram and crashes. And the error on the logs (which is attached at the end), points to admin.$cmd what appear in other warnings before without another impact. This issue can not happen for a week, and suddenly happens a day 6am when nobody is calling the server. I suspect some internal MongoDB usage.

Does anyone have a TIP on why the CPU usage peaks appear or how to avoid them? I could always upgrade the VM or use MongoDB atlas but has no sense that this happens in a VM in which traffic is almost unexisting

{"t":{"$date":"2023-01-11T07:32:53.117+00:00"},"s":"I",  "c":"COMMAND",  "id":23099,   "ctx":"PeriodicTaskRunner","msg":"Task finished","attr":{"taskName":"DBConnectionPool-cleaner","durationMillis":1437}}

{"t":{"$date":"2023-01-11T07:32:35.867+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"conn29","msg":"Slow query","attr":{"type":"command","ns":"admin.$cmd","command":{"ismaster":1,"$db":"admin"},"numYields":0,"reslen":304,"locks":{},"remote":"127.0.0.1:53792","protocol":"op_msg","durationMillis":43549}}

{"t":{"$date":"2023-01-11T07:31:52.574+00:00"},"s":"I",  "c":"COMMAND",  "id":51803,   "ctx":"LogicalSessionCacheReap","msg":"Slow query","attr":{"type":"command","ns":"config.transactions","command":{"find":"transactions","filter":{"lastWriteDate":{"$lt":{"$date":"2023-01-11T06:58:42.761Z"}}},"projection":{"_id":1},"sort":{"_id":1},"readConcern":{},"$db":"config"},"planSummary":"EOF","keysExamined":0,"docsExamined":0,"cursorExhausted":true,"numYields":0,"nreturned":0,"queryExecutionEngine":"classic","reslen":108,"locks":{"FeatureCompatibilityVersion":{"acquireCount":{"r":3}},"ReplicationStateTransition":{"acquireCount":{"w":1}},"Global":{"acquireCount":{"r":3}},"Mutex":{"acquireCount":{"r":2}}},"readConcern":{"provenance":"implicitDefault"},"storage":{},"protocol":"op_msg","durationMillis":109845}}


问:
How to change data type in pandas dataframe from "object" to "float"?
I tried to change the data type of one column in dataframe pandas for column: df_new_better['Percentage Reduction'] from "object" to "float" in order to calculate the average.

```<code>df_final = pd.DataFrame(list(zip( new_storage_p_two,  new_storage_c_two,   new_storage_result, backward_storage_result, gap, cycle_time_reduction_percentage)),columns =['P2', 'C2', 'Cycle Time New Sequence', 'Cycle Time Backward Sequence','Cycle Time Difference','Percentage Reduction'])

df_final.head()
</code>```

Then, I used .astype(float) for the column: df_new_better['Percentage Reduction']

```<code>df_new_better = df_final[df_final['Cycle Time Difference'] > 0]
df_new_better['Percentage Reduction'].astype(float)
df_new_better.dtypes
</code>```

However, the dtype of column remains the same as "object" as per below screenshot.

Can anyone tell me what should be done, please? Thank you.

Body:
I tried to change the data type of one column in dataframe pandas for column: df_new_better['Percentage Reduction'] from "object" to "float" in order to calculate the average.

df_final = pd.DataFrame(list(zip( new_storage_p_two,  new_storage_c_two,   new_storage_result, backward_storage_result, gap, cycle_time_reduction_percentage)),columns =['P2', 'C2', 'Cycle Time New Sequence', 'Cycle Time Backward Sequence','Cycle Time Difference','Percentage Reduction'])

df_final.head()

Then, I used .astype(float) for the column: df_new_better['Percentage Reduction']

df_new_better = df_final[df_final['Cycle Time Difference'] > 0]
df_new_better['Percentage Reduction'].astype(float)
df_new_better.dtypes

However, the dtype of column remains the same as "object" as per below screenshot.

Can anyone tell me what should be done, please? Thank you.


问:
Position fixed is not working with Backdrop-filter
I am tring to make a glass effect in navbar of my website. Here is the code:

HTML:

```<code><nav class="navbar">
    <div class="logo">
        <a href="#">Logo</a>
    </div>
    <div class="mobile_nav">
        <i class="fa-solid fa-bars"></i>
    </div>
    <menu class="menu">
        <a href="#">Home</a>
        <a href="#pricing">Pricing</a>
        <a href="#about">About</a>
        <a href="#contact">Get in Touch</a>
    </menu>
</nav>
</code>```

CSS:

```<code>@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700;900&display=swap');
:root{
    --black: #0f0f19;
    --gray: #7a7b7f;
    --light-gray: #ddd;
    --primary: #0da87c;
    --white: #fff;
}
*{
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    box-sizing: border-box;
}
a{
    text-decoration: none;
    color:var(--black);
}

.navbar{
    width:100vw;
    width: calc(100vw - 100px);
    margin-left: 50px;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    background: #e2e2e2a6;
    display:flex;
    justify-content:space-evenly;
    height:70px;
    line-height: 70px;
    position:fixed;
    top: 0;
    left: 0;
    z-index: 99;
    backdrop-filter: blur(5px);
}
.navbar a{
    padding: 5px 10px;
    color: var(--gray);
    font-size: 14px;
    font-weight: bold;
    transition: all .25s ease-in-out;
}
.navbar menu a:hover{
    color: var(--black);
}
.mobile_nav{
    display: none;
}
.navbar + *{
    margin-top:70px;
}
@media screen and (max-width: 768px) {
    .mobile_nav{
        display: block;
        position: fixed;
        right: 24px;
    }
    .navbar menu{
        width: calc(100% - 20px);
        margin: 0 10px;
        position: fixed;
        left: 0;
        bottom: -50%;
        display: flex;
        flex-direction: column;
        background-color: #333;
        line-height: 30px;
        border-radius: 30px 30px 0 0;
        padding: 10px;
        transition: bottom .25s ease-in-out;
    }
    .mobile_nav{
        font-size: 24px;
    }
    .active{
        bottom: 0 !important;
    }
}
</code>```

If you try to view the above code on a mobile screen, you will notice that when you click on the hamburger icon the menu should come from the bottom of the screen but when I add backdrop-filter: unset; to the .navbar class, it is working fine but when I add this, it removes the glass effect.

I'm trying to add the glass effect on both desktop and mobile screens with position: fixed on the inner tag. Help me out please!

Body:
I am tring to make a glass effect in navbar of my website. Here is the code:

HTML:

        Logo

    <menu class="menu">
        Home
        Pricing
        About
        Get in Touch
    </menu>

CSS:

@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700;900&display=swap');
:root{
    --black: #0f0f19;
    --gray: #7a7b7f;
    --light-gray: #ddd;
    --primary: #0da87c;
    --white: #fff;
}
*{
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    box-sizing: border-box;
}
a{
    text-decoration: none;
    color:var(--black);
}

.navbar{
    width:100vw;
    width: calc(100vw - 100px);
    margin-left: 50px;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    background: #e2e2e2a6;
    display:flex;
    justify-content:space-evenly;
    height:70px;
    line-height: 70px;
    position:fixed;
    top: 0;
    left: 0;
    z-index: 99;
    backdrop-filter: blur(5px);
}
.navbar a{
    padding: 5px 10px;
    color: var(--gray);
    font-size: 14px;
    font-weight: bold;
    transition: all .25s ease-in-out;
}
.navbar menu a:hover{
    color: var(--black);
}
.mobile_nav{
    display: none;
}
.navbar + *{
    margin-top:70px;
}
@media screen and (max-width: 768px) {
    .mobile_nav{
        display: block;
        position: fixed;
        right: 24px;
    }
    .navbar menu{
        width: calc(100% - 20px);
        margin: 0 10px;
        position: fixed;
        left: 0;
        bottom: -50%;
        display: flex;
        flex-direction: column;
        background-color: #333;
        line-height: 30px;
        border-radius: 30px 30px 0 0;
        padding: 10px;
        transition: bottom .25s ease-in-out;
    }
    .mobile_nav{
        font-size: 24px;
    }
    .active{
        bottom: 0 !important;
    }
}

If you try to view the above code on a mobile screen, you will notice that when you click on the hamburger icon the menu should come from the bottom of the screen but when I add backdrop-filter: unset; to the .navbar class, it is working fine but when I add this, it removes the glass effect.

I'm trying to add the glass effect on both desktop and mobile screens with position: fixed on the inner tag. Help me out please!


问:
unable to use api using curl in php
i am working on linkedin api in php and trying to post "comment" on "linkedin post" (dynamic), I tried with following code but not working,I am getting following error

```<code>{"message":"java.net.URISyntaxException: Illegal character in path at index 20: /rest/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments"}
</code>```

I tried with following code but not working,Kindly tell me which type of parameter should i pass(use) ?

what is "{shareUrn|ugcPostUrn|commentUrn}/comments" which type of data should i use

which parameter should use for "actor","object"

Here is my complete code

```<code>$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.linkedin.com/rest/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n   \"actor\":\"urn:li:person:A8xe03Qt10\",\n   \"object\":\"urn:li:activity:6631349431612559360\",\n   \"message\":{\n      \"text\":\"commentV2 with image entity\"\n   },\n   \"content\":[\n      {\n         \"entity\":{\n            \"digitalmediaAsset\":\"urn:li:digitalmediaAsset:C552CAQGu16obsGZENQ\"\n         },\n         \"type\":\"IMAGE\"\n      }\n   ]\n}");

$headers = array();
$headers[] = 'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxx';
$headers[] = 'Linkedin-Version: 202208';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
print_R($result);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
</code>```

Title: unable to use api using curl in php

Body:
i am working on linkedin api in php and trying to post "comment" on "linkedin post" (dynamic), I tried with following code but not working,I am getting following error

{"message":"java.net.URISyntaxException: Illegal character in path at index 20: /rest/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments"}

I tried with following code but not working,Kindly tell me which type of parameter should i pass(use) ?

what is "{shareUrn|ugcPostUrn|commentUrn}/comments" which type of data should i use

which parameter should use for "actor","object"

Here is my complete code

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://api.linkedin.com/rest/socialActions/{shareUrn|ugcPostUrn|commentUrn}/comments');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\n   \"actor\":\"urn:li:person:A8xe03Qt10\",\n   \"object\":\"urn:li:activity:6631349431612559360\",\n   \"message\":{\n      \"text\":\"commentV2 with image entity\"\n   },\n   \"content\":[\n      {\n         \"entity\":{\n            \"digitalmediaAsset\":\"urn:li:digitalmediaAsset:C552CAQGu16obsGZENQ\"\n         },\n         \"type\":\"IMAGE\"\n      }\n   ]\n}");

$headers = array();
$headers[] = 'Authorization: Bearer xxxxxxxxxxxxxxxxxxxxx';
$headers[] = 'Linkedin-Version: 202208';
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
print_R($result);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);


问:
VS Code custom folding behaviour (fold all)
Is it possible to easily change fold behaviour in VS Code? What I'm specifically looking for, is a way to fold ALL sections containing "#Region <> #EndRegion" and "Function Get-Example { <> }" with one keybind, without folding any other blocks of code.

Have tried "CTRL+K,CTRL+0", but this also folds/collapses every other kind of blocks - which I don't want. Also tried "CTRL+K,CTRL+n" but not getting the desired result.


问:
gIntersects TopologyException in rgeos R
I have a shapefile that represents ecoregions of the world. I am trying to determine which ecoregions are intersected by the distributions of my species of interest. I am using the latest version of R and the rgdal and rgeos packages.

I load in a list of species ranges called 'rangelist'.

I load in my ecoregions shapefile (eco), and create a list called 'regions', which contains a SpatialPolygonsDataFrame object for every ecoregion:

```<code>readOGR(ecofile,gsub(".shp","",ecofile))->eco
regions<-list()
for (i in 1:length(unique(eco$ECO_NAME))){
    print(unique(eco$ECO_NAME)[i])
    eco[eco$ECO_NAME==unique(eco$ECO_NAME)[i],]->regions[[i]]
}
names(regions)<-as.character(unique(eco$ECO_NAME))
</code>```

I then run a loop function that checks each range from 'rangelist' against each of these ecoregions from 'regions'. This works fine until:

```<code>> gIntersects(rangelist[[49]],regions[[23]])
Error in RGEOSBinPredFunc(spgeom1, spgeom2, byid, func) :
  TopologyException: side location conflict at -78.7709 -8.18245
</code>```

I loaded the original ecoregions shapefile into arcMap 10 and ran the "check geometry" tool but it found no problems.

The original sources of the data are:
species ranges:
http://www.natureserve.org/getData/birdMaps.jsp
ecoregions:
http://www.worldwildlife.org/science/data/item1875.html

I have temporarily posted here a zip file containing 2 Rdata files and an R script to allow you to reproduce the error (file size is 33mb).

Does anyone have any idea as to how I can fix or get around this problem?

ContentLicense: CC BY-SA 3.0

Body:
I have a shapefile that represents ecoregions of the world. I am trying to determine which ecoregions are intersected by the distributions of my species of interest. I am using the latest version of R and the rgdal and rgeos packages.

I load in a list of species ranges called 'rangelist'.

I load in my ecoregions shapefile (eco), and create a list called 'regions', which contains a SpatialPolygonsDataFrame object for every ecoregion:

readOGR(ecofile,gsub(".shp","",ecofile))->eco
regions<-list()
for (i in 1:length(unique(eco$ECO_NAME))){
    print(unique(eco$ECO_NAME)[i])
    eco[eco$ECO_NAME==unique(eco$ECO_NAME)[i],]->regions[[i]]
}
names(regions)<-as.character(unique(eco$ECO_NAME))

I then run a loop function that checks each range from 'rangelist' against each of these ecoregions from 'regions'. This works fine until:

> gIntersects(rangelist[[49]],regions[[23]])
Error in RGEOSBinPredFunc(spgeom1, spgeom2, byid, func) :
  TopologyException: side location conflict at -78.7709 -8.18245

I loaded the original ecoregions shapefile into arcMap 10 and ran the "check geometry" tool but it found no problems.

The original sources of the data are:
species ranges:
http://www.natureserve.org/getData/birdMaps.jsp
ecoregions:
http://www.worldwildlife.org/science/data/item1875.html

I have temporarily posted here a zip file containing 2 Rdata files and an R script to allow you to reproduce the error (file size is 33mb).

Does anyone have any idea as to how I can fix or get around this problem?


问:
Springdoc update from Springfox result in 406 error
I am migrating springfox to spring doc and get 406 error.
Similar like this: https://github.com/springdoc/springdoc-openapi/issues/950
Only the swagger-ui got the issue but the /v3/api-docs can generate the json/yaml file.

After I debug the DispatcherServlet in doDispatch, an exception occur during getHandler.

The exception is:

org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation.

Below is the picture of the debug. If I debug further, the request /swagger-ui/index.html is actually mapped to an endpoint that accept /{param1}/{param2} that generates application/json. So, how to map the swagger path to the resource instead of a controller? Thank you

Spring boot version 1.5.x (spring 4.x). springdoc version 1.6.14.


问:
I am getting Launch darkly post error in my react app
I am creating a react app, but whenever I make post or get requests in react app. It throws errors like this:

POST https://events.launchdarkly.com/events/bulk/62913038bb88120c8d0102a7 net::ERR_BLOCKED_BY_CLIENT

This error is coming for 4-5 times.
I am not using "launch darkly" anywhere in my app.


问:
How to add hint for return folder path in PhpStorm?

<?php

namespace Some\NamespacePath;

class Path {
    function library(): string {
        $namespaceParts = explode('\\', __NAMESPACE__);
        return dirname(__DIR__, count($namespaceParts) + 1) . '/library';
    }
}

// Autocomplete and «got to file» features are not working here in PhpStorm
echo Path::library() . '/path/to/file.php';
```

How make autocomplete work in this case?

I need to let IDE know, that method library() returns project://library path to directory library from project root folder.

Body:
<?php

namespace Some\NamespacePath;

class Path {
    function library(): string {
        $namespaceParts = explode('\\', __NAMESPACE__);
        return dirname(__DIR__, count($namespaceParts) + 1) . '/library';
    }
}

// Autocomplete and «got to file» features are not working here in PhpStorm
echo Path::library() . '/path/to/file.php';

How make autocomplete work in this case?

I need to let IDE know, that method library() returns project://library path to directory library from project root folder.


问:
How to retrieve specific data from request in pytest
Hi so what I am trying to do is when I run the test the user will be created (makes an id of an user) and at the end of the test I want to delete that user. The way I decided to go to find that user is to pass the username I gave to that user in this case 'test123'.

So first I need the auth and get_user_by_username to run before delete. But when I put assert on user.status_code I get 422 instead of 200. When I try it in the swagger it works fine and I get 200 response

Here is the code:

```<code>def test_delete_new_users():
    auth = client.post('/token',
                       data={'username': 'test123', 'password': 'test123'}
                       )
    access_token = auth.json().get('access_token')
    user = client.post(
        '/user/get_user_by_username',
        json={"username": "test123", }
    )
    assert user.status_code == 200

    response = client.delete(
        '/user/delete/' + user.json().get('user_id'),
         headers={'Authorization': 'bearer' + access_token}
    )
    assert response.status_code == 200
</code>```

When I remove the assert part of the code and just run it I get this error:

```<code>FAILED tests_main.py::test_delete_new_users - TypeError: can only concatenate str (not "NoneType") to str
</code>```

this is get_user_by_username API:

```<code> @router.post('/get_user_by_username', response_model=UserDisplay)
    async def get_user_by_username(username: str, db: Session = Depends(database.get_db)):
        user = db.query(models.User).filter(models.User.username == username).first()

        if user is None:
            raise HTTPException(status_code=404, detail='Not found')

        return user
</code>```

This is the request and response on swagger:

Body:
Hi so what I am trying to do is when I run the test the user will be created (makes an id of an user) and at the end of the test I want to delete that user. The way I decided to go to find that user is to pass the username I gave to that user in this case 'test123'.

So first I need the auth and get_user_by_username to run before delete. But when I put assert on user.status_code I get 422 instead of 200. When I try it in the swagger it works fine and I get 200 response

Here is the code:

def test_delete_new_users():
    auth = client.post('/token',
                       data={'username': 'test123', 'password': 'test123'}
                       )
    access_token = auth.json().get('access_token')
    user = client.post(
        '/user/get_user_by_username',
        json={"username": "test123", }
    )
    assert user.status_code == 200

    response = client.delete(
        '/user/delete/' + user.json().get('user_id'),
         headers={'Authorization': 'bearer' + access_token}
    )
    assert response.status_code == 200

When I remove the assert part of the code and just run it I get this error:

FAILED tests_main.py::test_delete_new_users - TypeError: can only concatenate str (not "NoneType") to str

this is get_user_by_username API:

 @router.post('/get_user_by_username', response_model=UserDisplay)
    async def get_user_by_username(username: str, db: Session = Depends(database.get_db)):
        user = db.query(models.User).filter(models.User.username == username).first()

        if user is None:
            raise HTTPException(status_code=404, detail='Not found')

        return user

This is the request and response on swagger:


问:
How to get the correct typing for overridden generic methods
I want to write a new container class. For this, the class inherits from collections.abc.Container.

Short reminder (this is what the container looks like):

```<code>@runtime_checkable
class Container(Protocol[_T_co]):
    @abstractmethod
    def __contains__(self, __x: object) -> bool: ...
</code>```

That is what my first implementation looked like:

```<code>from collections.abc import Container
from typing import Generic, TypeVar

_ContainerType = TypeVar('_ContainerType')

class MyContainer(Container[_ContainerType], Generic[_ContainerType]):

    def _find(self, __value: _ContainerType) -> int:
        '''Returns the index of the specified element, or -1 if this container does not contain the element.'''
        return -1

    def __contains__(self, __x: _ContainerType) -> bool:
        return self._find(__x) >= 0
</code>```

But running mypy (mypy --strict --show-error-context .) gave me the following output:

```<code>my_container.py: note: In member "__contains__" of class "MyContainer":
my_container.py:12: error: Argument 1 of "__contains__" is incompatible with supertype "Container"; supertype defines the argument type as "object"
my_container.py:12: note: This violates the Liskov substitution principle
my_container.py:12: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
</code>```

Adapting the argument type to the base class type

```<code>    def __contains__(self, __x: object) -> bool:
        return self._find(__x) >= 0
</code>```

results in another error:

```<code>my_container.py: note: In member "__contains__" of class "MyContainer":
my_container.py:13: error: Argument 1 to "_find" of "MyContainer" has incompatible type "object"; expected "_ContainerType"
</code>```

Mypy is right on both cases. But how can I fix it?
(In other situations I use isinstance(...) to check the type. Then mypy accepts the Any -> <other_type> assignment. But I don't have a fix type here.)

Body:
I want to write a new container class. For this, the class inherits from collections.abc.Container.

Short reminder (this is what the container looks like):

@runtime_checkable
class Container(Protocol[_T_co]):
    @abstractmethod
    def __contains__(self, __x: object) -> bool: ...

That is what my first implementation looked like:

from collections.abc import Container
from typing import Generic, TypeVar

_ContainerType = TypeVar('_ContainerType')

class MyContainer(Container[_ContainerType], Generic[_ContainerType]):

    def _find(self, __value: _ContainerType) -> int:
        '''Returns the index of the specified element, or -1 if this container does not contain the element.'''
        return -1

    def __contains__(self, __x: _ContainerType) -> bool:
        return self._find(__x) >= 0

But running mypy (mypy --strict --show-error-context .) gave me the following output:

my_container.py: note: In member "__contains__" of class "MyContainer":
my_container.py:12: error: Argument 1 of "__contains__" is incompatible with supertype "Container"; supertype defines the argument type as "object"
my_container.py:12: note: This violates the Liskov substitution principle
my_container.py:12: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides

Adapting the argument type to the base class type

    def __contains__(self, __x: object) -> bool:
        return self._find(__x) >= 0

results in another error:

my_container.py: note: In member "__contains__" of class "MyContainer":
my_container.py:13: error: Argument 1 to "_find" of "MyContainer" has incompatible type "object"; expected "_ContainerType"

Mypy is right on both cases. But how can I fix it?
(In other situations I use isinstance(...) to check the type. Then mypy accepts the Any -> <other_type> assignment. But I don't have a fix type here.)


问:
How to get a youtube channelid from the channels link programmatically
I need to get the channelid of a youtube channel (to use the youtube data api) with the link of the channel.
The problem is that there are a few types of links for a youtube channel.
The first one is where the channel id is in the link:

https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw

This is ok because i can just extract the channelid from the link.
The problem comes with the second one:

https://www.youtube.com/@PewDiePie

This is the link you normally get for a youtube channel and it has a @ instead of the channelid.

When i use the youtube api to get the channel id of a not so popular channel i get the wrong results:

https://www.googleapis.com/youtube/v3/search?part=snippet&q=@pewdiepie6&type=channel&key=[API_KEY]

I would like to get the channel info and channelid for the channel with the @pewdiepie6 handle.

But i get the more popular channel with the @pewdiepie6802 handle.
Also, i get more than 1 channel as a result.

```<code>{
  "kind": "youtube#searchListResponse",
  "etag": "ecshCA97Jd0CuntIj9NzN3UF37U",
  "nextPageToken": "CAUQAA",
  "regionCode": "CH",
  "pageInfo": {
    "totalResults": 51,
    "resultsPerPage": 5
  },
  "items": [
    {
      "kind": "youtube#searchResult",
      "etag": "x4yStPuXhfUUIaev-BCMiq1JQ4E",
      "id": {
        "kind": "youtube#channel",
        "channelId": "UCnJABWFF_vWuPgPjGjVJF8A"
      },
      "snippet": {
        "publishedAt": "2018-03-02T14:07:51Z",
        "channelId": "UCnJABWFF_vWuPgPjGjVJF8A",
        "title": "PewDiePie",
        "description": "",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu84CCwyUjzgQkuvN7ms2JUCU0EgofxrTdhZLZKs=s88-c-k-c0xffffffff-no-rj-mo"
          },
          "medium": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu84CCwyUjzgQkuvN7ms2JUCU0EgofxrTdhZLZKs=s240-c-k-c0xffffffff-no-rj-mo"
          },
          "high": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu84CCwyUjzgQkuvN7ms2JUCU0EgofxrTdhZLZKs=s800-c-k-c0xffffffff-no-rj-mo"
          }
        },
        "channelTitle": "PewDiePie",
        "liveBroadcastContent": "none",
        "publishTime": "2018-03-02T14:07:51Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "2et4mkoeeilV2DhJRH7M5xlgnuQ",
      "id": {
        "kind": "youtube#channel",
        "channelId": "UCSn7KcaNdOrVf4aH-6OdFMg"
      },
      "snippet": {
        "publishedAt": "2017-04-23T06:06:06Z",
        "channelId": "UCSn7KcaNdOrVf4aH-6OdFMg",
        "title": "PewDiePie 6",
        "description": "",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu8OB0Z-JNTYnB2Q0KLoV6LjvpUYpYfN0sfAMgfT=s88-c-k-c0xffffffff-no-rj-mo"
          },
          "medium": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu8OB0Z-JNTYnB2Q0KLoV6LjvpUYpYfN0sfAMgfT=s240-c-k-c0xffffffff-no-rj-mo"
          },
          "high": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu8OB0Z-JNTYnB2Q0KLoV6LjvpUYpYfN0sfAMgfT=s800-c-k-c0xffffffff-no-rj-mo"
          }
        },
        "channelTitle": "PewDiePie 6",
        "liveBroadcastContent": "none",
        "publishTime": "2017-04-23T06:06:06Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "88l8OAYbY0S8XY9NbWcqW2QtJJ4",
      "id": {
        "kind": "youtube#channel",
        "channelId": "UCpqNuOLjibXIO43tJbZ-s3w"
      },
      "snippet": {
        "publishedAt": "2017-06-17T21:56:28Z",
        "channelId": "UCpqNuOLjibXIO43tJbZ-s3w",
        "title": "PewDiePie",
        "description": "",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu-GIq-DWy8zPGzPmQnb5LHvR_MlnlK3t-G5-45i=s88-c-k-c0xffffffff-no-rj-mo"
          },
          "medium": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu-GIq-DWy8zPGzPmQnb5LHvR_MlnlK3t-G5-45i=s240-c-k-c0xffffffff-no-rj-mo"
          },
          "high": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu-GIq-DWy8zPGzPmQnb5LHvR_MlnlK3t-G5-45i=s800-c-k-c0xffffffff-no-rj-mo"
          }
        },
        "channelTitle": "PewDiePie",
        "liveBroadcastContent": "none",
        "publishTime": "2017-06-17T21:56:28Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "MItPbLglqDfEkQ-fXSbQef7js2c",
      "id": {
        "kind": "youtube#channel",
        "channelId": "UCQXfsdNRgLL0Cz67stMFNVQ"
      },
      "snippet": {
        "publishedAt": "2018-03-31T09:27:20Z",
        "channelId": "UCQXfsdNRgLL0Cz67stMFNVQ",
        "title": "Marian Pewdiepie 6",
        "description": "Nu voi mai posta mai mult de 1 an căci nu prea am vhef Dar totuși dați subscribe.",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu9G8MRCxqrk5dCx9T6lxjWpaAL62QuD54LGpgV6=s88-c-k-c0xffffffff-no-rj-mo"
          },
          "medium": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu9G8MRCxqrk5dCx9T6lxjWpaAL62QuD54LGpgV6=s240-c-k-c0xffffffff-no-rj-mo"
          },
          "high": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu9G8MRCxqrk5dCx9T6lxjWpaAL62QuD54LGpgV6=s800-c-k-c0xffffffff-no-rj-mo"
          }
        },
        "channelTitle": "Marian Pewdiepie 6",
        "liveBroadcastContent": "upcoming",
        "publishTime": "2018-03-31T09:27:20Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "_yNYVPOhK2ZEn0yq580TFty6AHU",
      "id": {
        "kind": "youtube#channel",
        "channelId": "UCR8SFIzFOxf50N0lYER8_-w"
      },
      "snippet": {
        "publishedAt": "2019-03-09T20:56:38Z",
        "channelId": "UCR8SFIzFOxf50N0lYER8_-w",
        "title": "Go sub to Pewdiepie 6",
        "description": "",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu_3fwpv9uhEyzb_bUgNuzETQHpdgvKv-xDSYQ=s88-c-k-c0xffffffff-no-rj-mo"
          },
          "medium": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu_3fwpv9uhEyzb_bUgNuzETQHpdgvKv-xDSYQ=s240-c-k-c0xffffffff-no-rj-mo"
          },
          "high": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu_3fwpv9uhEyzb_bUgNuzETQHpdgvKv-xDSYQ=s800-c-k-c0xffffffff-no-rj-mo"
          }
        },
        "channelTitle": "Go sub to Pewdiepie 6",
        "liveBroadcastContent": "none",
        "publishTime": "2019-03-09T20:56:38Z"
      }
    }
  ]
}

</code>```

I also tried to extract the channelid out of the javascript of the page but using Beautiful Soup.
But i could not get it to return the right javascript.

There is also a second api link with the forUsername parameter.
But with this link it tries to look for a user which uploads on a channel which is not what i want.

At the end of the day i want a safe method to get the channel id with the channels link.
https://www.youtube.com/@pewdiepie6
=> UCl-0ct6u2AAfsqGGgVh5dEw

(I got this manually out of the @pewdiepie6 javascript file from the page at externalid)

Body:
I need to get the channelid of a youtube channel (to use the youtube data api) with the link of the channel.
The problem is that there are a few types of links for a youtube channel.
The first one is where the channel id is in the link:

https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw

This is ok because i can just extract the channelid from the link.
The problem comes with the second one:

https://www.youtube.com/@PewDiePie

This is the link you normally get for a youtube channel and it has a @ instead of the channelid.

When i use the youtube api to get the channel id of a not so popular channel i get the wrong results:

https://www.googleapis.com/youtube/v3/search?part=snippet&q=@pewdiepie6&type=channel&key=[API_KEY]

I would like to get the channel info and channelid for the channel with the @pewdiepie6 handle.

But i get the more popular channel with the @pewdiepie6802 handle.
Also, i get more than 1 channel as a result.

{
  "kind": "youtube#searchListResponse",
  "etag": "ecshCA97Jd0CuntIj9NzN3UF37U",
  "nextPageToken": "CAUQAA",
  "regionCode": "CH",
  "pageInfo": {
    "totalResults": 51,
    "resultsPerPage": 5
  },
  "items": [
    {
      "kind": "youtube#searchResult",
      "etag": "x4yStPuXhfUUIaev-BCMiq1JQ4E",
      "id": {
        "kind": "youtube#channel",
        "channelId": "UCnJABWFF_vWuPgPjGjVJF8A"
      },
      "snippet": {
        "publishedAt": "2018-03-02T14:07:51Z",
        "channelId": "UCnJABWFF_vWuPgPjGjVJF8A",
        "title": "PewDiePie",
        "description": "",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu84CCwyUjzgQkuvN7ms2JUCU0EgofxrTdhZLZKs=s88-c-k-c0xffffffff-no-rj-mo"
          },
          "medium": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu84CCwyUjzgQkuvN7ms2JUCU0EgofxrTdhZLZKs=s240-c-k-c0xffffffff-no-rj-mo"
          },
          "high": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu84CCwyUjzgQkuvN7ms2JUCU0EgofxrTdhZLZKs=s800-c-k-c0xffffffff-no-rj-mo"
          }
        },
        "channelTitle": "PewDiePie",
        "liveBroadcastContent": "none",
        "publishTime": "2018-03-02T14:07:51Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "2et4mkoeeilV2DhJRH7M5xlgnuQ",
      "id": {
        "kind": "youtube#channel",
        "channelId": "UCSn7KcaNdOrVf4aH-6OdFMg"
      },
      "snippet": {
        "publishedAt": "2017-04-23T06:06:06Z",
        "channelId": "UCSn7KcaNdOrVf4aH-6OdFMg",
        "title": "PewDiePie 6",
        "description": "",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu8OB0Z-JNTYnB2Q0KLoV6LjvpUYpYfN0sfAMgfT=s88-c-k-c0xffffffff-no-rj-mo"
          },
          "medium": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu8OB0Z-JNTYnB2Q0KLoV6LjvpUYpYfN0sfAMgfT=s240-c-k-c0xffffffff-no-rj-mo"
          },
          "high": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu8OB0Z-JNTYnB2Q0KLoV6LjvpUYpYfN0sfAMgfT=s800-c-k-c0xffffffff-no-rj-mo"
          }
        },
        "channelTitle": "PewDiePie 6",
        "liveBroadcastContent": "none",
        "publishTime": "2017-04-23T06:06:06Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "88l8OAYbY0S8XY9NbWcqW2QtJJ4",
      "id": {
        "kind": "youtube#channel",
        "channelId": "UCpqNuOLjibXIO43tJbZ-s3w"
      },
      "snippet": {
        "publishedAt": "2017-06-17T21:56:28Z",
        "channelId": "UCpqNuOLjibXIO43tJbZ-s3w",
        "title": "PewDiePie",
        "description": "",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu-GIq-DWy8zPGzPmQnb5LHvR_MlnlK3t-G5-45i=s88-c-k-c0xffffffff-no-rj-mo"
          },
          "medium": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu-GIq-DWy8zPGzPmQnb5LHvR_MlnlK3t-G5-45i=s240-c-k-c0xffffffff-no-rj-mo"
          },
          "high": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu-GIq-DWy8zPGzPmQnb5LHvR_MlnlK3t-G5-45i=s800-c-k-c0xffffffff-no-rj-mo"
          }
        },
        "channelTitle": "PewDiePie",
        "liveBroadcastContent": "none",
        "publishTime": "2017-06-17T21:56:28Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "MItPbLglqDfEkQ-fXSbQef7js2c",
      "id": {
        "kind": "youtube#channel",
        "channelId": "UCQXfsdNRgLL0Cz67stMFNVQ"
      },
      "snippet": {
        "publishedAt": "2018-03-31T09:27:20Z",
        "channelId": "UCQXfsdNRgLL0Cz67stMFNVQ",
        "title": "Marian Pewdiepie 6",
        "description": "Nu voi mai posta mai mult de 1 an căci nu prea am vhef Dar totuși dați subscribe.",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu9G8MRCxqrk5dCx9T6lxjWpaAL62QuD54LGpgV6=s88-c-k-c0xffffffff-no-rj-mo"
          },
          "medium": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu9G8MRCxqrk5dCx9T6lxjWpaAL62QuD54LGpgV6=s240-c-k-c0xffffffff-no-rj-mo"
          },
          "high": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu9G8MRCxqrk5dCx9T6lxjWpaAL62QuD54LGpgV6=s800-c-k-c0xffffffff-no-rj-mo"
          }
        },
        "channelTitle": "Marian Pewdiepie 6",
        "liveBroadcastContent": "upcoming",
        "publishTime": "2018-03-31T09:27:20Z"
      }
    },
    {
      "kind": "youtube#searchResult",
      "etag": "_yNYVPOhK2ZEn0yq580TFty6AHU",
      "id": {
        "kind": "youtube#channel",
        "channelId": "UCR8SFIzFOxf50N0lYER8_-w"
      },
      "snippet": {
        "publishedAt": "2019-03-09T20:56:38Z",
        "channelId": "UCR8SFIzFOxf50N0lYER8_-w",
        "title": "Go sub to Pewdiepie 6",
        "description": "",
        "thumbnails": {
          "default": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu_3fwpv9uhEyzb_bUgNuzETQHpdgvKv-xDSYQ=s88-c-k-c0xffffffff-no-rj-mo"
          },
          "medium": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu_3fwpv9uhEyzb_bUgNuzETQHpdgvKv-xDSYQ=s240-c-k-c0xffffffff-no-rj-mo"
          },
          "high": {
            "url": "https://yt3.ggpht.com/ytc/AMLnZu_3fwpv9uhEyzb_bUgNuzETQHpdgvKv-xDSYQ=s800-c-k-c0xffffffff-no-rj-mo"
          }
        },
        "channelTitle": "Go sub to Pewdiepie 6",
        "liveBroadcastContent": "none",
        "publishTime": "2019-03-09T20:56:38Z"
      }
    }
  ]
}

I also tried to extract the channelid out of the javascript of the page but using Beautiful Soup.
But i could not get it to return the right javascript.

There is also a second api link with the forUsername parameter.
But with this link it tries to look for a user which uploads on a channel which is not what i want.

At the end of the day i want a safe method to get the channel id with the channels link.
https://www.youtube.com/@pewdiepie6
=> UCl-0ct6u2AAfsqGGgVh5dEw

(I got this manually out of the @pewdiepie6 javascript file from the page at externalid)


问:
CMSIS DSP library for ARM and MATLAB gives two different results of FFT
I am working on a project where I have to compute FFT of a signal. Same signal is fed through both MATLAB and STM32 controller and results are compared.

Results seems to be different from each other. I don't know what I am doing wrong.

The STM32 Code is below.

```<code>//Pre-FFT
arm_fill_f32(0, &tempBuff_1[FrameLen], 256-(FrameLen)); //zero padding

PreFFTProcess(tempBuff_1, tempBuff_2, 256); //Convert format from Real[0],Real[1],Real[2],Real[3].. to Real[0],Img[0],Real[1],Img[1]...

//FFT
arm_cfft_f32(&fftInstance, tempBuff_2 , 0, 1); //FFT

arm_cmplx_mag_f32(tempBuff_2, tempBuff_1, 256); //ABS
</code>```

The MATLAB code: Out = abs(fft(Input,256));

The results:

MATLAB vs STM32 FFT Result1

MATLAB vs STM32 FFT Result2

Body:
I am working on a project where I have to compute FFT of a signal. Same signal is fed through both MATLAB and STM32 controller and results are compared.

Results seems to be different from each other. I don't know what I am doing wrong.

The STM32 Code is below.

//Pre-FFT
arm_fill_f32(0, &tempBuff_1[FrameLen], 256-(FrameLen)); //zero padding

PreFFTProcess(tempBuff_1, tempBuff_2, 256); //Convert format from Real[0],Real[1],Real[2],Real[3].. to Real[0],Img[0],Real[1],Img[1]...

//FFT
arm_cfft_f32(&fftInstance, tempBuff_2 , 0, 1); //FFT

arm_cmplx_mag_f32(tempBuff_2, tempBuff_1, 256); //ABS

The MATLAB code: Out = abs(fft(Input,256));

The results:

MATLAB vs STM32 FFT Result1

MATLAB vs STM32 FFT Result2


问:
Something wrong with QGraphicsScene y-acxis
I have a simple example with QGraphicsScene wrong behavior

```<code>#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsItem>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QGraphicsScene * scene = new QGraphicsScene(this);
    ui->graphicsView->setScene(scene);
    //background
    ui->graphicsView->setBackgroundBrush(Qt::black);

    QLineF y_line(ui->graphicsView->sceneRect().center().x(), ui->graphicsView->sceneRect().center().y() - 100,
                  ui->graphicsView->sceneRect().center().x(), ui->graphicsView->sceneRect().center().y() - 550);

    QLineF x_line(ui->graphicsView->sceneRect().center().x() - 100, ui->graphicsView->sceneRect().center().y(),
                  ui->graphicsView->sceneRect().center().x() - 550, ui->graphicsView->sceneRect().center().y());

    scene->addLine(y_line, QPen(Qt::yellow));

    //add line X
    scene->addLine(x_line, QPen(Qt::green));
    ui->graphicsView->fitInView(ui->graphicsView->sceneRect());
}

MainWindow::~MainWindow()
{
    delete ui;
}

</code>```

I uave this:

And this is ok, i think
BUT

if i comment out add line X

i have this :

How you can see the line direction!! changed .

How somebody can explain this???
Wrong behavior  i think? some bugs in Qt?

Body:
I have a simple example with QGraphicsScene wrong behavior

#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsView>
#include <QGraphicsItem>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QGraphicsScene * scene = new QGraphicsScene(this);
    ui->graphicsView->setScene(scene);
    //background
    ui->graphicsView->setBackgroundBrush(Qt::black);

    QLineF y_line(ui->graphicsView->sceneRect().center().x(), ui->graphicsView->sceneRect().center().y() - 100,
                  ui->graphicsView->sceneRect().center().x(), ui->graphicsView->sceneRect().center().y() - 550);

    QLineF x_line(ui->graphicsView->sceneRect().center().x() - 100, ui->graphicsView->sceneRect().center().y(),
                  ui->graphicsView->sceneRect().center().x() - 550, ui->graphicsView->sceneRect().center().y());

    scene->addLine(y_line, QPen(Qt::yellow));

    //add line X
    scene->addLine(x_line, QPen(Qt::green));
    ui->graphicsView->fitInView(ui->graphicsView->sceneRect());
}

MainWindow::~MainWindow()
{
    delete ui;
}

I uave this:

And this is ok, i think
BUT

if i comment out add line X

i have this :

How you can see the line direction!! changed .

How somebody can explain this???
Wrong behavior  i think? some bugs in Qt?


问:
localStorage persist data in react MERN Stack App
I am building a full-stack React App with mongodb and I am trying to persist user data when I log in using localStorage. However, the localStorage is only storing the null value. I have failed to figure out what I am doing wrong, a little would be golden at this point. I am using contextApi for this, and I have provided the code below.... Please save me, your help will be heavily appreciated. The login route  works perfectly fine in the backend.

I expected the localstorage to save the user information when I login. The login in works, and as a result, the login proceeds to the home page as expected ,but the user information does not persist in the localstorage but rather returns a null value.

Here is the login page code

```<code>import React, { useState, useContext } from 'react'
import { AuthContext } from '../../context/AuthContext';
import axios from "axios";
import { useNavigate } from "react-router-dom";

import "./login.css";

const Login = () => {
    const [credentials, setCredentials] = useState({
        username: undefined,
        password: undefined
    });

    const { user ,loading, error, dispatch } = useContext(AuthContext);

    const navigate = useNavigate();

    const handleChange = (e) => {
        setCredentials((prev) => ({ ...prev, [e.target.id]: e.target.value}));
    }

    const handleClick = async (e) => {
        e.preventDefault();

        dispatch({ type: "LOGIN_START" });

        try {
            const res = await axios.post("/auth/login", credentials);
            dispatch({ type: "LOGIN_SUCCESS", payload: res.data })
            navigate("/")
        } catch(err) {
            dispatch({type: "LOGIN_FAILURE", payload: err.response.data})
        }
    }

    console.log(user);

  return (
    <div className='login'>
        <div className="lContainer">
            <input type="text" placeholder='username' id='username' onChange={handleChange} className="lInput" />
            <input type="password" placeholder='password' id='password' onChange={handleChange} className="lInput" />
            <button disabled={loading} onClick={handleClick} className="lButton">Login</button>
            {error && <span>{error.message}</span>}
        </div>
    </div>
  )
}

export default Login;
</code>```

This is the contextApi code for the user-authentication

```<code>
import { createContext, useReducer, useEffect } from "react";

const INITIAL_STATE = {
    user: JSON.parse(localStorage.getItem("user")) || null,
    loading: false,
    error: null
};

export const AuthContext = createContext(INITIAL_STATE);

const AuthReducer = (state, action) => {
    switch (action.type) {
        case "LOGIN_START":
            return {
                user: null,
                loading: true,
                error: null
            };
        case "LOGIN_SUCCCES":
            return {
                user: action.payload,
                loading: false,
                error: null
            };
        case "LOGIN_FAILURE":
            return {
                user: null,
                loading: false,
                error: action.payload
            };
        case "LOGOUT":
            return {
                user: null,
                loading: false,
                error: null
            }
        default:
            return state
    }
};

export const AuthContextProvider = ({ children }) => {
    const [state, dispatch] = useReducer(AuthReducer, INITIAL_STATE);

    /**
     * ! save user to localstorage
     */
    useEffect(() => {
        localStorage.setItem("user", JSON.stringify(state.user));
    }, [state.user]);

    return (
        <AuthContext.Provider
            value={{
                user: state.user,
                loading: state.loading,
                error: state.error,
                dispatch
            }}
        >
            {children}
        </AuthContext.Provider>
    )
}

I expected the localstorage to save the user information when I login. The login in works, and as a result, the login proceeds to the home page as expected ,but the user information does not persist in the localstorage but rather returns a null value.
</code>```

Body:
I am building a full-stack React App with mongodb and I am trying to persist user data when I log in using localStorage. However, the localStorage is only storing the null value. I have failed to figure out what I am doing wrong, a little would be golden at this point. I am using contextApi for this, and I have provided the code below.... Please save me, your help will be heavily appreciated. The login route  works perfectly fine in the backend.

I expected the localstorage to save the user information when I login. The login in works, and as a result, the login proceeds to the home page as expected ,but the user information does not persist in the localstorage but rather returns a null value.

Here is the login page code

import React, { useState, useContext } from 'react'
import { AuthContext } from '../../context/AuthContext';
import axios from "axios";
import { useNavigate } from "react-router-dom";

import "./login.css";

const Login = () => {
    const [credentials, setCredentials] = useState({
        username: undefined,
        password: undefined
    });

    const { user ,loading, error, dispatch } = useContext(AuthContext);

    const navigate = useNavigate();

    const handleChange = (e) => {
        setCredentials((prev) => ({ ...prev, [e.target.id]: e.target.value}));
    }

    const handleClick = async (e) => {
        e.preventDefault();

        dispatch({ type: "LOGIN_START" });

        try {
            const res = await axios.post("/auth/login", credentials);
            dispatch({ type: "LOGIN_SUCCESS", payload: res.data })
            navigate("/")
        } catch(err) {
            dispatch({type: "LOGIN_FAILURE", payload: err.response.data})
        }
    }

    console.log(user);

  return (

            <input type="text" placeholder='username' id='username' onChange={handleChange} className="lInput" />
            <input type="password" placeholder='password' id='password' onChange={handleChange} className="lInput" />
            <button disabled={loading} onClick={handleClick} className="lButton">Login</button>
            {error && {error.message}}

  )
}

export default Login;

This is the contextApi code for the user-authentication

import { createContext, useReducer, useEffect } from "react";

const INITIAL_STATE = {
    user: JSON.parse(localStorage.getItem("user")) || null,
    loading: false,
    error: null
};

export const AuthContext = createContext(INITIAL_STATE);

const AuthReducer = (state, action) => {
    switch (action.type) {
        case "LOGIN_START":
            return {
                user: null,
                loading: true,
                error: null
            };
        case "LOGIN_SUCCCES":
            return {
                user: action.payload,
                loading: false,
                error: null
            };
        case "LOGIN_FAILURE":
            return {
                user: null,
                loading: false,
                error: action.payload
            };
        case "LOGOUT":
            return {
                user: null,
                loading: false,
                error: null
            }
        default:
            return state
    }
};

export const AuthContextProvider = ({ children }) => {
    const [state, dispatch] = useReducer(AuthReducer, INITIAL_STATE);

    /**
     * ! save user to localstorage
     */
    useEffect(() => {
        localStorage.setItem("user", JSON.stringify(state.user));
    }, [state.user]);

    return (
        <AuthContext.Provider
            value={{
                user: state.user,
                loading: state.loading,
                error: state.error,
                dispatch
            }}
        >
            {children}
        </AuthContext.Provider>
    )
}

I expected the localstorage to save the user information when I login. The login in works, and as a result, the login proceeds to the home page as expected ,but the user information does not persist in the localstorage but rather returns a null value.


问:
AddDefaultImplementarionEntries as True shows Invalid plugin configuration: manifest
currently I’m moving my corporate Project from Java 11 to Java 17 and while updating my maven war plug-in from 3.3.1 to 3.3.2 I’m having this warning which is invalid plug-in configuration manifest which was working fine when the version was 3.3 .1

please suggest what to do.
My maven version in pom is 3.8.1 and my war plugin after updating is 3.3.2. And jdk is 17 and in pom as well Java version is 17


问:
In Flutter how to zoom one image while icons which are overlaid over the image will not move i.e. always keep those icons lined up perfectly?
In Flutter I have done overlaying of two icons on one image as shown,icons overlay on image,
These icons should be in the fixed position as shown here,icons actual position
Now if I zoom the image, the icons are getting shifted along with the zooming as shown below
icon shifted while zooming
Again icons are shifted for zooming in as shown here  icon again shifted while zooming

```<code>import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

  class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Image Zoom Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: Zoom(),
      ),
    );
  }
}
class Zoom extends StatefulWidget
{
  @override
  MyStatelessWidget createState()=> MyStatelessWidget();
}
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends State<Zoom> {

  @override
  Widget build(BuildContext context) {
return Scaffold(
      body: Container(
        padding: new EdgeInsets.only(left: 16.0, bottom: 8.0, right: 16.0),
        color: Colors.white,
        alignment: Alignment.center,

          child: new Stack(
          children: <Widget>[
              InteractiveViewer(
              child: Image.asset("images/ncdscreen_oralimage.png"),

            ),
            new Positioned(
              left: 80.0,
              top: 6.0,
              child: new Icon(Icons.radio_button_checked,
              color: Colors.black)
            ),
            new Positioned(
              left: 110.0,
              top: 24.0,
              child: new Icon(Icons.radio_button_checked,
              color: Colors.black)
            ),
          ],
        ),
      ),
    );
  }
}

</code>```

I expect those icons should not move when I do zooming of the image, It should be fixed on that position and while scrolling as shown below

original position

after zooming, the icons' position still fixed

Body:
In Flutter I have done overlaying of two icons on one image as shown,icons overlay on image,
These icons should be in the fixed position as shown here,icons actual position
Now if I zoom the image, the icons are getting shifted along with the zooming as shown below
icon shifted while zooming
Again icons are shifted for zooming in as shown here  icon again shifted while zooming

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

  class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Image Zoom Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: Scaffold(
        appBar: AppBar(title: const Text(_title)),
        body: Zoom(),
      ),
    );
  }
}
class Zoom extends StatefulWidget
{
  @override
  MyStatelessWidget createState()=> MyStatelessWidget();
}
/// This is the stateless widget that the main application instantiates.
class MyStatelessWidget extends State<Zoom> {

  @override
  Widget build(BuildContext context) {
return Scaffold(
      body: Container(
        padding: new EdgeInsets.only(left: 16.0, bottom: 8.0, right: 16.0),
        color: Colors.white,
        alignment: Alignment.center,

          child: new Stack(
          children: <Widget>[
              InteractiveViewer(
              child: Image.asset("images/ncdscreen_oralimage.png"),

            ),
            new Positioned(
              left: 80.0,
              top: 6.0,
              child: new Icon(Icons.radio_button_checked,
              color: Colors.black)
            ),
            new Positioned(
              left: 110.0,
              top: 24.0,
              child: new Icon(Icons.radio_button_checked,
              color: Colors.black)
            ),
          ],
        ),
      ),
    );
  }
}

I expect those icons should not move when I do zooming of the image, It should be fixed on that position and while scrolling as shown below

original position

after zooming, the icons' position still fixed


问:
Is it possible embed gist url in swift uikit?
I would like to embed gist url in swift uikit (mobile) like in this picture

Is it possible to do that?

I tried to use some styles but they are not working fully functional


问:
Kong: kong-spec-expose plugin cannot load the documentation(302 permanently moved)
I have hard times configuring this kong-spec-expose plugin.It is supposed to automatically configure the routes with Swagger. After some time I managed to configure it but when i try to access the documentation of a certain route it is always giving me the 302 permanently moved.So i tested it with curl and here I will leave a link for the kong plugin and a screenshot of the request..

https://docs.konghq.com/hub/optum/kong-spec-expose/

```<code>*   Trying 127.0.0.1:8000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /api/employee-controller/profile/user/12/base/specz HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Moved Temporarily
< Date: Wed, 11 Jan 2023 09:50:38 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Kong-Response-Latency: 409
< Server: kong/2.8.1

</code>```

Actually I tried configuring the plugin on multiple routes then on service level but nothing seems to work out.. then tried to analyse where this request is redirected but with no results.

Body:
I have hard times configuring this kong-spec-expose plugin.It is supposed to automatically configure the routes with Swagger. After some time I managed to configure it but when i try to access the documentation of a certain route it is always giving me the 302 permanently moved.So i tested it with curl and here I will leave a link for the kong plugin and a screenshot of the request..

https://docs.konghq.com/hub/optum/kong-spec-expose/

*   Trying 127.0.0.1:8000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET /api/employee-controller/profile/user/12/base/specz HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Moved Temporarily
< Date: Wed, 11 Jan 2023 09:50:38 GMT
< Content-Type: text/html; charset=utf-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-Kong-Response-Latency: 409
< Server: kong/2.8.1

Actually I tried configuring the plugin on multiple routes then on service level but nothing seems to work out.. then tried to analyse where this request is redirected but with no results.


问:
Passing arguments to an inline script Bash task fails?
I have an inline script as shown. The requirement is that there could be different variables that needs to be passed and those are secretive. In azure pipelines, we can use variable groups and encrypt them. The idea is used below. From the documentation(https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/bash-v3?view=azure-pipelines), arguments can be passed only if we write a shell script file, and execute the file through the task mentioned below.

However, the shell script file fails at the set -eufo pipefail command and it throws the following error:

```<code>/home/vsts/work/1/s/script.sh: line 2: set: pipefail
: invalid option name
##[error]Bash exited with code '2'.
</code>```

Hence, there is an inline script as below:

```<code>variables:
- group: ScheduledUpdate

steps:
- task: Bash@3
  inputs:
    targetType: 'inline'
    arguments: '$(SOURCE_URL)'
    script: |
      #!usr/bin/sh
      set -eufo pipefail
      echo "Argument 1 is $1"
      echo "done"
</code>```

However, there is a failure with respect to passing arguments. I get the following error:

```<code>/home/pkapikad/myagent/_work/_temp/7dfddc0a-4a40-4235-9752-c1c0e136372c.sh: line 3: $1: unbound variable
##[error]Bash exited with code '1'.
Finishing: Bash
</code>```

Why is this caused?
How can be pass arguments to a inline script inside bash task in azure devops?

Body:
I have an inline script as shown. The requirement is that there could be different variables that needs to be passed and those are secretive. In azure pipelines, we can use variable groups and encrypt them. The idea is used below. From the documentation(https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/bash-v3?view=azure-pipelines), arguments can be passed only if we write a shell script file, and execute the file through the task mentioned below.

However, the shell script file fails at the set -eufo pipefail command and it throws the following error:

/home/vsts/work/1/s/script.sh: line 2: set: pipefail
: invalid option name
##[error]Bash exited with code '2'.

Hence, there is an inline script as below:

variables:
- group: ScheduledUpdate

steps:
- task: Bash@3
  inputs:
    targetType: 'inline'
    arguments: '$(SOURCE_URL)'
    script: |
      #!usr/bin/sh
      set -eufo pipefail
      echo "Argument 1 is $1"
      echo "done"

However, there is a failure with respect to passing arguments. I get the following error:

/home/pkapikad/myagent/_work/_temp/7dfddc0a-4a40-4235-9752-c1c0e136372c.sh: line 3: $1: unbound variable
##[error]Bash exited with code '1'.
Finishing: Bash

Why is this caused?
How can be pass arguments to a inline script inside bash task in azure devops?


问:
declare(strict_types=1) globally in PHP 8.2
With all the new upgrades released in PHP 8.2 with readonly classes, is it possible to do:

```<code>declare(strict_types=1);
</code>```

globally in a project?

Body:
With all the new upgrades released in PHP 8.2 with readonly classes, is it possible to do:

declare(strict_types=1);

globally in a project?


问:
Content Security Policy (CSP) with unsafe-hashes is not working on mozilla firefox
I used the unsafe-hashes for our Content-Security-Policy to override the errors for our html inline attached events, so in Chrome it works fine and scripts like this are working properly:

```<code><a id="myAnchor" onclick="executeMyMethod()"></a>
</code>```

The problem seems that for mozilla firefox the unsafe-hashes are not implemented as described here https://caniuse.com/?search=unsafe-hashes.

Is there a way to do the same in firefox? Because they suggest to replace with eventListener like this:

```<code>document.getElementById("myAnchor").addEventListener("click", executeMyMethod);
</code>```

But there are a lot of different file and repos to refactor, and it is not viable.

Thanks a lot.

Body:
I used the unsafe-hashes for our Content-Security-Policy to override the errors for our html inline attached events, so in Chrome it works fine and scripts like this are working properly:

The problem seems that for mozilla firefox the unsafe-hashes are not implemented as described here https://caniuse.com/?search=unsafe-hashes.

Is there a way to do the same in firefox? Because they suggest to replace with eventListener like this:

document.getElementById("myAnchor").addEventListener("click", executeMyMethod);

But there are a lot of different file and repos to refactor, and it is not viable.

Thanks a lot.