问:
How to split a string by another string in Arduino?
I have a character array like below:

```<code>char array[] = "AAAA... A1... 3. B1.";
</code>```

How can I split this array by the string "..." in Arduino? I have tried:

```<code>ptr = strtok(array, "...");
</code>```

and the output is the following:

```<code>AAAA,
 A1,
 3,
 B1
</code>```

But I actually want output to be

```<code>AAAA,
A1,
3.B1.
</code>```

How to get this output?

edit:

My full code is this:

```<code>char array[] = "AAAA... A1... 3. B1.";
char *strings[10];
char *ptr = NULL;`enter code here`

void setup()
{
       Serial.begin(9600);

       byte index = 0;
       ptr = strtok(array, "...");  // takes a list of delimiters
       while(ptr != NULL)
       {
            strings[index] = ptr;
            index++;
            ptr = strtok(NULL, "...");  // takes a list of delimiters
       }

       for(int n = 0; n < index; n++)
       {
          Serial.println(strings[n]);
       }
    }
</code>```

答:
I looked for a split function and I didn't find one that meets my requirement, so I made one and it works for me so far, of course in the future I will make some improvements, but it got me out of trouble.

But there is also the strtok function and better use that.
https://www.delftstack.com/es/howto/arduino/arduino-strtok/

I have the split function

Arduino code:

```<code>void split(String * vecSplit, int dimArray,String content,char separator){
if(content.length()==0)
    return;
 content = content + separator;
 int countVec = 0;
 int posSep = 0;
 int posInit = 0;
 while(countVec<dimArray){
   posSep = content.indexOf(separator,posSep);
   if(posSep<0){
    return;
   }
 countVec++;
 String splitStr = content.substring(posInit,posSep);
 posSep = posSep+1;
 posInit = posSep;
 vecSplit[countVec] = splitStr;
 countVec++;
</code>```

}
}

Llamada a funcion:

```<code>smsContent = "APN:4g.entel;DOMAIN:domolin.com;DELAY_GPS:60";
String vecSplit[10];

split(vecSplit,10,smsContent,';');
for(int i = 0;i<10;i++){
   Serial.println(vecSplit[i]);
}
</code>```

String input:
APN:4gentel;DOMAIN:domolin.com;DELAY_GPS:60

Output:

APN:4g.entel

DOMAIN:domolin.com

DELAY_GPS:60

RESET:true

enter image description here

Body:
I have a character array like below:

char array[] = "AAAA... A1... 3. B1.";

How can I split this array by the string "..." in Arduino? I have tried:

ptr = strtok(array, "...");

and the output is the following:

AAAA,
 A1,
 3,
 B1

But I actually want output to be

AAAA,
A1,
3.B1.

How to get this output?

edit:

My full code is this:

char array[] = "AAAA... A1... 3. B1.";
char *strings[10];
char *ptr = NULL;`enter code here`

void setup()
{
       Serial.begin(9600);

       byte index = 0;
       ptr = strtok(array, "...");  // takes a list of delimiters
       while(ptr != NULL)
       {
            strings[index] = ptr;
            index++;
            ptr = strtok(NULL, "...");  // takes a list of delimiters
       }

       for(int n = 0; n < index; n++)
       {
          Serial.println(strings[n]);
       }
    }

Body:
I looked for a split function and I didn't find one that meets my requirement, so I made one and it works for me so far, of course in the future I will make some improvements, but it got me out of trouble.

But there is also the strtok function and better use that.
https://www.delftstack.com/es/howto/arduino/arduino-strtok/

I have the split function

Arduino code:

void split(String * vecSplit, int dimArray,String content,char separator){
if(content.length()==0)
    return;
 content = content + separator;
 int countVec = 0;
 int posSep = 0;
 int posInit = 0;
 while(countVec<dimArray){
   posSep = content.indexOf(separator,posSep);
   if(posSep<0){
    return;
   }
 countVec++;
 String splitStr = content.substring(posInit,posSep);
 posSep = posSep+1;
 posInit = posSep;
 vecSplit[countVec] = splitStr;
 countVec++;

}
}

Llamada a funcion:

smsContent = "APN:4g.entel;DOMAIN:domolin.com;DELAY_GPS:60";
String vecSplit[10];

split(vecSplit,10,smsContent,';');
for(int i = 0;i<10;i++){
   Serial.println(vecSplit[i]);
}

String input:
APN:4gentel;DOMAIN:domolin.com;DELAY_GPS:60

Output:

APN:4g.entel

DOMAIN:domolin.com

DELAY_GPS:60

RESET:true

enter image description here


来源: stackexchange

问:
Framebuffer not completing on GL_DEPTH_ATTACHMENT render to texture
I'm attempting shadow mapping in OpenGL, and have been unable to render specifically GL_DEPTH_ATTACHMENT to a frame buffer. glCheckFramebufferStatus does not return complete but only when targeting the depth attachment - it works fine for color attachment0.

```<code>    glBindFramebuffer(GL_FRAMEBUFFER, ShadowMapFrameBuffer);
    glDrawBuffer(GL_NONE);
    glReadBuffer(GL_NONE);
    glViewport(0, 0, LightMapResolution, LightMapResolution);
    glClear(GL_DEPTH_BUFFER_BIT);

// Shader works fine with colour, too.
    std::shared_ptr<Shader> mapShader = Shaders["shadowMap"];

    glGenTextures(1, &DEBUGSHADOW);
    glBindTexture(GL_TEXTURE_2D, DEBUGSHADOW);
// I've tried GL_UNSIGNED_INT in the type and GL_DEPTH_COMPONENT16 as the internal format as per my search results to no avail.
    glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, LightMapResolution, LightMapResolution, 0, GL_FLOAT, GL_FLOAT, NULL);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, DEBUGSHADOW, 0);

    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
    {
        clog::Error(CLOGINFO, "Framebuffer broke!", false);
    }

// Drawing code omitted. Irrelevant to the issue and functions fine.

    glViewport(0, 0, windowWidth, windowHeight);
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    return;
</code>```

For completeness, the shaders are taken from LearnOpenGL and are as follows:

```<code>#version 460 core
layout (location = 0) in vec3 aPos;

uniform mat4 lightMatrix;
uniform mat4 modelMatrix;

void main()
{
    gl_Position = lightMatrix * modelMatrix * vec4(aPos, 1.0);
}
</code>```
```<code>#version 460 core

void main()
{
}
</code>```

The program outputs the error message within the conditional "Framebuffer broke!" any time the buffer is configured for GL_DEPTH_ATTACHMENT and I'm unsure why. As far as I can tell my code does no deviate from the aforementioned LearnOpenGL article (https://learnopengl.com/Advanced-Lighting/Shadows/Shadow-Mapping).

答:
It turned out to be a twofold issue. At some point I'd made a type in glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, LightMapResolution, LightMapResolution, 0, GL_FLOAT, GL_FLOAT, NULL); The first instance of GL_FLOAT should've been GL_DEPTH_COMPONENT. This caused the incomplete framebuffer.

The second error was found through glGetError(). I was calling glClear() before the framebuffer had an attachment (presumably?) and it was reporting GL_INVALID_FRAMEBUFFER_OPERATION (1286 in decimal for reference).

After fixing the above issues the framebuffer behaves as expected.

ContentLicense: CC BY-SA 4.0

Body:
I'm attempting shadow mapping in OpenGL, and have been unable to render specifically GL_DEPTH_ATTACHMENT to a frame buffer. glCheckFramebufferStatus does not return complete but only when targeting the depth attachment - it works fine for color attachment0.

    glBindFramebuffer(GL_FRAMEBUFFER, ShadowMapFrameBuffer);
    glDrawBuffer(GL_NONE);
    glReadBuffer(GL_NONE);
    glViewport(0, 0, LightMapResolution, LightMapResolution);
    glClear(GL_DEPTH_BUFFER_BIT);

// Shader works fine with colour, too.
    std::shared_ptr<Shader> mapShader = Shaders["shadowMap"];

    glGenTextures(1, &DEBUGSHADOW);
    glBindTexture(GL_TEXTURE_2D, DEBUGSHADOW);
// I've tried GL_UNSIGNED_INT in the type and GL_DEPTH_COMPONENT16 as the internal format as per my search results to no avail.
    glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, LightMapResolution, LightMapResolution, 0, GL_FLOAT, GL_FLOAT, NULL);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, DEBUGSHADOW, 0);

    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
    {
        clog::Error(CLOGINFO, "Framebuffer broke!", false);
    }

// Drawing code omitted. Irrelevant to the issue and functions fine.

    glViewport(0, 0, windowWidth, windowHeight);
    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    return;

For completeness, the shaders are taken from LearnOpenGL and are as follows:

#version 460 core
layout (location = 0) in vec3 aPos;

uniform mat4 lightMatrix;
uniform mat4 modelMatrix;

void main()
{
    gl_Position = lightMatrix * modelMatrix * vec4(aPos, 1.0);
}

#version 460 core

void main()
{
}

The program outputs the error message within the conditional "Framebuffer broke!" any time the buffer is configured for GL_DEPTH_ATTACHMENT and I'm unsure why. As far as I can tell my code does no deviate from the aforementioned LearnOpenGL article (https://learnopengl.com/Advanced-Lighting/Shadows/Shadow-Mapping).


问:
What are these valueless attributes added to my Razor pages?
I've barely made any changes to the default ASP.NET Core 6 Razor Pages template, but by default it creates these valueless attributes in the rendered HTML:

```<code><div b-nhqxrkkbzm class="container">
    <main b-nhqxrkkbzm role="main" class="pb-3">
</code>```

The .cshtml source looks like this:

```<code><div class="container">
    <main role="main" class="pb-3">
</code>```

What are these attributes, what do they do, and how are they being added?

答: This is the new feature about CSS isolation in .Net6, you can find it in this document.</p>

Body:
I've barely made any changes to the default ASP.NET Core 6 Razor Pages template, but by default it creates these valueless attributes in the rendered HTML:

The .cshtml source looks like this:

What are these attributes, what do they do, and how are they being added?


问:
How would you recover a corrupt Firestore database to the point of failure?
Firestore's export and import services enable you to recover a corrupt database to some point prior to your desired recovery time. But how would you roll the database forward from there to the actual point of failure?

Would you have to develop your own recovery process, together with transaction-logging arrangements to drive this?

As an example of why you might need this, imagine you've just been informed that a Junior member of your IT staff, thinking they were deleting a collection of test data from the company's Firestore database has actually deleted the company's Customer_Details collection.

You have a copy of the collection from the last time your automated Export ran - but this is now a fortnight old and your company has been acquiring new customers through its online transaction site at a rapid rate. There are no paper records for these customers. You are sunk!

In your previous employment, you'd used a SQL database that automatically created log files that would allow you to recover a corrupted database to its point of failure by reloading it from a dump and then rolling it forward. Firestore doesn't appear to have an equivalent facility. If so, how could you have designed your system to replicate this functionality?

答:
There is what you called Cloud Firestore triggers which handles events in Cloud Firestore with no need to update client code.

You can attempt to write the new update to Firestore. If it succeeds, your .then can resolve the promise and the function can end. If it fails, add some lines to the .catch to update the document with change.before.data()

Below is the sample code:

```<code>const admin = require('firebase-admin');
const functions = require('firebase-functions');

admin.initializeApp();

const firestore = admin.firestore();

exports.myFunction = functions.firestore
  .document('myCollection/{myDocumentId}')
  .onUpdate((change, context) => {

  const newValue = change.after.data();
  const oldValue = change.before.data();

  let myChanges = {
    // Update a value
  };

  return change.after.ref.update(myChanges)
    .then(() => {
      console.log('Document updated successfully');
      return Promise.resolve();
    })
    .catch(() => {
      // The update failed and the document needs to be rolled back
      return change.before.ref.set(oldValue);
    })
    .then(() => {
      console.log('Document was rolled back');
      return Promise.resolve();
    })
    .catch(err => {
      console.error(err);
      return Promise.reject(err);
    });
});
</code>```

The document will then return to its previous value.

For Firestore Backups:

There are various ways to trigger Cloud Firestore backups:

Datastore Import/Export UI

Firebase CLI

exportDocuments API

Scheduled data exports

You can also develop your own recovery process by using Cloud Workflows.

Steps to create your own recovery process:

Create Cloud Storage Bucket. (You can skip these if you already have.)

Create the Cloud Workflow definition to execute Firestore export API call.

To define a workflow, go to Cloud Workflows page.

You will be prompted to Enable the Cloud Workflows API if you haven’t done so for your project. Make sure after you enabled the API, you open the console again.

On the Cloud Workflow Dashboard, hit Create.

Set a workflow name and description: e.g. firestoreExportDocuments

Choose region: e.g. us-central1. Hit Next.

You will notice there is a service account preselected, remember that. It may have the form of
xxxxxxxxxxx-compute@developer.gserviceaccount.com

On the next page, paste the below snippet, edit the path to your bucket on line 5.
```<code>- initialize:
    assign:
      - project: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - firestoreDatabaseId: (default)
      - firestoreBackupBucket: gs://my_bucket_for_backups
- exportFirestoreDatabaseAll:
    call: http.post
    args:
      url: ${"https://firestore.googleapis.com/v1/projects/"+project+"/databases/"+firestoreDatabaseId+":exportDocuments"}
      auth:
        type: OAuth2
      body:
        outputUriPrefix: ${firestoreBackupBucket}
    result: result
- returnResult:
    return: ${result}
</code>```

Click Deploy. Your workflow will get deployed.

Setup IAM permissions to execute the Cloud Workflow.

Go to IAM Permissions page, and identify the service account from the list. Choose from the right menu the Edit option.

Add the following permissions:

Cloud Datastore Import Export Admin: Full access to manage imports and exports.

Storage Object Creator: Access to create objects in GCS.

Workflow Invoker: Access to execute workflows and manage the executions.

At this time, you can execute your workflow. The workflow status will show succeeded status when the workflow was able to trigger the Firestore export/backup process.

Setup the invocation via Cloud Scheduler

Go to Cloud Scheduler page, enable the API if prompted, and revisit the Scheduler page.

To crate a scheduled job, hit Create Job:

Use a name and description for your scheduler. e.g.: workflows-datastore-export-backup

For midnight trigger use this syntax: 0 0 * * *. You can generate cron schedules here.

In the Target selector choose: HTTP as method choose POST

Enter the below URL:
https://workflowexecutions.googleapis.com/v1beta/projects/<PROJECT-ID>/locations/us-central1/workflows/<WORKFLOW_NAME>/executions

Replace the placeholders.

In Show more section, configure Auth header: OAuth, and add your service account previously used, and for Scope use:
https://www.googleapis.com/auth/cloud-platform

Leave other selections with their default selections.

Run the scheduler.

On the Cloud Scheduler entries, hit Run now.

A successful export is logged to Firestore/Datastore Import/Export page.

The output is on your selected Cloud Storage bucket and the format is not self readable, files are packet into many parts and there is a manifest file that resembles the schema and format. To import/restore backups to a Firestore/Datastore instance, you can do that manually from the Datastore Import/Export UI.

UPDATE:

You could also use Scheduled data exports as you mentioned. I included it on the options above.

Based on the scenarios given, once you delete a document in Firestore, the documents are gone for good. Currently, there is no undelete feature but there's a way you can implement an undo feature. If you have a function that deletes a document, you have to modify the delete function to not actually delete the document, and instead just update the UI to remove the view. You would have to schedule the deletion to happen some time later. The undo option would then just restore the visibility of the deleted document and cancel the delayed deletion.

Also, it is highly recommended to consider adding a new boolean field to the document to mark that it's deleted or not, and use that in a filter for the query you pass to FirebaseUI. The field would have to be present on every document in order for it to filter correctly. After the UI is done, you would then have to figure out how to actually delete all the documents you marked for deletion in the UI.

I'd also recommend to create a Feature Request if you want to have this kind of feature.

Body:
There is what you called Cloud Firestore triggers which handles events in Cloud Firestore with no need to update client code.

You can attempt to write the new update to Firestore. If it succeeds, your .then can resolve the promise and the function can end. If it fails, add some lines to the .catch to update the document with change.before.data()

Below is the sample code:

const admin = require('firebase-admin');
const functions = require('firebase-functions');

admin.initializeApp();

const firestore = admin.firestore();

exports.myFunction = functions.firestore
  .document('myCollection/{myDocumentId}')
  .onUpdate((change, context) => {

  const newValue = change.after.data();
  const oldValue = change.before.data();

  let myChanges = {
    // Update a value
  };

  return change.after.ref.update(myChanges)
    .then(() => {
      console.log('Document updated successfully');
      return Promise.resolve();
    })
    .catch(() => {
      // The update failed and the document needs to be rolled back
      return change.before.ref.set(oldValue);
    })
    .then(() => {
      console.log('Document was rolled back');
      return Promise.resolve();
    })
    .catch(err => {
      console.error(err);
      return Promise.reject(err);
    });
});

The document will then return to its previous value.

For Firestore Backups:

There are various ways to trigger Cloud Firestore backups:

Datastore Import/Export UI

Firebase CLI

exportDocuments API

Scheduled data exports

You can also develop your own recovery process by using Cloud Workflows.

Steps to create your own recovery process:

Create Cloud Storage Bucket. (You can skip these if you already have.)

Create the Cloud Workflow definition to execute Firestore export API call.

To define a workflow, go to Cloud Workflows page.

You will be prompted to Enable the Cloud Workflows API if you haven’t done so for your project. Make sure after you enabled the API, you open the console again.

On the Cloud Workflow Dashboard, hit Create.

Set a workflow name and description: e.g. firestoreExportDocuments

Choose region: e.g. us-central1. Hit Next.

You will notice there is a service account preselected, remember that. It may have the form of
xxxxxxxxxxx-compute@developer.gserviceaccount.com

On the next page, paste the below snippet, edit the path to your bucket on line 5.

- initialize:
    assign:
      - project: ${sys.get_env("GOOGLE_CLOUD_PROJECT_ID")}
      - firestoreDatabaseId: (default)
      - firestoreBackupBucket: gs://my_bucket_for_backups
- exportFirestoreDatabaseAll:
    call: http.post
    args:
      url: ${"https://firestore.googleapis.com/v1/projects/"+project+"/databases/"+firestoreDatabaseId+":exportDocuments"}
      auth:
        type: OAuth2
      body:
        outputUriPrefix: ${firestoreBackupBucket}
    result: result
- returnResult:
    return: ${result}

Click Deploy. Your workflow will get deployed.

Setup IAM permissions to execute the Cloud Workflow.

Go to IAM Permissions page, and identify the service account from the list. Choose from the right menu the Edit option.

Add the following permissions:

Cloud Datastore Import Export Admin: Full access to manage imports and exports.

Storage Object Creator: Access to create objects in GCS.

Workflow Invoker: Access to execute workflows and manage the executions.

At this time, you can execute your workflow. The workflow status will show succeeded status when the workflow was able to trigger the Firestore export/backup process.

Setup the invocation via Cloud Scheduler

Go to Cloud Scheduler page, enable the API if prompted, and revisit the Scheduler page.

To crate a scheduled job, hit Create Job:

Use a name and description for your scheduler. e.g.: workflows-datastore-export-backup

For midnight trigger use this syntax: 0 0 * * *. You can generate cron schedules here.

In the Target selector choose: HTTP as method choose POST

Enter the below URL:
https://workflowexecutions.googleapis.com/v1beta/projects/<PROJECT-ID>/locations/us-central1/workflows/<WORKFLOW_NAME>/executions

Replace the placeholders.

In Show more section, configure Auth header: OAuth, and add your service account previously used, and for Scope use:
https://www.googleapis.com/auth/cloud-platform

Leave other selections with their default selections.

Run the scheduler.

On the Cloud Scheduler entries, hit Run now.

A successful export is logged to Firestore/Datastore Import/Export page.

The output is on your selected Cloud Storage bucket and the format is not self readable, files are packet into many parts and there is a manifest file that resembles the schema and format. To import/restore backups to a Firestore/Datastore instance, you can do that manually from the Datastore Import/Export UI.

UPDATE:

You could also use Scheduled data exports as you mentioned. I included it on the options above.

Based on the scenarios given, once you delete a document in Firestore, the documents are gone for good. Currently, there is no undelete feature but there's a way you can implement an undo feature. If you have a function that deletes a document, you have to modify the delete function to not actually delete the document, and instead just update the UI to remove the view. You would have to schedule the deletion to happen some time later. The undo option would then just restore the visibility of the deleted document and cancel the delayed deletion.

Also, it is highly recommended to consider adding a new boolean field to the document to mark that it's deleted or not, and use that in a filter for the query you pass to FirebaseUI. The field would have to be present on every document in order for it to filter correctly. After the UI is done, you would then have to figure out how to actually delete all the documents you marked for deletion in the UI.

I'd also recommend to create a Feature Request if you want to have this kind of feature.


问:
How to reduce time using Javascript?
How can I use reduce() to calculate the total of all times (in string format) in the following array?

time["00:30", "01:45", "02:33"]

times.reduce((time, nextTime) => time + nextTime, 0)

I was thinking I need to split(":"), parseInt() and some more calculations or is there an easier way to do this?

答:
If you can use an open JavaScript library like moment.js, the following is simple and preserves your string formatted times.

Note that I'm passing in "00:00" as the default value to reduce() so that times are calculated from a zero baseline, which also follows the string formatting that we'll use for all other values in the array.

```<code>const times["00:30", "01:45", "02:33"]

const totalTime = times.reduce((time, nextTime) => {
  return moment(time, "hh:mm")
          .add(nextTime, "hh:mm")
          .format("hh:mm");
}, "00:00");

console.log("total time -->", totalTime);

// total time --> "04:48"
</code>```

If we added logging inside reduce() to view the accumulation of values:

```<code>"12:30"
"02:15"
"04:48"
"total time -->" "04:48"
</code>```

Notice that the result after the first pass was "12:30".  If all times in the array summed to less than one clock hour the end result may not be acceptable for your particular use case.

Title: How to reduce time using Javascript?

Body:
If you can use an open JavaScript library like moment.js, the following is simple and preserves your string formatted times.

Note that I'm passing in "00:00" as the default value to reduce() so that times are calculated from a zero baseline, which also follows the string formatting that we'll use for all other values in the array.

const times["00:30", "01:45", "02:33"]

const totalTime = times.reduce((time, nextTime) => {
  return moment(time, "hh:mm")
          .add(nextTime, "hh:mm")
          .format("hh:mm");
}, "00:00");

console.log("total time -->", totalTime);

// total time --> "04:48"

If we added logging inside reduce() to view the accumulation of values:

"12:30"
"02:15"
"04:48"
"total time -->" "04:48"

Notice that the result after the first pass was "12:30".  If all times in the array summed to less than one clock hour the end result may not be acceptable for your particular use case.


问:
Regarding use of @(posedge clock) statement
I'm trying to collect 160-bits data from a wishbone port which is 32-bits and driven at each posedge of the clock. In order to able to do that, trying to use the "for" loop:

```<code>always @(posedge wb_clk_i) begin

    for (index = 0 ; index < 5 ;@(posedge wb_clk_i) index = index + 1) begin
        adrholder[index] = wbs_adr_i;
    end
    //some fsm process using 128-bit of 160-bit data
end
</code>```

I'm not sure whether the @(posedge wb_clk_i) index = index + 1 is going to work or not. Due to not completing the design, I could not apply the testbench.

Additionally, I am open to advice on other ways to collect the data.

答:
I am assuming that you are trying to fill the array and the address of that array has to be incremented on a posedge clk behavior. Try this

```<code>always @(posedge wb_clk_i) begin
        adrholder[index] = wbs_adr_i;
    end
    //some fsm process using 128-bit of 160-bit data
end

always @(posedge wb_clk_i or negedge reset) begin //Add a reset port
     if(!reset)
      index <= 'd0;
     else
      index <= (index=='d4) ? 'd0 : index + 1'd1;
   end
</code>```

Body:
I'm trying to collect 160-bits data from a wishbone port which is 32-bits and driven at each posedge of the clock. In order to able to do that, trying to use the "for" loop:

always @(posedge wb_clk_i) begin

    for (index = 0 ; index < 5 ;@(posedge wb_clk_i) index = index + 1) begin
        adrholder[index] = wbs_adr_i;
    end
    //some fsm process using 128-bit of 160-bit data
end

I'm not sure whether the @(posedge wb_clk_i) index = index + 1 is going to work or not. Due to not completing the design, I could not apply the testbench.

Additionally, I am open to advice on other ways to collect the data.

Body:
I am assuming that you are trying to fill the array and the address of that array has to be incremented on a posedge clk behavior. Try this

always @(posedge wb_clk_i) begin
        adrholder[index] = wbs_adr_i;
    end
    //some fsm process using 128-bit of 160-bit data
end

always @(posedge wb_clk_i or negedge reset) begin //Add a reset port
     if(!reset)
      index <= 'd0;
     else
      index <= (index=='d4) ? 'd0 : index + 1'd1;
   end


问:
API call to crypto.com in node returns invalid JSON response
I'm sending a POST request to the crypto.com public API (reference) using node-fetch. More specifically, I'm am attempting to call the private method get-account-summary and I am signing the request beforehand with my API Key and my Secret Key as prescribed on their API reference page (see digital signature).

const requestBody = JSON.stringify(signRequest(request, apiKey, apiSecret));

fetch('https://api.crypto.com/v2/private/get-account-summary', {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: requestBody
})
.then(response => response.body)
.then(data => {
  console.log('Success:', data);
})
.catch((error) => {
  console.error('Error:', error);
});
```
<p>The request is apparently successful, but I'm struggling to make sense of the API response which is supposed to look like this:</p>
<pre class="lang-json prettyprint-override"><code>{
    "id": 11,
    "method": "private/get-account-summary",
    "code": 0,
    "result": {
        "accounts": [
            {
                "balance": 99999999.905000000000000000,
                "available": 99999996.905000000000000000,
                "order": 3.000000000000000000,
                "stake": 0,
                "currency": "CRO"
            }
        ]
    }
}
</code>```

but this is what I actually get:

Success: PassThrough {
  _readableState: ReadableState {
    objectMode: false,
    highWaterMark: 16384,
    buffer: BufferList { head: null, tail: null, length: 0 },
    length: 0,
    pipes: [],
    flowing: null,
    ended: true,
    endEmitted: false,
    reading: false,
    constructed: true,
    sync: false,
    needReadable: false,
    emittedReadable: false,
    readableListening: false,
    resumeScheduled: false,
    errorEmitted: false,
    emitClose: true,
    autoDestroy: true,
    destroyed: false,
    errored: null,
    closed: false,
    closeEmitted: false,
    defaultEncoding: 'utf8',
    awaitDrainWriters: null,
    multiAwaitDrain: false,
    readingMore: false,
    dataEmitted: false,
    decoder: null,
    encoding: null,
    [Symbol(kPaused)]: null
  },
  _events: [Object: null prototype] {
    prefinish: [Function: prefinish],
    error: [Function (anonymous)]
  },
  _eventsCount: 2,
  _maxListeners: undefined,
  _writableState: WritableState {
    objectMode: false,
    highWaterMark: 16384,
    finalCalled: true,
    needDrain: false,
    ending: true,
    ended: true,
    finished: true,
    destroyed: false,
    decodeStrings: true,
    defaultEncoding: 'utf8',
    length: 0,
    writing: false,
    corked: 0,
    sync: false,
    bufferProcessing: false,
    onwrite: [Function: bound onwrite],
    writecb: null,
    writelen: 0,
    afterWriteTickInfo: null,
    buffered: [],
    bufferedIndex: 0,
    allBuffers: true,
    allNoop: true,
    pendingcb: 0,
    constructed: true,
    prefinished: true,
    errorEmitted: false,
    emitClose: true,
    autoDestroy: true,
    errored: null,
    closed: false,
    closeEmitted: false,
    [Symbol(kOnFinished)]: []
  },
  allowHalfOpen: true,
  [Symbol(kCapture)]: false,
  [Symbol(kCallback)]: null
}
```
<p>You may have noticed that I logged the <code>response.body</code> to the console rather than the <code>response.json()</code> because whenever I call the latter, I get an "invalid json error"</p>
<blockquote>
<pre class="lang-none prettyprint-override"><code>Error: FetchError: invalid json response body at
https://api.crypto.com/v2/private/get-account-summary reason:
Unexpected end of JSON input
    at C:\Users\...\app\node_modules\node-fetch\lib\index.js:273:32
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  type: 'invalid-json'
</code>```

答:
EDIT: Sorry I missed the end of the question. If json() is invalid and the text() returns nothing, I would say you should check your request body. The request is successful, but you get an empty response.

Not sure why you are using response.body. You need to use json() if you want the response in a JSON format. This will take the body and return a promise which resolve to the requested format. You can read it here.

So, your code should look like this:

```<code>fetch('https://api.crypto.com/v2/private/get-account-summary', {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: requestBody
})
.then(response => response.json())
.then(data => {
  console.log('Success:', data);
})
.catch((error) => {
  console.error('Error:', error);
});
</code>```

Body:
I'm sending a POST request to the crypto.com public API (reference) using node-fetch. More specifically, I'm am attempting to call the private method get-account-summary and I am signing the request beforehand with my API Key and my Secret Key as prescribed on their API reference page (see digital signature).

const requestBody = JSON.stringify(signRequest(request, apiKey, apiSecret));

fetch('https://api.crypto.com/v2/private/get-account-summary', {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: requestBody
})
.then(response => response.body)
.then(data => {
  console.log('Success:', data);
})
.catch((error) => {
  console.error('Error:', error);
});

The request is apparently successful, but I'm struggling to make sense of the API response which is supposed to look like this:

{
    "id": 11,
    "method": "private/get-account-summary",
    "code": 0,
    "result": {
        "accounts": [
            {
                "balance": 99999999.905000000000000000,
                "available": 99999996.905000000000000000,
                "order": 3.000000000000000000,
                "stake": 0,
                "currency": "CRO"
            }
        ]
    }
}

but this is what I actually get:

Success: PassThrough {
  _readableState: ReadableState {
    objectMode: false,
    highWaterMark: 16384,
    buffer: BufferList { head: null, tail: null, length: 0 },
    length: 0,
    pipes: [],
    flowing: null,
    ended: true,
    endEmitted: false,
    reading: false,
    constructed: true,
    sync: false,
    needReadable: false,
    emittedReadable: false,
    readableListening: false,
    resumeScheduled: false,
    errorEmitted: false,
    emitClose: true,
    autoDestroy: true,
    destroyed: false,
    errored: null,
    closed: false,
    closeEmitted: false,
    defaultEncoding: 'utf8',
    awaitDrainWriters: null,
    multiAwaitDrain: false,
    readingMore: false,
    dataEmitted: false,
    decoder: null,
    encoding: null,
    [Symbol(kPaused)]: null
  },
  _events: [Object: null prototype] {
    prefinish: [Function: prefinish],
    error: [Function (anonymous)]
  },
  _eventsCount: 2,
  _maxListeners: undefined,
  _writableState: WritableState {
    objectMode: false,
    highWaterMark: 16384,
    finalCalled: true,
    needDrain: false,
    ending: true,
    ended: true,
    finished: true,
    destroyed: false,
    decodeStrings: true,
    defaultEncoding: 'utf8',
    length: 0,
    writing: false,
    corked: 0,
    sync: false,
    bufferProcessing: false,
    onwrite: [Function: bound onwrite],
    writecb: null,
    writelen: 0,
    afterWriteTickInfo: null,
    buffered: [],
    bufferedIndex: 0,
    allBuffers: true,
    allNoop: true,
    pendingcb: 0,
    constructed: true,
    prefinished: true,
    errorEmitted: false,
    emitClose: true,
    autoDestroy: true,
    errored: null,
    closed: false,
    closeEmitted: false,
    [Symbol(kOnFinished)]: []
  },
  allowHalfOpen: true,
  [Symbol(kCapture)]: false,
  [Symbol(kCallback)]: null
}

You may have noticed that I logged the response.body to the console rather than the response.json() because whenever I call the latter, I get an "invalid json error"

Error: FetchError: invalid json response body at
https://api.crypto.com/v2/private/get-account-summary reason:
Unexpected end of JSON input
    at C:\Users\...\app\node_modules\node-fetch\lib\index.js:273:32
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  type: 'invalid-json'

Body:
EDIT: Sorry I missed the end of the question. If json() is invalid and the text() returns nothing, I would say you should check your request body. The request is successful, but you get an empty response.

Not sure why you are using response.body. You need to use json() if you want the response in a JSON format. This will take the body and return a promise which resolve to the requested format. You can read it here.

So, your code should look like this:

fetch('https://api.crypto.com/v2/private/get-account-summary', {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: requestBody
})
.then(response => response.json())
.then(data => {
  console.log('Success:', data);
})
.catch((error) => {
  console.error('Error:', error);
});


问:
What is The Use Of # in C or C++?
i would like to know the usage of # in C or C++..... please can u inform me what is the purpose of # or Why it is used?</p>

答:
In C/C++, the # sign marks preprocessor directives.

If you're not familiar with the preprocessor, it works as part of the compilation process, handling includes, macros, and more.  It actually adds code to the source file before the final compilation.  If you're using gcc/g++, you can see what the preprocessor generates by using the -E flag.

Example preprocessor directives:

Includes:

```<code>#include <iostream>
</code>```

Includes are used to insert the contents of the included file into the current file at the location of the directive.

Constants:

```<code>#define RANDOM_NUMBER 4
</code>```

During processing, every instance of RANDOM_NUMBER in the file will be textually replaced with 4

Conditional compilation:

```<code>#ifdef DEBUG
printf( "Random number: %d", RANDOM_NUMBER );
#endif
</code>```

In this case, the print statement will only be a part of the compiled program if the DEBUG macro has been defined.

ContentLicense: CC BY-SA 3.0

Title: What is The Use Of # in C or C++?

Body:
In C/C++, the # sign marks preprocessor directives.

If you're not familiar with the preprocessor, it works as part of the compilation process, handling includes, macros, and more.  It actually adds code to the source file before the final compilation.  If you're using gcc/g++, you can see what the preprocessor generates by using the -E flag.

Example preprocessor directives:

Includes:

#include <iostream>

Includes are used to insert the contents of the included file into the current file at the location of the directive.

Constants:

#define RANDOM_NUMBER 4

During processing, every instance of RANDOM_NUMBER in the file will be textually replaced with 4

Conditional compilation:

#ifdef DEBUG
printf( "Random number: %d", RANDOM_NUMBER );
#endif

In this case, the print statement will only be a part of the compiled program if the DEBUG macro has been defined.


问:
cmake find_program command does not find lib.exe
In my CMake file I need to use lib.exe in custom command when building on Windows to combine multiple static libraries into one.
I tried to use find_program command to find the executable:

```<code>find_program(LIB_EXE NAMES lib.exe)
</code>```

but it always sets the variable to not found. What is the right way to find lib.exe?

[EDIT] Fixed NAME->NAMES, but the program is still not found

答:
Check the file CMakeCache.txt in your build directory, and search for "lib.exe".

There you can find "lib.exe" can be located by the variable ${CMAKE_AR}.

Body:
In my CMake file I need to use lib.exe in custom command when building on Windows to combine multiple static libraries into one.
I tried to use find_program command to find the executable:

find_program(LIB_EXE NAMES lib.exe)

but it always sets the variable to not found. What is the right way to find lib.exe?

[EDIT] Fixed NAME->NAMES, but the program is still not found


问:
How to setup selenoid with docker-compose
I'm trying to setup selenoid to run inside docker with a docker-compose. I have tried following the guide on https://aerokube.com/selenoid/1.6.0/#_selenoid_with_docker_compose and have produced a docker-compose.yml file looking like this:

version: '3.6'

services:
  selenoid:
    image: aerokube/selenoid:latest-release
    command: -conf /etc/selenoid/browsers.json -video-output-dir /opt/selenoid/video -log-output-dir /opt/selenoid/logs
    network_mode: bridge
    ports:
      - 5656:4444
    environment:
      OVERRIDE_VIDEO_OUTPUT_DIR: /opt/selenoid/video
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./selenoid/video:/opt/selenoid/video
      - ./selenoid/logs:/opt/selenoid/logs
      - ./selenoid/browsers.json:/etc/selenoid/browsers.json:ro

  selenoid-ui:
    image: aerokube/selenoid-ui:latest-release
    command: --selenoid-uri http://selenoid:4444
    network_mode: bridge
    ports:
      - 5599:8080
```
<p>and <code>browsers.json</code>:</p>
<pre class="lang-json prettyprint-override"><code>{
  "chrome": {
    "default": "91.0",
    "versions": {
      "91.0": {
        "image": "selenoid/vnc_chrome:91.0",
        "port": "4444"
      }
    }
  }
}
</code>```

But with this kotlin configuration:

Configuration.remote = "http://localhost:5656/wd/hub"
Configuration.browserCapabilities = DesiredCapabilities().apply {
    setCapability("browserName", "chrome")
    setCapability("browserVersion", "91.0")
    setCapability("enableVNC", true)
    setCapability("selenoid:options", mapOf(
        "enableVNC" to true,
        "enableVideo" to true,
        "name" to "Kotlin BrowserTest",
    ))
}
```
<p>I'm getting these errors within selenoid logs:</p>
```2021/06/04 16:32:29 [-] [NEW_REQUEST] [unknown] [172.17.0.1]
2021/06/04 16:32:29 [-] [NEW_REQUEST_ACCEPTED] [unknown] [172.17.0.1]
2021/06/04 16:32:29 [5] [LOCATING_SERVICE] [chrome] [91.0]
2021/06/04 16:32:29 [5] [USING_DOCKER] [chrome] [91.0]
2021/06/04 16:32:29 [5] [CREATING_CONTAINER] [selenoid/vnc_chrome:91.0]
2021/06/04 16:32:29 [5] [STARTING_CONTAINER] [selenoid/vnc_chrome:91.0] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d]
2021/06/04 16:32:29 [5] [CONTAINER_STARTED] [selenoid/vnc_chrome:91.0] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d] [0.34s]
2021/06/04 16:32:29 [5] [CREATING_VIDEO_CONTAINER] [selenoid/video-recorder:latest-release]
2021/06/04 16:32:29 [5] [STARTING_VIDEO_CONTAINER] [selenoid/video-recorder:latest-release] [cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181]
2021/06/04 16:32:29 [5] [VIDEO_CONTAINER_STARTED] [selenoid/video-recorder:latest-release] [cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181] [0.29s]
2021/06/04 16:32:29 [5] [SERVICE_STARTED] [selenoid/vnc_chrome:91.0] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d] [0.10s]
2021/06/04 16:32:29 [5] [PROXY_TO] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d] [http://172.17.0.4:4444]
2021/06/04 16:32:29 [5] [SESSION_ATTEMPTED] [http://172.17.0.4:4444] [1]
2021/06/04 16:32:30 [5] [SESSION_CREATED] [412ed8c80871bde7c90cfd1fec72c616] [1] [1.03s]
2021/06/04 16:32:30 [9] [SESSION_DELETED] [412ed8c80871bde7c90cfd1fec72c616]
2021/06/04 16:32:30 [5] [STOPPING_VIDEO_CONTAINER] [cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181]
2021/06/04 16:32:31 [5] [REMOVING_CONTAINER] [cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181]
2021/06/04 16:32:31 [5] [FAILED_TO_REMOVE_CONTAINER] [cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181] [Error: No such container: cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181]
2021/06/04 16:32:31 [5] [REMOVING_CONTAINER] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d]
2021/06/04 16:32:31 [5] [CONTAINER_REMOVED] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d]
2021/06/04 16:32:31 [5] [VIDEO_ERROR] [Failed to rename /opt/selenoid/video/selenoid2217ce756f255ba8e693926caa899ca2.mp4 to /opt/selenoid/video/412ed8c80871bde7c90cfd1fec72c616.mp4: rename /opt/selenoid/video/selenoid2217ce756f255ba8e693926caa899ca2.mp4 /opt/selenoid/video/412ed8c80871bde7c90cfd1fec72c616.mp4: no such file or directory]
```
<p>and these logs within junit</p>
```unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: chrome=91.0.4472.77)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'JOL-WORKSTATION', ip: '10.5.21.136', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
selenide.remote: http://localhost:5656/wd/hub
Driver info: org.openqa.selenium.remote.RemoteWebDriver
selenide.url: http://localhost:3000
Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 91.0.4472.77, chrome: {chromedriverVersion: 91.0.4472.19 (1bf021f248676..., userDataDir: /tmp/.com.google.Chrome.QFkx1l}, goog:chromeOptions: {debuggerAddress: localhost:37451}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
selenide.baseUrl: http://localhost:8080
Session ID: 412ed8c80871bde7c90cfd1fec72c616
org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: chrome=91.0.4472.77)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'JOL-WORKSTATION', ip: '10.5.21.136', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
selenide.remote: http://localhost:5656/wd/hub
Driver info: org.openqa.selenium.remote.RemoteWebDriver
selenide.url: http://localhost:3000
Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 91.0.4472.77, chrome: {chromedriverVersion: 91.0.4472.19 (1bf021f248676..., userDataDir: /tmp/.com.google.Chrome.QFkx1l}, goog:chromeOptions: {debuggerAddress: localhost:37451}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
selenide.baseUrl: http://localhost:8080
Session ID: 412ed8c80871bde7c90cfd1fec72c616
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:277)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:857)
    at com.codeborne.selenide.drivercommands.Navigator.lambda$navigateTo$0(Navigator.java:70)
    at com.codeborne.selenide.logevents.SelenideLogger.run(SelenideLogger.java:139)
    at com.codeborne.selenide.drivercommands.Navigator.navigateTo(Navigator.java:66)
    at com.codeborne.selenide.drivercommands.Navigator.open(Navigator.java:30)
    at com.codeborne.selenide.SelenideDriver.open(SelenideDriver.java:86)
    at com.codeborne.selenide.Selenide.open(Selenide.java:49)
    at com.apurebase.puredynamic.selenium.BrowserTest.beforeEach(BrowserTest.kt:49)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptLifecycleMethod(TimeoutExtension.java:126)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptBeforeEachMethod(TimeoutExtension.java:76)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeMethodInExtensionContext(ClassBasedTestDescriptor.java:490)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$synthesizeBeforeEachMethodAdapter$19(ClassBasedTestDescriptor.java:475)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachMethods$2(TestMethodTestDescriptor.java:167)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$5(TestMethodTestDescriptor.java:195)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:195)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachMethods(TestMethodTestDescriptor.java:164)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:127)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at com.sun.proxy.$Proxy2.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:135)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    at java.base/java.lang.Thread.run(Thread.java:832)
```

答: In Kotlin configuration try to change localhost to current active IPV4 of your system

Body:
I'm trying to setup selenoid to run inside docker with a docker-compose. I have tried following the guide on https://aerokube.com/selenoid/1.6.0/#_selenoid_with_docker_compose and have produced a docker-compose.yml file looking like this:

version: '3.6'

services:
  selenoid:
    image: aerokube/selenoid:latest-release
    command: -conf /etc/selenoid/browsers.json -video-output-dir /opt/selenoid/video -log-output-dir /opt/selenoid/logs
    network_mode: bridge
    ports:
      - 5656:4444
    environment:
      OVERRIDE_VIDEO_OUTPUT_DIR: /opt/selenoid/video
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./selenoid/video:/opt/selenoid/video
      - ./selenoid/logs:/opt/selenoid/logs
      - ./selenoid/browsers.json:/etc/selenoid/browsers.json:ro

  selenoid-ui:
    image: aerokube/selenoid-ui:latest-release
    command: --selenoid-uri http://selenoid:4444
    network_mode: bridge
    ports:
      - 5599:8080

and browsers.json:

{
  "chrome": {
    "default": "91.0",
    "versions": {
      "91.0": {
        "image": "selenoid/vnc_chrome:91.0",
        "port": "4444"
      }
    }
  }
}

But with this kotlin configuration:

Configuration.remote = "http://localhost:5656/wd/hub"
Configuration.browserCapabilities = DesiredCapabilities().apply {
    setCapability("browserName", "chrome")
    setCapability("browserVersion", "91.0")
    setCapability("enableVNC", true)
    setCapability("selenoid:options", mapOf(
        "enableVNC" to true,
        "enableVideo" to true,
        "name" to "Kotlin BrowserTest",
    ))
}

I'm getting these errors within selenoid logs:

2021/06/04 16:32:29 [-] [NEW_REQUEST] [unknown] [172.17.0.1]
2021/06/04 16:32:29 [-] [NEW_REQUEST_ACCEPTED] [unknown] [172.17.0.1]
2021/06/04 16:32:29 [5] [LOCATING_SERVICE] [chrome] [91.0]
2021/06/04 16:32:29 [5] [USING_DOCKER] [chrome] [91.0]
2021/06/04 16:32:29 [5] [CREATING_CONTAINER] [selenoid/vnc_chrome:91.0]
2021/06/04 16:32:29 [5] [STARTING_CONTAINER] [selenoid/vnc_chrome:91.0] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d]
2021/06/04 16:32:29 [5] [CONTAINER_STARTED] [selenoid/vnc_chrome:91.0] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d] [0.34s]
2021/06/04 16:32:29 [5] [CREATING_VIDEO_CONTAINER] [selenoid/video-recorder:latest-release]
2021/06/04 16:32:29 [5] [STARTING_VIDEO_CONTAINER] [selenoid/video-recorder:latest-release] [cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181]
2021/06/04 16:32:29 [5] [VIDEO_CONTAINER_STARTED] [selenoid/video-recorder:latest-release] [cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181] [0.29s]
2021/06/04 16:32:29 [5] [SERVICE_STARTED] [selenoid/vnc_chrome:91.0] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d] [0.10s]
2021/06/04 16:32:29 [5] [PROXY_TO] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d] [http://172.17.0.4:4444]
2021/06/04 16:32:29 [5] [SESSION_ATTEMPTED] [http://172.17.0.4:4444] [1]
2021/06/04 16:32:30 [5] [SESSION_CREATED] [412ed8c80871bde7c90cfd1fec72c616] [1] [1.03s]
2021/06/04 16:32:30 [9] [SESSION_DELETED] [412ed8c80871bde7c90cfd1fec72c616]
2021/06/04 16:32:30 [5] [STOPPING_VIDEO_CONTAINER] [cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181]
2021/06/04 16:32:31 [5] [REMOVING_CONTAINER] [cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181]
2021/06/04 16:32:31 [5] [FAILED_TO_REMOVE_CONTAINER] [cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181] [Error: No such container: cd11f627cf455453547e76bae90d9bb337d631d370c86eff4e6aaddff4e69181]
2021/06/04 16:32:31 [5] [REMOVING_CONTAINER] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d]
2021/06/04 16:32:31 [5] [CONTAINER_REMOVED] [1eefaee9142bc58215382caaf39a87cf7ce0a25ab64dd432241074262ef6325d]
2021/06/04 16:32:31 [5] [VIDEO_ERROR] [Failed to rename /opt/selenoid/video/selenoid2217ce756f255ba8e693926caa899ca2.mp4 to /opt/selenoid/video/412ed8c80871bde7c90cfd1fec72c616.mp4: rename /opt/selenoid/video/selenoid2217ce756f255ba8e693926caa899ca2.mp4 /opt/selenoid/video/412ed8c80871bde7c90cfd1fec72c616.mp4: no such file or directory]

and these logs within junit

unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: chrome=91.0.4472.77)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'JOL-WORKSTATION', ip: '10.5.21.136', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
selenide.remote: http://localhost:5656/wd/hub
Driver info: org.openqa.selenium.remote.RemoteWebDriver
selenide.url: http://localhost:3000
Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 91.0.4472.77, chrome: {chromedriverVersion: 91.0.4472.19 (1bf021f248676..., userDataDir: /tmp/.com.google.Chrome.QFkx1l}, goog:chromeOptions: {debuggerAddress: localhost:37451}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
selenide.baseUrl: http://localhost:8080
Session ID: 412ed8c80871bde7c90cfd1fec72c616
org.openqa.selenium.WebDriverException: unknown error: net::ERR_CONNECTION_REFUSED
  (Session info: chrome=91.0.4472.77)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'JOL-WORKSTATION', ip: '10.5.21.136', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '15.0.2'
selenide.remote: http://localhost:5656/wd/hub
Driver info: org.openqa.selenium.remote.RemoteWebDriver
selenide.url: http://localhost:3000
Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 91.0.4472.77, chrome: {chromedriverVersion: 91.0.4472.19 (1bf021f248676..., userDataDir: /tmp/.com.google.Chrome.QFkx1l}, goog:chromeOptions: {debuggerAddress: localhost:37451}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
selenide.baseUrl: http://localhost:8080
Session ID: 412ed8c80871bde7c90cfd1fec72c616
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:277)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:857)
    at com.codeborne.selenide.drivercommands.Navigator.lambda$navigateTo$0(Navigator.java:70)
    at com.codeborne.selenide.logevents.SelenideLogger.run(SelenideLogger.java:139)
    at com.codeborne.selenide.drivercommands.Navigator.navigateTo(Navigator.java:66)
    at com.codeborne.selenide.drivercommands.Navigator.open(Navigator.java:30)
    at com.codeborne.selenide.SelenideDriver.open(SelenideDriver.java:86)
    at com.codeborne.selenide.Selenide.open(Selenide.java:49)
    at com.apurebase.puredynamic.selenium.BrowserTest.beforeEach(BrowserTest.kt:49)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptLifecycleMethod(TimeoutExtension.java:126)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptBeforeEachMethod(TimeoutExtension.java:76)
    at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
    at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeMethodInExtensionContext(ClassBasedTestDescriptor.java:490)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$synthesizeBeforeEachMethodAdapter$19(ClassBasedTestDescriptor.java:475)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachMethods$2(TestMethodTestDescriptor.java:167)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$5(TestMethodTestDescriptor.java:195)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:195)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachMethods(TestMethodTestDescriptor.java:164)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:127)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at com.sun.proxy.$Proxy2.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:135)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    at java.base/java.lang.Thread.run(Thread.java:832)


问:
onChange Not Updating State At Correct Time
I'm trying to save the value of the input field to state. When the defaultValue is 'projectName', and I delete the word 'Name' from the input field, I want the state to update so that the defaultValue is 'project'. When I console.log e.target.value in the onChange, I can see the change happening when I make the deletion, and my code in the onChange is saving the value to state, but unfortunately, the state does not update. Any thoughts as to why?

Here is a Code Sandbox: https://codesandbox.io/s/amazing-river-o15h4?file=/src/Child.js

... And here is a screenshot of the console.log in the onChange and the setState call not updating:

App.js

import "./styles.css";

import Child from "./Child";

export default function App() {
  const thisIsState = {
    id: 1,
    projectName: "projectName",
    description: "description"
  };

  return (

      <Child project={thisIsState} />

  );
}

```
<p>Child.js</p>
<pre class="lang-js prettyprint-override"><code>import { useState, useEffect } from "react";
import "./styles.css";

export default function Child(props) {
  console.log(props);
  const [state, setState] = useState({
    projectName: "",
    description: ""
  });

  let project = props.project;
  let errors = props.errors;
  useEffect(
    (state) => {
      setState({
        ...state,
        projectName: project.projectName,
        description: project.description
      });
      console.log("useEffect1 state: ", state);
    },
    [project, errors]
  );

  const onChange = (e) => {
    console.log("e.target.value in onChange: ", e.target.value);
    setState((state) => ({
      ...state,
      [e.target.name]: e.target.value
    }));
    console.log("onChange() state: ", state);
  };
  return (
    <div className="App">
      <form>
        <input
          type="text"
          placeholder="Project Name"
          name="projectName"
          defaultValue={props.project.projectName}
          onChange={onChange}
          style={{ marginBottom: "15px" }}
        />
        <br />
        <input
          type="text"
          placeholder="Project Name"
          name="projectDescription"
          defaultValue={props.project.description}
          onChange={onChange}
        />
      </form>
    </div>
  );
}

</code>```

答:
Try something like this in your Child component instead of console.log(props). Props does not change because you did not change default state. If you try to log actual state, it is changing.

```<code>const [state, setState] = useState({
    projectName: "",
    description: ""
  });
console.log(state);
</code>```

Body:
I'm trying to save the value of the input field to state. When the defaultValue is 'projectName', and I delete the word 'Name' from the input field, I want the state to update so that the defaultValue is 'project'. When I console.log e.target.value in the onChange, I can see the change happening when I make the deletion, and my code in the onChange is saving the value to state, but unfortunately, the state does not update. Any thoughts as to why?

Here is a Code Sandbox: https://codesandbox.io/s/amazing-river-o15h4?file=/src/Child.js

... And here is a screenshot of the console.log in the onChange and the setState call not updating:

App.js

import "./styles.css";

import Child from "./Child";

export default function App() {
  const thisIsState = {
    id: 1,
    projectName: "projectName",
    description: "description"
  };

  return (

      <Child project={thisIsState} />

  );
}

Child.js

import { useState, useEffect } from "react";
import "./styles.css";

export default function Child(props) {
  console.log(props);
  const [state, setState] = useState({
    projectName: "",
    description: ""
  });

  let project = props.project;
  let errors = props.errors;
  useEffect(
    (state) => {
      setState({
        ...state,
        projectName: project.projectName,
        description: project.description
      });
      console.log("useEffect1 state: ", state);
    },
    [project, errors]
  );

  const onChange = (e) => {
    console.log("e.target.value in onChange: ", e.target.value);
    setState((state) => ({
      ...state,
      [e.target.name]: e.target.value
    }));
    console.log("onChange() state: ", state);
  };
  return (

      <form>
        <input
          type="text"
          placeholder="Project Name"
          name="projectName"
          defaultValue={props.project.projectName}
          onChange={onChange}
          style={{ marginBottom: "15px" }}
        />

        <input
          type="text"
          placeholder="Project Name"
          name="projectDescription"
          defaultValue={props.project.description}
          onChange={onChange}
        />
      </form>

  );
}

Body:
Try something like this in your Child component instead of console.log(props). Props does not change because you did not change default state. If you try to log actual state, it is changing.

const [state, setState] = useState({
    projectName: "",
    description: ""
  });
console.log(state);


问:
Convert array in JSON file to string
Here's a snippet of my JSON object (EDITED) -

```<code>[{
    "traditional": "%",
    "simplified": "%",
    "referencedTraditional": [],
    "referencedSimplified": [],
    "pinyinNumeric": "pa1",
    "pinyinDiacritic": "pā",
    "definitions": [
        "percent (Tw)"
    ],
    "definitionsDiacritic": [
        "percent (Tw)"
    ]
},
{
"traditional":"龠","simplified":"龠","referencedTraditional":[{"cp":"9fa0","c":"龠"}],"referencedSimplified":[{"cp":"9fa0","c":"龠"}],"pinyinNumeric":"yue4","pinyinDiacritic":"yuè","definitions":["ancient unit of volume (half a 合[ge3], equivalent to 50ml)","ancient flute"],"definitionsDiacritic":["ancient unit of volume (half a 合[gě], equivalent to 50ml)","ancient flute"]},
    {"traditional":"龡","simplified":"龡","referencedTraditional":[{"cp":"9fa1","c":"龡"}],"referencedSimplified":[{"cp":"9fa1","c":"龡"}],"pinyinNumeric":"chui4","pinyinDiacritic":"chuì","definitions":["to blow (a flute)","archaic version of 吹"],"definitionsDiacritic":["to blow (a flute)","archaic version of 吹"]},
]
</code>```

I want to convert every key called definitions from an array into a string.

E.g. From ["percent (Tw)"] to "percent (Tw)". Basically, I don't want the array brackets.

So far, I've tried looping through the file and converting every "definitions" key with JSON.stringify() or toString() -

```<code>translations.forEach(key => JSON.stringify((key.definitions)))
</code>```

However, nothing changes in the outputted file.

答:
const obj = {
    traditional: '%',
    simplified: '%',
    referencedTraditional: [],
    referencedSimplified: [],
    pinyinNumeric: 'pa1',
    pinyinDiacritic: 'pā',
    definitions: ['percent (Tw)'],
    definitionsDiacritic: ['percent (Tw)'],
};

const returnStringDefinitions = (obj) => {
    const arr = [];
    for (const [key, value] of Object.entries(obj)) {
        if (key === 'definitions') arr.push(value.toString());
    }
    return arr;
};

console.log(returnStringDefinitions(obj));```

Title: Convert array in JSON file to string

Body:
Here's a snippet of my JSON object (EDITED) -

[{
    "traditional": "%",
    "simplified": "%",
    "referencedTraditional": [],
    "referencedSimplified": [],
    "pinyinNumeric": "pa1",
    "pinyinDiacritic": "pā",
    "definitions": [
        "percent (Tw)"
    ],
    "definitionsDiacritic": [
        "percent (Tw)"
    ]
},
{
"traditional":"龠","simplified":"龠","referencedTraditional":[{"cp":"9fa0","c":"龠"}],"referencedSimplified":[{"cp":"9fa0","c":"龠"}],"pinyinNumeric":"yue4","pinyinDiacritic":"yuè","definitions":["ancient unit of volume (half a 合[ge3], equivalent to 50ml)","ancient flute"],"definitionsDiacritic":["ancient unit of volume (half a 合[gě], equivalent to 50ml)","ancient flute"]},
    {"traditional":"龡","simplified":"龡","referencedTraditional":[{"cp":"9fa1","c":"龡"}],"referencedSimplified":[{"cp":"9fa1","c":"龡"}],"pinyinNumeric":"chui4","pinyinDiacritic":"chuì","definitions":["to blow (a flute)","archaic version of 吹"],"definitionsDiacritic":["to blow (a flute)","archaic version of 吹"]},
]

I want to convert every key called definitions from an array into a string.

E.g. From ["percent (Tw)"] to "percent (Tw)". Basically, I don't want the array brackets.

So far, I've tried looping through the file and converting every "definitions" key with JSON.stringify() or toString() -

translations.forEach(key => JSON.stringify((key.definitions)))

However, nothing changes in the outputted file.


问:
Need for try catch within a constructor
The link http://gotw.ca/gotw/066.htm states that

Moral #1: Constructor function-try-block handlers have only one purpose -- to translate an exception. (And maybe to do logging or some other side effects.) They are not useful for any other purpose.

While http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.8

If a constructor throws an exception, the object's destructor is not run. If your object has already done something that needs to be undone (such as allocating some memory, opening a file, or locking a semaphore), this "stuff that needs to be undone" must be remembered by a data member inside the object.

Are these 2 statements not contradictory?  The first one kind of implies that the try catch within a constructor is pretty much useless while the second says that it is needed to free resources.  What am i missing here?

答:
Moral #1 talks about function-try-block & the second statement talks about a normal try catch block, both are distinctly different.

You need to understand the different between the two to understand how the two sentences make sense. This answer here explains that.

Title: Need for try catch within a constructor


问:
My if loop is taking effect even when it should not
I am making a random number guessing program where users try to guess a number between 1 and 100 while receiving whether they were higher or lower. one of the stipulations was that there must be a function to quit the program upon the user entering Q or q so I formatted my loop as such:

```<code>$RandomNumber = Get-Random -Minimum 1 -Maximum 101
write-output $RandomNumber
$GuessNumber = 0
While ($RandomNumber -ne $Guess)
{
    $Guess = Read-Host -Prompt 'Guess a number between 1 and 100 Or enter Q to quit'
    if ($Guess -eq 'q' -or 'Q')
    {
        Write-output "Thank you for playing"
        BREAK
    }
    if ($Guess -gt 100 -or $Guess -le 1)
    {
        Write-Output 'Invalid Input please enter a number between 1 and 100'

    }
    if ($Guess -le $RandomNumber)
    {
        Write-output 'Your number is lower than the hidden number please guess again'
        $GuessNumber = $GuessNumber +1
    }
    if ($Guess -gt $RandomNumber)
    {
        Write-output 'Your number is higher than the hidden number please guess again'
        $GuessNumber = $GuessNumber +1
    }
    if ($Guess -eq $RandomNumber)
    {
        $GuessNumber = $GuessNumber +1
        Write-output 'Congratulations you guessed the number in' $GuessNumber 'tries'
    }
}
</code>```

the issue I run into is even when the input is equal to 10 for example it still outputs "Thank you for playing" meaning that if loop has taken effect. I am not sure why this occurs as I'm new to powershell and a reasoning for this happening would be helpful

答:
Your error partially comes from -or 'Q' which evaluates to $true always:

```<code>$false -or 'somestring' # => True
</code>```

And it's also worth noting, -eq is case insensitive ('q' -eq 'Q' is $true).
The other error comes from comparing a string with an integer. The output from Read-Host is System.String in this case:

```<code>'50' -gt 100 # => True
'50' -lt 100 # => False
</code>```

On the other hand, you could make your code more readable using a switch statement. For input validation you could use a recursive script block to make sure its always right (between 1 and 100 or Q). To break the outer while loop you can use a labeled break.

```<code>$RandomNumber = Get-Random -Minimum 1 -Maximum 101

$validation = {
    $choice = Read-Host 'Guess a number between 1 and 100 Or enter Q to quit'
    if($choice -notmatch '^([1-9][0-9]?|100|q)$') {
        Write-Warning 'Invalid Input, try again.'
        return & $validation
    }
    $choice
}

$attempts = 0

:outer while($true) {
    $choice = & $validation
    if($choice -eq 'q') {
        # End the Game
        'Thanks for Playing'
        break
    }

    $attempts++

    switch([int]$choice) {
        {$_ -gt $RandomNumber} {
            "$_ was greater than hidden number"
            break
        }
        {$_ -lt $RandomNumber} {
            "$_ was lower than hidden number"
            break
        }
        default {
            "You guessed right after $attempts tries, Congratulations!"
            break outer
        }
    }
}
</code>```

Body:
I am making a random number guessing program where users try to guess a number between 1 and 100 while receiving whether they were higher or lower. one of the stipulations was that there must be a function to quit the program upon the user entering Q or q so I formatted my loop as such:

$RandomNumber = Get-Random -Minimum 1 -Maximum 101
write-output $RandomNumber
$GuessNumber = 0
While ($RandomNumber -ne $Guess)
{
    $Guess = Read-Host -Prompt 'Guess a number between 1 and 100 Or enter Q to quit'
    if ($Guess -eq 'q' -or 'Q')
    {
        Write-output "Thank you for playing"
        BREAK
    }
    if ($Guess -gt 100 -or $Guess -le 1)
    {
        Write-Output 'Invalid Input please enter a number between 1 and 100'

    }
    if ($Guess -le $RandomNumber)
    {
        Write-output 'Your number is lower than the hidden number please guess again'
        $GuessNumber = $GuessNumber +1
    }
    if ($Guess -gt $RandomNumber)
    {
        Write-output 'Your number is higher than the hidden number please guess again'
        $GuessNumber = $GuessNumber +1
    }
    if ($Guess -eq $RandomNumber)
    {
        $GuessNumber = $GuessNumber +1
        Write-output 'Congratulations you guessed the number in' $GuessNumber 'tries'
    }
}

the issue I run into is even when the input is equal to 10 for example it still outputs "Thank you for playing" meaning that if loop has taken effect. I am not sure why this occurs as I'm new to powershell and a reasoning for this happening would be helpful

Body:
Your error partially comes from -or 'Q' which evaluates to $true always:

$false -or 'somestring' # => True

And it's also worth noting, -eq is case insensitive ('q' -eq 'Q' is $true).
The other error comes from comparing a string with an integer. The output from Read-Host is System.String in this case:

'50' -gt 100 # => True
'50' -lt 100 # => False

On the other hand, you could make your code more readable using a switch statement. For input validation you could use a recursive script block to make sure its always right (between 1 and 100 or Q). To break the outer while loop you can use a labeled break.

$RandomNumber = Get-Random -Minimum 1 -Maximum 101

$validation = {
    $choice = Read-Host 'Guess a number between 1 and 100 Or enter Q to quit'
    if($choice -notmatch '^([1-9][0-9]?|100|q)$') {
        Write-Warning 'Invalid Input, try again.'
        return & $validation
    }
    $choice
}

$attempts = 0

:outer while($true) {
    $choice = & $validation
    if($choice -eq 'q') {
        # End the Game
        'Thanks for Playing'
        break
    }

    $attempts++

    switch([int]$choice) {
        {$_ -gt $RandomNumber} {
            "$_ was greater than hidden number"
            break
        }
        {$_ -lt $RandomNumber} {
            "$_ was lower than hidden number"
            break
        }
        default {
            "You guessed right after $attempts tries, Congratulations!"
            break outer
        }
    }
}


问:
js join("\n") not start at new line
I am using an Ant Design table, and this is one of my columns. I would like to show every name on a new line, and I'm using "\n" but it's not working - it only adds spaces, it doesn't start the second name at the new line.</p>
```<code>{
    title: "Borrower Name",
    width: 150,
    dataIndex: "borrower",
    render: (record) => record.map((a) => a.name).join("\n"),
}
</code>```

答:
map() function should return something,
Should be like this:</p>
```<code>render: (record) => record.map(a => {return a.name}).join("\n")

</code>```

Title: js join("\n") not start at new line

Body:
I am using an Ant Design table, and this is one of my columns. I would like to show every name on a new line, and I'm using "\n" but it's not working - it only adds spaces, it doesn't start the second name at the new line.

{
    title: "Borrower Name",
    width: 150,
    dataIndex: "borrower",
    render: (record) => record.map((a) => a.name).join("\n"),
}

Body:
map() function should return something,
Should be like this:

render: (record) => record.map(a => {return a.name}).join("\n")


问:
Mule 4 adding a timestamp to a filepath location and name
```<code>Path folder/finename
</code>```

So the folder name that I want to save the file in is "output" and "ScheduleTest.csv" this is the filename I like to call it, but I want to add a timestamp to it. This is on a File Write module. Does anyone know how to do that in expression mode?

```<code><file:write doc:name="Write" doc:id="bba24eb0-8f63-4b6c-9c40-b5529325b4ea" config-ref="File_Config" path="output/ScheduleTest.csv" mode="APPEND">
        <file:content><![CDATA[#[output application/csv header=false --- payload]]]></file:content>
    </file:write>
</code>```

答:
In an expression you can use DataWeave expressions to create the timestamp as needed:</p>
```<code>path="#['output/ScheduleTest.csv' ++ now() as DateTime as String {format: 'yyyyMMddHHmmss'} ]"
</code>```

Body:
Path folder/finename

So the folder name that I want to save the file in is "output" and "ScheduleTest.csv" this is the filename I like to call it, but I want to add a timestamp to it. This is on a File Write module. Does anyone know how to do that in expression mode?

<file:write doc:name="Write" doc:id="bba24eb0-8f63-4b6c-9c40-b5529325b4ea" config-ref="File_Config" path="output/ScheduleTest.csv" mode="APPEND">
        <file:content><![CDATA[#[output application/csv header=false --- payload]]]></file:content>
    </file:write>

Body:
In an expression you can use DataWeave expressions to create the timestamp as needed:

path="#['output/ScheduleTest.csv' ++ now() as DateTime as String {format: 'yyyyMMddHHmmss'} ]"


问:
how to convert string to vector<int> c++
I would like to convert an string into a vector, so that it looks like the following:

```<code>string number = "0110";
vector < int > Vec;
</code>```

with the result:

```<code>Vec[0] = 0
Vec[1] = 1
Vec[2] = 1
Vec[3] = 0
</code>```

My problem is that the number starts with a 0, so using % doesn't seem to work if i first transform my string to an int

答:
I noticed that the question is modified to make it answerable:</p>
```<code>#include <string>
#include <vector>

int main(){
    using namespace std;
    string number = "0110";
    vector < int > Vec;
    for(char& digit : number){
        Vec.push_back(digit - '0');
    }
}
</code>```

Body:
I would like to convert an string into a vector, so that it looks like the following:

string number = "0110";
vector < int > Vec;

with the result:

Vec[0] = 0
Vec[1] = 1
Vec[2] = 1
Vec[3] = 0

My problem is that the number starts with a 0, so using % doesn't seem to work if i first transform my string to an int

Body:
I noticed that the question is modified to make it answerable:

#include <string>
#include <vector>

int main(){
    using namespace std;
    string number = "0110";
    vector < int > Vec;
    for(char& digit : number){
        Vec.push_back(digit - '0');
    }
}


问:
Unexpected symbol 'dim' with a OLEDB connection
How do I fix this error? I'm using asp.net

Compilation Error

Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.

Compiler Error Message: CS1519: Unexpected symbol `Dim' in class, struct, or interface member declaration

Source code:

```<code><%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
sub Page_Load
Dim dbconn As OleDbConnection
dbconn=New OleDbConnection("Provider=SQLOLEDB;
Data source='http://localhost';
User Id='90782';
Password='@ER#82L(*&!';")
dbconn.Open()
end sub
</script>
</code>```

PS: Double quote added, but this didn't fix the problem.

答:
Try This:</p>

```<code><%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
      sub Page_Load
         Dim dbconn As OleDbConnection
         dbconn=New OleDbConnection("Provider=SQLOLEDB;
                   Data source='http://localhost';
                   User Id='90782';
                   Password='@ER#82L(*&!';")
         dbconn.Open()
      end sub
</script>
</code>```

Body:
How do I fix this error? I'm using asp.net

Compilation Error

Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.

Compiler Error Message: CS1519: Unexpected symbol `Dim' in class, struct, or interface member declaration

Source code:

<%@ Import Namespace="System.Data.OleDb" %>

PS: Double quote added, but this didn't fix the problem.

Body:
Try This:

<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
      sub Page_Load
         Dim dbconn As OleDbConnection
         dbconn=New OleDbConnection("Provider=SQLOLEDB;
                   Data source='http://localhost';
                   User Id='90782';
                   Password='@ER#82L(*&!';")
         dbconn.Open()
      end sub
</script>