问:
How to run the same asynctask more than once?
I have my asyncTask run when the activity first starts, then if network connectivity is not available then i have a refresh button that tries to run the asyncTask to try again. But i get a debug error saying this..

```<code>07-29 18:14:21.290: ERROR/AndroidRuntime(9080): FATAL EXCEPTION: main
07-29 18:14:21.290: ERROR/AndroidRuntime(9080): java.lang.IllegalStateException: Cannot execute task: the task has already been executed (a task can be executed only once)
   07-29 18:14:21.290: ERROR/AndroidRuntime(9080):     at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:541)
   07-29 18:14:21.290: ERROR/AndroidRuntime(9080):     at android.os.AsyncTask.execute(AsyncTask.java:499)
  07-29 18:14:21.290: ERROR/AndroidRuntime(9080):     at com.fttech.gameIT.MainMenu$1.onClick(MainMenu.java:90)
</code>```

Is there anyway to run this twice?

答:
You can do it like this :

```<code>private MyAsyncTask createAsyncTask(){
    if (myAsyncTask == null){
        return myAsyncTask = new MyAsyncTask();
    }
        myAsyncTask.cancel(true);
        return myAsyncTask = new MyAsyncTask();
 }
</code>```

and then you can use it :

```<code>createAsyncTask().execute();
</code>```

this make a new instance of your background task everytime.

Body:
I have my asyncTask run when the activity first starts, then if network connectivity is not available then i have a refresh button that tries to run the asyncTask to try again. But i get a debug error saying this..

07-29 18:14:21.290: ERROR/AndroidRuntime(9080): FATAL EXCEPTION: main
07-29 18:14:21.290: ERROR/AndroidRuntime(9080): java.lang.IllegalStateException: Cannot execute task: the task has already been executed (a task can be executed only once)
   07-29 18:14:21.290: ERROR/AndroidRuntime(9080):     at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:541)
   07-29 18:14:21.290: ERROR/AndroidRuntime(9080):     at android.os.AsyncTask.execute(AsyncTask.java:499)
  07-29 18:14:21.290: ERROR/AndroidRuntime(9080):     at com.fttech.gameIT.MainMenu$1.onClick(MainMenu.java:90)

Is there anyway to run this twice?

Body:
You can do it like this :

private MyAsyncTask createAsyncTask(){
    if (myAsyncTask == null){
        return myAsyncTask = new MyAsyncTask();
    }
        myAsyncTask.cancel(true);
        return myAsyncTask = new MyAsyncTask();
 }

and then you can use it :

createAsyncTask().execute();

this make a new instance of your background task everytime.


来源: stackexchange

问:
Magento indexing blank page, status pending
My indexing page keeps blank on the most recent version of Magento. I can't seem to find out why!

What I've tried:

Using SSH:

```<code>php -f indexer.php reindex all
</code>```

I got a response that indexing will begin. So I don't receive this message:

```<code>Index process is working now. Please try run this process later
</code>```

But each time I try to check the status, all I get is:

```<code>Product Attributes:            Pending
Product Prices:                Pending
Catalog URL Rewrites:          Pending
Product Flat Data:             Pending
Category Flat Data:            Pending
Category Products:             Pending
Catalog Search Index:          Pending
Stock Status:                  Pending
Tag Aggregation Data:          Pending
</code>```

I also tried to set the indexing to "manual update" using SSH. This didn't fix the issue and I still got a blank page :(

How can I fix my blank indexing page?

Edit:
Problem was caused by a corrupt extension

答: The problem was caused by a corrupt (partially uploaded) extension.</p>

ContentLicense: CC BY-SA 3.0

Body:
My indexing page keeps blank on the most recent version of Magento. I can't seem to find out why!

What I've tried:

Using SSH:

php -f indexer.php reindex all

I got a response that indexing will begin. So I don't receive this message:

Index process is working now. Please try run this process later

But each time I try to check the status, all I get is:

Product Attributes:            Pending
Product Prices:                Pending
Catalog URL Rewrites:          Pending
Product Flat Data:             Pending
Category Flat Data:            Pending
Category Products:             Pending
Catalog Search Index:          Pending
Stock Status:                  Pending
Tag Aggregation Data:          Pending

I also tried to set the indexing to "manual update" using SSH. This didn't fix the issue and I still got a blank page :(

How can I fix my blank indexing page?

Edit:
Problem was caused by a corrupt extension

ContentLicense: CC BY-SA 4.0


问:
Java - How to wait until uploadFileToBlockBlob has finished?
Having a problem with Azure's sdk v10, when I'm uploading files the code carries on while the upload does its thing, but I'd really like to hold until the upload finishes.

I saw c# has an 'await' function, is there a Java way to handle this?

```<code>try{

    AsynchronousFileChannel fileChannel = AsynchronousFileChannel.open(file.toPath());

    TransferManager.uploadFileToBlockBlob(fileChannel, blob, 8*1024*1024, null, null)
        .subscribe( azureResponse -> {
        logger.info("Status code: " + azureResponse.response().statusCode());
        if( azureResponse.response().statusCode() != 201){
            logger.error("upload failed - " + azureResponse.response().body());
            // throw exception
        }
    });
} catch( Exception e ) {
  // handle the exception
}
</code>```

答:
I am not familiar with azure in particular but perhaps you can write a while loop that blocks thread executing until the upload process has finished. Something as simple as this should do the trick provided you have a separate boolean method that returns true when the file has finished uploading:

```<code>while(!hasFileUploaded())
{
    // do nothing here
}
</code>```

I am sorry if this answer seems a bit generic but without further knowledge about how and where the file is being uploaded I can't tell you exactly how to validate the upload process.

Body:
Having a problem with Azure's sdk v10, when I'm uploading files the code carries on while the upload does its thing, but I'd really like to hold until the upload finishes.

I saw c# has an 'await' function, is there a Java way to handle this?

try{

    AsynchronousFileChannel fileChannel = AsynchronousFileChannel.open(file.toPath());

    TransferManager.uploadFileToBlockBlob(fileChannel, blob, 8*1024*1024, null, null)
        .subscribe( azureResponse -> {
        logger.info("Status code: " + azureResponse.response().statusCode());
        if( azureResponse.response().statusCode() != 201){
            logger.error("upload failed - " + azureResponse.response().body());
            // throw exception
        }
    });
} catch( Exception e ) {
  // handle the exception
}

Body:
I am not familiar with azure in particular but perhaps you can write a while loop that blocks thread executing until the upload process has finished. Something as simple as this should do the trick provided you have a separate boolean method that returns true when the file has finished uploading:

while(!hasFileUploaded())
{
    // do nothing here
}

I am sorry if this answer seems a bit generic but without further knowledge about how and where the file is being uploaded I can't tell you exactly how to validate the upload process.


问:
How to send an email template to multiple users (email addresses) in Odoo 12
I want to send an email to multiple users in Odoo 12 when a scheduler runs with custom data in email. I created my email template in the XML file. Also, I have a method which returns all my email addresses as a list. How can I loop over this list in email template in "email_to" field and get all email addresses and send the email to all of those emails?

Following is my email template:

```<code><?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data noupdate="1">
        <record id="repayment_due_date_reminder_email_template" model="mail.template">
            <field name="name">Repayment Due Date Reminder Email Template</field>
            <field name="email_from">admin@netlinks.af</field>
            <field name="subject">Repayment Due Date Reminder</field>
            <field name="email_to">${for email in object.get_groups_usesr_email():
                                        }</field>
            <field name="lang">${object.lang}</field>
            <field name="model_id" ref="hr_payroll_advance_salary.model_loan_request"/>
            <field name="body_html">
                <![CDATA[
                <p>The following loan installment is due for repayment:<br/>
                Loan Recepient: ${(object.employee_id.name)}<br/>
                Total Loan Amount: ${(object.loan_amount)} ${(object.currency)} <br/>
                Installment Due: ${(object.loan_amount)} ${(object.currency)} <br/>
                Repayment Date: ${(object.repayment_schedule_ids.repayment_date)} <br/>
                You can view the loan record here for further details </p>
                ]]>
            </field>
        </record>
    </data>
</odoo>
</code>```

I call the email template using the below code:

```<code>template_rec = self.env.ref('hr_payroll_advance_salary.repayment_due_date_reminder_email_template')
template_rec.send_mail(loan.id, force_send=True)
</code>```

And this is the method which returns emails:

```<code>@api.multi
    def get_groups_usesr_email(self):
        emails = []
        user_ids = self.get_users_from_groups('group_nl_finance_manager')
        emails = self.get_users_email('group_nl_finance_manager', user_ids)
        user_ids = self.get_users_from_groups('group_nl_ceo')
        new_emails = self.get_users_email('group_nl_ceo', user_ids)
        for email in new_emails:
            emails.append(email)
        return emails
</code>```

I'm doing the above things in order to send an email to all users of two different groups and I am not sure if it's the appropriate way or not. Is it possible to do what I want to do or not or it can be done using another way?

答:
You can use the mass_mailing (Email Marketing
By Odoo S.A) module to do that. </p>

Body:
I want to send an email to multiple users in Odoo 12 when a scheduler runs with custom data in email. I created my email template in the XML file. Also, I have a method which returns all my email addresses as a list. How can I loop over this list in email template in "email_to" field and get all email addresses and send the email to all of those emails?

Following is my email template:

<?xml version="1.0" encoding="utf-8"?>
<odoo>
    <data noupdate="1">
        <record id="repayment_due_date_reminder_email_template" model="mail.template">
            <field name="name">Repayment Due Date Reminder Email Template</field>
            <field name="email_from">admin@netlinks.af</field>
            <field name="subject">Repayment Due Date Reminder</field>
            <field name="email_to">${for email in object.get_groups_usesr_email():
                                        }</field>
            <field name="lang">${object.lang}</field>
            <field name="model_id" ref="hr_payroll_advance_salary.model_loan_request"/>
            <field name="body_html">
                <![CDATA[

The following loan installment is due for repayment:

                Loan Recepient: ${(object.employee_id.name)}

                Total Loan Amount: ${(object.loan_amount)} ${(object.currency)}

                Installment Due: ${(object.loan_amount)} ${(object.currency)}

                Repayment Date: ${(object.repayment_schedule_ids.repayment_date)}

                You can view the loan record here for further details

                ]]>
            </field>
        </record>
    </data>
</odoo>

I call the email template using the below code:

template_rec = self.env.ref('hr_payroll_advance_salary.repayment_due_date_reminder_email_template')
template_rec.send_mail(loan.id, force_send=True)

And this is the method which returns emails:

@api.multi
    def get_groups_usesr_email(self):
        emails = []
        user_ids = self.get_users_from_groups('group_nl_finance_manager')
        emails = self.get_users_email('group_nl_finance_manager', user_ids)
        user_ids = self.get_users_from_groups('group_nl_ceo')
        new_emails = self.get_users_email('group_nl_ceo', user_ids)
        for email in new_emails:
            emails.append(email)
        return emails

I'm doing the above things in order to send an email to all users of two different groups and I am not sure if it's the appropriate way or not. Is it possible to do what I want to do or not or it can be done using another way?


问:
How to delete each third row from
 using only JavaScript?
I want to delete each third row in this code.
How I can do this?
Thanks for any answers

I was trying to do something like this:

```<code>const table = document.getElementById('myTable');

for (let i =0; i <table.rows.length; i++) {
  if (i%3 === 0 ) {
    table.deleteRow(i)
  }
}
</code>```

I have this table:

```<code>        <tbody>
            <tr>
                <td>First row.</td>
            </tr>
            <tr>
                <td>Second row.</td>
            </tr>
          <tr>
                <td>DELETE 3</td>
            </tr>
          <tr>
                <td>4 row.</td>
            </tr>
          <tr>
                <td>5 row.</td>
            </tr>
          <tr>
                <td>DELETE 6</td>
            </tr>
          <tr>
                <td>First row.</td>
            </tr>
            <tr>
                <td>Second row.</td>
            </tr>
          <tr>
                <td>DELETE 9</td>
            </tr>
        </tbody>
</code>```

I need a script which I will put in the console of my browser and I will delete each third row in anything table. Thank you!

答:
Use Array.forEach to iterate over a selection of all the rows.

const tableRows = document.querySelectorAll("#mytable tr")

Array.from(tableRows).forEach((row, i) => {
  if ((i + 1) % 3 === 0) {
    row.parentNode.removeChild(row);
  }
})```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table id="mytable">
  <tbody>
    <tr>
      <td>1 row.</td>
    </tr>
    <tr>
      <td>2 row.</td>
    </tr>
    <tr>
      <td>DELETE 3</td>
    </tr>
    <tr>
      <td>4 row.</td>
    </tr>
    <tr>
      <td>5 row.</td>
    </tr>
    <tr>
      <td>DELETE 6</td>
    </tr>
    <tr>
      <td>7 row.</td>
    </tr>
    <tr>
      <td>8 row.</td>
    </tr>
    <tr>
      <td>DELETE 9</td>
    </tr>
  </tbody>
</table></code>```

Or use ECMAScript 2015's spread syntax to do the same thing

[...document.querySelectorAll('#mytable tr')].forEach((el, i) => {if (i % 3 === 2) {el.remove()}});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table id="mytable">
  <tbody>
    <tr>
      <td>1 row.</td>
    </tr>
    <tr>
      <td>2 row.</td>
    </tr>
    <tr>
      <td>DELETE 3</td>
    </tr>
    <tr>
      <td>4 row.</td>
    </tr>
    <tr>
      <td>5 row.</td>
    </tr>
    <tr>
      <td>DELETE 6</td>
    </tr>
    <tr>
      <td>7 row.</td>
    </tr>
    <tr>
      <td>8 row.</td>
    </tr>
    <tr>
      <td>DELETE 9</td>
    </tr>
  </tbody>
</table></code>```

Title: How to delete each third row from <tbody> using only JavaScript?

Body:
I want to delete each third row in this code.
How I can do this?
Thanks for any answers

I was trying to do something like this:

const table = document.getElementById('myTable');

for (let i =0; i <table.rows.length; i++) {
  if (i%3 === 0 ) {
    table.deleteRow(i)
  }
}

I have this table:

                First row.

                Second row.

                DELETE 3

                4 row.

                5 row.

                DELETE 6

                First row.

                Second row.

                DELETE 9

I need a script which I will put in the console of my browser and I will delete each third row in anything table. Thank you!

Body:
Use Array.forEach to iterate over a selection of all the rows.

const tableRows = document.querySelectorAll("#mytable tr")

Array.from(tableRows).forEach((row, i) => {
  if ((i + 1) % 3 === 0) {
    row.parentNode.removeChild(row);
  }
})

<table id="mytable">
  <tbody>
    <tr>
      <td>1 row.</td>
    </tr>
    <tr>
      <td>2 row.</td>
    </tr>
    <tr>
      <td>DELETE 3</td>
    </tr>
    <tr>
      <td>4 row.</td>
    </tr>
    <tr>
      <td>5 row.</td>
    </tr>
    <tr>
      <td>DELETE 6</td>
    </tr>
    <tr>
      <td>7 row.</td>
    </tr>
    <tr>
      <td>8 row.</td>
    </tr>
    <tr>
      <td>DELETE 9</td>
    </tr>
  </tbody>
</table>

Or use ECMAScript 2015's spread syntax to do the same thing

[...document.querySelectorAll('#mytable tr')].forEach((el, i) => {if (i % 3 === 2) {el.remove()}});

<table id="mytable">
  <tbody>
    <tr>
      <td>1 row.</td>
    </tr>
    <tr>
      <td>2 row.</td>
    </tr>
    <tr>
      <td>DELETE 3</td>
    </tr>
    <tr>
      <td>4 row.</td>
    </tr>
    <tr>
      <td>5 row.</td>
    </tr>
    <tr>
      <td>DELETE 6</td>
    </tr>
    <tr>
      <td>7 row.</td>
    </tr>
    <tr>
      <td>8 row.</td>
    </tr>
    <tr>
      <td>DELETE 9</td>
    </tr>
  </tbody>
</table>


问:
How configure maven-war-plugin for tomcat
I can not generate proper WAR file for Tomcat.

I am using MAVEN 3.6.1, Java 12.0.1 and IDE Eclipse. My app is working fine when I run it in eclipse (Run as > Spring Boot App) but the problem is when I am trying to run my WAR file after generate it.

I am doing java -jar .war  and I am getting:

```<code>Error: Could not find or load main class com.blw.linemanager.Application
Caused by: java.lang.ClassNotFoundException: com.blw.linemanager.Application
</code>```

I was googling and reading stackoverflow cause I found many post about it but still can not run it. What I am doing wrong?

After some reading I figured out that I have some how configure maven-war-plugin (am I right?) and in pom I did some changes but it does not help.

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>bwl</groupId>
    <artifactId>LineManager</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.8.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.1.3.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-utils</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <properties>
        <start-class>com.blw.linemanager.Application</start-class>
        <maven.compiler.source>12</maven.compiler.source>
        <maven.compiler.target>12</maven.compiler.target>
    </properties>

    <build>
        <finalName>LineManager</finalName>
        <outputDirectory>${project.build.directory}</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <release>12</release>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/META-INF</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/main/resources/META-INF</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archive>
                        <manifest>
                            <classpathPrefix>${project.build.directory}/WEB-INF/classes</classpathPrefix>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.blw.linemanager.Application</mainClass>
                        </manifest>
                        <manifestFile>${project.build.directory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
```

<p>Also because on the beginning I was getting error 'no main manifest attribute' I add it and now it looks like this</p>

```Manifest-Version: 1.0
Created-By: Apache Maven ${maven.version}
Build-Jdk: ${java.version}
```

<p>Is my way of think wrong? Should I be able to run .war file as java -jar .war or this is missunderstanding?</p>

<pre class="lang-java prettyprint-override"><code>@SpringBootApplication
public class Application extends org.springframework.boot.web.support.SpringBootServletInitializer {
    public static void main(String [] args) {
        SpringApplication app = new SpringApplication(Application.class);
        app.run(args);
    }

    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(Application.class);
    }

}
</code>```

答:
It is better to get a working spring boot application from here to avoid versions conflicts and the like.
For a war-file deployment (into a local tomcat for example), your application must extend  SpringBootServletInitializer:

```<code>    @SpringBootApplication
    public class SpringBootTomcatApplication extends SpringBootServletInitializer {
      public static void main(String[] args) {
        SpringApplication.run(SpringBootTomcatApplication.class, args);
      }

      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SpringBootTomcatApplication.class);
      }
    }
</code>```

Change in your pom the  packaging to war.

```<code><packaging>war</packaging>
</code>```

To generate a war-file you need just the spring-boot-maven-plugin:

```<code><build>
  <plugins>
    <plugin>
      <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
  </plugins>
</build>
</code>```

And yes you don't need the maven-war-plugin. Just for testing purposes let's annotate our application with @RestController and introduce a simple endpoint:

```<code>    @RestController
    @SpringBootApplication
    public class SpringBootTomcatApplication extends SpringBootServletInitializer {
    ...
      @RequestMapping(value = "/")
      public String hello() {
        return "Hello World from Tomcat";
      }
    }
</code>```

In the Local terminal (in eclipse Ctrl+Alt+T)  just enter mvn package than copy the generated war-file from target folder, paste it under the webapps folder of your local Tomcat, request http://localhost:8080/{your-application-name} and you should see the message Hello World from Tomcat.
Now you can add the dependencies you need and continue coding.

Body:
I can not generate proper WAR file for Tomcat.

I am using MAVEN 3.6.1, Java 12.0.1 and IDE Eclipse. My app is working fine when I run it in eclipse (Run as > Spring Boot App) but the problem is when I am trying to run my WAR file after generate it.

I am doing java -jar .war  and I am getting:

Error: Could not find or load main class com.blw.linemanager.Application
Caused by: java.lang.ClassNotFoundException: com.blw.linemanager.Application

I was googling and reading stackoverflow cause I found many post about it but still can not run it. What I am doing wrong?

After some reading I figured out that I have some how configure maven-war-plugin (am I right?) and in pom I did some changes but it does not help.

<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>bwl</groupId>
    <artifactId>LineManager</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.8.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.1.3.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.1</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.plexus</groupId>
            <artifactId>plexus-utils</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <properties>
        <start-class>com.blw.linemanager.Application</start-class>
        <maven.compiler.source>12</maven.compiler.source>
        <maven.compiler.target>12</maven.compiler.target>
    </properties>

    <build>
        <finalName>LineManager</finalName>
        <outputDirectory>${project.build.directory}</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <release>12</release>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/META-INF</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/main/resources/META-INF</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                    <archive>
                        <manifest>
                            <classpathPrefix>${project.build.directory}/WEB-INF/classes</classpathPrefix>
                            <addClasspath>true</addClasspath>
                            <mainClass>com.blw.linemanager.Application</mainClass>
                        </manifest>
                        <manifestFile>${project.build.directory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

Also because on the beginning I was getting error 'no main manifest attribute' I add it and now it looks like this

Manifest-Version: 1.0
Created-By: Apache Maven ${maven.version}
Build-Jdk: ${java.version}

Is my way of think wrong? Should I be able to run .war file as java -jar .war or this is missunderstanding?

@SpringBootApplication
public class Application extends org.springframework.boot.web.support.SpringBootServletInitializer {
    public static void main(String [] args) {
        SpringApplication app = new SpringApplication(Application.class);
        app.run(args);
    }

    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(Application.class);
    }

}

Body:
It is better to get a working spring boot application from here to avoid versions conflicts and the like.
For a war-file deployment (into a local tomcat for example), your application must extend  SpringBootServletInitializer:

    @SpringBootApplication
    public class SpringBootTomcatApplication extends SpringBootServletInitializer {
      public static void main(String[] args) {
        SpringApplication.run(SpringBootTomcatApplication.class, args);
      }

      @Override
      protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(SpringBootTomcatApplication.class);
      }
    }

Change in your pom the  packaging to war.

<packaging>war</packaging>

To generate a war-file you need just the spring-boot-maven-plugin:

<build>
  <plugins>
    <plugin>
      <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
  </plugins>
</build>

And yes you don't need the maven-war-plugin. Just for testing purposes let's annotate our application with @RestController and introduce a simple endpoint:

    @RestController
    @SpringBootApplication
    public class SpringBootTomcatApplication extends SpringBootServletInitializer {
    ...
      @RequestMapping(value = "/")
      public String hello() {
        return "Hello World from Tomcat";
      }
    }

In the Local terminal (in eclipse Ctrl+Alt+T)  just enter mvn package than copy the generated war-file from target folder, paste it under the webapps folder of your local Tomcat, request http://localhost:8080/{your-application-name} and you should see the message Hello World from Tomcat.
Now you can add the dependencies you need and continue coding.


问:
AWS TransitGateway VPN Routes Remain in Blackhole State
Has someone here succeeded in implementing an AWS VPN Connection with AWS TransitGateway service?

I've created and configured my transit gateway and attachement of type VPN, with a transit gateway route table and association.
I've downloaded the resulting vpn connection with static routing configuration and configured my on-prem routers, and my tunnels are up.

However :

I can reach my tunnels' public IP addresses from the on-prem network
and AWS VPC

I can reach my tunnels' public IP addresses from my on-prem
network

I can't reach my on-prem router's public IP address

I can't reach any host from my on-prem network to AWS VPC, and inversely

When I look at the corresponding transit gateway route table, I can see all VPN routes are in blackhole state. If I set them to the active state, but they still come back to blackhole state. In this blackhole state the TransitGateway drops packets silently...

Any help?

答:
I've also added the route to the onpremise  network 10.0.0.0/8 in the transit gateway route associated to the VPC attachement  (not the VPN attachement) attached to the concerned aws VPC , and now I can reach the onpremise network through the TGW from aws.

I think packets first leaves the VPC they belong to, and need a route to get to the VPN, this route is the VPN attachement (the route I've added to the tgw VPN attachment route table, has the VPN attachment as the target), and then from the VPN attachment, the rest of the flow  is handled by the VPN attachment through VPN connection.

So to conclude, in order your AWS TGW achieving VPN connection, you need a VPN attachment to establish VPN connections, and a VPC attachement associated to the AWS VPC you want to connect to your onpremise network, and then route to onpremise network in both VPN and VPC attachments related transit gateway route tables.

The above disposition is in the case you don't work with transit gateway default route table, and make specific transit gateway route table for each attachment


问:
iteration over object of object
I have the following structure

```<code>[
  {
    "name": null
    "match": [{
                 "id": 0,
                 "location": ""

             "awayTeam": {
                     "id": 1568,
                     "teamName": "Manly United" },
                 "homeTeam": {
                     "id": 1523,
                     "teamName": "Sydney FC Youth" },
                     "matchDataProvider": [{
                            "id": 2953046,
                         "updatedDate": null }],
                 "matchPunditPrediction": [],
                 "matchResult": null,
                     "userMatchPrediction": []
               }]
   }
]
</code>```

I need to iterate over the match element and retrieve properties

答:
You can do by:
arr = your full array.

```<code>arr.forEach(obj => {
  obj.match.forEach(m => {
    // This contains the match object.
    console.log(m);
    console.log(m.id);
  })
})
</code>```

For html.

```<code><div *ngFor="let item of myData">
  <div *ngFor="let match of item.match | json"> {{ match }} </div>
</div>
</code>```

Title: iteration over object of object

Body:
I have the following structure

[
  {
    "name": null
    "match": [{
                 "id": 0,
                 "location": ""

             "awayTeam": {
                     "id": 1568,
                     "teamName": "Manly United" },
                 "homeTeam": {
                     "id": 1523,
                     "teamName": "Sydney FC Youth" },
                     "matchDataProvider": [{
                            "id": 2953046,
                         "updatedDate": null }],
                 "matchPunditPrediction": [],
                 "matchResult": null,
                     "userMatchPrediction": []
               }]
   }
]

I need to iterate over the match element and retrieve properties

Body:
You can do by:
arr = your full array.

arr.forEach(obj => {
  obj.match.forEach(m => {
    // This contains the match object.
    console.log(m);
    console.log(m.id);
  })
})

For html.

<div *ngFor="let item of myData">
  <div *ngFor="let match of item.match | json"> {{ match }} </div>
</div>


问:
Why we need to use <uses-feature> attribute?
My question is related to camera. When an application needs to use the system camera, we create an intent with ACTION_IMAGE_CAPTURE action and add a permission like this in the manifest file.

```<code><uses-permission android:name="android.permission.CAMERA"/>
</code>```

But besides that, there is one such

```<code><uses-feature android:name="android.hardware.camera"/>
</code>```

What is it for? I read that if this line is written, then if the phone does not have a camera the application will not install. Is it true? And besides this, why do we need this?

And for what the line <uses-feature/> is generally responsible in manifest file?

答: <uses-feature/> is there to guide Google play store to filter out this application from devices which do not have Camera hardware.

Body:
My question is related to camera. When an application needs to use the system camera, we create an intent with ACTION_IMAGE_CAPTURE action and add a permission like this in the manifest file.

<uses-permission android:name="android.permission.CAMERA"/>

But besides that, there is one such

<uses-feature android:name="android.hardware.camera"/>

What is it for? I read that if this line is written, then if the phone does not have a camera the application will not install. Is it true? And besides this, why do we need this?

And for what the line <uses-feature/> is generally responsible in manifest file?


问:
Vector option in Java
I am using vector of object. My issue is the removal from vector is expensive operation( O(n^2)). What would be the replacement of vector in Java. In my uses addition and removal is extensively happens.

i am C++ person don't know much Java

答:
Actually, the difference between Vector and ArrayList is that Vector is synchronized whereas ArrayList is not. Generally, you don't need synchronization and thus you'd use ArrayList (much like StringBuffer <-> StringBuilder).

The replacement mostly depends on how you intend to use the collection.

Adding objects to an ArrayList is quite fast, since if more space is required, it is normally doubled, and if you know the size requirements in advance, even better.

Removing from an ArrayList is O(n) but iteration and random access are fast.

If you have frequent add or remove operations and otherwise iterate over the list, a LinkedList would be fine.

You could even consider using a LinkedHashMap which allows fast access as well as preserves the order of insertion.

Title: Vector option in Java


问:
Can't import Airflow plugins
Following Airflow tutorial here.

Problem: The webserver returns the following error

```<code>Broken DAG: [/usr/local/airflow/dags/test_operator.py] cannot import name
MyFirstOperator
</code>```

Notes:
The directory structure looks like this:

```<code>airflow_home
├── airflow.cfg
├── airflow.db
├── dags
│   └── test_operators.py
├── plugins
│   └── my_operators.py
└── unittests.cfg
</code>```

I am attempting to import the plugin in 'test_operators.py' like this:

```<code>from airflow.operators import MyFirstOperator
</code>```

The code is all the same as what is found in the tutorial.

答:
In my case I managed to make a custom operator with the following steps:

Airflow 10.3

in DAG File from airflow.operators import MacrosPostgresOperator

In ~/airflow/plugins folder I have a python file custom_operator.py and the code is pretty simple

from airflow.plugins_manager import AirflowPlugin
from airflow.operators.postgres_operator import PostgresOperator

 class MacrosPostgresOperator(PostgresOperator):
    template_fields = ('sql', 'parameters')

class MacrosFirstPlugin(AirflowPlugin):
    name = "macros_first_plugin"
    operators = [MacrosPostgresOperator]
```

Title: Can't import Airflow plugins

Body:
Following Airflow tutorial here.

Problem: The webserver returns the following error

Broken DAG: [/usr/local/airflow/dags/test_operator.py] cannot import name
MyFirstOperator

Notes:
The directory structure looks like this:

airflow_home
├── airflow.cfg
├── airflow.db
├── dags
│   └── test_operators.py
├── plugins
│   └── my_operators.py
└── unittests.cfg

I am attempting to import the plugin in 'test_operators.py' like this:

from airflow.operators import MyFirstOperator

The code is all the same as what is found in the tutorial.


问:
Why am I getting error CS0246: The type or namespace name could not be found?
I am using Snarl C# API to send notifications to snarl.

Now I have saved the content of above url in a file named SnarlNetwork.cs and the content of my test.cs file are:

```<code>using SnarlNetworkProtocol;
using System;
class test
{
    public static void Main(String[] args)
    {
        SNP snarl_object = new SNP();
        string hostname = "localhost";
        string hostport = "9887";
        string appName = "Spotify";

        bool val = snarl_object.register(hostname, hostport, appName);

        if (val == true)
        {
            string title = "hello";
            string message = "world";
            string timeout = "5";
            bool newval = snarl_object.notify(hostname, hostport, appName, null, title, message, timeout);

            if (newval == true)
            {
                Console.WriteLine("sucessfull");

            }
        }
    }

}
</code>```

Now when I try to compile my test.cs file using csc test.cs I get the following error:

```<code>C:\Users\Noob\csharp>csc test.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.4926
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.

test.cs(1,7): error CS0246: The type or namespace name 'SnarlNetworkProtocol' could not be found (are you missing a using directive or an assembly reference?)
</code>```

So, what am I doing wrong here because according to me I am not missing any using directive.

答: I had a similar problem after first pulling and starting a new solution. It was fixed in visual studio by first cleaning the project. Then restoring the packages. When I built again, there were no more type or namespace errors.</p>

Body:
I am using Snarl C# API to send notifications to snarl.

Now I have saved the content of above url in a file named SnarlNetwork.cs and the content of my test.cs file are:

using SnarlNetworkProtocol;
using System;
class test
{
    public static void Main(String[] args)
    {
        SNP snarl_object = new SNP();
        string hostname = "localhost";
        string hostport = "9887";
        string appName = "Spotify";

        bool val = snarl_object.register(hostname, hostport, appName);

        if (val == true)
        {
            string title = "hello";
            string message = "world";
            string timeout = "5";
            bool newval = snarl_object.notify(hostname, hostport, appName, null, title, message, timeout);

            if (newval == true)
            {
                Console.WriteLine("sucessfull");

            }
        }
    }

}

Now when I try to compile my test.cs file using csc test.cs I get the following error:

C:\Users\Noob\csharp>csc test.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.4926
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.

test.cs(1,7): error CS0246: The type or namespace name 'SnarlNetworkProtocol' could not be found (are you missing a using directive or an assembly reference?)

So, what am I doing wrong here because according to me I am not missing any using directive.


问:
Show real runtime hyperlink when using asp tag helper
when I generate a hyperlink with asp-tag helpers it looks like this:

```<code><a asp-page="/demo">Demo</a>
</code>```

The html output looks like that:

```<code><a href="/test/Demo">Demo</a>
</code>```

But I want to show the user not the hyperlink "Demo" but instead the real address at runtime (localhost:xxxx/test/demo).

The problem ist that at compile time I did not know that. Is there an easy way that the asp-page feature generates me the hyperlink content?

答:
If I understand you, you want the actual content of the link to be the URL rather than the string "Demo". If that's the case, you'll need to use the UrlHelper:

```<code><a asp-page="/demo">@Url.Page("/demo")</a>
</code>```

That introduces a bit of duplication, though, so I'd actually suggest doing something like:

```<code>@{ var demoUrl = Url.Page("/demo"); }
<a href="@demoUrl">@demoUrl</a>
</code>```

If you want an absolute URL, then you need to pass the scheme param:

```<code>Url.Page("/demo", null, null, PageContext.HttpContext.Request.Scheme)
</code>```

Body:
when I generate a hyperlink with asp-tag helpers it looks like this:

Demo

The html output looks like that:

Demo

But I want to show the user not the hyperlink "Demo" but instead the real address at runtime (localhost:xxxx/test/demo).

The problem ist that at compile time I did not know that. Is there an easy way that the asp-page feature generates me the hyperlink content?

Body:
If I understand you, you want the actual content of the link to be the URL rather than the string "Demo". If that's the case, you'll need to use the UrlHelper:

<a asp-page="/demo">@Url.Page("/demo")</a>

That introduces a bit of duplication, though, so I'd actually suggest doing something like:

@{ var demoUrl = Url.Page("/demo"); }
<a href="@demoUrl">@demoUrl</a>

If you want an absolute URL, then you need to pass the scheme param:

Url.Page("/demo", null, null, PageContext.HttpContext.Request.Scheme)


问:
Loop into CSV file and get specific values from headers PHP
I'm trying to import CSV file in order to automate the candidacies insertion.

As a first step, the user imports an excel file (.xls, .xls). From file, I convert it to csv in order to exploit it better thanks to PhpSpreadSheet library.

Example of csv file :

I would like to recover only some data columns, like lastName, firstName, gender, phonenumber .

For that, I'm using regular expressions to detect them. In every detection, I store the result in array.
However afterward, how can I recover data from these columns ?

```<code>$headers = [];
if(($handle = fopen($loadedSheetName.'.csv', "r")) !== FALSE)
{
    foreach (fgetcsv($handle, 1000, ';') as $key => $header)
    {
        if (preg_match('/^(lastName)/i', $header, $matches))
        {
            $headers[$key] = $header;
        }

        if (preg_match('/^(firstName)/i', $header, $matches))
        {
            $headers[$key] = $header;
        }

        if (preg_match("/^(gender)/i", $header, $matches))
        {
            $headers[$key] = $header;
        }

        if (preg_match("/^(phoneNumber)/i", $header, $matches))
        {
            $headers[$key] = $header;
        }
    }

    $keys = array_keys($headers);
    $values = array_values($headers);

    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
    {
        $num = count($data);

        for ($c=0; $c < $num; $c++)
        {
            echo $data[$c] . "<br />\n";
        }
    }

    fclose($handle);
}
</code>```

答:
```<code><?php
$headers = [];
$skip_headers = Array('lastname', 'firstname', 'gender', 'phonenumber');
if(($handle = fopen($loadedSheetName.'.csv', "r")) !== FALSE)
{
    foreach (fgetcsv($handle, 1000, ';') as $key => $header)
    {
        if (!in_array(strtolower($header), $skip_headers))
        {
            $headers[$key] = $header;
        }

    }

    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
    {
       foreach ($headers as $key_ => $value)
       {
           echo $data[$key_] . "<br />\n";
       }
    }

    fclose($handle);
}
</code>```

Body:
I'm trying to import CSV file in order to automate the candidacies insertion.

As a first step, the user imports an excel file (.xls, .xls). From file, I convert it to csv in order to exploit it better thanks to PhpSpreadSheet library.

Example of csv file :

I would like to recover only some data columns, like lastName, firstName, gender, phonenumber .

For that, I'm using regular expressions to detect them. In every detection, I store the result in array.
However afterward, how can I recover data from these columns ?

$headers = [];
if(($handle = fopen($loadedSheetName.'.csv', "r")) !== FALSE)
{
    foreach (fgetcsv($handle, 1000, ';') as $key => $header)
    {
        if (preg_match('/^(lastName)/i', $header, $matches))
        {
            $headers[$key] = $header;
        }

        if (preg_match('/^(firstName)/i', $header, $matches))
        {
            $headers[$key] = $header;
        }

        if (preg_match("/^(gender)/i", $header, $matches))
        {
            $headers[$key] = $header;
        }

        if (preg_match("/^(phoneNumber)/i", $header, $matches))
        {
            $headers[$key] = $header;
        }
    }

    $keys = array_keys($headers);
    $values = array_values($headers);

    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
    {
        $num = count($data);

        for ($c=0; $c < $num; $c++)
        {
            echo $data[$c] . "
\n";
        }
    }

    fclose($handle);
}


问:
Changing the selected value of a Pull Down Box on selection of a value in the same Pull Down Box
I'm trying to create a 'Online Banking'-styly authentication for my website where the user selects the 5th and 6th and [whatever] number letter from a secret passphrase via 3 pulldown boxes, each pull down box representing 1 letter of the passphrase, randomly choosen by the app, and once they select the requested digit in each pull down, the pulldown should display an asterisk [*] instead of displaying the secret passphrase's digit.

Also I'm using jQuery to manipulate and catch events on the select boxes.

I'm currently using the

```<code>$('#selectboxID').change(function() {pulldownObfuscation('selectboxID','hfID')});
</code>```

but I've tried

```<code>.blur()   and  .click()
</code>```

and using a custom function to count clicks and react on second click also fails.

My current method is not very smooth, and reacting to the 'onChange' event, and then changing the contents appears to confuse the browser a bit, hence 'not smooth'. It works best using the keyboard, but using the mouse means focus jumps around annoying between the text boxes, and work best if I 'click and hold' on the text box.

Any thoughts on the best cross browser solution using jquery?

```<code>function pulldownObfuscation(pullDownID,hfID) {
        var selectedVal = new String($('#' + pullDownID + ' :selected').val());
        if (selectedVal == '*') return;
        $('#' + hfID).val(selectedVal);
        $('#' + pullDownID + ' option:eq(1)').attr('selected','selected');
}
</code>```

I have a 'hiddenfield' storing the users selected value (cant rely on the pull down box's value), above function does the actual 'obfuscation'.

答:
Could you explain the functionality a little more? Is there just a single select element? This may be partway towards what you want. See it working here: http://jsfiddle.net/Yre8X/</p>

```<code>$('select option').click(function(){
   var selectedVal = $(this).val();
   if (selectedVal=='*'){
      return;
   }else{
      $(this).parent().attr('disabled','true');
      $(this).parent().next('#hfID').val(selectedVal);
      $(this).parent().children('option').text('*').val('*');
   }
});
</code>```

Body:
I'm trying to create a 'Online Banking'-styly authentication for my website where the user selects the 5th and 6th and [whatever] number letter from a secret passphrase via 3 pulldown boxes, each pull down box representing 1 letter of the passphrase, randomly choosen by the app, and once they select the requested digit in each pull down, the pulldown should display an asterisk [*] instead of displaying the secret passphrase's digit.

Also I'm using jQuery to manipulate and catch events on the select boxes.

I'm currently using the

$('#selectboxID').change(function() {pulldownObfuscation('selectboxID','hfID')});

but I've tried

.blur()   and  .click()

and using a custom function to count clicks and react on second click also fails.

My current method is not very smooth, and reacting to the 'onChange' event, and then changing the contents appears to confuse the browser a bit, hence 'not smooth'. It works best using the keyboard, but using the mouse means focus jumps around annoying between the text boxes, and work best if I 'click and hold' on the text box.

Any thoughts on the best cross browser solution using jquery?

function pulldownObfuscation(pullDownID,hfID) {
        var selectedVal = new String($('#' + pullDownID + ' :selected').val());
        if (selectedVal == '*') return;
        $('#' + hfID).val(selectedVal);
        $('#' + pullDownID + ' option:eq(1)').attr('selected','selected');
}

I have a 'hiddenfield' storing the users selected value (cant rely on the pull down box's value), above function does the actual 'obfuscation'.

Body:
Could you explain the functionality a little more? Is there just a single select element? This may be partway towards what you want. See it working here: http://jsfiddle.net/Yre8X/

$('select option').click(function(){
   var selectedVal = $(this).val();
   if (selectedVal=='*'){
      return;
   }else{
      $(this).parent().attr('disabled','true');
      $(this).parent().next('#hfID').val(selectedVal);
      $(this).parent().children('option').text('*').val('*');
   }
});


问:
Disabling Text Editing in an EDITTEXT box in C++ while keeping scrolling enabled
So my dilemma comes from making a UI in C++ with the windows API. I need to have an EDITTEXT box which allows for scrolling but doesn't allow the user to edit the text that gets displayed in the box. So far, it looks like this.

```<code>EDITTEXT        ID_STATUS,7,237,439,50, WS_VSCROLL | ES_MULTILINE
</code>```

This allows for the text to be scrolled if it's long and breaks it into new lines. However, if i add the DISABLED option to this, it disables both the scrollbar and the text. What would be the best way to solve this situation? I've also tried adding

```<code>SendDlgItemMessage(ID_STATUS, EM_SETREADONLY, 0, 0);
</code>```

before the UI gets previewed to see if this would disable text editing but it doesn't. Any help would be appreciated.

答:
EM_SETREADONLY is correct but you failed to actually ask it to be read-only. Try

```<code>SendDlgItemMessage(ID_STATUS, EM_SETREADONLY, TRUE, 0);
</code>```

wParam

Specifies whether to set or remove the ES_READONLY style. A value of TRUE sets the ES_READONLY style; a value of FALSE removes the ES_READONLY style.

You can also specify the ES_READONLY style when you create the control.

Body:
So my dilemma comes from making a UI in C++ with the windows API. I need to have an EDITTEXT box which allows for scrolling but doesn't allow the user to edit the text that gets displayed in the box. So far, it looks like this.

EDITTEXT        ID_STATUS,7,237,439,50, WS_VSCROLL | ES_MULTILINE

This allows for the text to be scrolled if it's long and breaks it into new lines. However, if i add the DISABLED option to this, it disables both the scrollbar and the text. What would be the best way to solve this situation? I've also tried adding

SendDlgItemMessage(ID_STATUS, EM_SETREADONLY, 0, 0);

before the UI gets previewed to see if this would disable text editing but it doesn't. Any help would be appreciated.

Body:
EM_SETREADONLY is correct but you failed to actually ask it to be read-only. Try

SendDlgItemMessage(ID_STATUS, EM_SETREADONLY, TRUE, 0);

wParam

Specifies whether to set or remove the ES_READONLY style. A value of TRUE sets the ES_READONLY style; a value of FALSE removes the ES_READONLY style.

You can also specify the ES_READONLY style when you create the control.


问:
Powershell API Data Extraction
I'm getting data back from an API for a system of ours using Powershell but it doesn't quite return it correctly. It is putting the data all under one header as seen below. I'm trying to extract the downloadLink part only

Tried converting to JSON to see if I could get anywhere else with it.

```<code>$token = ".."
$web = Invoke-RestMethod -uri $url -Method Get -Headers @{'Authorization' = $token}
echo $web
</code>```

I get this as the outcome:

```<code>documents
---------
{@{documentName=Name.docx.pdf; downloadLink=https://app.xxx.com/api/docs/employees/111/shared/111}, {@{documentName=Name.docx.pdf; downloadLink=https://app.xxx.com/api/docs/employees/111/shared/111} ...
</code>```

What I need to get is the downloadLink, but as it's all coming under the documents header I can't do a simple select or get on it.

答:
Have you tried converting the results from JSON using ConvertFrom-Json? See the code example below.

Please note the change I made to the ContentType to the Invoke-RestMethod as well.

```<code>$token = ".."
$web = Invoke-RestMethod -uri $url -Method Get -ContentType "application/json" -Headers @{'Authorization' = $token}
$webResults = $web | ConvertFrom-Json
echo ($json | ConvertFrom-Json).downloadLink
</code>```

Title: Powershell API Data Extraction

Body:
I'm getting data back from an API for a system of ours using Powershell but it doesn't quite return it correctly. It is putting the data all under one header as seen below. I'm trying to extract the downloadLink part only

Tried converting to JSON to see if I could get anywhere else with it.

$token = ".."
$web = Invoke-RestMethod -uri $url -Method Get -Headers @{'Authorization' = $token}
echo $web

I get this as the outcome:

documents
---------
{@{documentName=Name.docx.pdf; downloadLink=https://app.xxx.com/api/docs/employees/111/shared/111}, {@{documentName=Name.docx.pdf; downloadLink=https://app.xxx.com/api/docs/employees/111/shared/111} ...

What I need to get is the downloadLink, but as it's all coming under the documents header I can't do a simple select or get on it.

Body:
Have you tried converting the results from JSON using ConvertFrom-Json? See the code example below.

Please note the change I made to the ContentType to the Invoke-RestMethod as well.

$token = ".."
$web = Invoke-RestMethod -uri $url -Method Get -ContentType "application/json" -Headers @{'Authorization' = $token}
$webResults = $web | ConvertFrom-Json
echo ($json | ConvertFrom-Json).downloadLink


问:
Node.js endpoint ampersand is getting appended when making an ajax call
I've the below code which I'm using to hit a node.js endpoint. However when it is getting hit, the endpoint URL appends an & to it like this,

```<code>http://localhost:3004/expenses/?q=&12/02/2014
</code>```

Hence I'm not getting the desired result back.

Here is how my code looks like,

```<code>$('#myForm').on('submit', (e)=>{
    e.preventDefault();

    $.ajax({
        type: 'GET',
        url: 'http://localhost:3004/expenses/?q=',
        processData: false,
        data: $('#startDate').val(),
        contentType: 'application/json',
        success:(data, status)=>{
            // alert(status);
        },
        error:()=>{
            alert('problem');
        }
    })
})
</code>```

Can someone shed some light?

答:
The issue is most likely related to the processData: false telling jQuery to not format the data for the request, and the GET url already containing ? in it.  Given that you are not giving the request json, I would suggest reducing your call to simplify the issue.

```<code>$.ajax({
    type: 'GET',
    url: 'http://localhost:3004/expenses/',
    data: { q: $('#startDate').val() },
    success:(data, status)=>{
        // alert(status);
    },
    error:()=>{
        alert('problem');
    }
});
</code>```

If you do not give the processData in the options, it will convert the data you give it to a query param for the request.  Given that this is a GET request, it will generate the ?q=<value> for you.  And as mentioned in the comments, you do not need contentType: application/json on the options as that is telling jQuery to put the content type on the request so the server knows you are sending it json in the body.  Which you are not, :)

Body:
I've the below code which I'm using to hit a node.js endpoint. However when it is getting hit, the endpoint URL appends an & to it like this,

http://localhost:3004/expenses/?q=&12/02/2014

Hence I'm not getting the desired result back.

Here is how my code looks like,

$('#myForm').on('submit', (e)=>{
    e.preventDefault();

    $.ajax({
        type: 'GET',
        url: 'http://localhost:3004/expenses/?q=',
        processData: false,
        data: $('#startDate').val(),
        contentType: 'application/json',
        success:(data, status)=>{
            // alert(status);
        },
        error:()=>{
            alert('problem');
        }
    })
})

Can someone shed some light?

Body:
The issue is most likely related to the processData: false telling jQuery to not format the data for the request, and the GET url already containing ? in it.  Given that you are not giving the request json, I would suggest reducing your call to simplify the issue.

$.ajax({
    type: 'GET',
    url: 'http://localhost:3004/expenses/',
    data: { q: $('#startDate').val() },
    success:(data, status)=>{
        // alert(status);
    },
    error:()=>{
        alert('problem');
    }
});

If you do not give the processData in the options, it will convert the data you give it to a query param for the request.  Given that this is a GET request, it will generate the ?q=<value> for you.  And as mentioned in the comments, you do not need contentType: application/json on the options as that is telling jQuery to put the content type on the request so the server knows you are sending it json in the body.  Which you are not, :)


问:
ML Engine Batch Prediction running on wrong python version

So I have a tensorflow model in python 3.5 registered with the ML engine and I want to run a batch prediction job using it. My API request body looks like:

```<code>{
  "versionName": "XXXXX/v8_0QSZ",
  "dataFormat": "JSON",
  "inputPaths": [
    "XXXXX"
  ],
  "outputPath": "XXXXXX",
  "region": "us-east1",
  "runtimeVersion": "1.12",
  "accelerator": {
    "count": "1",
    "type": "NVIDIA_TESLA_P100"
  }
}
</code>```

Then the batch prediction job runs and returns "Job completed successfully.", however, it was completely unsuccessful and consistently threw the following error for each input:

```<code>Exception during running the graph: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above. [[node convolution_layer/conv1d/conv1d/Conv2D (defined at /usr/local/lib/python2.7/dist-packages/google/cloud/ml/prediction/frameworks/tf_prediction_lib.py:210) = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](convolution_layer/conv1d/conv1d/Conv2D-0-TransposeNHWCToNCHW-LayoutOptimizer, convolution_layer/conv1d/conv1d/ExpandDims_1)]] [[{{node Cast_6/_495}} = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_789_Cast_6", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]
</code>```

My questions are:

Why does the batch job report success when in reality it completely failed?

In the exception above it mentions python 2.7... yet the model is registered as python 3.5 and there is no way to specify the python version using the API. Why is the batch prediction using 2.7?

What in general can I do to make this work?

Does this have anything to do with my accelerator option?

答: Response from batch prediction dev: "we don't officially support Python 3 yet. However, the issue you're encountering is a known bug affecting our GPU runtimes for TF 1.11 and 1.12</p>

Body:
So I have a tensorflow model in python 3.5 registered with the ML engine and I want to run a batch prediction job using it. My API request body looks like:

{
  "versionName": "XXXXX/v8_0QSZ",
  "dataFormat": "JSON",
  "inputPaths": [
    "XXXXX"
  ],
  "outputPath": "XXXXXX",
  "region": "us-east1",
  "runtimeVersion": "1.12",
  "accelerator": {
    "count": "1",
    "type": "NVIDIA_TESLA_P100"
  }
}

Then the batch prediction job runs and returns "Job completed successfully.", however, it was completely unsuccessful and consistently threw the following error for each input:

Exception during running the graph: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above. [[node convolution_layer/conv1d/conv1d/Conv2D (defined at /usr/local/lib/python2.7/dist-packages/google/cloud/ml/prediction/frameworks/tf_prediction_lib.py:210) = Conv2D[T=DT_FLOAT, data_format="NCHW", dilations=[1, 1, 1, 1], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:GPU:0"](convolution_layer/conv1d/conv1d/Conv2D-0-TransposeNHWCToNCHW-LayoutOptimizer, convolution_layer/conv1d/conv1d/ExpandDims_1)]] [[{{node Cast_6/_495}} = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/device:CPU:0", send_device="/job:localhost/replica:0/task:0/device:GPU:0", send_device_incarnation=1, tensor_name="edge_789_Cast_6", tensor_type=DT_INT64, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

My questions are:

Why does the batch job report success when in reality it completely failed?

In the exception above it mentions python 2.7... yet the model is registered as python 3.5 and there is no way to specify the python version using the API. Why is the batch prediction using 2.7?

What in general can I do to make this work?

Does this have anything to do with my accelerator option?


问:
How to prevent form submission until onsubmit function completes?
For my onsubmit function, I have a function that requests for user's location and adds their location to the input values of my form.
However, when the user clicks on the submit button and a pop-up appears and asks the user to allow the browser to know their location, my form always submits before the user could answer the pop-up. This leaves the function incompleted and the input values become undefined.

I have tried adding a "return true;" statement until my onsubmit function ends, but the form still gets submitted prior. I have also tried adding  "e.preventDefault();" before my function completes. None of the methods worked so far...

My form:

<form action="/login" onsubmit="getLocation()" method="POST">
    <button type="submit" class="btn btn-dark">Login</button>
    <input id="currentUserLattitude" type=hidden name="currentLocation" value="placeholder">
    <input id="currentUserLongitude" type=hidden name="currentLocation" value="placeholder">
</form>
```

<p>The onsubmit function:  </p>

```function getLocation(e) {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(onGeoSuccess, onGeoError);
        return true;
    } else {
        alert("Geolocation is not supported by this browser.");
    }
}

function onGeoSuccess(position) {
    document.getElementById("currentUserLattitude").value = position.coords.latitude;
    document.getElementById("currentUserLongitude").value = position.coords.longitude;
}

function onGeoError(err) {
    alert("Error code " + err.code + ". " + err.message);
}
```

答: Change from using an onSubmit to onComplete</p>

Body:
For my onsubmit function, I have a function that requests for user's location and adds their location to the input values of my form.
However, when the user clicks on the submit button and a pop-up appears and asks the user to allow the browser to know their location, my form always submits before the user could answer the pop-up. This leaves the function incompleted and the input values become undefined.

I have tried adding a "return true;" statement until my onsubmit function ends, but the form still gets submitted prior. I have also tried adding  "e.preventDefault();" before my function completes. None of the methods worked so far...

My form:

<form action="/login" onsubmit="getLocation()" method="POST">
    <button type="submit" class="btn btn-dark">Login</button>
    <input id="currentUserLattitude" type=hidden name="currentLocation" value="placeholder">
    <input id="currentUserLongitude" type=hidden name="currentLocation" value="placeholder">
</form>

The onsubmit function:

function getLocation(e) {
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(onGeoSuccess, onGeoError);
        return true;
    } else {
        alert("Geolocation is not supported by this browser.");
    }
}

function onGeoSuccess(position) {
    document.getElementById("currentUserLattitude").value = position.coords.latitude;
    document.getElementById("currentUserLongitude").value = position.coords.longitude;
}

function onGeoError(err) {
    alert("Error code " + err.code + ". " + err.message);
}


答:
```<code><uses-feature android:name="android.hardware.camera"/>
</code>```

above line will use to check the device have camera hardware.

When you upload an app on play store they will filter your app based on the feature for the specific device,

if any device will search your app on play store and that device doesn't have camera hardware then they will not be allowed to install an app on that device.

but if your requirement is to force download the app if the device doesn't have camara hardware the you can use :
 <uses-feature android:name="android.hardware.camera" android:required="false"/>
the android:required = "false" will allow you to install

hope you understand

Title: Why we need to use <uses-feature> attribute?

Body:
<uses-feature android:name="android.hardware.camera"/>

above line will use to check the device have camera hardware.

When you upload an app on play store they will filter your app based on the feature for the specific device,

if any device will search your app on play store and that device doesn't have camera hardware then they will not be allowed to install an app on that device.

but if your requirement is to force download the app if the device doesn't have camara hardware the you can use :
 <uses-feature android:name="android.hardware.camera" android:required="false"/>
the android:required = "false" will allow you to install

hope you understand


问:
Create multiple folders to save several sessions on mobaXterm
I depend heavily on MobaXterm to connect to remote servers. My saved session list is beyond manageable now. Is there a way to create folders and organize my sessions in MobaXterm?

Thank you in advance!

答:
Sure: Right click on User sessions:

And then "new folder"


问:
How do i clear a multi-select input using Cypress?
How do i clear (deselect) all options within a multi-select input using Cypress?

The documentation here does not seem to cover this scenario: https://docs.cypress.io/api/commands/select.html#Syntax

The clear() command apparently cannot be applied to selects, as you might expect
https://docs.cypress.io/api/commands/clear.html#Syntax

I have tried passing an empty string / array / null to select() but i get the following error:

CypressError: Timed out retrying: cy.select() failed because it could not find a single <option> with value or text matching: ''

答:
Since Cypress 8.6.0, this is supported in Cypress: https://stackoverflow.com/a/69537449/3474615

Before 8.6.0:

You can use cy.invoke() to call the .val('') method on the underlying JQuery element, which will cause it to be cleared.

Like this:

cy.get('select')
.invoke('val', '')
```
<p>Note that this will not emit the <code>change</code> event. If you want to test that your code reacts to the <code>change</code> event, you can cause it to be emitted with <code>cy.trigger()</code>:</p>
<pre class="lang-js prettyprint-override"><code>cy.get('select')
.invoke('val', '')
.trigger('change')
</code>```

I've also filed a feature request for this functionality, as it does seem like something that should be included with Cypress by default.

Body:
Since Cypress 8.6.0, this is supported in Cypress: https://stackoverflow.com/a/69537449/3474615

Before 8.6.0:

You can use cy.invoke() to call the .val('') method on the underlying JQuery element, which will cause it to be cleared.

Like this:

cy.get('select')
.invoke('val', '')

Note that this will not emit the change event. If you want to test that your code reacts to the change event, you can cause it to be emitted with cy.trigger():

cy.get('select')
.invoke('val', '')
.trigger('change')

I've also filed a feature request for this functionality, as it does seem like something that should be included with Cypress by default.


问:
Angular - Life-cycle: Child component to be fully loaded
Is it possible for a parent component to be notified for a child component to be loaded especially when it comes to ng-container and ng-template.

As in Yes! I see that you've grown strong, my child!

Say we have a component like this:

@Component({
  selector: 'my-app',
  template: `
  <ng-container *ngIf="!showElse; else elseBlock">

Hi!

  </ng-container>
  <ng-template #elseBlock>
    <hello name="{{ name }}"></hello>
  </ng-template>
  <button (click)="showElse = !showElse">Show else</button>
  `,
  styles: ['']
})
export class AppComponent  {
  name = 'Angular';
  showElse = false;
  @ViewChild('hello') hello: HelloComponent;
}
```

Is there a way for AppComponent to know if HelloComponentis fully loaded or do I need a custom solution inside HelloComponent?

I'm currently sitting with a less-than-optimal solution (a setTimeout() based stuff that I don't like).

Here's what I'm thinking about:

- Add an EventEmitter to my HelloComponent;

- Use the HelloComponent's life cycle to emit an event during, say, ngAfterContentChecked

- Intercept this event in my AppComponent and do the thing.

What are your thoughts on that subject?

Edit

So far, I've tried what you've suggested (hook to AfterViewInit, make use of @ViewChildren...) but had no success.

Just to be sure, I tried again without the <ng-container>...<ng-template> stuff and simply hiding my HelloComponent using the [hidden] directive...

By emitting an event during the HelloComponent's AfterContentChecked and hooking this event in AppComponent, it works like a charm. (see on stackblitz )

This solution is way more classy than my previous setTimeout-based one

Now, the reason I wanted to make use of the <ng-container>...<ng-template> mechanic is because my actual component is just a tiny bit heavier than the example HelloComponent.

If anyone has a better idea to keep using the container-template mechanic, I'm all ears.

答:
you can use ngAfterVIewChecked in your parent component, that tells the parent component that angular has finished change detection on all children

So if you have 5 child component you can know when all child views are updated but you can't know if a specific child component has been updated

Body:
Is it possible for a parent component to be notified for a child component to be loaded especially when it comes to ng-container and ng-template.

As in Yes! I see that you've grown strong, my child!

Say we have a component like this:

@Component({
  selector: 'my-app',
  template: `
  <ng-container *ngIf="!showElse; else elseBlock">

Hi!

  </ng-container>
  <ng-template #elseBlock>
    <hello name="{{ name }}"></hello>
  </ng-template>
  <button (click)="showElse = !showElse">Show else</button>
  `,
  styles: ['']
})
export class AppComponent  {
  name = 'Angular';
  showElse = false;
  @ViewChild('hello') hello: HelloComponent;
}

Is there a way for AppComponent to know if HelloComponentis fully loaded or do I need a custom solution inside HelloComponent?

I'm currently sitting with a less-than-optimal solution (a setTimeout() based stuff that I don't like).

Here's what I'm thinking about:

- Add an EventEmitter to my HelloComponent;

- Use the HelloComponent's life cycle to emit an event during, say, ngAfterContentChecked

- Intercept this event in my AppComponent and do the thing.

What are your thoughts on that subject?

Edit

So far, I've tried what you've suggested (hook to AfterViewInit, make use of @ViewChildren...) but had no success.

Just to be sure, I tried again without the <ng-container>...<ng-template> stuff and simply hiding my HelloComponent using the [hidden] directive...

By emitting an event during the HelloComponent's AfterContentChecked and hooking this event in AppComponent, it works like a charm. (see on stackblitz )

This solution is way more classy than my previous setTimeout-based one

Now, the reason I wanted to make use of the <ng-container>...<ng-template> mechanic is because my actual component is just a tiny bit heavier than the example HelloComponent.

If anyone has a better idea to keep using the container-template mechanic, I'm all ears.


问:
How do I use Assert to verify that an exception has been thrown with MSTest?
How do I use Assert (or other Test class) to verify that an exception has been thrown when using MSTest/Microsoft.VisualStudio.TestTools.UnitTesting?

答:
My preferred method for implementing this is to write a method called Throws, and use it just like any other Assert method. Unfortunately, .NET doesn't allow you to write a static extension method, so you can't use this method as if it actually belongs to the build in Assert class; just make another called MyAssert or something similar. The class looks like this:

```<code>using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace YourProject.Tests
{
    public static class MyAssert
    {
        public static void Throws<T>( Action func ) where T : Exception
        {
            var exceptionThrown = false;
            try
            {
                func.Invoke();
            }
            catch ( T )
            {
                exceptionThrown = true;
            }

            if ( !exceptionThrown )
            {
                throw new AssertFailedException(
                    String.Format("An exception of type {0} was expected, but not thrown", typeof(T))
                    );
            }
        }
    }
}
</code>```

That means that your unit test looks like this:

```<code>[TestMethod()]
public void ExceptionTest()
{
    String testStr = null;
    MyAssert.Throws<NullReferenceException>(() => testStr.ToUpper());
}
</code>```

Which looks and behaves much more like the rest of your unit test syntaxes.

Body:
My preferred method for implementing this is to write a method called Throws, and use it just like any other Assert method. Unfortunately, .NET doesn't allow you to write a static extension method, so you can't use this method as if it actually belongs to the build in Assert class; just make another called MyAssert or something similar. The class looks like this:

using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace YourProject.Tests
{
    public static class MyAssert
    {
        public static void Throws<T>( Action func ) where T : Exception
        {
            var exceptionThrown = false;
            try
            {
                func.Invoke();
            }
            catch ( T )
            {
                exceptionThrown = true;
            }

            if ( !exceptionThrown )
            {
                throw new AssertFailedException(
                    String.Format("An exception of type {0} was expected, but not thrown", typeof(T))
                    );
            }
        }
    }
}

That means that your unit test looks like this:

[TestMethod()]
public void ExceptionTest()
{
    String testStr = null;
    MyAssert.Throws<NullReferenceException>(() => testStr.ToUpper());
}

Which looks and behaves much more like the rest of your unit test syntaxes.


问:
Drools on Wildfly LDAP authentication, properties authorisation
After authentication to business-central (drools-workbench), the user has no authorization. I have the LDAP search config confirmed in the  block and using the properties files in the authorization block.

The "properties" config works fine when LDAP is off for auth and using local property files for authentication also but when LDAP is on for authentication, authorization breaks. The files are in the correct location with correct permissions. This is in the docker container built from here: https://github.com/jboss-dockerfiles/drools

XML looks like this:

```<code> <security-realm name="ApplicationRealm">
            <authentication>
                <local default-user="$local" skip-group-loading="false"/>
                <ldap connection="ldap" base-dn="ou=Users,ou=XXXXXXX,dc=XX,dc=XXXXX">
                    <username-filter attribute="sAMAccountName"/>
                </ldap>
            </authentication>
            <authorization>
                <properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
            </authorization>
        </security-realm>
</code>```

I expected the user to have admin access as it works when I use properties files for authentication as well as authorisation. I do get an odd error when ldap is on for authentication:

09:06:27,486 ERROR

  [org.uberfire.ext.security.management.BackendUserSystemManager]
  (default task-1) UsersManagementService initialization failure:

  java.lang.RuntimeException: Properties file for users not found at
  './standalone/configuration/application-users.properties'.

Which seems obvious but not as the file exists and has the users etc in it, correct permissions.

答: Have confirmed the group search config so this is no longer relevant. </p>

Body:
After authentication to business-central (drools-workbench), the user has no authorization. I have the LDAP search config confirmed in the  block and using the properties files in the authorization block.

The "properties" config works fine when LDAP is off for auth and using local property files for authentication also but when LDAP is on for authentication, authorization breaks. The files are in the correct location with correct permissions. This is in the docker container built from here: https://github.com/jboss-dockerfiles/drools

XML looks like this:

 <security-realm name="ApplicationRealm">
            <authentication>
                <local default-user="$local" skip-group-loading="false"/>
                <ldap connection="ldap" base-dn="ou=Users,ou=XXXXXXX,dc=XX,dc=XXXXX">
                    <username-filter attribute="sAMAccountName"/>
                </ldap>
            </authentication>
            <authorization>
                <properties path="application-roles.properties" relative-to="jboss.server.config.dir"/>
            </authorization>
        </security-realm>

I expected the user to have admin access as it works when I use properties files for authentication as well as authorisation. I do get an odd error when ldap is on for authentication:

09:06:27,486 ERROR

  [org.uberfire.ext.security.management.BackendUserSystemManager]
  (default task-1) UsersManagementService initialization failure:

  java.lang.RuntimeException: Properties file for users not found at
  './standalone/configuration/application-users.properties'.

Which seems obvious but not as the file exists and has the users etc in it, correct permissions.


问:
How to delete each third row from
 using only JavaScript?
I want to delete each third row in this code.
How I can do this?
Thanks for any answers

I was trying to do something like this:

```<code>const table = document.getElementById('myTable');

for (let i =0; i <table.rows.length; i++) {
  if (i%3 === 0 ) {
    table.deleteRow(i)
  }
}
</code>```

I have this table:

```<code>        <tbody>
            <tr>
                <td>First row.</td>
            </tr>
            <tr>
                <td>Second row.</td>
            </tr>
          <tr>
                <td>DELETE 3</td>
            </tr>
          <tr>
                <td>4 row.</td>
            </tr>
          <tr>
                <td>5 row.</td>
            </tr>
          <tr>
                <td>DELETE 6</td>
            </tr>
          <tr>
                <td>First row.</td>
            </tr>
            <tr>
                <td>Second row.</td>
            </tr>
          <tr>
                <td>DELETE 9</td>
            </tr>
        </tbody>
</code>```

I need a script which I will put in the console of my browser and I will delete each third row in anything table. Thank you!

答:
You can try the following way:

var table = document.querySelectorAll('tbody tr');

for (let i =0; i <table.length; i++) {
  if(i%3==2)
    table[i].remove();
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table>
  <tbody>
    <tr>
        <td>First row.</td>
    </tr>
    <tr>
        <td>Second row.</td>
    </tr>
    <tr>
        <td>DELETE 3</td>
    </tr>
    <tr>
        <td>4 row.</td>
    </tr>
    <tr>
        <td>5 row.</td>
    </tr>
    <tr>
        <td>DELETE 6</td>
    </tr>
    <tr>
        <td>First row.</td>
    </tr>
    <tr>
        <td>Second row.</td>
    </tr>
    <tr>
        <td>DELETE 9</td>
    </tr>
  </tbody>
</table></code>```

Body:
I want to delete each third row in this code.
How I can do this?
Thanks for any answers

I was trying to do something like this:

const table = document.getElementById('myTable');

for (let i =0; i <table.rows.length; i++) {
  if (i%3 === 0 ) {
    table.deleteRow(i)
  }
}

I have this table:

                First row.

                Second row.

                DELETE 3

                4 row.

                5 row.

                DELETE 6

                First row.

                Second row.

                DELETE 9

I need a script which I will put in the console of my browser and I will delete each third row in anything table. Thank you!

Body:
You can try the following way:

var table = document.querySelectorAll('tbody tr');

for (let i =0; i <table.length; i++) {
  if(i%3==2)
    table[i].remove();
}

<table>
  <tbody>
    <tr>
        <td>First row.</td>
    </tr>
    <tr>
        <td>Second row.</td>
    </tr>
    <tr>
        <td>DELETE 3</td>
    </tr>
    <tr>
        <td>4 row.</td>
    </tr>
    <tr>
        <td>5 row.</td>
    </tr>
    <tr>
        <td>DELETE 6</td>
    </tr>
    <tr>
        <td>First row.</td>
    </tr>
    <tr>
        <td>Second row.</td>
    </tr>
    <tr>
        <td>DELETE 9</td>
    </tr>
  </tbody>
</table>