问:
Draco. I have .obj model. How can I compress it to file with .drc extension?
The main problem is that after decoding file, I get PointCloud while a have to get Mesh. So common instruction from draco repository (https://github.com/google/draco/blob/master/javascript/npm/draco3d/draco_nodejs_example.js) does not suit me because I can't get num_faces from PointCloud. That's why I get 'mesh.num_faces is not a function'

I expect to get .drc compressed file from 3d model with .obj extension, but I get following error: "mesh.num_faces is not a function"
Here is my function for encoding. I took it from draco repository

```<code>const encoder = new this.encoderModule.Encoder();
const meshBuilder = new this.encoderModule.MeshBuilder();

const newMesh = new this.encoderModule.Mesh();

const numFaces = mesh.num_faces();

const numIndices = numFaces * 3;
const numPoints = mesh.num_points();
const indices = new Uint32Array(numIndices);

console.log('Number of faces ' + numFaces);
console.log('Number of vertices ' + numPoints);

// Add Faces to mesh
const ia = new this.decoderModule.DracoInt32Array();
for (let i = 0; i < numFaces; ++i) {
  decoder.GetFaceFromMesh(mesh, i, ia);
  const index = i * 3;
  indices[index] = ia.GetValue(0);
  indices[index + 1] = ia.GetValue(1);
  indices[index + 2] = ia.GetValue(2);
}
this.decoderModule.destroy(ia);
meshBuilder.AddFacesToMesh(newMesh, numFaces, indices);

const attrs = { POSITION: 3, NORMAL: 3, COLOR: 3, TEX_COORD: 2 };

Object.keys(attrs).forEach((attr) => {
  const stride = attrs[attr];
  const numValues = numPoints * stride;
  const decoderAttr = this.decoderModule[attr];
  const encoderAttr = this.encoderModule[attr];
  const attrId = decoder.GetAttributeId(mesh, decoderAttr);

  if (attrId < 0) {
    return;
  }

  console.log('Adding %s attribute', attr);

  const attribute = decoder.GetAttribute(mesh, attrId);
  const attributeData = new this.decoderModule.DracoFloat32Array();
  decoder.GetAttributeFloatForAllPoints(mesh, attribute, attributeData);

  assert(numValues === attributeData.size(), 'Wrong attribute size.');

  const attributeDataArray = new Float32Array(numValues);
  for (let i = 0; i < numValues; ++i) {
    attributeDataArray[i] = attributeData.GetValue(i);
  }

  this.decoderModule.destroy(attributeData);
  meshBuilder.AddFloatAttributeToMesh(
    newMesh,
    encoderAttr,
    numPoints,
    stride,
    attributeDataArray,
  );
});

const encodedData = new this.encoderModule.DracoInt8Array();
// Set encoding options.
encoder.SetSpeedOptions(5, 5);
encoder.SetAttributeQuantization(this.encoderModule.POSITION, 10);
encoder.SetEncodingMethod(this.encoderModule.MESH_EDGEBREAKER_ENCODING);

// Encoding.
console.log('Encoding...');
const encodedLen = encoder.EncodeMeshToDracoBuffer(newMesh, encodedData);
this.encoderModule.destroy(newMesh);

if (encodedLen > 0) {
  console.log('Encoded size is ' + encodedLen);
} else {
  console.log('Error: Encoding failed.');
}
// Copy encoded data to buffer.
const outputBuffer = new ArrayBuffer(encodedLen);
const outputData = new Int8Array(outputBuffer);
for (let i = 0; i < encodedLen; ++i) {
  outputData[i] = encodedData.GetValue(i);
}
this.encoderModule.destroy(encodedData);
this.encoderModule.destroy(encoder);
this.encoderModule.destroy(meshBuilder);
</code>```

Body:
The main problem is that after decoding file, I get PointCloud while a have to get Mesh. So common instruction from draco repository (https://github.com/google/draco/blob/master/javascript/npm/draco3d/draco_nodejs_example.js) does not suit me because I can't get num_faces from PointCloud. That's why I get 'mesh.num_faces is not a function'

I expect to get .drc compressed file from 3d model with .obj extension, but I get following error: "mesh.num_faces is not a function"
Here is my function for encoding. I took it from draco repository

const encoder = new this.encoderModule.Encoder();
const meshBuilder = new this.encoderModule.MeshBuilder();

const newMesh = new this.encoderModule.Mesh();

const numFaces = mesh.num_faces();

const numIndices = numFaces * 3;
const numPoints = mesh.num_points();
const indices = new Uint32Array(numIndices);

console.log('Number of faces ' + numFaces);
console.log('Number of vertices ' + numPoints);

// Add Faces to mesh
const ia = new this.decoderModule.DracoInt32Array();
for (let i = 0; i < numFaces; ++i) {
  decoder.GetFaceFromMesh(mesh, i, ia);
  const index = i * 3;
  indices[index] = ia.GetValue(0);
  indices[index + 1] = ia.GetValue(1);
  indices[index + 2] = ia.GetValue(2);
}
this.decoderModule.destroy(ia);
meshBuilder.AddFacesToMesh(newMesh, numFaces, indices);

const attrs = { POSITION: 3, NORMAL: 3, COLOR: 3, TEX_COORD: 2 };

Object.keys(attrs).forEach((attr) => {
  const stride = attrs[attr];
  const numValues = numPoints * stride;
  const decoderAttr = this.decoderModule[attr];
  const encoderAttr = this.encoderModule[attr];
  const attrId = decoder.GetAttributeId(mesh, decoderAttr);

  if (attrId < 0) {
    return;
  }

  console.log('Adding %s attribute', attr);

  const attribute = decoder.GetAttribute(mesh, attrId);
  const attributeData = new this.decoderModule.DracoFloat32Array();
  decoder.GetAttributeFloatForAllPoints(mesh, attribute, attributeData);

  assert(numValues === attributeData.size(), 'Wrong attribute size.');

  const attributeDataArray = new Float32Array(numValues);
  for (let i = 0; i < numValues; ++i) {
    attributeDataArray[i] = attributeData.GetValue(i);
  }

  this.decoderModule.destroy(attributeData);
  meshBuilder.AddFloatAttributeToMesh(
    newMesh,
    encoderAttr,
    numPoints,
    stride,
    attributeDataArray,
  );
});

const encodedData = new this.encoderModule.DracoInt8Array();
// Set encoding options.
encoder.SetSpeedOptions(5, 5);
encoder.SetAttributeQuantization(this.encoderModule.POSITION, 10);
encoder.SetEncodingMethod(this.encoderModule.MESH_EDGEBREAKER_ENCODING);

// Encoding.
console.log('Encoding...');
const encodedLen = encoder.EncodeMeshToDracoBuffer(newMesh, encodedData);
this.encoderModule.destroy(newMesh);

if (encodedLen > 0) {
  console.log('Encoded size is ' + encodedLen);
} else {
  console.log('Error: Encoding failed.');
}
// Copy encoded data to buffer.
const outputBuffer = new ArrayBuffer(encodedLen);
const outputData = new Int8Array(outputBuffer);
for (let i = 0; i < encodedLen; ++i) {
  outputData[i] = encodedData.GetValue(i);
}
this.encoderModule.destroy(encodedData);
this.encoderModule.destroy(encoder);
this.encoderModule.destroy(meshBuilder);


来源: stackexchange

问:
Linux: ld does not find dynamic library, even though file exists
I'm trying to build a Qt application, which involves a call to uic. I am on Ubuntu 22.04 (on WSL1, though that should hopefully not make a difference). I installed the necessary packages, but I cannot invoke uic:

```<code>❯ /usr/lib/qt5/bin/uic
/usr/lib/qt5/bin/uic: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
</code>```

I have covered the usual bases. The usual symlinks and the actual library exist:

```<code>❯ ls -l /usr/lib/x86_64-linux-gnu/libQt5Core.*
-rw-r--r-- 1 root root    1210 Aug 10 10:37 /usr/lib/x86_64-linux-gnu/libQt5Core.prl
lrwxrwxrwx 1 root root      20 Aug 10 10:37 /usr/lib/x86_64-linux-gnu/libQt5Core.so -> libQt5Core.so.5.15.3
lrwxrwxrwx 1 root root      20 Aug 10 10:37 /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 -> libQt5Core.so.5.15.3
lrwxrwxrwx 1 root root      20 Aug 10 10:37 /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15 -> libQt5Core.so.5.15.3
-rw-r--r-- 1 root root 5613992 Aug 10 10:37 /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3
❯ file /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=4745cda28772e27ab5124c79ddc26da084782cee, for GNU/Linux 3.17.0, stripped
</code>```

My LD_LIBRARY_PATH looks okay (it's usually more complex, I simplified it for debugging):

```<code>❯ echo $LD_LIBRARY_PATH
/usr/lib/x86_64-linux-gnu
</code>```

Let's look at what ld actually does (the full log is long, therefore I moved it to the end):

```<code>❯ LD_DEBUG=all /usr/lib/qt5/bin/uic
[…]
      6223:     file=libQt5Core.so.5 [0];  needed by /usr/lib/qt5/bin/uic [0]
      6223:     find library=libQt5Core.so.5 [0]; searching
      6223:      search path=/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3:/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2:/usr/lib/x86_64-linux-gnu/tls/haswell/x86_64:/usr/lib/x86_64-linux-gnu/tls/haswell:/usr/lib/x86_64-linux-gnu/tls/x86_64:/usr/lib/x86_64-linux-gnu/tls:/usr/lib/x86_64-linux-gnu/haswell/x86_64:/usr/lib/x86_64-linux-gnu/haswell:/usr/lib/x86_64-linux-gnu/x86_64:/usr/lib/x86_64-linux-gnu          (system search path)
[…]
      6223:       trying file=/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
      6223:      search cache=/etc/ld.so.cache
      6223:      search path=/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3:/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2:/lib/x86_64-linux-gnu/tls/haswell/x86_64:/lib/x86_64-linux-gnu/tls/haswell:/lib/x86_64-linux-gnu/tls/x86_64:/lib/x86_64-linux-gnu/tls:/lib/x86_64-linux-gnu/haswell/x86_64:/lib/x86_64-linux-gnu/haswell:/lib/x86_64-linux-gnu/x86_64:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib/glibc-hwcaps/x86-64-v3:/lib/glibc-hwcaps/x86-64-v2:/lib/tls/haswell/x86_64:/lib/tls/haswell:/lib/tls/x86_64:/lib/tls:/lib/haswell/x86_64:/lib/haswell:/lib/x86_64:/lib:/usr/lib/glibc-hwcaps/x86-64-v3:/usr/lib/glibc-hwcaps/x86-64-v2:/usr/lib/tls/haswell/x86_64:/usr/lib/tls/haswell:/usr/lib/tls/x86_64:/usr/lib/tls:/usr/lib/haswell/x86_64:/usr/lib/haswell:/usr/lib/x86_64:/usr/lib            (system search path)
[…]
      6223:
/usr/lib/qt5/bin/uic: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
</code>```

So, according to ld's debug output, it actually 'tries' a file that is a valid symlink to the library we need. Still it fails to load the library, without any further debug output.

At this point, I'm at a loss. What else can I do to track this down?

Omitted Full ld Debug Log

```<code>❯ LD_DEBUG=all /usr/lib/qt5/bin/uic
      6223:     symbol=__vdso_clock_gettime;  lookup in file=linux-vdso.so.1 [0]
      6223:     binding file linux-vdso.so.1 [0] to linux-vdso.so.1 [0]: normal symbol `__vdso_clock_gettime' [LINUX_2.6]
      6223:     symbol=__vdso_gettimeofday;  lookup in file=linux-vdso.so.1 [0]
      6223:     binding file linux-vdso.so.1 [0] to linux-vdso.so.1 [0]: normal symbol `__vdso_gettimeofday' [LINUX_2.6]
      6223:     symbol=__vdso_time;  lookup in file=linux-vdso.so.1 [0]
      6223:     binding file linux-vdso.so.1 [0] to linux-vdso.so.1 [0]: normal symbol `__vdso_time' [LINUX_2.6]
      6223:     symbol=__vdso_getcpu;  lookup in file=linux-vdso.so.1 [0]
      6223:     binding file linux-vdso.so.1 [0] to linux-vdso.so.1 [0]: normal symbol `__vdso_getcpu' [LINUX_2.6]
      6223:     symbol=__vdso_clock_getres;  lookup in file=linux-vdso.so.1 [0]
      6223:
      6223:     file=libQt5Core.so.5 [0];  needed by /usr/lib/qt5/bin/uic [0]
      6223:     find library=libQt5Core.so.5 [0]; searching
      6223:      search path=/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3:/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2:/usr/lib/x86_64-linux-gnu/tls/haswell/x86_64:/usr/lib/x86_64-linux-gnu/tls/haswell:/usr/lib/x86_64-linux-gnu/tls/x86_64:/usr/lib/x86_64-linux-gnu/tls:/usr/lib/x86_64-linux-gnu/haswell/x86_64:/usr/lib/x86_64-linux-gnu/haswell:/usr/lib/x86_64-linux-gnu/x86_64:/usr/lib/x86_64-linux-gnu          (system search path)
      6223:       trying file=/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/tls/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/tls/haswell/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/tls/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/tls/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/haswell/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
      6223:      search cache=/etc/ld.so.cache
      6223:      search path=/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3:/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2:/lib/x86_64-linux-gnu/tls/haswell/x86_64:/lib/x86_64-linux-gnu/tls/haswell:/lib/x86_64-linux-gnu/tls/x86_64:/lib/x86_64-linux-gnu/tls:/lib/x86_64-linux-gnu/haswell/x86_64:/lib/x86_64-linux-gnu/haswell:/lib/x86_64-linux-gnu/x86_64:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib/glibc-hwcaps/x86-64-v3:/lib/glibc-hwcaps/x86-64-v2:/lib/tls/haswell/x86_64:/lib/tls/haswell:/lib/tls/x86_64:/lib/tls:/lib/haswell/x86_64:/lib/haswell:/lib/x86_64:/lib:/usr/lib/glibc-hwcaps/x86-64-v3:/usr/lib/glibc-hwcaps/x86-64-v2:/usr/lib/tls/haswell/x86_64:/usr/lib/tls/haswell:/usr/lib/tls/x86_64:/usr/lib/tls:/usr/lib/haswell/x86_64:/usr/lib/haswell:/usr/lib/x86_64:/usr/lib            (system search path)
      6223:       trying file=/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/tls/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/tls/haswell/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/tls/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/tls/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/haswell/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
      6223:       trying file=/lib/glibc-hwcaps/x86-64-v3/libQt5Core.so.5
      6223:       trying file=/lib/glibc-hwcaps/x86-64-v2/libQt5Core.so.5
      6223:       trying file=/lib/tls/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/tls/haswell/libQt5Core.so.5
      6223:       trying file=/lib/tls/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/tls/libQt5Core.so.5
      6223:       trying file=/lib/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/haswell/libQt5Core.so.5
      6223:       trying file=/lib/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/libQt5Core.so.5
      6223:       trying file=/usr/lib/glibc-hwcaps/x86-64-v3/libQt5Core.so.5
      6223:       trying file=/usr/lib/glibc-hwcaps/x86-64-v2/libQt5Core.so.5
      6223:       trying file=/usr/lib/tls/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/tls/haswell/libQt5Core.so.5
      6223:       trying file=/usr/lib/tls/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/tls/libQt5Core.so.5
      6223:       trying file=/usr/lib/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/haswell/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/libQt5Core.so.5
      6223:
/usr/lib/qt5/bin/uic: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I'm trying to build a Qt application, which involves a call to uic. I am on Ubuntu 22.04 (on WSL1, though that should hopefully not make a difference). I installed the necessary packages, but I cannot invoke uic:

❯ /usr/lib/qt5/bin/uic
/usr/lib/qt5/bin/uic: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory

I have covered the usual bases. The usual symlinks and the actual library exist:

❯ ls -l /usr/lib/x86_64-linux-gnu/libQt5Core.*
-rw-r--r-- 1 root root    1210 Aug 10 10:37 /usr/lib/x86_64-linux-gnu/libQt5Core.prl
lrwxrwxrwx 1 root root      20 Aug 10 10:37 /usr/lib/x86_64-linux-gnu/libQt5Core.so -> libQt5Core.so.5.15.3
lrwxrwxrwx 1 root root      20 Aug 10 10:37 /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 -> libQt5Core.so.5.15.3
lrwxrwxrwx 1 root root      20 Aug 10 10:37 /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15 -> libQt5Core.so.5.15.3
-rw-r--r-- 1 root root 5613992 Aug 10 10:37 /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3
❯ file /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3
/usr/lib/x86_64-linux-gnu/libQt5Core.so.5.15.3: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=4745cda28772e27ab5124c79ddc26da084782cee, for GNU/Linux 3.17.0, stripped

My LD_LIBRARY_PATH looks okay (it's usually more complex, I simplified it for debugging):

❯ echo $LD_LIBRARY_PATH
/usr/lib/x86_64-linux-gnu

Let's look at what ld actually does (the full log is long, therefore I moved it to the end):

❯ LD_DEBUG=all /usr/lib/qt5/bin/uic
[…]
      6223:     file=libQt5Core.so.5 [0];  needed by /usr/lib/qt5/bin/uic [0]
      6223:     find library=libQt5Core.so.5 [0]; searching
      6223:      search path=/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3:/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2:/usr/lib/x86_64-linux-gnu/tls/haswell/x86_64:/usr/lib/x86_64-linux-gnu/tls/haswell:/usr/lib/x86_64-linux-gnu/tls/x86_64:/usr/lib/x86_64-linux-gnu/tls:/usr/lib/x86_64-linux-gnu/haswell/x86_64:/usr/lib/x86_64-linux-gnu/haswell:/usr/lib/x86_64-linux-gnu/x86_64:/usr/lib/x86_64-linux-gnu          (system search path)
[…]
      6223:       trying file=/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
      6223:      search cache=/etc/ld.so.cache
      6223:      search path=/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3:/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2:/lib/x86_64-linux-gnu/tls/haswell/x86_64:/lib/x86_64-linux-gnu/tls/haswell:/lib/x86_64-linux-gnu/tls/x86_64:/lib/x86_64-linux-gnu/tls:/lib/x86_64-linux-gnu/haswell/x86_64:/lib/x86_64-linux-gnu/haswell:/lib/x86_64-linux-gnu/x86_64:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib/glibc-hwcaps/x86-64-v3:/lib/glibc-hwcaps/x86-64-v2:/lib/tls/haswell/x86_64:/lib/tls/haswell:/lib/tls/x86_64:/lib/tls:/lib/haswell/x86_64:/lib/haswell:/lib/x86_64:/lib:/usr/lib/glibc-hwcaps/x86-64-v3:/usr/lib/glibc-hwcaps/x86-64-v2:/usr/lib/tls/haswell/x86_64:/usr/lib/tls/haswell:/usr/lib/tls/x86_64:/usr/lib/tls:/usr/lib/haswell/x86_64:/usr/lib/haswell:/usr/lib/x86_64:/usr/lib            (system search path)
[…]
      6223:
/usr/lib/qt5/bin/uic: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory

So, according to ld's debug output, it actually 'tries' a file that is a valid symlink to the library we need. Still it fails to load the library, without any further debug output.

At this point, I'm at a loss. What else can I do to track this down?

Omitted Full ld Debug Log

❯ LD_DEBUG=all /usr/lib/qt5/bin/uic
      6223:     symbol=__vdso_clock_gettime;  lookup in file=linux-vdso.so.1 [0]
      6223:     binding file linux-vdso.so.1 [0] to linux-vdso.so.1 [0]: normal symbol `__vdso_clock_gettime' [LINUX_2.6]
      6223:     symbol=__vdso_gettimeofday;  lookup in file=linux-vdso.so.1 [0]
      6223:     binding file linux-vdso.so.1 [0] to linux-vdso.so.1 [0]: normal symbol `__vdso_gettimeofday' [LINUX_2.6]
      6223:     symbol=__vdso_time;  lookup in file=linux-vdso.so.1 [0]
      6223:     binding file linux-vdso.so.1 [0] to linux-vdso.so.1 [0]: normal symbol `__vdso_time' [LINUX_2.6]
      6223:     symbol=__vdso_getcpu;  lookup in file=linux-vdso.so.1 [0]
      6223:     binding file linux-vdso.so.1 [0] to linux-vdso.so.1 [0]: normal symbol `__vdso_getcpu' [LINUX_2.6]
      6223:     symbol=__vdso_clock_getres;  lookup in file=linux-vdso.so.1 [0]
      6223:
      6223:     file=libQt5Core.so.5 [0];  needed by /usr/lib/qt5/bin/uic [0]
      6223:     find library=libQt5Core.so.5 [0]; searching
      6223:      search path=/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3:/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2:/usr/lib/x86_64-linux-gnu/tls/haswell/x86_64:/usr/lib/x86_64-linux-gnu/tls/haswell:/usr/lib/x86_64-linux-gnu/tls/x86_64:/usr/lib/x86_64-linux-gnu/tls:/usr/lib/x86_64-linux-gnu/haswell/x86_64:/usr/lib/x86_64-linux-gnu/haswell:/usr/lib/x86_64-linux-gnu/x86_64:/usr/lib/x86_64-linux-gnu          (system search path)
      6223:       trying file=/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/tls/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/tls/haswell/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/tls/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/tls/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/haswell/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
      6223:      search cache=/etc/ld.so.cache
      6223:      search path=/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3:/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2:/lib/x86_64-linux-gnu/tls/haswell/x86_64:/lib/x86_64-linux-gnu/tls/haswell:/lib/x86_64-linux-gnu/tls/x86_64:/lib/x86_64-linux-gnu/tls:/lib/x86_64-linux-gnu/haswell/x86_64:/lib/x86_64-linux-gnu/haswell:/lib/x86_64-linux-gnu/x86_64:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/lib/glibc-hwcaps/x86-64-v3:/lib/glibc-hwcaps/x86-64-v2:/lib/tls/haswell/x86_64:/lib/tls/haswell:/lib/tls/x86_64:/lib/tls:/lib/haswell/x86_64:/lib/haswell:/lib/x86_64:/lib:/usr/lib/glibc-hwcaps/x86-64-v3:/usr/lib/glibc-hwcaps/x86-64-v2:/usr/lib/tls/haswell/x86_64:/usr/lib/tls/haswell:/usr/lib/tls/x86_64:/usr/lib/tls:/usr/lib/haswell/x86_64:/usr/lib/haswell:/usr/lib/x86_64:/usr/lib            (system search path)
      6223:       trying file=/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v3/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/glibc-hwcaps/x86-64-v2/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/tls/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/tls/haswell/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/tls/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/tls/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/haswell/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/x86_64-linux-gnu/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64-linux-gnu/libQt5Core.so.5
      6223:       trying file=/lib/glibc-hwcaps/x86-64-v3/libQt5Core.so.5
      6223:       trying file=/lib/glibc-hwcaps/x86-64-v2/libQt5Core.so.5
      6223:       trying file=/lib/tls/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/tls/haswell/libQt5Core.so.5
      6223:       trying file=/lib/tls/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/tls/libQt5Core.so.5
      6223:       trying file=/lib/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/haswell/libQt5Core.so.5
      6223:       trying file=/lib/x86_64/libQt5Core.so.5
      6223:       trying file=/lib/libQt5Core.so.5
      6223:       trying file=/usr/lib/glibc-hwcaps/x86-64-v3/libQt5Core.so.5
      6223:       trying file=/usr/lib/glibc-hwcaps/x86-64-v2/libQt5Core.so.5
      6223:       trying file=/usr/lib/tls/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/tls/haswell/libQt5Core.so.5
      6223:       trying file=/usr/lib/tls/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/tls/libQt5Core.so.5
      6223:       trying file=/usr/lib/haswell/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/haswell/libQt5Core.so.5
      6223:       trying file=/usr/lib/x86_64/libQt5Core.so.5
      6223:       trying file=/usr/lib/libQt5Core.so.5
      6223:
/usr/lib/qt5/bin/uic: error while loading shared libraries: libQt5Core.so.5: cannot open shared object file: No such file or directory


问:
txt mime type allows .js or .r files
With the below validation rule, it accepts not only txt files, also allows .js and .r files.

```<code>$request->validate([
    'file' => 'required|mimes:doc,docx,xlx,xlsx,ppt,pptx,csv,pdf,jpg,jpeg,png,gif,odt,ods,odp,txt|max:10240'
]);

</code>```

How can I make it only accept real txt files?

Title: txt mime type allows .js or .r files

Body:
With the below validation rule, it accepts not only txt files, also allows .js and .r files.

$request->validate([
    'file' => 'required|mimes:doc,docx,xlx,xlsx,ppt,pptx,csv,pdf,jpg,jpeg,png,gif,odt,ods,odp,txt|max:10240'
]);

How can I make it only accept real txt files?


问:
Webpack 5 svg xml not working with variable in path
I have a create-react-app test site. I did the following in webpack.config

```<code>test: /\.svg$/,
type: 'asset/source',
</code>```

When I do this I get the svg xml source as intended.

```<code>const logo = require(`./logo.svg`);
console.log("logo: ", logo);
</code>```

But when I do this I get "/static/media/logo.6ce24c58023cc2f8fd88.svg" How do I get this also to work as above.

```<code>const logoName = "logo";
const logo = require(`./${logoName}.svg`);
console.log("logo: ", logo);
</code>```

Body:
I have a create-react-app test site. I did the following in webpack.config

test: /\.svg$/,
type: 'asset/source',

When I do this I get the svg xml source as intended.

const logo = require(`./logo.svg`);
console.log("logo: ", logo);

But when I do this I get "/static/media/logo.6ce24c58023cc2f8fd88.svg" How do I get this also to work as above.

const logoName = "logo";
const logo = require(`./${logoName}.svg`);
console.log("logo: ", logo);


问:
Elasticsearch querying a multi-valued field with position (index)
I have a document with multiple multi-valued fields.
I want to search for documents that have a certain value, on a certain field, in a given position.

For example, I have this document :

```<code> {
    "color": [ "red", "blue" ]
 }
</code>```

How do I write a query to get documents that have the value "Red", in position 0 for field color ?

Body:
I have a document with multiple multi-valued fields.
I want to search for documents that have a certain value, on a certain field, in a given position.

For example, I have this document :

 {
    "color": [ "red", "blue" ]
 }

How do I write a query to get documents that have the value "Red", in position 0 for field color ?


问:
Get the value of a specified field from a keychain with multiple key-value pairs
I want to share my keychain between 2 apps with react-native-keychain:

I have App1 (developed in a programming language) which sets the keychain with multiple key-value pairs.
And I have App2 (react native) where I have to retrieve a specified field from the keychain, but I don't know how.

I found this How to save Multiple Key Values using react-native-keychain? but I cannot use getGenericPassword because the service is already set by the App1 with other value than the key, neither getInternetCredentials because the server is not set by the App1.
What would be the solution for this? Thanks!


问:
Error regarding Uploading an Image in mysql db using SpringBoot and thymleaf
I was trying to add a profile pic when setting up the profile page unfortunately, I couldn't. Here is what I did.

1: Added an image tag and an input of type file

code:

 -- Here instead of name I added th:field="*{profilePic}" still this is not binding with the pojo field

2: Updated Address table with an new Column profilePic with type blob;

3: Added this filed in the Address Entity class and also in Profile Pojo class as Profile Pojo is a simple pojo class which has all the fields in Person and Address Entity. Given inorder to get the data from a form to edit my Profile details

code:    in Address entity class:

```<code>                    @Lob

                    @Column(name = "profilePic",nullable = true)

                     private byte[] profilePic;

         in Profile Pojo :

                     @Lob

                      private byte[] profilePic;
</code>```

4: Controller handling the request @{/updateProfile}" (above form)

code:   @RequestMapping(value = "/updateProfile")

I used the @RequestParam("fileImage") MultipartFile file bcoz I couldn't get the file from profile object passed into this req and cannot use byte()

```<code> public String updateProfile(@RequestParam("fileImage") MultipartFile file, @Valid @ModelAttribute("editprofile") Profile profile, Errors errors,                                 HttpSession httpSession) throws IOException {
</code>```

if(errors.hasErrors()){

return "EditProfile.html";

}

PersonPojo person=(PersonPojo) httpSession.getAttribute("loggedInPerson");         log.info(file.getOriginalFilename().toString());

```<code>     person.setName(profile.getName());
</code>```

person.setEmail(profile.getEmail());

person.setMobileNumber(profile.getMobileNumber());

if(person.getAddress() == null || !(person.getAddress().getAddressId()>0)){

```<code> person.setAddress(new AddressPoJO());

    }
</code>```

person.getAddress().setAddress1(profile.getAddress1());         person.getAddress().setAddress2(profile.getAddress2());

person.getAddress().setCity(profile.getCity());

person.getAddress().setState(profile.getState());         person.getAddress().setZip_code(profile.getZipCode());        person.getAddress().setProfilePic(imageUtil.compressImage(file.getBytes()));       personRepository.save(person);

httpSession.setAttribute("loggedInPerson", person);

return "redirect:/displayProfile";

}

5: Error am getting is when saving the person to repository

in code :  personRepository.save(person);

the error is :

could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet // This is the error showing in the browser (via Global exception handler)

error in console:

Caused by: java.sql.SQLSyntaxErrorException: Unknown column 'addresspoj1_.profile_pic' in 'field list'

and also pointing to the line of code personRepository.save(person);

Note: column name at db is profilePic and in the address and profile pojo its profilePic even its same I given name attr also.

I tried adding the name in the Address and profile pojo as profile_pic as in the error and given name attribute to the field in Address Pojo Entity class. Still not working

Body:
I was trying to add a profile pic when setting up the profile page unfortunately, I couldn't. Here is what I did.

1: Added an image tag and an input of type file

code:

 -- Here instead of name I added th:field="*{profilePic}" still this is not binding with the pojo field

2: Updated Address table with an new Column profilePic with type blob;

3: Added this filed in the Address Entity class and also in Profile Pojo class as Profile Pojo is a simple pojo class which has all the fields in Person and Address Entity. Given inorder to get the data from a form to edit my Profile details

code:    in Address entity class:

                    @Lob

                    @Column(name = "profilePic",nullable = true)

                     private byte[] profilePic;

         in Profile Pojo :

                     @Lob

                      private byte[] profilePic;

4: Controller handling the request @{/updateProfile}" (above form)

code:   @RequestMapping(value = "/updateProfile")

I used the @RequestParam("fileImage") MultipartFile file bcoz I couldn't get the file from profile object passed into this req and cannot use byte()

 public String updateProfile(@RequestParam("fileImage") MultipartFile file, @Valid @ModelAttribute("editprofile") Profile profile, Errors errors,                                 HttpSession httpSession) throws IOException {

if(errors.hasErrors()){

return "EditProfile.html";

}

PersonPojo person=(PersonPojo) httpSession.getAttribute("loggedInPerson");         log.info(file.getOriginalFilename().toString());

     person.setName(profile.getName());

person.setEmail(profile.getEmail());

person.setMobileNumber(profile.getMobileNumber());

if(person.getAddress() == null || !(person.getAddress().getAddressId()>0)){

 person.setAddress(new AddressPoJO());

    }

person.getAddress().setAddress1(profile.getAddress1());         person.getAddress().setAddress2(profile.getAddress2());

person.getAddress().setCity(profile.getCity());

person.getAddress().setState(profile.getState());         person.getAddress().setZip_code(profile.getZipCode());        person.getAddress().setProfilePic(imageUtil.compressImage(file.getBytes()));       personRepository.save(person);

httpSession.setAttribute("loggedInPerson", person);

return "redirect:/displayProfile";

}

5: Error am getting is when saving the person to repository

in code :  personRepository.save(person);

the error is :

could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet // This is the error showing in the browser (via Global exception handler)

error in console:

Caused by: java.sql.SQLSyntaxErrorException: Unknown column 'addresspoj1_.profile_pic' in 'field list'

and also pointing to the line of code personRepository.save(person);

Note: column name at db is profilePic and in the address and profile pojo its profilePic even its same I given name attr also.

I tried adding the name in the Address and profile pojo as profile_pic as in the error and given name attribute to the field in Address Pojo Entity class. Still not working


问:
Change footer size in HTML, displayed in browser control
```<code><!DOCTYPE html>
<html lang="en" direction="ltr">
    <head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>%%%TITLE%%%</title>

            <meta http-equiv="Content-Type" content="text/html">

            <link rel="stylesheet" href="./page-styles-16.css">
                <!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> -->
            <link rel="stylesheet" href="./bootstrap.min.css">
                <!-- Optional theme -->
            <!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css"> -->
            <link rel="stylesheet" href="./bootstrap-theme.min.css">
            <link rel="stylesheet" type="text/css" href="./vw_stylesheet.css">
            <link rel="stylesheet" type="text/css" href="./vw_stylesheet_16.css">
            <link rel="stylesheet" type="text/css" href="./styles-non-responsive.css">

    </head>

<body id="home" class="ind-prt">

    <!--Main Nav-->
    <div class="nav-wrap non-responsive-navigation navbar-fixed-top">
        <div class="head-container">
            <input type="checkbox" id="menustate" class="menustate">
            <nav id="vwMainNav" class="navbar navbar-expand vw-main-nav">

            <a class="navbar-brand" href="https://www.vectorworks.net/">
                <img src="./vw-logo-full.svg"
                class="img-fluid d-none d-lg-block d-xl-block" width="100%" style="max-width:100%; height:auto; width:100% \9;"
                alt="Vectorworks, Inc.">
                </a>

                <div class="navbar" id="vwMainNavCollapse">
                    <ul class="navbar-nav mr-auto">
                        <li class="nav-item">
                            <a class="nav-link" href="%%%PARTNER_PRODUCTS_URL%%%" %%%PARTNER_STYLE%%%>%%%PARTNER_PRODUCTS%%%</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="%%%INSTALLED_PRODUCTS_URL%%%" %%%INSTALLED_STYLE%%%>%%%INSTALLED_PRODUCTS%%%</a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>
    </div>

    <div style="float: right; padding: 20px;">
        %%%SUPPORT_MESSAGE%%%
    </div>

    <!--//Main Nav-->
    <div id="container" class="">

         <!-- Browser notification for ie. -->
        <div id="ie-alert" class="alert alert-dismissible" role="alert" style="background-color:#5391cd;color:#fff;margin-top:-20px;padding-top:5px;padding-bottom:5px;text-align:center;border-radius:0px;display:none;">
            <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
            For an optimized viewing experience, please view the website on Google Chrome or Mozilla Firefox.
        </div>

        <div class="main-container" id="contentWrapper">
            <div class="main wrapper clearfix">

                <div class="row">
                    <div class="col-xs-4">
                    %%%CATEGORIES_LIST%%%
                    </div>

                    <div class="main-content col-xs-8">
                    %%%PRODUCT_DETAILS%%%
                    </div>
                </div>

            </div>
        </div><!-- /.main-container -->

    </div>

<div style="padding: 20px;">
    <p class="copy-right">
    <b>Third Party Content, Products, and Services Disclaimer</b>
    <br>

    <br>
    </p>
</div>

<!--//Footer-->
<footer class="footer non-responsive-footer">
    <div class="main-container ">
        <div class="row footer-bottom">
            <div class="col-xs-6 col-xs-offset-2">
                <p class="links">
                    <a href="https://www.vectorworks.net/legal/privacy">Privacy</a> |
                    <a href="https://www.nemetschek.com/en/">Nemetschek Group</a>
                </p>
                <p class="address">MD 21046, USA | Contact Us: 410.290.5114</p>
                <p class="copy-right">©.</p>
            </div>
        </div>
    </div>
</footer>

</body></html>
</code>```

Hello, Is there a way to decrease the size of the footer of this HTML? Tried changing height in CSS stylesheets, but getting large empty space when displaying the page or even footer not displayed. Thanks in advance for suggestions.

Tried changing height, bottom, position parameters in CSS stylesheets without success.

Body:
<!DOCTYPE html>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>%%%TITLE%%%</title>

            <meta http-equiv="Content-Type" content="text/html">

            <link rel="stylesheet" href="./page-styles-16.css">

            <link rel="stylesheet" href="./bootstrap.min.css">

            <link rel="stylesheet" href="./bootstrap-theme.min.css">
            <link rel="stylesheet" type="text/css" href="./vw_stylesheet.css">
            <link rel="stylesheet" type="text/css" href="./vw_stylesheet_16.css">
            <link rel="stylesheet" type="text/css" href="./styles-non-responsive.css">

            <input type="checkbox" id="menustate" class="menustate">

                            %%%PARTNER_PRODUCTS%%%

                            %%%INSTALLED_PRODUCTS%%%

        %%%SUPPORT_MESSAGE%%%

            <button type="button" class="close" data-dismiss="alert" aria-label="Close">×</button>
            For an optimized viewing experience, please view the website on Google Chrome or Mozilla Firefox.

                    %%%CATEGORIES_LIST%%%

                    %%%PRODUCT_DETAILS%%%

    Third Party Content, Products, and Services Disclaimer

                    Privacy |
                    Nemetschek Group

MD 21046, USA | Contact Us: 410.290.5114

©.

Hello, Is there a way to decrease the size of the footer of this HTML? Tried changing height in CSS stylesheets, but getting large empty space when displaying the page or even footer not displayed. Thanks in advance for suggestions.

Tried changing height, bottom, position parameters in CSS stylesheets without success.


问:
facing issues with Index life cycle policy
I have a indexes which are auto generated in the format filebeat-7.17.8-YYYY.MM.DD.
Created alias for the index

```<code> curl -XPUT /filebeat-7.17.8-*/_alias/filebeat-1'
</code>```

Now when ILM is getting executed i am seeing the below error.

```<code>java.lang.IllegalArgumentException: index name does not match pattern '^.*-\d+$'
</code>```

Body:
I have a indexes which are auto generated in the format filebeat-7.17.8-YYYY.MM.DD.
Created alias for the index

 curl -XPUT /filebeat-7.17.8-*/_alias/filebeat-1'

Now when ILM is getting executed i am seeing the below error.

java.lang.IllegalArgumentException: index name does not match pattern '^.*-\d+$'


问:
Plugin @nomicfoundation/hardhat-toolbox requires the following dependencies to be installed
node version : 16.17.1
npm version : 9.2.0
Documentations say that if you have npm version 7+ you do not need to install any dependencies . Just install the toolbox . But even after having a npm version 9.2.0 it gives me the following error

Error HH801: Plugin @nomicfoundation/hardhat-toolbox requires the following dependencies to be installed: @ethersproject/providers, @nomicfoundation/hardhat-network-helpers, @nomicfoundation/hardhat-chai-matchers, @nomiclabs/hardhat-ethers, @nomiclabs/hardhat-etherscan, @types/chai, @types/mocha, @typechain/ethers-v5, @typechain/hardhat, chai, ethers, hardhat-gas-reporter, solidity-coverage, ts-node, typechain, typescript. Please run: npm install --save-dev "@ethersproject/providers@^5.4.7" "@nomicfoundation/hardhat-network-helpers@^1.0.0" "@nomicfoundation/hardhat-chai-matchers@^1.0.0" "@nomiclabs/hardhat-ethers@^2.0.0" "@nomiclabs/hardhat-etherscan@^3.0.0" "@types/chai@^4.2.0" "@types/mocha@>=9.1.0" "@typechain/ethers-v5@^10.1.0" "@typechain/hardhat@^6.1.2" "chai@^4.2.0" "ethers@^5.4.7" "hardhat-gas-reporter@^1.0.8" "solidity-coverage@^0.8.1" "ts-node@>=8.0.0" "typechain@^8.1.0" "typescript@>=4.5.0"

After installing dependencies it works ig , but why do we need to install if the documentation says you don't need to .


问:
Why does this error occur when I remove these unused variables? Matplotlib animation: self._frames[0].save( > IndexError: list index out of range
I am animating a 360 rotation of a figure to get a full view of the 3D graph, saving it as a GIF. The problem lies within my function that updates the viewing angle of the figure, which is an input to the Matplotlib class FuncAnimation. This is a super simple code, and I'm just trying to understand two lines.

1. Working code:

This first block of code works perfectly and generates this GIF.

```<code>import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D

# Create a 3D figure
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Generate data for the graph
# (replace with your own data)
x = [1, 2, 3]
y = [1, 2, 3]
z = [1, 2, 3]
ax.scatter(x, y, z)

# Function to update the graph for each frame of the animation
def update_graph(num, ax, x, y, z):
    ax.view_init(elev=10., azim=num)

# Create the animation
ani = animation.FuncAnimation(fig, update_graph, frames=360, fargs=(ax, x, y, z), interval=100)

# Save the animation as a GIF
ani.save('animation.gif', writer='imagemagick')
</code>```

2. Not working code:

This second block of code is where my confusion begins. It is exactly the same as the first block of code except the x, y, z variables are removed from the update_graph function and from the fargs input to FuncAnimation. When running this one, I get the error:

```<code>> self._frames[0].save(
> IndexError: list index out of range
</code>```
```<code>import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D

# Create a 3D figure
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Generate data for the graph
# (replace with your own data)
x = [1, 2, 3]
y = [1, 2, 3]
z = [1, 2, 3]
ax.scatter(x, y, z)

# Function to update the graph for each frame of the animation
def update_graph(num, ax):
    ax.view_init(elev=10., azim=num)

# Create the animation
ani = animation.FuncAnimation(fig, update_graph, frames=360, fargs=(ax), interval=100)

# Save the animation as a GIF
ani.save('animation__.gif', writer='imagemagick')
</code>```

3. Working again

If I go further in deleting seemingly unused bits of code by removing the fargs input and leaving num (the frame number) as the only input to the update_graph function, it works again.

```<code>import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D

# Create a 3D figure
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Generate data for the graph
# (replace with your own data)
x = [1, 2, 3]
y = [1, 2, 3]
z = [1, 2, 3]
ax.scatter(x, y, z)

# Function to update the graph for each frame of the animation
def update_graph(num):
    ax.view_init(elev=10., azim=num)

# Create the animation
ani = animation.FuncAnimation(fig, update_graph, frames=360, interval=100)

# Save the animation as a GIF
ani.save('animation__.gif', writer='imagemagick')
</code>```

Question

Why does the code work in cases 1 and 3, but not 2? What does FuncAnimation do with the update_graph function and the fargs input?

Body:
I am animating a 360 rotation of a figure to get a full view of the 3D graph, saving it as a GIF. The problem lies within my function that updates the viewing angle of the figure, which is an input to the Matplotlib class FuncAnimation. This is a super simple code, and I'm just trying to understand two lines.

1. Working code:

This first block of code works perfectly and generates this GIF.

import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D

# Create a 3D figure
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Generate data for the graph
# (replace with your own data)
x = [1, 2, 3]
y = [1, 2, 3]
z = [1, 2, 3]
ax.scatter(x, y, z)

# Function to update the graph for each frame of the animation
def update_graph(num, ax, x, y, z):
    ax.view_init(elev=10., azim=num)

# Create the animation
ani = animation.FuncAnimation(fig, update_graph, frames=360, fargs=(ax, x, y, z), interval=100)

# Save the animation as a GIF
ani.save('animation.gif', writer='imagemagick')

2. Not working code:

This second block of code is where my confusion begins. It is exactly the same as the first block of code except the x, y, z variables are removed from the update_graph function and from the fargs input to FuncAnimation. When running this one, I get the error:

> self._frames[0].save(
> IndexError: list index out of range

import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D

# Create a 3D figure
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Generate data for the graph
# (replace with your own data)
x = [1, 2, 3]
y = [1, 2, 3]
z = [1, 2, 3]
ax.scatter(x, y, z)

# Function to update the graph for each frame of the animation
def update_graph(num, ax):
    ax.view_init(elev=10., azim=num)

# Create the animation
ani = animation.FuncAnimation(fig, update_graph, frames=360, fargs=(ax), interval=100)

# Save the animation as a GIF
ani.save('animation__.gif', writer='imagemagick')

3. Working again

If I go further in deleting seemingly unused bits of code by removing the fargs input and leaving num (the frame number) as the only input to the update_graph function, it works again.

import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D

# Create a 3D figure
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')

# Generate data for the graph
# (replace with your own data)
x = [1, 2, 3]
y = [1, 2, 3]
z = [1, 2, 3]
ax.scatter(x, y, z)

# Function to update the graph for each frame of the animation
def update_graph(num):
    ax.view_init(elev=10., azim=num)

# Create the animation
ani = animation.FuncAnimation(fig, update_graph, frames=360, interval=100)

# Save the animation as a GIF
ani.save('animation__.gif', writer='imagemagick')

Question

Why does the code work in cases 1 and 3, but not 2? What does FuncAnimation do with the update_graph function and the fargs input?


问:
How to searching data using Apollo Client in React JS project?
How to perform text-based searches on the React JS frontend using the Apollo Client ? .

In the server's query specification, I must include a variable for inputting the search:

```<code>query($input: GetAllUserInput) {
        getAllUsers(input: $input) {
            rows {
                username
            }
        }
    }

{ "input":{ "search": "richarddoe" } }
</code>```

On the frontend, I am using useQuery hooks on the main page, then distributing the query results to components such as tables and the search component.

Problem :

However, when performing a search, the input does not save the text, and sometimes the number of items in the table also changes without accurate results.

Total Account in the server :

After Searching :

Question :

What is the correct way to perform item searches according to the specified specification (React, useQuery, Apollo-client)?

page (pengaturanPengguna) :

```<code>function useUserFilter() {
  const [filters, _updateFilter] = useState({
    username: undefined,
  });

  const updateFilter = (filterType, value) => {
    _updateFilter({
      [filterType]: value,
    });
  };

  return {
    models : { filters },
    operations : { updateFilter } ,
  }
}
const PengaturanPengguna = () => {
  // fetching search result
  const [searchValue, setSearchValue] = useState('');
  const { models, operations } = useUserFilter();

  // pagination
  const [currentPage, setCurrentPage] = useState(1);
  const sizeFetchDataPerPage = 10;

  const { data, refetch, loading, error } = useQuery(GET_ALL_USERS, {
    variables: {
      input: {
        size: sizeFetchDataPerPage,
        page: currentPage,
        search: searchValue
      },
    },
  });

  const totalPages = data?.getAllUsers.totalPages;

  useEffect(() => {
    if (data) {
      setCurrentPage(data?.getAllUsers.currentPage);
    }
  }, [data])

  if (loading) return <Loading/>;
  if (error)
    return (
      <p>
        Error... {error.message} {console.log(JSON.stringify(error, null, 2))}{" "}
      </p>
    );

  // refetch data
  const handleRefreshClick = () => {
    refetch();
  };

  // search data
  **const handleChange = (e) => {
      setSearchValue(e.target.value)
  };

  const handleSearch = (e) => {
    e.preventDefault();
    refetch({
      variables: {
        input: {
          size: sizeFetchDataPerPage,
          page: currentPage,
          searchValue: searchValue,
        }
      }
    })
  }**

  return (
    <Container>
      <CardInfo data={data} />
      <Card>
        <Card.Title>
          <span className="base-md text-regular mt-2 std-txt-primary-200">
            Data Pengguna Dashboard
          </span>
        </Card.Title>
        <Card.Body>
          <div className="d-flex justify-content-between">
            <Form inline>
            **<Search onChange={handleChange} onClick={handleSearch}/>
              <Button variant='secondary' onClick={handleRefreshClick} disabled={loading}>{loading ? 'Loading...' : 'Muat Ulang'}</Button>**
            </Form>
            <div>
              <Button variant="success">Daftar Akun</Button>
            </div>
          </div>
          <TableUserInfo data={data} />
          <div className="d-flex justify-content-between">
            <div className="align-self-center">
              <span>Keterangan : </span>
              <StyledDiv>
                <Legend color="#40B4BA" />
                <StyledSpan>Aktif</StyledSpan>
              </StyledDiv>
              <StyledDiv>
                <Legend color="#78909C" />
                <StyledSpan>Tidak Aktif</StyledSpan>
              </StyledDiv>
            </div>
            <PageNavigator
              totalPages={totalPages}
              currentPage={currentPage}
              setCurrentPage={setCurrentPage}
            />
          </div>
        </Card.Body>
      </Card>
    </Container>
  );
};
</code>```

Search Component :

```<code>const Search = ({ onChange, onClick }) => {
    const [search, setSearch] = useState('');

    const handleChange = (e) => {
        setSearch(e.target.value)
    }
    return (
        <Form>
            <InputGroup className="mb-3">
                <Button type="submit" onClick={onClick}><FontAwesomeIcon icon={faSearch} /></Button>
                <FormControl type="string" placeholder="Search..." onChange={onChange} />
            </InputGroup>
        </Form>
    );
  };
</code>```

Table Component :

```<code>const TableUserInfo = ({ data }) => {
  // show modals
  const [showModal, setShowModal] = useState(false);

  // get username as id
  const [username, setUsername] = useState("");

  const handleShowModal = () => setShowModal(true);
  const handleCloseModal = () => setShowModal(false);

  if(!data || !data.getAllUsers || !data.getAllUsers.rows || !data.getAllUsers.rows.length ) {
    return ( <p className="text-center"> Tidak ada data tersedia </p> )
  }

  return (
    <Table responsive>
      <thead>
        <tr>
          <th>No</th>
          <th>Nama Pengguna</th>
          <th>Role Akun</th>
          <th>Email</th>
          <th>Tanggal Daftar</th>
          <th>Status Akun</th>
          <th>Pengaturan</th>
        </tr>
      </thead>
      <tbody>
      {data.getAllUsers.rows.map((user, index) => (
          <tr key={user.username}>
            <td>{index + 1}</td>
            <td>{user.username}</td>
            <td>{user.group_id}</td>
            <td>{user.email}</td>
            <td>{user.created_dtm}</td>
            <td>{user.status}</td>
            <td>
              {user.status !== "ACTIVE"
                ? [
                    <Button key="Aktifkan Akun" className="d-block mb-2 text-white bg-secondary w-100">
                      Aktifkan Akun
                    </Button>,
                    <Button
                      key="Ganti Role Akun"
                      className="d-block mb-2 btn-block btn-sm w-100"
                      disabled
                    >
                      Ganti Role Akun
                    </Button>,
                  ]
                : user.group_id === "admin"
                ? [
                    <Button key="Ganti Role Akun" variant="outline-success" className="d-block btn-sm mb-2 w-100">
                      Ganti Role Akun
                    </Button>,
                  ]
                : [
                    <Button key="Pilih Role Akun" className="d-block btn-sm mb-2 w-100">
                      Pilih Role Akun
                    </Button>,
                  ]}
              <Button key="Edit" variant="outline-primary" onClick={() => { setShowModal(true); setUsername(user.username); }} className="d-block btn-block btn-sm mb-2 w-100">
                Edit
              </Button>
              <Button key="Hapus" variant="outline-danger" className="d-block btn-block btn-sm mb-2 w-100">
                Hapus
              </Button>
            </td>
          </tr>
        ))}
      </tbody>
      {showModal ? (
        <ModalEdit
          show={handleShowModal}
          onClose={handleCloseModal}
          username={username}
        />
      ) : null}
    </Table>
  );
};
</code>```

Body:
How to perform text-based searches on the React JS frontend using the Apollo Client ? .

In the server's query specification, I must include a variable for inputting the search:

query($input: GetAllUserInput) {
        getAllUsers(input: $input) {
            rows {
                username
            }
        }
    }

{ "input":{ "search": "richarddoe" } }

On the frontend, I am using useQuery hooks on the main page, then distributing the query results to components such as tables and the search component.

Problem :

However, when performing a search, the input does not save the text, and sometimes the number of items in the table also changes without accurate results.

Total Account in the server :

After Searching :

Question :

What is the correct way to perform item searches according to the specified specification (React, useQuery, Apollo-client)?

page (pengaturanPengguna) :

function useUserFilter() {
  const [filters, _updateFilter] = useState({
    username: undefined,
  });

  const updateFilter = (filterType, value) => {
    _updateFilter({
      [filterType]: value,
    });
  };

  return {
    models : { filters },
    operations : { updateFilter } ,
  }
}
const PengaturanPengguna = () => {
  // fetching search result
  const [searchValue, setSearchValue] = useState('');
  const { models, operations } = useUserFilter();

  // pagination
  const [currentPage, setCurrentPage] = useState(1);
  const sizeFetchDataPerPage = 10;

  const { data, refetch, loading, error } = useQuery(GET_ALL_USERS, {
    variables: {
      input: {
        size: sizeFetchDataPerPage,
        page: currentPage,
        search: searchValue
      },
    },
  });

  const totalPages = data?.getAllUsers.totalPages;

  useEffect(() => {
    if (data) {
      setCurrentPage(data?.getAllUsers.currentPage);
    }
  }, [data])

  if (loading) return <Loading/>;
  if (error)
    return (

        Error... {error.message} {console.log(JSON.stringify(error, null, 2))}{" "}

    );

  // refetch data
  const handleRefreshClick = () => {
    refetch();
  };

  // search data
  **const handleChange = (e) => {
      setSearchValue(e.target.value)
  };

  const handleSearch = (e) => {
    e.preventDefault();
    refetch({
      variables: {
        input: {
          size: sizeFetchDataPerPage,
          page: currentPage,
          searchValue: searchValue,
        }
      }
    })
  }**

  return (
    <Container>
      <CardInfo data={data} />
      <Card>
        <Card.Title>

            Data Pengguna Dashboard

        </Card.Title>
        <Card.Body>

            <Form inline>
            **<Search onChange={handleChange} onClick={handleSearch}/>
              <Button variant='secondary' onClick={handleRefreshClick} disabled={loading}>{loading ? 'Loading...' : 'Muat Ulang'}</Button>**
            </Form>

              <Button variant="success">Daftar Akun</Button>

          <TableUserInfo data={data} />

              Keterangan :

              </StyledDiv>

              </StyledDiv>

            <PageNavigator
              totalPages={totalPages}
              currentPage={currentPage}
              setCurrentPage={setCurrentPage}
            />

        </Card.Body>
      </Card>
    </Container>
  );
};

Search Component :

const Search = ({ onChange, onClick }) => {
    const [search, setSearch] = useState('');

    const handleChange = (e) => {
        setSearch(e.target.value)
    }
    return (
        <Form>
            <InputGroup className="mb-3">
                <Button type="submit" onClick={onClick}><FontAwesomeIcon icon={faSearch} /></Button>
                <FormControl type="string" placeholder="Search..." onChange={onChange} />
            </InputGroup>
        </Form>
    );
  };

Table Component :

const TableUserInfo = ({ data }) => {
  // show modals
  const [showModal, setShowModal] = useState(false);

  // get username as id
  const [username, setUsername] = useState("");

  const handleShowModal = () => setShowModal(true);
  const handleCloseModal = () => setShowModal(false);

  if(!data || !data.getAllUsers || !data.getAllUsers.rows || !data.getAllUsers.rows.length ) {
    return (
 Tidak ada data tersedia
 )
  }

  return (

          No
          Nama Pengguna
          Role Akun
          Email
          Tanggal Daftar
          Status Akun
          Pengaturan

      {data.getAllUsers.rows.map((user, index) => (

            {index + 1}
            {user.username}
            {user.group_id}
            {user.email}
            {user.created_dtm}
            {user.status}

              {user.status !== "ACTIVE"
                ? [
                    <Button key="Aktifkan Akun" className="d-block mb-2 text-white bg-secondary w-100">
                      Aktifkan Akun
                    </Button>,
                    <Button
                      key="Ganti Role Akun"
                      className="d-block mb-2 btn-block btn-sm w-100"
                      disabled
                    >
                      Ganti Role Akun
                    </Button>,
                  ]
                : user.group_id === "admin"
                ? [
                    <Button key="Ganti Role Akun" variant="outline-success" className="d-block btn-sm mb-2 w-100">
                      Ganti Role Akun
                    </Button>,
                  ]
                : [
                    <Button key="Pilih Role Akun" className="d-block btn-sm mb-2 w-100">
                      Pilih Role Akun
                    </Button>,
                  ]}
              <Button key="Edit" variant="outline-primary" onClick={() => { setShowModal(true); setUsername(user.username); }} className="d-block btn-block btn-sm mb-2 w-100">
                Edit
              </Button>
              <Button key="Hapus" variant="outline-danger" className="d-block btn-block btn-sm mb-2 w-100">
                Hapus
              </Button>

        ))}

      {showModal ? (
        <ModalEdit
          show={handleShowModal}
          onClose={handleCloseModal}
          username={username}
        />
      ) : null}

  );
};


问:
KQL sentinel - query a user log on/off activity for the month
I'm new to KQL and I'm trying to pull user sign in data for the month, currently this is the query I've used to pull data for a specific day. How can I get all the sign in/off times for the month, I imagine the summarize operator is my problem as its grouping the rest of the data I need but unsure on the best way to go about retrieving it.

```<code>SecurityEvent
| where TimeGenerated > startofday(ago(30d))
| where TimeGenerated < endofday(ago(15h))
| where EventID in (4624, 4625, 4634)
| where TargetUserName contains "Johnsmith"
| summarize StartTime = min(TimeGenerated), EndTimec = max(TimeGenerated), count() by LogonTypeName, Account, Activity
| extend timestamp = StartTime
| extend timestamp = EndTimec
</code>```

Here is the results from the above query with the account column removed.

LogonTypeName
Activity
StartTime [UTC]
EndTimec [UTC]
count_
timestamp [UTC]

3 - Network
4624 - An account was successfully logged on.
1/10/2023, 7:57:19.026 AM
1/10/2023, 3:57:34.764 PM
208
1/10/2023, 3:57:34.764 PM

3 - Network
4634 - An account was logged off.
1/10/2023, 7:57:19.066 AM
1/10/2023, 3:57:34.831 PM
208
1/10/2023, 3:57:34.831 PM

I'm trying to pull user data of the time they sign in and sign off everyday that month for auditing purposes. The issue is the above query is only returning yesterday times and not the other 29 days of the month.

Apologies if the formatting for this question isn't perfect.

Body:
I'm new to KQL and I'm trying to pull user sign in data for the month, currently this is the query I've used to pull data for a specific day. How can I get all the sign in/off times for the month, I imagine the summarize operator is my problem as its grouping the rest of the data I need but unsure on the best way to go about retrieving it.

SecurityEvent
| where TimeGenerated > startofday(ago(30d))
| where TimeGenerated < endofday(ago(15h))
| where EventID in (4624, 4625, 4634)
| where TargetUserName contains "Johnsmith"
| summarize StartTime = min(TimeGenerated), EndTimec = max(TimeGenerated), count() by LogonTypeName, Account, Activity
| extend timestamp = StartTime
| extend timestamp = EndTimec

Here is the results from the above query with the account column removed.

LogonTypeName
Activity
StartTime [UTC]
EndTimec [UTC]
count_
timestamp [UTC]

3 - Network
4624 - An account was successfully logged on.
1/10/2023, 7:57:19.026 AM
1/10/2023, 3:57:34.764 PM
208
1/10/2023, 3:57:34.764 PM

3 - Network
4634 - An account was logged off.
1/10/2023, 7:57:19.066 AM
1/10/2023, 3:57:34.831 PM
208
1/10/2023, 3:57:34.831 PM

I'm trying to pull user data of the time they sign in and sign off everyday that month for auditing purposes. The issue is the above query is only returning yesterday times and not the other 29 days of the month.

Apologies if the formatting for this question isn't perfect.


问:
Scrape a dynamic element on website for several URLs
I want to scrape the content of a single span element on a website.
The content is loaded dynamically so my attempt to use Google sheets didn't work (only static content can be scraped through importxml there).

I want to do this for about 2000 pages that all have the same url and only have a different url parameter each.

Best case would be that I have a spreadsheet afterwards that has the columns "URL parameter" and "span content".


问:
Problem with Bind mount on Azure Web App Service for Containers with docker-compose
I have a problem with starting my_app on Azure Web App Service for containers. I followed few tutorials and checked this amswer but I still get the following error:

```<code>ERROR - Exception in multi-container config parsing: YamlException: (Line: 22, Col: 9, Idx: 498) - (Line: 22, Col: 37, Idx: 526): Bind mount must start with ${WEBAPP_STORAGE_HOME}.
</code>```

My docker-compose file looks like this:

```<code>version: '3'

services:
  db:
    container_name: my_app_django_db
    image: postgres:14.5-alpine
    volumes:
        - postgres_data:/var/lib/postgresql/data/
    networks:
      - my_app_network
    env_file:
      - ./.env.prod

  app:
    container_name: my_app_django_app
    build:
      context: ./backend
      dockerfile: Dockerfile.prod
    restart: always
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - ./backend/:/usr/src/backend/
    networks:
      - my_app_network
    ports:
      - 8000:8000
    env_file:
      - ./.env.prod
    depends_on:
      - db

  react:
    container_name: my_app_react_app
    build:
      context: ./frontend
      dockerfile: Dockerfile.prod
    restart: always
    command: npm start
    volumes:
      - ./frontend/:/usr/src/frontend/
    networks:
      - my_app_network
    ports:
      - 3000:3000
    env_file:
      - ./.env.prod
    depends_on:
      - app

  redis:
    container_name: my_app_redis
    image: redis:7-alpine
    ports:
      - 6379:6379
    networks:
      - my_app_network

  celery_worker:
    container_name: my_app_celery_worker
    restart: always
    build:
      context: ./backend
    command: celery -A my_app_settings worker --loglevel=info --logfile=logs/celery.log
    volumes:
      - ./backend:/usr/src/backend
    networks:
      - my_app_network
    env_file:
      - ./.env.prod
    depends_on:
      - db
      - redis
      - app

  celery-beat:
    container_name: my_app_celery_beat
    build: ./backend
    command: celery -A my_app_settings beat -l info
    volumes:
      - ./backend:/usr/src/backend
    networks:
      - my_app_network
    env_file:
      - ./.env.prod
    depends_on:
      - db
      - redis
      - app

  nginx:
    container_name: my_app_nginx
    restart: always
    build: ./azure/nginx

    ports:
      - "8080:8080"
    networks:
      - my_app_network
    volumes:
      - static_volume:/home/app/web/staticfiles
      - media_volume:/home/app/web/mediafiles
    depends_on:
      - app

volumes:
  postgres_data:
  static_volume:
  media_volume:

networks:
  my_app_network:
    driver: bridge
</code>```

My path mapping in App Service configuration looks like this:

It seems that error (lie 22) refers to volume in postgres:14.5-alpine but I don't know how to fix this error.

Body:
I have a problem with starting my_app on Azure Web App Service for containers. I followed few tutorials and checked this amswer but I still get the following error:

ERROR - Exception in multi-container config parsing: YamlException: (Line: 22, Col: 9, Idx: 498) - (Line: 22, Col: 37, Idx: 526): Bind mount must start with ${WEBAPP_STORAGE_HOME}.

My docker-compose file looks like this:

version: '3'

services:
  db:
    container_name: my_app_django_db
    image: postgres:14.5-alpine
    volumes:
        - postgres_data:/var/lib/postgresql/data/
    networks:
      - my_app_network
    env_file:
      - ./.env.prod

  app:
    container_name: my_app_django_app
    build:
      context: ./backend
      dockerfile: Dockerfile.prod
    restart: always
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - ./backend/:/usr/src/backend/
    networks:
      - my_app_network
    ports:
      - 8000:8000
    env_file:
      - ./.env.prod
    depends_on:
      - db

  react:
    container_name: my_app_react_app
    build:
      context: ./frontend
      dockerfile: Dockerfile.prod
    restart: always
    command: npm start
    volumes:
      - ./frontend/:/usr/src/frontend/
    networks:
      - my_app_network
    ports:
      - 3000:3000
    env_file:
      - ./.env.prod
    depends_on:
      - app

  redis:
    container_name: my_app_redis
    image: redis:7-alpine
    ports:
      - 6379:6379
    networks:
      - my_app_network

  celery_worker:
    container_name: my_app_celery_worker
    restart: always
    build:
      context: ./backend
    command: celery -A my_app_settings worker --loglevel=info --logfile=logs/celery.log
    volumes:
      - ./backend:/usr/src/backend
    networks:
      - my_app_network
    env_file:
      - ./.env.prod
    depends_on:
      - db
      - redis
      - app

  celery-beat:
    container_name: my_app_celery_beat
    build: ./backend
    command: celery -A my_app_settings beat -l info
    volumes:
      - ./backend:/usr/src/backend
    networks:
      - my_app_network
    env_file:
      - ./.env.prod
    depends_on:
      - db
      - redis
      - app

  nginx:
    container_name: my_app_nginx
    restart: always
    build: ./azure/nginx

    ports:
      - "8080:8080"
    networks:
      - my_app_network
    volumes:
      - static_volume:/home/app/web/staticfiles
      - media_volume:/home/app/web/mediafiles
    depends_on:
      - app

volumes:
  postgres_data:
  static_volume:
  media_volume:

networks:
  my_app_network:
    driver: bridge

My path mapping in App Service configuration looks like this:

It seems that error (lie 22) refers to volume in postgres:14.5-alpine but I don't know how to fix this error.


问:
CUDA "out of memory" with plenty of memory in the VRAM
I'm having a crash in my CUDA code that I do not understand: it tells me that it's running out of memory when there is plenty left annd I'm not allocating very huge arrays.

Here is the code:

```<code>#include <iostream>

#define CHECK_CUDA_ERROR(val) check((val), #val, __FILE__, __LINE__)
template <typename T>
__device__ void check(T err, const char* const func, const char* const file, const int line) {
    if(err != cudaSuccess) {
        printf("CUDA Runtime Error at: %s : line %d\n", file, line);
        printf("%s\n", cudaGetErrorString(err));
    }
}

__device__ int* generate_spike_train() {
    const int n = 70000;
    int* spike_train;

    CHECK_CUDA_ERROR(cudaMalloc(&spike_train, n * sizeof(int))); // 70,000 * 4 = 0.267 MB.

    // Do stuff;

    return spike_train;
}

__global__ void run_simulations() {
    int* spike_train = generate_spike_train();

    // Do stuff.

    cudaFree(spike_train);
}

int main(int argc, char *argv[]) {
    const float to_MB = 1024.0f * 1024.0f;
    const int n_blocks = 30;
    const int n_threads = 2;
    size_t free, total;

    cudaMemGetInfo(&free, &total);
    printf("Memory left: %f / %f MB\n", free / to_MB, total / to_MB);

    run_simulations<<<n_blocks, n_threads>>>();
    cudaDeviceSynchronize();

    cudaMemGetInfo(&free, &total);
    printf("Memory left: %f / %f MB\n", free / to_MB, total / to_MB);
}
</code>```

I'm compiling and running the code using:

```<code>$ nvcc -rdc=true test.cu
$ ./a.out
Memory left: 7791.625000 / 7982.437500 MB
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
Memory left: 7781.625000 / 7982.437500 MB
</code>```

As you can see, I have plenty of VRAM (8 GB) and I'm only trying to allocate 16 MB total (counting all blocks and all threads).

I'm running on an RTX 2080 with CUDA 11.6 (drivers 520.61.05) on Ubuntu 20.04 LTS.

Thanks!

Body:
I'm having a crash in my CUDA code that I do not understand: it tells me that it's running out of memory when there is plenty left annd I'm not allocating very huge arrays.

Here is the code:

#include <iostream>

#define CHECK_CUDA_ERROR(val) check((val), #val, __FILE__, __LINE__)
template <typename T>
__device__ void check(T err, const char* const func, const char* const file, const int line) {
    if(err != cudaSuccess) {
        printf("CUDA Runtime Error at: %s : line %d\n", file, line);
        printf("%s\n", cudaGetErrorString(err));
    }
}

__device__ int* generate_spike_train() {
    const int n = 70000;
    int* spike_train;

    CHECK_CUDA_ERROR(cudaMalloc(&spike_train, n * sizeof(int))); // 70,000 * 4 = 0.267 MB.

    // Do stuff;

    return spike_train;
}

__global__ void run_simulations() {
    int* spike_train = generate_spike_train();

    // Do stuff.

    cudaFree(spike_train);
}

int main(int argc, char *argv[]) {
    const float to_MB = 1024.0f * 1024.0f;
    const int n_blocks = 30;
    const int n_threads = 2;
    size_t free, total;

    cudaMemGetInfo(&free, &total);
    printf("Memory left: %f / %f MB\n", free / to_MB, total / to_MB);

    run_simulations<<<n_blocks, n_threads>>>();
    cudaDeviceSynchronize();

    cudaMemGetInfo(&free, &total);
    printf("Memory left: %f / %f MB\n", free / to_MB, total / to_MB);
}

I'm compiling and running the code using:

$ nvcc -rdc=true test.cu
$ ./a.out
Memory left: 7791.625000 / 7982.437500 MB
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
CUDA Runtime Error at: test.cu : line 18
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
out of memory
Memory left: 7781.625000 / 7982.437500 MB

As you can see, I have plenty of VRAM (8 GB) and I'm only trying to allocate 16 MB total (counting all blocks and all threads).

I'm running on an RTX 2080 with CUDA 11.6 (drivers 520.61.05) on Ubuntu 20.04 LTS.

Thanks!


问:
Autosave excel without opening the document
I have a daily meeting document that takes data from other excel documents.
This daily meeting document is synced to a tv screen so i want this document
to automaticly save every 10 minutes. Is that possibly with scripts in "automate" ?


问:
Client Certificate does not work on .NET 6.0
EDIT2: It also works with .NET 7.0, straight on my mac machine... I can't upgrade to 7.0 though, so I am still stuck...

EDIT: Running the exact same code on a docker container with .NET 6 also works... Could this problem only happens on MacOS ?

I am facing a weird issue in which I am trying to make an https call with a client certificate authentication and I am getting a "400 The SSL certificate error" response from the server.

The weirdness is that running the EXACT same code with .NET Core 3.1 simply works...

Has anyone seen anything like that?

I wrote a simplified version of my code, but it reproduces the problem perfectly:

const string url = "https://myservice";
const string path = "myendpoint";
var fileData = File.ReadAllBytes("/some/certificate.p12");
var certificate = new X509Certificate2(fileData, "the_cert_password");
var handler = new HttpClientHandler
{
    ClientCertificateOptions = ClientCertificateOption.Manual
};
handler.ClientCertificates.Add(certificate);

var httpClient = new HttpClient(handler)
{
    BaseAddress = new Uri(url)
};

var httpMessage = new HttpRequestMessage
{
    Content = new StringContent("{}", Encoding.UTF8, "application/json"),
    Method = HttpMethod.Post,
    RequestUri = new Uri($"{httpClient.BaseAddress}{path}")
};
var result = await httpClient.SendAsync(httpMessage);
var content = await result.Content.ReadAsStringAsync();

Console.WriteLine(content);
```


问:
unable to execute sql query in teradata using teradatasql python module
I want to run a SQL query in Teradata using the Teradata SQL python module. I am getting the below error.

Code:

```<code>import teradatasql
conn='{"host":"hostname","logmech":"KRB5"}'
cxnn=teradatasql.connect(conn)
</code>```

Body:
I want to run a SQL query in Teradata using the Teradata SQL python module. I am getting the below error.

Code:

import teradatasql
conn='{"host":"hostname","logmech":"KRB5"}'
cxnn=teradatasql.connect(conn)


问:
How to integrate JIRA with Azure Translator to translate jira issues, comments
As there is google translator already present. But for security reason its not safe to integrate with JIRA. So I wanted to integrate JIRA with Azure translator. Is there any way to integrate both by using any external plugin Or do I refer any source code for the same.

Need suggestions for the same


问:
curve_fit() producing flat line
I'm trying to fit a Cauchy distribution to 2D data stored in a .csv file. I can't for the life of me work out why I just get a flat line for the distribution.

Any help getting the distribution to fit the data is much appreciated!

Code is as follows:

```<code>from scipy.stats import cauchy
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
import pandas as pd

def cauchy_pdf(x, loc, scale):
    return cauchy.pdf(x, loc, scale)

data = pd.read_csv('../camera_array_1.csv')
x = data['Distance_pixels'].values
y = data['Gray_Value'].values

popt, pcov = curve_fit(cauchy_pdf, x, y)

loc, scale = popt

plt.scatter(x, y, label='Data')
plt.plot(x, cauchy_pdf(x, *popt), 'r-')
plt.show()
</code>```

.csv file

Title: curve_fit() producing flat line

Body:
I'm trying to fit a Cauchy distribution to 2D data stored in a .csv file. I can't for the life of me work out why I just get a flat line for the distribution.

Any help getting the distribution to fit the data is much appreciated!

Code is as follows:

from scipy.stats import cauchy
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
import pandas as pd

def cauchy_pdf(x, loc, scale):
    return cauchy.pdf(x, loc, scale)

data = pd.read_csv('../camera_array_1.csv')
x = data['Distance_pixels'].values
y = data['Gray_Value'].values

popt, pcov = curve_fit(cauchy_pdf, x, y)

loc, scale = popt

plt.scatter(x, y, label='Data')
plt.plot(x, cauchy_pdf(x, *popt), 'r-')
plt.show()

.csv file


问:
How to call Google translate dropdown on change programmatically
I have created simple google translate dropdown for my website used this solution from w3schools https://www.w3schools.com/howto/howto_google_translate.asp this is working fine.

I have tried solution mentioned in the https://www.w3schools.com/howto/howto_google_translate.asp it's working fine Image from my site . Now I want to call the onchange event of this dropdown and call translate api for custom selected language programmatically. please suggest some solution for that Thanks in advance


问:
Does the initalization vector need to be kept, to decrypt data?
I am trying to understand how I can encrypt a string with a passphrase, save it (for instance in a file) and decrypt it later with a different application.

I am following this example: https://attacomsian.com/blog/nodejs-encrypt-decrypt-data#encrypt-and-decrypt-text

I am confused about the "initialization vector". Does the application that decrypts the data need the same vector? So does it need to be stored with the data?

For example if I do this:

```<code>const algorithm = 'aes-256-ctr'
const secretKey = 'vOVH6sdmpNWjRRIqCc7rdxs01lwHzfr3'

const encrypt = text => {
  const iv = crypto.randomBytes(16)

  const cipher = crypto.createCipheriv(algorithm, secretKey, iv)

  const encrypted = Buffer.concat([cipher.update(text), cipher.final()])

  return {
    iv: iv.toString('hex'),
    content: encrypted.toString('hex')
  }
}

const encryptedContent=encrypt("somethingsecret").content
writeFileSync("somefile.txt", encryptedContent))
</code>```

it will save the encrypted data to "somefile.txt".

Is it then possible for a different application to decrypt the "somefile.txt" contents, without the initialization vector that was created during the encryption?

Body:
I am trying to understand how I can encrypt a string with a passphrase, save it (for instance in a file) and decrypt it later with a different application.

I am following this example: https://attacomsian.com/blog/nodejs-encrypt-decrypt-data#encrypt-and-decrypt-text

I am confused about the "initialization vector". Does the application that decrypts the data need the same vector? So does it need to be stored with the data?

For example if I do this:

const algorithm = 'aes-256-ctr'
const secretKey = 'vOVH6sdmpNWjRRIqCc7rdxs01lwHzfr3'

const encrypt = text => {
  const iv = crypto.randomBytes(16)

  const cipher = crypto.createCipheriv(algorithm, secretKey, iv)

  const encrypted = Buffer.concat([cipher.update(text), cipher.final()])

  return {
    iv: iv.toString('hex'),
    content: encrypted.toString('hex')
  }
}

const encryptedContent=encrypt("somethingsecret").content
writeFileSync("somefile.txt", encryptedContent))

it will save the encrypted data to "somefile.txt".

Is it then possible for a different application to decrypt the "somefile.txt" contents, without the initialization vector that was created during the encryption?


问:
How to send a push notification to pwa from a nodejs server?
I have a working PWA application and i have tried integrating push notifications to it which worked. But those notifications happened totally in the front end, a user has to click a button and a push notifications would show up.

In my application i have a cronjob that runs every night to check if certain things are updated. If so i want to send a push notification to a user to notify them.

But i cannot find any information regarding this subject so I'm thinking it's not possible since the nodejs server doesn't have a connection to the PWA. Is there something I'm overlooking on my approach or is it simply not possible?


问:
Is it possible to mount my Google Drive in Colab and authenticate to Google with GSpread in one step?
I am trying to make in one step this two actions in my Google Colab: mount my drive and authorize with GSpread to use Google Sheets which are also in my drive.

I don't understand why it is necessary to authorize the access to my drive twice but I haven't found any other way to do it simpler

This is my approach to the problem but this makes my authorize twice

```<code>from google.colab import drive
import pandas as pd
import numpy as np
import requests
import json
import matplotlib.pyplot as plt
import numpy as np

from google.colab import auth
import gspread
from google.auth import default

drive.mount('/content/gdrive')

#autenticating to google
auth.authenticate_user()
creds, _ = default()
gc = gspread.authorize(creds)
</code>```

Body:
I am trying to make in one step this two actions in my Google Colab: mount my drive and authorize with GSpread to use Google Sheets which are also in my drive.

I don't understand why it is necessary to authorize the access to my drive twice but I haven't found any other way to do it simpler

This is my approach to the problem but this makes my authorize twice

from google.colab import drive
import pandas as pd
import numpy as np
import requests
import json
import matplotlib.pyplot as plt
import numpy as np

from google.colab import auth
import gspread
from google.auth import default

drive.mount('/content/gdrive')

#autenticating to google
auth.authenticate_user()
creds, _ = default()
gc = gspread.authorize(creds)


问:
Inject a Nest.js provider/service in registerAs config
I included in a Nest.js config registerAs, an implementation to access AWS secrets

```<code>import {
  GetSecretValueCommand,
  SecretsManagerClient,
} from "@aws-sdk/client-secrets-manager";
import { registerAs } from "@nestjs/config";

export default registerAs("jwt", async () => {
  const secretName = "secretName";

  const client = new SecretsManagerClient({
    region: "region",
  });

  let jwtSecret = "";

  await client
    .send(
      new GetSecretValueCommand({
        SecretId: secretName,
        VersionStage: "AWSCURRENT",
      })
    )
    .then((response) => {
      const secretObj = JSON.parse(response.SecretString);
      jwtSecret = secretObj["SECRET"];
    })
    .catch((e) => {
      jwtSecret = "";
    });

  return {
    secret: process.env.JWT_SECRET || jwtSecret,
    audience: process.env.JWT_TOKEN_AUDIENCE || "localhost",
    issuer: process.env.JWT_TOKEN_ISSUER || "localhost",
    accessTokenTtl: parseInt(process.env.JWT_ACCESS_TOKEN_TTL ?? "3600", 10),
    refreshTokenTtl: parseInt(process.env.JWT_REFRESH_TOKEN_TTL ?? "86400", 10),
  };
});
</code>```

I extracted the code before the return clause in a separate Nest.js service called SecretService to be reusable from other points in the code. Unfortunately, I don't understand how to inject the SecretService inside the registerAs function.
Could you help me with that?

Body:
I included in a Nest.js config registerAs, an implementation to access AWS secrets

import {
  GetSecretValueCommand,
  SecretsManagerClient,
} from "@aws-sdk/client-secrets-manager";
import { registerAs } from "@nestjs/config";

export default registerAs("jwt", async () => {
  const secretName = "secretName";

  const client = new SecretsManagerClient({
    region: "region",
  });

  let jwtSecret = "";

  await client
    .send(
      new GetSecretValueCommand({
        SecretId: secretName,
        VersionStage: "AWSCURRENT",
      })
    )
    .then((response) => {
      const secretObj = JSON.parse(response.SecretString);
      jwtSecret = secretObj["SECRET"];
    })
    .catch((e) => {
      jwtSecret = "";
    });

  return {
    secret: process.env.JWT_SECRET || jwtSecret,
    audience: process.env.JWT_TOKEN_AUDIENCE || "localhost",
    issuer: process.env.JWT_TOKEN_ISSUER || "localhost",
    accessTokenTtl: parseInt(process.env.JWT_ACCESS_TOKEN_TTL ?? "3600", 10),
    refreshTokenTtl: parseInt(process.env.JWT_REFRESH_TOKEN_TTL ?? "86400", 10),
  };
});

I extracted the code before the return clause in a separate Nest.js service called SecretService to be reusable from other points in the code. Unfortunately, I don't understand how to inject the SecretService inside the registerAs function.
Could you help me with that?


问:
How to return value after async function done
I'm having problem with async function, in this senario, i want to return true outside async function after it run successful, but i still stuck, here is example of that

const returnSomethingIfHaveData = () => {
  const someAsyncFunc = async () => {
    try {
      const data = await fetch('https://dummyjson.com/products/1').then(()=>true)
      return data
    } catch (e) {
      console.log(e);
    }
  };
  if(someAsyncFunc().then(data=>data)===true) return true
  else if(someAsyncFunc().then(data=>data)===false) return false

};
console.log(returnSomethingIfHaveData()) // ==> always return nothing
```

Why it always false, and how to make it right? I mean it return true after it finish or i mean how to make it wait until api call done, mean how to make it return true always?

Body:
I'm having problem with async function, in this senario, i want to return true outside async function after it run successful, but i still stuck, here is example of that

const returnSomethingIfHaveData = () => {
  const someAsyncFunc = async () => {
    try {
      const data = await fetch('https://dummyjson.com/products/1').then(()=>true)
      return data
    } catch (e) {
      console.log(e);
    }
  };
  if(someAsyncFunc().then(data=>data)===true) return true
  else if(someAsyncFunc().then(data=>data)===false) return false

};
console.log(returnSomethingIfHaveData()) // ==> always return nothing

Why it always false, and how to make it right? I mean it return true after it finish or i mean how to make it wait until api call done, mean how to make it return true always?


问:
Lucas Lehmer C implementation up to M31 without BIGINT
I started learning C yesterday and I've literally just learned the basic data types (char, int, float), while loops, operators and printing.

Before I learn anything more, I wanted to set myself a mathematical challenge as the above should be enough to do elementary arithmetic. These are the constraints I'm working within - I'm well aware there are other ways to do the problem, like I could create an array to store all of the values of the Lucas Lehmer sequence, or I could use BIGINT etc. But I'm trying to use just what I've learned so far.

It just so happens that the largest possible INT value in C is 2^31-1, which is also a Mersenne Prime, M31. So I'd like to write a function which tests all candidate Mersennes up to M31.

This was my initial stab at it:

```<code>#include <stdio.h>
#include <stdbool.h>

int main() {
    int p = 3;
    while (p < 32) {
        int e = 0;
        int Mp = 1;
        while (e < p) {
            Mp *= 2;
            ++e;
        }
        Mp -= 1;
        printf("Testing p=%d: %d\n", p, Mp);
        int i = 0;
        int Si = 4;
        while (i < (p - 2))
        {
            Si = (Si * Si - 2) % Mp;
            ++i;
        }
        if (Si == 0) {
            printf("2^%d is prime: %d\n", p, Mp);
        }
        ++p;
        ++p;
    }
    return 0;
}
</code>```

This worked up to p = 13, at which point we get a problem in the generation of the Si numbers, in particular the squaring, which wraps round beyond the limit for a signed INT.

In order to handle the squaring in a way that doesn't involve getting a number bigger than 2^31-1 I turned multiplication into repeated addition:

```<code>int main() {
    int p = 3;
    while (p < 32) {
        int e = 0;
        int Mp = 1;
        while (e < p) {
            Mp *= 2;
            ++e;
        }
        Mp -= 1;
        int i = 0;
        int Si = 4;
        while (i < (p - 2))
        {
            int newSi;
            newSi = 0;
            int multiplications = 0;
            while (multiplications < Si) {
                newSi = (newSi + Si) % Mp;
                ++multiplications;
            }
            Si = newSi - 2;
            ++i;
        }
        if (Si == 0) {
            printf("2^%d is prime: %d\n", p, Mp);
        }
        ++p;
        ++p;
    }
    return 0;
}
</code>```

But this had a huge effect on the time complexity of the function. It also only detected up to 2^19-1 as prime. Switching all values to unsigned instead of int makes the algorithm work up to 2^31 - 1, as below, but I'm trying to avoid doing so as I'd really like to do this within the bounds of a signed integer, just to see if it's possible.

```<code>#include <stdio.h>

int main() {
    unsigned p = 3;
    while (p < 32) {
        unsigned e = 0;
        unsigned Mp = 1;
        while (e < p) {
            Mp *= 2;
            ++e;
        }
        Mp -= 1;
        unsigned i = 0;
        unsigned Si = 4;
        while (i < (p - 2))
        {
            unsigned newSi;
            newSi = 0;
            unsigned multiplications = 0;
            while (multiplications < Si) {
                newSi = (newSi + Si) % Mp;
                ++multiplications;
            }
            Si = newSi - 2;
            ++i;
        }
        if (Si == 0) {
            printf("2^%d is prime: %d\n", p, Mp);
        }
        ++p;
        ++p;
    }
    return 0;
}

</code>```

But this has had a huge effect on the time complexity of the function.

Can anyone advise if there's an efficient way to run this function with only the functionality I've learned to date? I'm very particular about this constraint on the functionality I can use - I could easily just follow the next few lessons and learn other features of C, but the challenge here is to do so using these elementary skills only. I have found other questions on StackOverflow relating to an implementation of LL testing, but none that ask about an efficient algorithm that just uses math operators, int, while and printf.

Body:
I started learning C yesterday and I've literally just learned the basic data types (char, int, float), while loops, operators and printing.

Before I learn anything more, I wanted to set myself a mathematical challenge as the above should be enough to do elementary arithmetic. These are the constraints I'm working within - I'm well aware there are other ways to do the problem, like I could create an array to store all of the values of the Lucas Lehmer sequence, or I could use BIGINT etc. But I'm trying to use just what I've learned so far.

It just so happens that the largest possible INT value in C is 2^31-1, which is also a Mersenne Prime, M31. So I'd like to write a function which tests all candidate Mersennes up to M31.

This was my initial stab at it:

#include <stdio.h>
#include <stdbool.h>

int main() {
    int p = 3;
    while (p < 32) {
        int e = 0;
        int Mp = 1;
        while (e < p) {
            Mp *= 2;
            ++e;
        }
        Mp -= 1;
        printf("Testing p=%d: %d\n", p, Mp);
        int i = 0;
        int Si = 4;
        while (i < (p - 2))
        {
            Si = (Si * Si - 2) % Mp;
            ++i;
        }
        if (Si == 0) {
            printf("2^%d is prime: %d\n", p, Mp);
        }
        ++p;
        ++p;
    }
    return 0;
}

This worked up to p = 13, at which point we get a problem in the generation of the Si numbers, in particular the squaring, which wraps round beyond the limit for a signed INT.

In order to handle the squaring in a way that doesn't involve getting a number bigger than 2^31-1 I turned multiplication into repeated addition:

int main() {
    int p = 3;
    while (p < 32) {
        int e = 0;
        int Mp = 1;
        while (e < p) {
            Mp *= 2;
            ++e;
        }
        Mp -= 1;
        int i = 0;
        int Si = 4;
        while (i < (p - 2))
        {
            int newSi;
            newSi = 0;
            int multiplications = 0;
            while (multiplications < Si) {
                newSi = (newSi + Si) % Mp;
                ++multiplications;
            }
            Si = newSi - 2;
            ++i;
        }
        if (Si == 0) {
            printf("2^%d is prime: %d\n", p, Mp);
        }
        ++p;
        ++p;
    }
    return 0;
}

But this had a huge effect on the time complexity of the function. It also only detected up to 2^19-1 as prime. Switching all values to unsigned instead of int makes the algorithm work up to 2^31 - 1, as below, but I'm trying to avoid doing so as I'd really like to do this within the bounds of a signed integer, just to see if it's possible.

#include <stdio.h>

int main() {
    unsigned p = 3;
    while (p < 32) {
        unsigned e = 0;
        unsigned Mp = 1;
        while (e < p) {
            Mp *= 2;
            ++e;
        }
        Mp -= 1;
        unsigned i = 0;
        unsigned Si = 4;
        while (i < (p - 2))
        {
            unsigned newSi;
            newSi = 0;
            unsigned multiplications = 0;
            while (multiplications < Si) {
                newSi = (newSi + Si) % Mp;
                ++multiplications;
            }
            Si = newSi - 2;
            ++i;
        }
        if (Si == 0) {
            printf("2^%d is prime: %d\n", p, Mp);
        }
        ++p;
        ++p;
    }
    return 0;
}

But this has had a huge effect on the time complexity of the function.

Can anyone advise if there's an efficient way to run this function with only the functionality I've learned to date? I'm very particular about this constraint on the functionality I can use - I could easily just follow the next few lessons and learn other features of C, but the challenge here is to do so using these elementary skills only. I have found other questions on StackOverflow relating to an implementation of LL testing, but none that ask about an efficient algorithm that just uses math operators, int, while and printf.


问:
I want to use parameterized query in @databricks/sql node.js
Query = "select * from repos where id="sj"

parameterized =

```<code>"select * from repos where id = ?"
result - executestatement(parameterized,"sj")
</code>```

I want to pass parameters to the sql query for @databricks/sql module but I am unable to figure out a way. The node.js package has this issue listed if anybody knows a work around?

Parameterizing the query for prevention of sql injection of application.

Body:
Query = "select * from repos where id="sj"

parameterized =

"select * from repos where id = ?"
result - executestatement(parameterized,"sj")

I want to pass parameters to the sql query for @databricks/sql module but I am unable to figure out a way. The node.js package has this issue listed if anybody knows a work around?

Parameterizing the query for prevention of sql injection of application.