问:
Spliting a list into sublists based on an element containing a string
I know there is a simple solution but I can't seem to find it.

I want to split a list based on an element just containing a string.

In this case "Store"

```<code>from itertools import groupby

test_string = ['Store465', 'Steve', '145658', '125', 'Brad', '457958', '200', 'Store678', 'John', '30122', '898', '123', 'O', 'Joe', '36789', '123', 'U', ' 456']

# I've tried

test_string[:] = [x for x in test_string if "Store" not in x]

print(test_string)

# but that will just remove the  Store elements

# ['Steve', '145658', '125', 'Brad', '457958', '200', 'John', '30122', '898', '123', 'O', 'Joe', '36789', '123', 'U', ' 456']

# and

test_result = [list(g) for k,g in groupby(test_string,lambda x:x if "Store" not in x) if not k]

# This creates an error.
#
#   File "<input>", line 13
#     test_result = [list(g) for k,g in groupby(test_string,lambda x:x if "Store" not in x) if not k]
#                                                                                ^
# SyntaxError: invalid syntax

</code>```

I've been on stackoverflow and google trying to find the correct syntax or process with no luck. My desired output would be

```<code>[['Store465', 'Steve', '145658', '125', 'Brad', '457958', '200'], ['Store678', 'John', '30122', '898', '123', 'O', 'Joe', '36789', '123', 'U', ' 456']]

</code>```

答:
To split the lists by the occurrence of Store in the list you could do something like this:

```<code>test_string = ['Store465', 'Steve', '145658', '125', 'Brad', '457958', '200', 'Store678', 'John', '30122', '898', '123', 'O', 'Joe', '36789', '123', 'U', ' 456']

test_loop = []
for item in test_string:
    if 'Store' in item: # create a new list to store all of the elements after store mentioned inside of the outer list
        test_loop.append([item])
    else:  # add elements after store into the last list and before the next mention of Store
        test_loop[-1].append(item)
print(test_loop)
</code>```

which gives:

```<code>[['Store465', 'Steve', '145658', '125', 'Brad', '457958', '200'], ['Store678', 'John', '30122', '898', '123', 'O', 'Joe', '36789', '123', 'U', ' 456']]
</code>```

Body:
I know there is a simple solution but I can't seem to find it.

I want to split a list based on an element just containing a string.

In this case "Store"

from itertools import groupby

test_string = ['Store465', 'Steve', '145658', '125', 'Brad', '457958', '200', 'Store678', 'John', '30122', '898', '123', 'O', 'Joe', '36789', '123', 'U', ' 456']

# I've tried

test_string[:] = [x for x in test_string if "Store" not in x]

print(test_string)

# but that will just remove the  Store elements

# ['Steve', '145658', '125', 'Brad', '457958', '200', 'John', '30122', '898', '123', 'O', 'Joe', '36789', '123', 'U', ' 456']

# and

test_result = [list(g) for k,g in groupby(test_string,lambda x:x if "Store" not in x) if not k]

# This creates an error.
#
#   File "<input>", line 13
#     test_result = [list(g) for k,g in groupby(test_string,lambda x:x if "Store" not in x) if not k]
#                                                                                ^
# SyntaxError: invalid syntax

I've been on stackoverflow and google trying to find the correct syntax or process with no luck. My desired output would be

[['Store465', 'Steve', '145658', '125', 'Brad', '457958', '200'], ['Store678', 'John', '30122', '898', '123', 'O', 'Joe', '36789', '123', 'U', ' 456']]

Body:
To split the lists by the occurrence of Store in the list you could do something like this:

test_string = ['Store465', 'Steve', '145658', '125', 'Brad', '457958', '200', 'Store678', 'John', '30122', '898', '123', 'O', 'Joe', '36789', '123', 'U', ' 456']

test_loop = []
for item in test_string:
    if 'Store' in item: # create a new list to store all of the elements after store mentioned inside of the outer list
        test_loop.append([item])
    else:  # add elements after store into the last list and before the next mention of Store
        test_loop[-1].append(item)
print(test_loop)

which gives:

[['Store465', 'Steve', '145658', '125', 'Brad', '457958', '200'], ['Store678', 'John', '30122', '898', '123', 'O', 'Joe', '36789', '123', 'U', ' 456']]


来源: stackexchange

问:
Casing of ./types does not match the underlying filesystem
So i had a bit weird warning from eslint

'./types' is a flow type file.
I think eslint read checkbox as a lowercase while in reality it is Checkbox (capital C).

I try git mv casesensitive tmp && git mv tmp CaseSensitive as discussed here: In a Git repository, how to properly rename a directory? but it still doesnt work.
because in the past that folder is lowercase (checkbox) and renamed to Uppercase (Checkbox) but it was work of other developer, i don't know what happen in his machine until this warning come in my machine. Maybe (another assumption) it was happen because of bad config of webpack/babel, im not sure.

答:
Got the same issue, all I did was restart my editor (vscode).
Hope this works out for you too.

also, try copying the content of the file, deleting the file, creating a new one, pasting your content, and importing accordingly

This kind of error can be frustrating.

but as it goes, if something doesn't work, and you have no clue, try switching it off and on again

ContentLicense: CC BY-SA 4.0


问:
Why does exec-maven-plugin run all phases twice?
When I run a build with maven using the exec-maven-plugin, it runs everything twice for some reason. Is there a way to fix this so it only runs once? I've tried setting my phase in the pom.xml to compile and package and either way, it runs twice. My pom looks like</p>

```<code><build>
  <plugins>
    <plugin>
      <artifactId>exec-maven-plugin</artifactId>
      <groupId>org.codehaus.mojo</groupId>
      <version>1.0</version>
      <executions>
        <execution>
          <id>foo</id>
          <phase>compile</phase>
          <goals>
            <goal>exec</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <executable>bash</executable>
        <commandlineArgs>myscript.sh</commandlineArgs>
      </configuration>
     </plugin>
    </plugins>
  </build>
</code>```

答:
I saw this happening due to the inclusion of:

```<code>                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.0.1</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
</code>```

This seems to be that the maven-source-plugin causes a re-execution of the generate-sources phase. See https://maven.apache.org/plugins/maven-source-plugin/jar-mojo.html

Invokes the execution of the lifecycle phase generate-sources prior to executing itself.

If I removed this plugin, the exec goal only executed once.

Body:
When I run a build with maven using the exec-maven-plugin, it runs everything twice for some reason. Is there a way to fix this so it only runs once? I've tried setting my phase in the pom.xml to compile and package and either way, it runs twice. My pom looks like

<build>
  <plugins>
    <plugin>
      <artifactId>exec-maven-plugin</artifactId>
      <groupId>org.codehaus.mojo</groupId>
      <version>1.0</version>
      <executions>
        <execution>
          <id>foo</id>
          <phase>compile</phase>
          <goals>
            <goal>exec</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <executable>bash</executable>
        <commandlineArgs>myscript.sh</commandlineArgs>
      </configuration>
     </plugin>
    </plugins>
  </build>

Body:
I saw this happening due to the inclusion of:

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-source-plugin</artifactId>
                    <version>3.0.1</version>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

This seems to be that the maven-source-plugin causes a re-execution of the generate-sources phase. See https://maven.apache.org/plugins/maven-source-plugin/jar-mojo.html

Invokes the execution of the lifecycle phase generate-sources prior to executing itself.

If I removed this plugin, the exec goal only executed once.


问:
CSS file got flooded with errors after VSC update
Yesterday I was working on my code as usual and everything was going fine.
Today, however, after turning on VSC I spotted that my CSS file got flooded with errors, I have no idea what happened.

Here's one example of code that worked before and now it's broken:

```<code>.portfolio {
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: (1fr)[6];
      grid-template-columns repeat(6, 1fr);
  grid-auto-rows: 300px 400px;
  grid-row-gap: 10px;
  grid-column-gap: 10px;
  grid-auto-flow: dense;
}
</code>```

I made a screenshot so you guys can see what I mean since it's my first post here and I hope it all seems clear.

https://i.stack.imgur.com/txK0n.png

Also, there is an even weirder occurrence that I can't handle, any ideas?

```<code>.nav {
  display: 0;
  position: fixed;
  z-index: 999;
  width: 66%;
  right: 0;
  top: 0;
  background: none;
  height: 100vh;
  padding: 1em;

  ul.primary-nav {
    margin-top: 5em;
  }

  li {
    color: white
  }

}
</code>```

https://imgur.com/a/ANlezCc - screen in VSC with problems

答:
Although this is not the answer you are looking for, I have identified just how to make your code runnable. I had to take yours, which is this:

```<code>.portfolio {
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: (1fr)[6];
      grid-template-columns repeat(6, 1fr);
  grid-auto-rows: 300px 400px;
  grid-row-gap: 10px;
  grid-column-gap: 10px;
  grid-auto-flow: dense;
}
</code>```

And switched to:

```<code>.portfolio {
    display: -ms-grid;
    display: grid;
    /* the line below bracket notation does not work…
    not sure how to fix this, just removed the number. */
    -ms-grid-columns: (1fr) [];
    /* the line below was missing a ':' */
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: 300px 400px;
    grid-row-gap: 10px;
    grid-column-gap: 10px;
    grid-auto-flow: dense;
}
</code>```

Please do tell me how different are the things that are displayed now on your website.

Update! 10/2/2022 12:10
The issue with the following code is your nesting

```<code>.nav {
  display: 0;
  position: fixed;
  z-index: 999;
  width: 66%;
  right: 0;
  top: 0;
  background: none;
  height: 100vh;
  padding: 1em;

  ul.primary-nav {
    margin-top: 5em;
  }

  li {
    color: white
  }

}
</code>```

I do not believe it is customary to have tags inside other tags as you have it above. You can definitely achieve the same thing without the nesting such as with this:

```<code>.nav {
    display: 0;
    position: fixed;
    z-index: 999;
    width: 66%;
    right: 0;
    top: 0;
    background: none;
    height: 100vh;
    padding: 1em;

}

ul .primary-nav {
    margin-top: 5em;
}

li {
    color: white
}
</code>```

or if you have specificity problems like so:

```<code>.nav {
    display: 0;
    position: fixed;
    z-index: 999;
    width: 66%;
    right: 0;
    top: 0;
    background: none;
    height: 100vh;
    padding: 1em;

}

ul .primary-nav .nav {
    margin-top: 5em;
}

li .nav {
    color: white
}
</code>```

I think they are trying to strengthen the CSS formatting by normalizing design practices. Have you tried using other IDE's like Intellij's Webstorm (paid software) or Brackets 2.0 (open-source maintained now)?

Body:
Yesterday I was working on my code as usual and everything was going fine.
Today, however, after turning on VSC I spotted that my CSS file got flooded with errors, I have no idea what happened.

Here's one example of code that worked before and now it's broken:

.portfolio {
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: (1fr)[6];
      grid-template-columns repeat(6, 1fr);
  grid-auto-rows: 300px 400px;
  grid-row-gap: 10px;
  grid-column-gap: 10px;
  grid-auto-flow: dense;
}

I made a screenshot so you guys can see what I mean since it's my first post here and I hope it all seems clear.

https://i.stack.imgur.com/txK0n.png

Also, there is an even weirder occurrence that I can't handle, any ideas?

.nav {
  display: 0;
  position: fixed;
  z-index: 999;
  width: 66%;
  right: 0;
  top: 0;
  background: none;
  height: 100vh;
  padding: 1em;

  ul.primary-nav {
    margin-top: 5em;
  }

  li {
    color: white
  }

}

https://imgur.com/a/ANlezCc - screen in VSC with problems

Body:
Although this is not the answer you are looking for, I have identified just how to make your code runnable. I had to take yours, which is this:

.portfolio {
  display: -ms-grid;
  display: grid;
  -ms-grid-columns: (1fr)[6];
      grid-template-columns repeat(6, 1fr);
  grid-auto-rows: 300px 400px;
  grid-row-gap: 10px;
  grid-column-gap: 10px;
  grid-auto-flow: dense;
}

And switched to:

.portfolio {
    display: -ms-grid;
    display: grid;
    /* the line below bracket notation does not work…
    not sure how to fix this, just removed the number. */
    -ms-grid-columns: (1fr) [];
    /* the line below was missing a ':' */
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: 300px 400px;
    grid-row-gap: 10px;
    grid-column-gap: 10px;
    grid-auto-flow: dense;
}

Please do tell me how different are the things that are displayed now on your website.

Update! 10/2/2022 12:10
The issue with the following code is your nesting

.nav {
  display: 0;
  position: fixed;
  z-index: 999;
  width: 66%;
  right: 0;
  top: 0;
  background: none;
  height: 100vh;
  padding: 1em;

  ul.primary-nav {
    margin-top: 5em;
  }

  li {
    color: white
  }

}

I do not believe it is customary to have tags inside other tags as you have it above. You can definitely achieve the same thing without the nesting such as with this:

.nav {
    display: 0;
    position: fixed;
    z-index: 999;
    width: 66%;
    right: 0;
    top: 0;
    background: none;
    height: 100vh;
    padding: 1em;

}

ul .primary-nav {
    margin-top: 5em;
}

li {
    color: white
}

or if you have specificity problems like so:

.nav {
    display: 0;
    position: fixed;
    z-index: 999;
    width: 66%;
    right: 0;
    top: 0;
    background: none;
    height: 100vh;
    padding: 1em;

}

ul .primary-nav .nav {
    margin-top: 5em;
}

li .nav {
    color: white
}

I think they are trying to strengthen the CSS formatting by normalizing design practices. Have you tried using other IDE's like Intellij's Webstorm (paid software) or Brackets 2.0 (open-source maintained now)?


问:
JavaFX 17 -> Custom TextArea/TextField Right Click Menu
I would like to ask a small question.
Indeed, I want to customize the menu that appears when we make a right click in a textarea or a textfield.
My goal would be to keep the basic menu (copy, paste, cut...) by adding the buttons I want.

I found this post that explains how to do it:
JavaFX Append to right click menu for TextField

```<code>import com.sun.javafx.scene.control.skin.TextFieldSkin;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.Stage;

public class GiveMeContext extends Application {
    @Override
    public void start(final Stage stage) throws Exception {
        TextField textField = new TextField();
        TextFieldSkin customContextSkin = new TextFieldSkin(textField) {
            @Override
            public void populateContextMenu(ContextMenu contextMenu) {
                super.populateContextMenu(contextMenu);
                contextMenu.getItems().add(0, new SeparatorMenuItem());
                contextMenu.getItems().add(0, new MenuItem("Register"));
            }
        };
        textField.setSkin(customContextSkin);

        stage.setScene(new Scene(textField));
        stage.show();
    }
    public static void main(String[] args) throws Exception {
        launch(args);
    }
}
</code>```

After trying, it works perfectly well for java 8, but as they were talking about it at the time, after java 9, it doesn't work anymore.

I tried to replace the problematic method (populateContextMenu) but unfortunately I couldn't find any way.

I would be very thankful if someone shows me how to do it using java 9+

答:
Your code won't work in JavaFX 9+ because of modularization. For details read this. The only thing you can do is to use context menu and fill it with your own values. A full example to do it in JavaFX 17 is below.

Step 1. Create new project.

Pom.xml:

```<code><?xml version="1.0" encoding="UTF-8"?>
<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>com.mycompany</groupId>
    <artifactId>mavenproject1</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.9.0</version>
            </plugin>
        </plugins>
    </build>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <dependencies>
           <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-controls</artifactId>
                <version>17.0.2-ea+2</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-base</artifactId>
                <version>17.0.2-ea+2</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-fxml</artifactId>
                <version>17.0.2-ea+2</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-graphics</artifactId>
                <version>17.0.2-ea+2</version>
                <scope>compile</scope>
            </dependency>
    </dependencies>
</project>
</code>```

module-info:

```<code>module Mavenproject1 {
    requires javafx.controls;
    requires javafx.base;
    requires javafx.fxml;
    requires javafx.graphics;
    opens com.mycompany;
}
</code>```

Main class:

```<code>package com.mycompany;

import javafx.scene.control.skin.TextFieldSkin;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextField;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.Stage;

public class NewMain2 extends Application {

    @Override
    public void start(final Stage stage) throws Exception {
        TextField textField = new TextField();

        ContextMenu contextMenu = new ContextMenu();
        MenuItem menuItem1 = new MenuItem("Choice 1");
        MenuItem menuItem2 = new MenuItem("Choice 2");
        MenuItem menuItem3 = new MenuItem("Choice 3");
        contextMenu.getItems().addAll(menuItem1, menuItem2, menuItem3);

        textField.setContextMenu(contextMenu);

        stage.setScene(new Scene(textField));
        stage.show();
    }
    public static void main(String[] args) throws Exception {
        launch(args);
    }
}
</code>```

Step 2. Build you project.

Step 3. Download JavaFX SDK from here.

Step 4 Run you project this way

```<code> java --module-path ./mavenproject1-1.0-SNAPSHOT.jar:/opt/javafx-sdk-17.0.2/lib --add-modules=javafx.controls,javafx.fxml -m Mavenproject1/com.mycompany.NewMain2
</code>```

Body:
I would like to ask a small question.
Indeed, I want to customize the menu that appears when we make a right click in a textarea or a textfield.
My goal would be to keep the basic menu (copy, paste, cut...) by adding the buttons I want.

I found this post that explains how to do it:
JavaFX Append to right click menu for TextField

import com.sun.javafx.scene.control.skin.TextFieldSkin;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.Stage;

public class GiveMeContext extends Application {
    @Override
    public void start(final Stage stage) throws Exception {
        TextField textField = new TextField();
        TextFieldSkin customContextSkin = new TextFieldSkin(textField) {
            @Override
            public void populateContextMenu(ContextMenu contextMenu) {
                super.populateContextMenu(contextMenu);
                contextMenu.getItems().add(0, new SeparatorMenuItem());
                contextMenu.getItems().add(0, new MenuItem("Register"));
            }
        };
        textField.setSkin(customContextSkin);

        stage.setScene(new Scene(textField));
        stage.show();
    }
    public static void main(String[] args) throws Exception {
        launch(args);
    }
}

After trying, it works perfectly well for java 8, but as they were talking about it at the time, after java 9, it doesn't work anymore.

I tried to replace the problematic method (populateContextMenu) but unfortunately I couldn't find any way.

I would be very thankful if someone shows me how to do it using java 9+

Body:
Your code won't work in JavaFX 9+ because of modularization. For details read this. The only thing you can do is to use context menu and fill it with your own values. A full example to do it in JavaFX 17 is below.

Step 1. Create new project.

Pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<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>com.mycompany</groupId>
    <artifactId>mavenproject1</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.9.0</version>
            </plugin>
        </plugins>
    </build>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <dependencies>
           <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-controls</artifactId>
                <version>17.0.2-ea+2</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-base</artifactId>
                <version>17.0.2-ea+2</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-fxml</artifactId>
                <version>17.0.2-ea+2</version>
                <scope>compile</scope>
            </dependency>
            <dependency>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-graphics</artifactId>
                <version>17.0.2-ea+2</version>
                <scope>compile</scope>
            </dependency>
    </dependencies>
</project>

module-info:

module Mavenproject1 {
    requires javafx.controls;
    requires javafx.base;
    requires javafx.fxml;
    requires javafx.graphics;
    opens com.mycompany;
}

Main class:

package com.mycompany;

import javafx.scene.control.skin.TextFieldSkin;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TextField;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.stage.Stage;

public class NewMain2 extends Application {

    @Override
    public void start(final Stage stage) throws Exception {
        TextField textField = new TextField();

        ContextMenu contextMenu = new ContextMenu();
        MenuItem menuItem1 = new MenuItem("Choice 1");
        MenuItem menuItem2 = new MenuItem("Choice 2");
        MenuItem menuItem3 = new MenuItem("Choice 3");
        contextMenu.getItems().addAll(menuItem1, menuItem2, menuItem3);

        textField.setContextMenu(contextMenu);

        stage.setScene(new Scene(textField));
        stage.show();
    }
    public static void main(String[] args) throws Exception {
        launch(args);
    }
}

Step 2. Build you project.

Step 3. Download JavaFX SDK from here.

Step 4 Run you project this way

 java --module-path ./mavenproject1-1.0-SNAPSHOT.jar:/opt/javafx-sdk-17.0.2/lib --add-modules=javafx.controls,javafx.fxml -m Mavenproject1/com.mycompany.NewMain2


问:
How can I connect to a MI via Integration Studio?
I am trying to connect MI via Integration Studio. I downloaded MI and ran micro-integrator.bat. to start MI.

```<code>C:\Users\yusuf.avci_alo-tech\Downloads\wso2mi-4.0.0\bin>micro-integrator.bat
[2021-12-02 11:41:29,367]  INFO {EventAdminConfigurationNotifier} - Logging configuration changed. (Event Admin service unavailable - no notification sent).
[2021-12-02 11:41:31,763]  INFO {AppDeployerServiceComponent} - Dashboard is configured. Initiating heartbeat component.
[2021-12-02 11:41:31,791]  INFO {PassThroughListeningIOReactorManager} - Pass-through HTTP Listener started on 0:0:0:0:0:0:0:0:8290
[2021-12-02 11:41:31,796]  INFO {PassThroughListeningIOReactorManager} - Pass-through HTTPS Listener started on 0:0:0:0:0:0:0:0:8253
[2021-12-02 11:41:31,797]  INFO {StartupFinalizer} - WSO2 Micro Integrator started in 4,08 seconds
[2021-12-02 11:41:31,878]  INFO {PassThroughListeningIOReactorManager} - Pass-through EI_INTERNAL_HTTP_INBOUND_ENDPOINT Listener started on 0:0:0:0:0:0:0:0:9201
[2021-12-02 11:41:31,888]  INFO {PassThroughListeningIOReactorManager} - Pass-through EI_INTERNAL_HTTPS_INBOUND_ENDPOINT Listener started on 0:0:0:0:0:0:0:0:9164
</code>```

Then, I try to add server in Integration Studio.

Define New Server

Entering The Ports

When I try to connect the server, I encounter this error:

```<code>Working directory does not exist: runtime/microesb
</code>```

What am I doing wrong? How can I deploy an integration project created in Integration Studio to a MI server other than the embedden one?

Note: I've found a similar question, but the answer wasn't useful for me:
connect WSO2 integration studio with remote server WSO2 Mi

答:
In the "Define a New Server" popup, click on Add link next to "Server Runtime Environment", and then point the CARBON_HOME to the folder where MI is installed.
This will fix this issue.</p>

Body:
I am trying to connect MI via Integration Studio. I downloaded MI and ran micro-integrator.bat. to start MI.

C:\Users\yusuf.avci_alo-tech\Downloads\wso2mi-4.0.0\bin>micro-integrator.bat
[2021-12-02 11:41:29,367]  INFO {EventAdminConfigurationNotifier} - Logging configuration changed. (Event Admin service unavailable - no notification sent).
[2021-12-02 11:41:31,763]  INFO {AppDeployerServiceComponent} - Dashboard is configured. Initiating heartbeat component.
[2021-12-02 11:41:31,791]  INFO {PassThroughListeningIOReactorManager} - Pass-through HTTP Listener started on 0:0:0:0:0:0:0:0:8290
[2021-12-02 11:41:31,796]  INFO {PassThroughListeningIOReactorManager} - Pass-through HTTPS Listener started on 0:0:0:0:0:0:0:0:8253
[2021-12-02 11:41:31,797]  INFO {StartupFinalizer} - WSO2 Micro Integrator started in 4,08 seconds
[2021-12-02 11:41:31,878]  INFO {PassThroughListeningIOReactorManager} - Pass-through EI_INTERNAL_HTTP_INBOUND_ENDPOINT Listener started on 0:0:0:0:0:0:0:0:9201
[2021-12-02 11:41:31,888]  INFO {PassThroughListeningIOReactorManager} - Pass-through EI_INTERNAL_HTTPS_INBOUND_ENDPOINT Listener started on 0:0:0:0:0:0:0:0:9164

Then, I try to add server in Integration Studio.

Define New Server

Entering The Ports

When I try to connect the server, I encounter this error:

Working directory does not exist: runtime/microesb

What am I doing wrong? How can I deploy an integration project created in Integration Studio to a MI server other than the embedden one?

Note: I've found a similar question, but the answer wasn't useful for me:
connect WSO2 integration studio with remote server WSO2 Mi


问:
Determine how similar two arrays are in PostgreSQL
I'm aware you can compare two arrays in PostgreSQL to see if the elements in one are contained in the elements of another like so,

```<code>SELECT ARRAY[1,2] <@ ARRAY[1,2,3] --> true
</code>```

Is there any way to get # of matches or say "if matches 2 of 3" ??

```<code>SELECT ARRAY[1,2] ?? ARRAY[1,2,3] --> 2/3 or 66.6666%
</code>```

I'm open to interesting solutions.. I want to take an array and ultimately say it must match 2 of 3 elements from another array in an inline query.. or >= 66% or something of that nature.

Ideally like this..

```<code>SELECT * FROM SOMETABLE WHERE ARRAY[1,2] ?? ARRAY[1,2,3] >= 66.66666666666667
</code>```

Thanks in advance.

答:
From here Array functions</p>
```<code>with match as
    (select count(a) as match_ct from unnest(ARRAY[1,2] ) as a
join
    (select * from  unnest(ARRAY[2,1,3]) as b)  t on a=t.b)
select
     match_ct/total_ct::numeric from match,
     (select count(*) as total_ct from unnest(ARRAY[1,2], ARRAY[2,1,3]) as t(a, b)) as total ;
        ?column?
------------------------
 0.66666666666666666667

</code>```

Body:
I'm aware you can compare two arrays in PostgreSQL to see if the elements in one are contained in the elements of another like so,

SELECT ARRAY[1,2] <@ ARRAY[1,2,3] --> true

Is there any way to get # of matches or say "if matches 2 of 3" ??

SELECT ARRAY[1,2] ?? ARRAY[1,2,3] --> 2/3 or 66.6666%

I'm open to interesting solutions.. I want to take an array and ultimately say it must match 2 of 3 elements from another array in an inline query.. or >= 66% or something of that nature.

Ideally like this..

SELECT * FROM SOMETABLE WHERE ARRAY[1,2] ?? ARRAY[1,2,3] >= 66.66666666666667

Thanks in advance.

Body:
From here Array functions

with match as
    (select count(a) as match_ct from unnest(ARRAY[1,2] ) as a
join
    (select * from  unnest(ARRAY[2,1,3]) as b)  t on a=t.b)
select
     match_ct/total_ct::numeric from match,
     (select count(*) as total_ct from unnest(ARRAY[1,2], ARRAY[2,1,3]) as t(a, b)) as total ;
        ?column?
------------------------
 0.66666666666666666667


问:
How to diagnose "x509: certificate signed by unknown authority" in Hyperledger Fabric 2.3.1
I am trying to follow tutorial https://medium.com/swlh/how-to-implement-hyperledger-fabric-external-chaincodes-within-a-kubernetes-cluster-fd01d7544523 to setup a Kubernetes based Hyperledger Fabric 2.3.1 network and deploy Java chaincode.
I have some Fabric 1.4 networks running so I have some experience with it.

I just want to deploy a 2.3.1 single node test network, not for production use... but after setting CA, Orderer an a single peer node (all version 2.3.1, except CA, obviously... using 1.4.9 for that as in the tutorial) I try to use the cli pod to do a basic query to check that system is ready to create the working channel and deploy chain code. For now only the System channel is created, so as a basic test to check system is ready I just do:

```<code>peer channel list
</code>```

and, after some logs, I am getting

```<code>2022-02-09 11:26:04.319 UTC [grpc] InfoDepth -> DEBU 023 [core]Channel Connectivity change to CONNECTING
2022-02-09 11:26:04.319 UTC [grpc] InfoDepth -> DEBU 024 [core]Subchannel picks a new address "peer0:7051" to connect
2022-02-09 11:26:04.324 UTC [comm.tls] ClientHandshake -> DEBU 025 Client TLS handshake completed in 1.726264ms remoteaddress=10.0.54.77:7051
2022-02-09 11:26:04.325 UTC [grpc] InfoDepth -> DEBU 026 [core]Subchannel Connectivity change to READY
2022-02-09 11:26:04.325 UTC [grpc] InfoDepth -> DEBU 027 [core]pickfirstBalancer: UpdateSubConnState: 0xc0001074e0, {READY <nil>}
2022-02-09 11:26:04.325 UTC [grpc] InfoDepth -> DEBU 028 [core]Channel Connectivity change to READY
2022-02-09 11:26:04.325 UTC [channelCmd] InitCmdFactory -> INFO 029 Endorser and orderer connections initialized
2022-02-09 11:26:04.326 UTC [msp.identity] Sign -> DEBU 02a Sign: plaintext: 0A8D070A5C08031A0C08CCC98E900610...631A0D0A0B4765744368616E6E656C73
2022-02-09 11:26:04.326 UTC [msp.identity] Sign -> DEBU 02b Sign: digest: B08705C37A3F785980059CCBFDF2F442ABA1FE37EB5D81CC186896B6845BCC54
Error: Failed sending proposal, got rpc error: code = Unknown desc = error validating proposal: access denied: channel [] creator org [myMSP]
</code>```

I have no logs in the orderer node. in peer 0, log is a bir more explicit about this:

```<code>2022-02-09 11:21:43.653 UTC [core.comm] ServerHandshake -> DEBU 2ec Server TLS handshake completed in 1.568175ms server=PeerServer remoteaddress=10.244.0.95:47938
2022-02-09 11:21:43.659 UTC [endorser] ProcessProposal -> DEBU 2ed request from 10.244.0.95:47938
2022-02-09 11:21:43.659 UTC [msp] DeserializeIdentity -> DEBU 2ee Obtaining identity
2022-02-09 11:21:43.660 UTC [msp.identity] newIdentity -> DEBU 2ef Creating identity instance for cert -----BEGIN CERTIFICATE-----
MIICCjCCAbGgAwIBAgIQFO7hTIQHz/qAxSMqwW9uKjAKBggqhkjOPQQDAjBfMQsw
CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy
YW5jaXNjbzEPMA0GA1UEChMGZ292Lm10MRIwEAYDVQQDEwljYS5nb3YubXQwHhcN
MjIwMjA5MTAxODAwWhcNMzIwMjA3MTAxODAwWjBhMQswCQYDVQQGEwJVUzETMBEG
A1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEOMAwGA1UE
CxMFYWRtaW4xFTATBgNVBAMMDEFkbWluQGdvdi5tdDBZMBMGByqGSM49AgEGCCqG
SM49AwEHA0IABD/oc/GiTNnSXqPRC4yScpoc/notc2uARE5oHjOXDvU827PuMr07
IMvBayCWboAp6SkR0/v+OtvEY/XlySVEjrujTTBLMA4GA1UdDwEB/wQEAwIHgDAM
BgNVHRMBAf8EAjAAMCsGA1UdIwQkMCKAIHLuh4sDVX5mfM2r7dH2C/m42LIowByU
zSATn/uJ+gOZMAoGCCqGSM49BAMCA0cAMEQCIDdWktsYpi8cX14xsSpaTFme57M6
jFFdfek96uV8A13AAiBaMwotEAzB7MD2eUV+v48L6PWkkcWxKAyyRdLOrqTtWQ==
-----END CERTIFICATE-----
2022-02-09 11:21:43.660 UTC [endorser] Validate -> WARN 2f0 access denied: channel the supplied identity is not valid: x509: certificate signed by unknown authority channel= txID=c0b88931
2022-02-09 11:21:43.660 UTC [comm.grpc.server] 1 -> INFO 2f1 unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=10.244.0.95:47938 error="error validating proposal: access denied: channel [] creator org [myMSP]" grpc.code=Unknown grpc.call_duration=1.168556ms
2022-02-09 11:21:43.664 UTC [grpc] InfoDepth -> DEBU 2f2 [transport]transport: loopyWriter.run returning. connection error: desc = "transport is closing"
</code>```

In the cryptogen and configtxgen processes I am not getting any errors or warnings. All files seem to be generated correctly. Also, in the started process of Orderer, CA, peer or cli there is no warning or error about any missing or incorrect certificate file.

How can I diagnose what my problem is and find what is wrong with that certificate? Maybe I have wrong values in the Ids, MSP names, ... in the configtx.yaml and crypto-config.yaml artifacts files, but I have checked them and can't find anything.

Any ideas on what or how to check and diagnose?

Thanks

答:
I wasn't able to diagnose but found a similar issue that happened to have the same origin.

Fabric v2.0 in kubernetes (minikube) - error Peer channel - error validating proposal: access denied: channel [] creator org [Org1MSP]

As said in that task... "I was missing CORE_PEER_MSPCONFIGPATH in the env in the yaml files for the deployment of peers.

Just adding this allowed me to successfully join the channel."

Body:
I am trying to follow tutorial https://medium.com/swlh/how-to-implement-hyperledger-fabric-external-chaincodes-within-a-kubernetes-cluster-fd01d7544523 to setup a Kubernetes based Hyperledger Fabric 2.3.1 network and deploy Java chaincode.
I have some Fabric 1.4 networks running so I have some experience with it.

I just want to deploy a 2.3.1 single node test network, not for production use... but after setting CA, Orderer an a single peer node (all version 2.3.1, except CA, obviously... using 1.4.9 for that as in the tutorial) I try to use the cli pod to do a basic query to check that system is ready to create the working channel and deploy chain code. For now only the System channel is created, so as a basic test to check system is ready I just do:

peer channel list

and, after some logs, I am getting

2022-02-09 11:26:04.319 UTC [grpc] InfoDepth -> DEBU 023 [core]Channel Connectivity change to CONNECTING
2022-02-09 11:26:04.319 UTC [grpc] InfoDepth -> DEBU 024 [core]Subchannel picks a new address "peer0:7051" to connect
2022-02-09 11:26:04.324 UTC [comm.tls] ClientHandshake -> DEBU 025 Client TLS handshake completed in 1.726264ms remoteaddress=10.0.54.77:7051
2022-02-09 11:26:04.325 UTC [grpc] InfoDepth -> DEBU 026 [core]Subchannel Connectivity change to READY
2022-02-09 11:26:04.325 UTC [grpc] InfoDepth -> DEBU 027 [core]pickfirstBalancer: UpdateSubConnState: 0xc0001074e0, {READY <nil>}
2022-02-09 11:26:04.325 UTC [grpc] InfoDepth -> DEBU 028 [core]Channel Connectivity change to READY
2022-02-09 11:26:04.325 UTC [channelCmd] InitCmdFactory -> INFO 029 Endorser and orderer connections initialized
2022-02-09 11:26:04.326 UTC [msp.identity] Sign -> DEBU 02a Sign: plaintext: 0A8D070A5C08031A0C08CCC98E900610...631A0D0A0B4765744368616E6E656C73
2022-02-09 11:26:04.326 UTC [msp.identity] Sign -> DEBU 02b Sign: digest: B08705C37A3F785980059CCBFDF2F442ABA1FE37EB5D81CC186896B6845BCC54
Error: Failed sending proposal, got rpc error: code = Unknown desc = error validating proposal: access denied: channel [] creator org [myMSP]

I have no logs in the orderer node. in peer 0, log is a bir more explicit about this:

2022-02-09 11:21:43.653 UTC [core.comm] ServerHandshake -> DEBU 2ec Server TLS handshake completed in 1.568175ms server=PeerServer remoteaddress=10.244.0.95:47938
2022-02-09 11:21:43.659 UTC [endorser] ProcessProposal -> DEBU 2ed request from 10.244.0.95:47938
2022-02-09 11:21:43.659 UTC [msp] DeserializeIdentity -> DEBU 2ee Obtaining identity
2022-02-09 11:21:43.660 UTC [msp.identity] newIdentity -> DEBU 2ef Creating identity instance for cert -----BEGIN CERTIFICATE-----
MIICCjCCAbGgAwIBAgIQFO7hTIQHz/qAxSMqwW9uKjAKBggqhkjOPQQDAjBfMQsw
CQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZy
YW5jaXNjbzEPMA0GA1UEChMGZ292Lm10MRIwEAYDVQQDEwljYS5nb3YubXQwHhcN
MjIwMjA5MTAxODAwWhcNMzIwMjA3MTAxODAwWjBhMQswCQYDVQQGEwJVUzETMBEG
A1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEOMAwGA1UE
CxMFYWRtaW4xFTATBgNVBAMMDEFkbWluQGdvdi5tdDBZMBMGByqGSM49AgEGCCqG
SM49AwEHA0IABD/oc/GiTNnSXqPRC4yScpoc/notc2uARE5oHjOXDvU827PuMr07
IMvBayCWboAp6SkR0/v+OtvEY/XlySVEjrujTTBLMA4GA1UdDwEB/wQEAwIHgDAM
BgNVHRMBAf8EAjAAMCsGA1UdIwQkMCKAIHLuh4sDVX5mfM2r7dH2C/m42LIowByU
zSATn/uJ+gOZMAoGCCqGSM49BAMCA0cAMEQCIDdWktsYpi8cX14xsSpaTFme57M6
jFFdfek96uV8A13AAiBaMwotEAzB7MD2eUV+v48L6PWkkcWxKAyyRdLOrqTtWQ==
-----END CERTIFICATE-----
2022-02-09 11:21:43.660 UTC [endorser] Validate -> WARN 2f0 access denied: channel the supplied identity is not valid: x509: certificate signed by unknown authority channel= txID=c0b88931
2022-02-09 11:21:43.660 UTC [comm.grpc.server] 1 -> INFO 2f1 unary call completed grpc.service=protos.Endorser grpc.method=ProcessProposal grpc.peer_address=10.244.0.95:47938 error="error validating proposal: access denied: channel [] creator org [myMSP]" grpc.code=Unknown grpc.call_duration=1.168556ms
2022-02-09 11:21:43.664 UTC [grpc] InfoDepth -> DEBU 2f2 [transport]transport: loopyWriter.run returning. connection error: desc = "transport is closing"

In the cryptogen and configtxgen processes I am not getting any errors or warnings. All files seem to be generated correctly. Also, in the started process of Orderer, CA, peer or cli there is no warning or error about any missing or incorrect certificate file.

How can I diagnose what my problem is and find what is wrong with that certificate? Maybe I have wrong values in the Ids, MSP names, ... in the configtx.yaml and crypto-config.yaml artifacts files, but I have checked them and can't find anything.

Any ideas on what or how to check and diagnose?

Thanks


问:
OCR in Sage Maker
Guys i am trying to build infrastructure on aws for getting help from others on annotation. currently we uses label-studio for text annotation. as might know you can label text by selecting through polygon and than writing what does selected area mean. ex: if polygon is made around english word than what writing out label  of it to annotate that given english word. for more see image below.

How can i do this in SageMaker Ground Truth. as far as i have gone i think it can just label pre defined words. you cant create custom label in it by selecting any given area using polygon in image am i right ?

答: Unfortunately LS doesn't support changing of labels on the fly.</p>

Title: OCR in Sage Maker


问:
System.out.printIn cannot find symbol
Whenever I try to compile this Java program in the command prompt I get an error about System.out.printIn saying that javac cannot find symbol. System.out.print works just fine but System.out.printIn refuses to cooperate. I've posted the program and the compiler message below. Thanks for the help.

```<code>    public class BeerSong {
public static void main (String[] args) {
int beerNum = 99;
String word = "bottles";

while (beerNum > 0) {

  if (beerNum == 1) {
    word = "bottle"; //singular, ONE bottle
}

System.out.printIn(beerNum + " " + word + "of beer on the wall");
System.out.printIn(beerNum + " " + word + "of beer.");
System.out.printIn("Take one down.");
System.out.printIn("Pass it around.");
beerNum = beerNum - 1;

if (beerNum > 0) {
    System.out.printIn(beerNum + " " + word + " of beer on the wall");
}   else {
    System.out.printIn("No more bottles of beer on the wall");
} //end else
} //end while loop
} //end main method
} //end class
</code>```

```<code>C:\Users\Jesse\Desktop>javac BeerSong.java
BeerSong.java:12: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn(beerNum + " " + word + "of beer on the wall");
              ^
BeerSong.java:13: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn(beerNum + " " + word + "of beer.");
              ^
BeerSong.java:14: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn("Take one down.");
              ^
BeerSong.java:15: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn("Pass it around.");
              ^
BeerSong.java:19: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
        System.out.printIn(beerNum + " " + word + " of beer on the wall");
                  ^
BeerSong.java:21: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
            System.out.printIn("No more bottles of beer on the wall");
                      ^
6 errors
</code>```

答: it is System.out.println and NOT System.out.printIn (lower case L and not upper case i)

ContentLicense: CC BY-SA 3.0

Title: System.out.printIn cannot find symbol

Body:
Whenever I try to compile this Java program in the command prompt I get an error about System.out.printIn saying that javac cannot find symbol. System.out.print works just fine but System.out.printIn refuses to cooperate. I've posted the program and the compiler message below. Thanks for the help.

    public class BeerSong {
public static void main (String[] args) {
int beerNum = 99;
String word = "bottles";

while (beerNum > 0) {

  if (beerNum == 1) {
    word = "bottle"; //singular, ONE bottle
}

System.out.printIn(beerNum + " " + word + "of beer on the wall");
System.out.printIn(beerNum + " " + word + "of beer.");
System.out.printIn("Take one down.");
System.out.printIn("Pass it around.");
beerNum = beerNum - 1;

if (beerNum > 0) {
    System.out.printIn(beerNum + " " + word + " of beer on the wall");
}   else {
    System.out.printIn("No more bottles of beer on the wall");
} //end else
} //end while loop
} //end main method
} //end class

C:\Users\Jesse\Desktop>javac BeerSong.java
BeerSong.java:12: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn(beerNum + " " + word + "of beer on the wall");
              ^
BeerSong.java:13: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn(beerNum + " " + word + "of beer.");
              ^
BeerSong.java:14: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn("Take one down.");
              ^
BeerSong.java:15: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
    System.out.printIn("Pass it around.");
              ^
BeerSong.java:19: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
        System.out.printIn(beerNum + " " + word + " of beer on the wall");
                  ^
BeerSong.java:21: cannot find symbol
symbol  : method printIn(java.lang.String)
location: class java.io.PrintStream
            System.out.printIn("No more bottles of beer on the wall");
                      ^
6 errors


问:
Vue router in main.js: this dependency was not found error
When I run npm run serve I get the This dependency was not found error, relating to the router that I'm trying to use in the main.js. I don't understand why this happens - the router is created and exported from src/router/router/js file and imported in the main.js file.

main.js:

```<code>import App from './App.vue'
import './assets/tailwind.css'
import Vue from 'vue'
import VueRouter from 'vue-router'
import router from 'router/router.js'

Vue.config.productionTip = false
Vue.use(VueRouter);

const app = new Vue({
  render: h => h(App),
}).$mount('#app')

app.use(router);
</code>```

router.js:

```<code>import { createRouter, createWebHistory } from 'vue-router'

import Home from '../views/Home.vue'
import About from '../views/About.vue'

const routes = [
    {
        path: '/home',
        name: 'Home',
        component: Home
    },
    {
        path: '/about',
        name: 'About',
        component: About
    }
]
const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
})
export default router
</code>```

This is my directory structure:

I get this error:

```<code>
This dependency was not found:

* router/router.js in ./src/main.js
</code>```

答:
I change import to

```<code>import router from `./router/router.js
</code>```

And also made new project with Vue 3 (was used Vue 2 for this one), where I installed vue-router@next. Then I followed this tutorial: https://www.vuemastery.com/blog/vue-router-a-tutorial-for-vue-3/

Changed main.js:

```<code>import { createApp } from 'vue'
import App from './App.vue'
import router from './router/router.js'

createApp(App).use(router).mount('#app')
</code>```

Body:
When I run npm run serve I get the This dependency was not found error, relating to the router that I'm trying to use in the main.js. I don't understand why this happens - the router is created and exported from src/router/router/js file and imported in the main.js file.

main.js:

import App from './App.vue'
import './assets/tailwind.css'
import Vue from 'vue'
import VueRouter from 'vue-router'
import router from 'router/router.js'

Vue.config.productionTip = false
Vue.use(VueRouter);

const app = new Vue({
  render: h => h(App),
}).$mount('#app')

app.use(router);

router.js:

import { createRouter, createWebHistory } from 'vue-router'

import Home from '../views/Home.vue'
import About from '../views/About.vue'

const routes = [
    {
        path: '/home',
        name: 'Home',
        component: Home
    },
    {
        path: '/about',
        name: 'About',
        component: About
    }
]
const router = createRouter({
    history: createWebHistory(process.env.BASE_URL),
    routes
})
export default router

This is my directory structure:

I get this error:

This dependency was not found:

* router/router.js in ./src/main.js

Body:
I change import to

import router from `./router/router.js

And also made new project with Vue 3 (was used Vue 2 for this one), where I installed vue-router@next. Then I followed this tutorial: https://www.vuemastery.com/blog/vue-router-a-tutorial-for-vue-3/

Changed main.js:

import { createApp } from 'vue'
import App from './App.vue'
import router from './router/router.js'

createApp(App).use(router).mount('#app')


问:
creating next app with: npx create-next-app giving me error
I'm trying to create a next app using the following CLI command: npx create-next-app and after entering my app name it gives me the following error:

Note that I have previously created a next app using the exact same method and it did work just as intented without any errors.

答:
I honestly dont know why, but running npm init and npm i create-nuxt-app worked for me.

Edit: the problem can be with globally installed package, try running npm uninstall -g create-nuxt-app if answer above didnt help.


问:
Prefill Google Sheet sidebar with Apps Script Properties Service values
I have written a code to show the form in a sidebar in google sheets and store the entered values such as full name, email address, mobile no. etc, in Apps Script Properties but the only issue I am facing is when I close the form and reopen it, the form does not show the last stored values as well as confirmation message on submit.

I want the form to show the last stored value from the Apps Script Properties and confirmation message on submit.

Please help.

Code.gs

```<code>function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Sidebar')
    .addItem('Show sidebar', 'showSidebar')
    .addToUi();
}

function showSidebar() {
  var userName = Session.getActiveUser().getEmail();
  var scriptProperties = PropertiesService.getScriptProperties();
  const html = HtmlService.createTemplateFromFile('index');
  html.data = {
    'fullName': scriptProperties.getProperty('fullName'),
    'emailAddress': scriptProperties.getProperty('emailAddress'),
    'mobileNumber': scriptProperties.getProperty('mobileNumber'),
    'city': scriptProperties.getProperty('city'),
    'weekday': scriptProperties.getProperty('weekday'),
    'triggerTime': scriptProperties.getProperty('triggerTime')
  };

  var popFullName = scriptProperties.getProperty('fullName');
  console.log({ html })
  var evaluatHTML = html.evaluate().setTitle('Sidebar')
  SpreadsheetApp.getUi().showSidebar(evaluatHTML)
};

function setfullName(fullName) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('fullName', fullName);
};

function setEmailAddress(emailAddress) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('emailAddress', emailAddress);
};

function setMobileNumber(mobileNumber) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('mobileNumber', mobileNumber);
};

function setCity(city) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('city', city);
};

function setday(day) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('weekday', day);
};

function setselectTime(selectTime) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('triggerTime', selectTime);
};

function testProp() {
  var popFullName = PropertiesService.getScriptProperties().getProperty('fullName');
  var popEmailAddress = PropertiesService.getScriptProperties().getProperty('emailAddress');
  var popMobileNumber = PropertiesService.getScriptProperties().getProperty('mobileNumber');
  var popcity = PropertiesService.getScriptProperties().getProperty('city');
  var popsetday = PropertiesService.getScriptProperties().getProperty('weekday');
  var popsettriggertime = PropertiesService.getScriptProperties().getProperty('triggerTime');
  console.log({ popFullName })
  console.log({ popEmailAddress })
  console.log({ popMobileNumber })
  console.log({ popcity })
  console.log({ popsetday })
  console.log({ popsettriggertime })
};
</code>```

index.html

```<code><!DOCTYPE html>
<html>

<head>
  <base target="_top">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
  <style>
    .form-row {
      margin-bottom: 15px;
    }
  </style>
</head>

<body>
  <div class="content-body">

    <div class="row">
      <div class="input-field col s12">
        <input id="fullName" type="text" class="validate">
        <label class="active" for="fullName">Full Name</label>
      </div>
    </div>

    <div class="row">
      <div class="input-field col s12">
        <input id="emailAddress" type="text" class="validate">
        <label for="emailAddress">Email Address</label>
      </div>
    </div>

    <div class="row">
      <div class="input-field col s12">
        <input id="mobileNumber" type="number" class="validate">
        <label for="mobileNumber">Mobile Number</label>
      </div>
    </div>

    <div class="row">
      <div class="input-field col s12">
        <input id="city" type="text" class="validate">
        <label for="city">City</label>
      </div>
    </div>

    <div class="row">
      <div class="input-field col s12">
        <select id="day">
<option value="">Choose</option>
<option value="MONDAY">MONDAY</option>
<option value="TUESDAY">TUESDAY</option>
<option value="WEDNESDAY">WEDNESDAY</option>
<option value="THURSDAY">THURSDAY</option>
<option value="FRIDAY">FRIDAY</option>
<option value="SATURDAY">SATURDAY</option>
<option value="SUNDAY">SUNDAY</option>
</select>
        <label>Select Day</label>
      </div>
    </div>

    <div class="row">
      <div class="input-field col s12">
        <select id="selectTime">
<option value="">Choose</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
        <label>Select Time</label>
      </div>
    </div>

    <div class="row">
      <button id="btn" class="btn waves-effect waves-light" onclick="setValueToProperties()" type="submit" name="action">Submit</button>
    </div>

    <div class="row">
      <button class="btn waves-effect waves-light" onClick="google.script.host.close()">Close</button>
    </div>

  </div>

  <script>
    function setValueToProperties() {
    const fullName = document.getElementById('fullName').value;
    google.script.run.setfullName(fullName);

    const emailAddress = document.getElementById('emailAddress').value;
    google.script.run.setEmailAddress(emailAddress);

    const mobileNumber = document.getElementById('mobileNumber').value;
    google.script.run.setMobileNumber(mobileNumber);

    const city = document.getElementById('city').value;
    google.script.run.setCity(city);

    const day = document.getElementById('day').value;
    google.script.run.setday(day);

    const selectTime = document.getElementById('selectTime').value;
    google.script.run.setselectTime(selectTime);

  }
  </script>

  <script>
    document.addEventListener('DOMContentLoaded', function() {
    var elems = document.querySelectorAll('select');
    var instances = M.FormSelect.init(elems);
    });
  </script>

  <script>
    var data = <?!=JSON.stringify(data);?>
  </script>

  <script>
    $(document).ready(function(){
             const keys = ["fullName", "emailAddress", "mobileNumber", "city", "day", "selectTime"];
             $.each(keys, function(key){
                 let val = data[keys[key]] ;
                 $("#"+keys[key]).val(val);
             });
  </script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

</body>

</html>
</code>```

答:
I found some issues in your code:

Missing }); for $(document).ready(function(){

$(document).ready(function(){ and other Jquery  won't work without

In <?!=JSON.stringify(data);?> you are converting the value of data to string instead of parsing it to JSON.

The correct way to access array in Jquery is $.each(function(index, value){ and you should use only the callback value instead of keys[key]

The structure of var data is in Object, data[keys[key]] wont work, it should be data[key]

Try this instead:

Code.gs

```<code>function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Sidebar')
    .addItem('Show sidebar', 'showSidebar')
    .addToUi();
}

function showSidebar() {
  var userName = Session.getActiveUser().getEmail();
  var scriptProperties = PropertiesService.getScriptProperties();
  const html = HtmlService.createTemplateFromFile('index');
  html.data = {
    'fullName': scriptProperties.getProperty('fullName'),
    'emailAddress': scriptProperties.getProperty('emailAddress'),
    'mobileNumber': scriptProperties.getProperty('mobileNumber'),
    'city': scriptProperties.getProperty('city'),
    'day': scriptProperties.getProperty('weekday'),
    'selectTime': scriptProperties.getProperty('triggerTime')
  };

  var popFullName = scriptProperties.getProperty('fullName');
  var evaluatHTML = html.evaluate().setTitle('Sidebar')
  SpreadsheetApp.getUi().showSidebar(evaluatHTML)
};

function setfullName(fullName) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('fullName', fullName);
};

function setEmailAddress(emailAddress) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('emailAddress', emailAddress);
};

function setMobileNumber(mobileNumber) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('mobileNumber', mobileNumber);
};

function setCity(city) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('city', city);
};

function setday(day) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('weekday', day);
};

function setselectTime(selectTime) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('triggerTime', selectTime);
};
</code>```

index.html

```<code><!DOCTYPE html>
<html>
  <head>
    <base target="_top" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" />
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

    <style>
      .form-row {
        margin-bottom: 15px;
      }
    </style>
  </head>

  <body>
    <div class="content-body">
      <div class="row">
        <div class="input-field col s12">
          <input id="fullName" type="text" class="validate" />
          <label class="active" for="fullName">Full Name</label>
        </div>
      </div>

      <div class="row">
        <div class="input-field col s12">
          <input id="emailAddress" type="text" class="validate" />
          <label for="emailAddress">Email Address</label>
        </div>
      </div>

      <div class="row">
        <div class="input-field col s12">
          <input id="mobileNumber" type="number" class="validate" />
          <label for="mobileNumber">Mobile Number</label>
        </div>
      </div>

      <div class="row">
        <div class="input-field col s12">
          <input id="city" type="text" class="validate" />
          <label for="city">City</label>
        </div>
      </div>

      <div class="row">
        <div class="input-field col s12">
          <select id="day">
            <option value="">Choose</option>
            <option value="MONDAY">MONDAY</option>
            <option value="TUESDAY">TUESDAY</option>
            <option value="WEDNESDAY">WEDNESDAY</option>
            <option value="THURSDAY">THURSDAY</option>
            <option value="FRIDAY">FRIDAY</option>
            <option value="SATURDAY">SATURDAY</option>
            <option value="SUNDAY">SUNDAY</option>
          </select>
          <label>Select Day</label>
        </div>
      </div>

      <div class="row">
        <div class="input-field col s12">
          <select id="selectTime">
            <option value="">Choose</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
          </select>
          <label>Select Time</label>
        </div>
      </div>

      <div class="row">
        <button id="btn" class="btn waves-effect waves-light" onclick="setValueToProperties()" type="submit" name="action">Submit</button>
      </div>

      <div class="row">
        <button class="btn waves-effect waves-light" onClick="google.script.host.close()">Close</button>
      </div>
    </div>

    <input id="test1" type="text" class="validate" />

    <script>
      function setValueToProperties() {
        const fullName = document.getElementById("fullName").value;
        google.script.run.setfullName(fullName);

        const emailAddress = document.getElementById("emailAddress").value;
        google.script.run.setEmailAddress(emailAddress);

        const mobileNumber = document.getElementById("mobileNumber").value;
        google.script.run.setMobileNumber(mobileNumber);

        const city = document.getElementById("city").value;
        google.script.run.setCity(city);

        const day = document.getElementById("day").value;
        google.script.run.setday(day);

        const selectTime = document.getElementById("selectTime").value;
        google.script.run.setselectTime(selectTime);
      }
    </script>

    <script>
      document.addEventListener("DOMContentLoaded", function () {
        var elems = document.querySelectorAll("select");
        var instances = M.FormSelect.init(elems);
      });
    </script>

    <script>
      var data = JSON.parse("<?=JSON.stringify(data)?>");
    </script>

    <script>
      $(document).ready(function(){
        const keys = ["fullName", "emailAddress", "mobileNumber", "city", "day", "selectTime"];
        $.each(keys, function(index, item){
          $("#"+item).val(data[item]);
        });
      });
    </script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
  </body>
</html>
</code>```

Output:

The values are from my previous form submit

Reference:

jQuery.each( array, callback )

Body:
I have written a code to show the form in a sidebar in google sheets and store the entered values such as full name, email address, mobile no. etc, in Apps Script Properties but the only issue I am facing is when I close the form and reopen it, the form does not show the last stored values as well as confirmation message on submit.

I want the form to show the last stored value from the Apps Script Properties and confirmation message on submit.

Please help.

Code.gs

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Sidebar')
    .addItem('Show sidebar', 'showSidebar')
    .addToUi();
}

function showSidebar() {
  var userName = Session.getActiveUser().getEmail();
  var scriptProperties = PropertiesService.getScriptProperties();
  const html = HtmlService.createTemplateFromFile('index');
  html.data = {
    'fullName': scriptProperties.getProperty('fullName'),
    'emailAddress': scriptProperties.getProperty('emailAddress'),
    'mobileNumber': scriptProperties.getProperty('mobileNumber'),
    'city': scriptProperties.getProperty('city'),
    'weekday': scriptProperties.getProperty('weekday'),
    'triggerTime': scriptProperties.getProperty('triggerTime')
  };

  var popFullName = scriptProperties.getProperty('fullName');
  console.log({ html })
  var evaluatHTML = html.evaluate().setTitle('Sidebar')
  SpreadsheetApp.getUi().showSidebar(evaluatHTML)
};

function setfullName(fullName) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('fullName', fullName);
};

function setEmailAddress(emailAddress) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('emailAddress', emailAddress);
};

function setMobileNumber(mobileNumber) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('mobileNumber', mobileNumber);
};

function setCity(city) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('city', city);
};

function setday(day) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('weekday', day);
};

function setselectTime(selectTime) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('triggerTime', selectTime);
};

function testProp() {
  var popFullName = PropertiesService.getScriptProperties().getProperty('fullName');
  var popEmailAddress = PropertiesService.getScriptProperties().getProperty('emailAddress');
  var popMobileNumber = PropertiesService.getScriptProperties().getProperty('mobileNumber');
  var popcity = PropertiesService.getScriptProperties().getProperty('city');
  var popsetday = PropertiesService.getScriptProperties().getProperty('weekday');
  var popsettriggertime = PropertiesService.getScriptProperties().getProperty('triggerTime');
  console.log({ popFullName })
  console.log({ popEmailAddress })
  console.log({ popMobileNumber })
  console.log({ popcity })
  console.log({ popsetday })
  console.log({ popsettriggertime })
};

index.html

<!DOCTYPE html>

  <base target="_top">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">

        <input id="fullName" type="text" class="validate">
        Full Name

        <input id="emailAddress" type="text" class="validate">
        Email Address

        <input id="mobileNumber" type="number" class="validate">
        Mobile Number

        <input id="city" type="text" class="validate">
        City

        <select id="day">
<option value="">Choose</option>
<option value="MONDAY">MONDAY</option>
<option value="TUESDAY">TUESDAY</option>
<option value="WEDNESDAY">WEDNESDAY</option>
<option value="THURSDAY">THURSDAY</option>
<option value="FRIDAY">FRIDAY</option>
<option value="SATURDAY">SATURDAY</option>
<option value="SUNDAY">SUNDAY</option>
</select>
        Select Day

        <select id="selectTime">
<option value="">Choose</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
</select>
        Select Time

      <button id="btn" class="btn waves-effect waves-light" onclick="setValueToProperties()" type="submit" name="action">Submit</button>

      <button class="btn waves-effect waves-light" onClick="google.script.host.close()">Close</button>

Body:
I found some issues in your code:

Missing }); for $(document).ready(function(){

$(document).ready(function(){ and other Jquery  won't work without <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

In <?!=JSON.stringify(data);?> you are converting the value of data to string instead of parsing it to JSON.

The correct way to access array in Jquery is $.each(function(index, value){ and you should use only the callback value instead of keys[key]

The structure of var data is in Object, data[keys[key]] wont work, it should be data[key]

Try this instead:

Code.gs

function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('Sidebar')
    .addItem('Show sidebar', 'showSidebar')
    .addToUi();
}

function showSidebar() {
  var userName = Session.getActiveUser().getEmail();
  var scriptProperties = PropertiesService.getScriptProperties();
  const html = HtmlService.createTemplateFromFile('index');
  html.data = {
    'fullName': scriptProperties.getProperty('fullName'),
    'emailAddress': scriptProperties.getProperty('emailAddress'),
    'mobileNumber': scriptProperties.getProperty('mobileNumber'),
    'city': scriptProperties.getProperty('city'),
    'day': scriptProperties.getProperty('weekday'),
    'selectTime': scriptProperties.getProperty('triggerTime')
  };

  var popFullName = scriptProperties.getProperty('fullName');
  var evaluatHTML = html.evaluate().setTitle('Sidebar')
  SpreadsheetApp.getUi().showSidebar(evaluatHTML)
};

function setfullName(fullName) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('fullName', fullName);
};

function setEmailAddress(emailAddress) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('emailAddress', emailAddress);
};

function setMobileNumber(mobileNumber) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('mobileNumber', mobileNumber);
};

function setCity(city) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('city', city);
};

function setday(day) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('weekday', day);
};

function setselectTime(selectTime) {
  var scriptProperties = PropertiesService.getScriptProperties();
  scriptProperties.setProperty('triggerTime', selectTime);
};

index.html

<!DOCTYPE html>
<html>
  <head>
    <base target="_top" />
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" />
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

    <style>
      .form-row {
        margin-bottom: 15px;
      }
    </style>
  </head>

  <body>
    <div class="content-body">
      <div class="row">
        <div class="input-field col s12">
          <input id="fullName" type="text" class="validate" />
          <label class="active" for="fullName">Full Name</label>
        </div>
      </div>

      <div class="row">
        <div class="input-field col s12">
          <input id="emailAddress" type="text" class="validate" />
          <label for="emailAddress">Email Address</label>
        </div>
      </div>

      <div class="row">
        <div class="input-field col s12">
          <input id="mobileNumber" type="number" class="validate" />
          <label for="mobileNumber">Mobile Number</label>
        </div>
      </div>

      <div class="row">
        <div class="input-field col s12">
          <input id="city" type="text" class="validate" />
          <label for="city">City</label>
        </div>
      </div>

      <div class="row">
        <div class="input-field col s12">
          <select id="day">
            <option value="">Choose</option>
            <option value="MONDAY">MONDAY</option>
            <option value="TUESDAY">TUESDAY</option>
            <option value="WEDNESDAY">WEDNESDAY</option>
            <option value="THURSDAY">THURSDAY</option>
            <option value="FRIDAY">FRIDAY</option>
            <option value="SATURDAY">SATURDAY</option>
            <option value="SUNDAY">SUNDAY</option>
          </select>
          <label>Select Day</label>
        </div>
      </div>

      <div class="row">
        <div class="input-field col s12">
          <select id="selectTime">
            <option value="">Choose</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            <option value="11">11</option>
            <option value="12">12</option>
            <option value="13">13</option>
            <option value="14">14</option>
            <option value="15">15</option>
            <option value="16">16</option>
            <option value="17">17</option>
            <option value="18">18</option>
            <option value="19">19</option>
            <option value="20">20</option>
            <option value="21">21</option>
            <option value="22">22</option>
            <option value="23">23</option>
          </select>
          <label>Select Time</label>
        </div>
      </div>

      <div class="row">
        <button id="btn" class="btn waves-effect waves-light" onclick="setValueToProperties()" type="submit" name="action">Submit</button>
      </div>

      <div class="row">
        <button class="btn waves-effect waves-light" onClick="google.script.host.close()">Close</button>
      </div>
    </div>

    <input id="test1" type="text" class="validate" />

    <script>
      function setValueToProperties() {
        const fullName = document.getElementById("fullName").value;
        google.script.run.setfullName(fullName);

        const emailAddress = document.getElementById("emailAddress").value;
        google.script.run.setEmailAddress(emailAddress);

        const mobileNumber = document.getElementById("mobileNumber").value;
        google.script.run.setMobileNumber(mobileNumber);

        const city = document.getElementById("city").value;
        google.script.run.setCity(city);

        const day = document.getElementById("day").value;
        google.script.run.setday(day);

        const selectTime = document.getElementById("selectTime").value;
        google.script.run.setselectTime(selectTime);
      }
    </script>

    <script>
      document.addEventListener("DOMContentLoaded", function () {
        var elems = document.querySelectorAll("select");
        var instances = M.FormSelect.init(elems);
      });
    </script>

    <script>
      var data = JSON.parse("<?=JSON.stringify(data)?>");
    </script>

    <script>
      $(document).ready(function(){
        const keys = ["fullName", "emailAddress", "mobileNumber", "city", "day", "selectTime"];
        $.each(keys, function(index, item){
          $("#"+item).val(data[item]);
        });
      });
    </script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
  </body>
</html>

Output:

The values are from my previous form submit

Reference:

jQuery.each( array, callback )


问:
Deploying asp.net MVC application
I've an ASP.NET MVC-2 Website, which is running perfect at my development machine(IIS-7, Win7).

When I copied my full website to remote server(Windows Hosting with  .net 4.0), it displays Error-404.

Can you pls assist me to deploy it in remote host machine.

答:
Your question is a bit broad, but for a start might I suggest not manually copying the files over to the new environment (acceptance, production, QA...etc.) as a "deployment mechanism".

Ideally you want to setup a continuous build system which allows you to automatically build your project(s), apply the correct configuration, package and deploy it.

Troy Hunt wrote an excellent 5-part series in which he explains how to create such a setup using TeamCity, Subversion, MSBuild, Web.Config Transformations and Web Deploy.

You can check out the series 'You're deploying it wrong! TeamCity, Subversion & Web Deploy' here:

Part 1: Config transforms

Part 2: MSBuild and deployable packages

Part 3: Publishing with Web Deploy

Part 4: Continuous builds with TeamCity

Part 5: Web Deploy with TeamCity

Of course the same setup is achievable using other software packages (e.g.: Team Foundation Server instead of TeamCity...etc.).

After you've deployed your site using Web Deploy (to a primary server), you can also use the Web Farm Framework to synchronize all of the servers in the farm. You want to avoid manual actions during deployment. Sure you can get all the steps (copying files, adjusting configuration files, synchronizing servers...etc.) correct, but in the long run mistakes are unavoidable.

Title: Deploying asp.net MVC application


问:
How to initialize CameraController with SharedPreferences?
First I have initialized my camera controller (camera: ^0.9.4+11) like this and it works:

```<code>class TakePictureScreen extends StatefulWidget {
  final CameraDescription camera;

  const TakePictureScreen({required Key key, required this.camera})
    : super(key: key);

  @override
  TakePictureScreenState createState() => TakePictureScreenState();
}

class TakePictureScreenState extends State<TakePictureScreen> {
  late CameraController _controller;
  late Future<void> _initializeControllerFuture;

  @override
  void initState() {
    super.initState();
    _controller = CameraController(
      widget.camera,
      ResolutionPreset.max, // TODO: this should come from SharedPreferences
    );
    _initializeControllerFuture = _controller.initialize();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: FutureBuilder<void>(
        future: _initializeControllerFuture,
        builder: (context, snapshot) {
          return (snapshot.connectionState == ConnectionState.done)
            ? CameraPreview(_controller)
            : Text("");
        }
      ),
    );
  }
}
</code>```

But now I want to load the ResolutionPreset dynamically from SharedPreferences (shared_preferences: ^2.0.13).

What's a good way to do this?

I failed when trying it like this (adding some variables and changing initState method):

```<code>final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
late Future<int> _resolutionIndex;
List<ResolutionPreset> resolutions = ResolutionPreset.values.toList(growable: false);
static const String sharedPrefResolution = "resolution";

@override
void initState() {
  super.initState();
  _resolutionIndex = _prefs.then((SharedPreferences prefs) {
    int resolutionIndex = prefs.getInt(sharedPrefResolution) ?? (resolutions.length - 1);
    _controller = CameraController(
      widget.camera,
      resolutions[resolutionIndex],
    );
    _initializeControllerFuture = _controller.initialize();
    return resolutionIndex;
  });
}
</code>```

Getting the error: LateInitializationError: Field '_initializeControllerFuture@19039262' has not been initialized.

答:
initState can't be an async method, and getting a value from SharedPreferences is an async function. You can't use await (or then) in initState, I mean you can use but the code execution will not wait for this to complete. So what happens here is that your build method will run earlier than the future getting the value from SharedPreferences completes. And as I presume your _initializeControllerFuture is marked as late, so when your build tries to use it, it is still null, and that will get you this error.

The common way to solve this issue is to use a FutureBuilder. Get the values from SharedPreferences with FutureBuilder, display a progress indicator while it is being loaded (it will be quick so if you think you can skip this part), and then when you get the value from it, build your widget using the value coming from SharedPreferences, and initialize CameraController only after this.

Body:
First I have initialized my camera controller (camera: ^0.9.4+11) like this and it works:

class TakePictureScreen extends StatefulWidget {
  final CameraDescription camera;

  const TakePictureScreen({required Key key, required this.camera})
    : super(key: key);

  @override
  TakePictureScreenState createState() => TakePictureScreenState();
}

class TakePictureScreenState extends State<TakePictureScreen> {
  late CameraController _controller;
  late Future<void> _initializeControllerFuture;

  @override
  void initState() {
    super.initState();
    _controller = CameraController(
      widget.camera,
      ResolutionPreset.max, // TODO: this should come from SharedPreferences
    );
    _initializeControllerFuture = _controller.initialize();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: FutureBuilder<void>(
        future: _initializeControllerFuture,
        builder: (context, snapshot) {
          return (snapshot.connectionState == ConnectionState.done)
            ? CameraPreview(_controller)
            : Text("");
        }
      ),
    );
  }
}

But now I want to load the ResolutionPreset dynamically from SharedPreferences (shared_preferences: ^2.0.13).

What's a good way to do this?

I failed when trying it like this (adding some variables and changing initState method):

final Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
late Future<int> _resolutionIndex;
List<ResolutionPreset> resolutions = ResolutionPreset.values.toList(growable: false);
static const String sharedPrefResolution = "resolution";

@override
void initState() {
  super.initState();
  _resolutionIndex = _prefs.then((SharedPreferences prefs) {
    int resolutionIndex = prefs.getInt(sharedPrefResolution) ?? (resolutions.length - 1);
    _controller = CameraController(
      widget.camera,
      resolutions[resolutionIndex],
    );
    _initializeControllerFuture = _controller.initialize();
    return resolutionIndex;
  });
}

Getting the error: LateInitializationError: Field '_initializeControllerFuture@19039262' has not been initialized.


问:
How to scoop up non-consecutive pieces of the input and concatenate the pieces together?
Here is an XML start tag and end tag with Hello, world inside the start-tag/end-tag pair:

```<code><foo>Hello, world</foo>
</code>```

In XML there is something called a CDATA section. It has this unusual syntax:

```<code><![CDATA[...]]>
</code>```

A CDATA section is a wrapper around data.

If a start-tag/end-tag pair contains a CDATA section, then the data inside the start-tag/end-tag pair is the concatenation of the data outside the CDATA section with the data inside the CDATA section. For example, the content of foo:

```<code><foo>First expression <![CDATA[A < B]]>, second expression <![CDATA[C < D + 1]]>.</foo>
</code>```

is this:

```<code>First expression A < B, second expression C < D + 1.
</code>```

Question: How to scoop up each piece within foo and concatenate the pieces together? That is, how to scoop up these pieces ("First expression ", "A < B", ", second expression ", "C < D + 1", ".") and concatenate them together?

Below is a lexer I created. It works fine if foo doesn't have any CDATA sections but when foo has a CDATA section the lexer hangs.

Notice that my lexer uses yyless() and yymore(). I am imitating the example at the bottom of page 137 in the book Flex & Bison. The lexer scoops up the characters before the CDATA section plus the CDATA start syntax, then it pushes the CDATA start syntax back into the input and calls yymore(). Another rule discards the CDATA start syntax. I think this is not the right approach. What is the right way to accomplish this? Is there a way to solve this problem without using yyless() and yymore()?

```<code>%option noyywrap
%x ELEMENT_CONTENT
%{
  enum yytokentype {
    TOK_START_TAG = 258,
    TOK_END_TAG = 259,
    TOK_ELEMENT_CONTENT = 260
  };
%}
%%
<INITIAL>{
   "<foo>"    { BEGIN(ELEMENT_CONTENT); return(TOK_START_TAG); }
   "</foo>"   { return(TOK_END_TAG); }
}

<ELEMENT_CONTENT>{
   [^<]+"<![CDATA["     { yyless(9); yymore(); }
   "<![CDATA["          { /* ignore CDATA start syntax */ }
   [^\]]+"]]>"          { yyless(3); yymore(); }
   "]]>"                { /* ignore CDATA end syntax */ }
   [^<]*                { BEGIN(INITIAL); return TOK_ELEMENT_CONTENT; }
}
%%
int main(int argc, char *argv[])
{
    printf("In the lexer\n");
    yyin = fopen(argv[1], "r");
    int tok;
    while (tok = yylex()) {
       switch (tok){
          case 258:
             printf("TOK_START_TAG: %s\n", yytext);
             break;
          case 259:
             printf("TOK_END_TAG: %s\n", yytext);
             break;
          case 260:
             printf("TOK_ELEMENT_CONTENT: %s\n", yytext);
             break;
          default:
             printf("unexpected: %s\n", yytext);
       }
    }

    fclose(yyin);

    return 0;
}
</code>```

答:
The text inside an HTML tag can be interrupted by a number of things, not just CDATA sections. It could contain entity references, or numerical entity references. It could contain comments, which will mostly be ignored, or it could contain content-less tags which are not of interest to the parser. And so on. A lexer which eliminated those things might be useful in a particular context, or it might create a problem which the lexer's client will end up tearing their hair out trying to solve. On the whole, these are issues the lexer should probably not attempt to solve; it's better design to just document the fact that text might be lexed as several consecutive TEXT tokens (or several consecutive "text-like" tokens). That's certainly the way I would  do it.

I understand that you're trying to take advantage of Flex's internal buffer to do the token concatenation in place, avoiding extra memory allocation and copying. That's a tempting optimisation, but it drops you into a twisty maze of details and corner cases. Furthermore, Flex is designed around the idea that tokens are "not too long"; extremely long tokens can trigger inefficiencies in the Flex algorithm.

There are well-known techniques for optimising string assembly, and you'd probably be better off using one of them (or a library which implements efficient string concatenation) and leave Flex's internals to Flex. :-)

Body:
Here is an XML start tag and end tag with Hello, world inside the start-tag/end-tag pair:

<foo>Hello, world</foo>

In XML there is something called a CDATA section. It has this unusual syntax:

<![CDATA[...]]>

A CDATA section is a wrapper around data.

If a start-tag/end-tag pair contains a CDATA section, then the data inside the start-tag/end-tag pair is the concatenation of the data outside the CDATA section with the data inside the CDATA section. For example, the content of foo:

<foo>First expression <![CDATA[A , second expression <![CDATA[C < D + 1]]>.</foo>

is this:

First expression A < B, second expression C < D + 1.

Question: How to scoop up each piece within foo and concatenate the pieces together? That is, how to scoop up these pieces ("First expression ", "A < B", ", second expression ", "C < D + 1", ".") and concatenate them together?

Below is a lexer I created. It works fine if foo doesn't have any CDATA sections but when foo has a CDATA section the lexer hangs.

Notice that my lexer uses yyless() and yymore(). I am imitating the example at the bottom of page 137 in the book Flex & Bison. The lexer scoops up the characters before the CDATA section plus the CDATA start syntax, then it pushes the CDATA start syntax back into the input and calls yymore(). Another rule discards the CDATA start syntax. I think this is not the right approach. What is the right way to accomplish this? Is there a way to solve this problem without using yyless() and yymore()?

%option noyywrap
%x ELEMENT_CONTENT
%{
  enum yytokentype {
    TOK_START_TAG = 258,
    TOK_END_TAG = 259,
    TOK_ELEMENT_CONTENT = 260
  };
%}
%%
<INITIAL>{
   "<foo>"    { BEGIN(ELEMENT_CONTENT); return(TOK_START_TAG); }
   "</foo>"   { return(TOK_END_TAG); }
}

<ELEMENT_CONTENT>{
   [^<]+"<![CDATA["     { yyless(9); yymore(); }
   "<![CDATA["          { /* ignore CDATA start syntax */ }
   [^\]]+"]]>"          { yyless(3); yymore(); }
   "]]>"                { /* ignore CDATA end syntax */ }
   [^<]*                { BEGIN(INITIAL); return TOK_ELEMENT_CONTENT; }
}
%%
int main(int argc, char *argv[])
{
    printf("In the lexer\n");
    yyin = fopen(argv[1], "r");
    int tok;
    while (tok = yylex()) {
       switch (tok){
          case 258:
             printf("TOK_START_TAG: %s\n", yytext);
             break;
          case 259:
             printf("TOK_END_TAG: %s\n", yytext);
             break;
          case 260:
             printf("TOK_ELEMENT_CONTENT: %s\n", yytext);
             break;
          default:
             printf("unexpected: %s\n", yytext);
       }
    }

    fclose(yyin);

    return 0;
}


问:
How to Find exact Match then Paste Similar Value to adjacent Cell
I am trying to create a function which match the exact value in the raw string if macthes then paste the value but here Lookup function is giving an wrong answer.

I know how to extract it using Left function but how to macth exact string like in VBA we use Criteria: "" & CellValue & "".

```<code>=LOOKUP(99^99,SEARCH($K$3:$K$97,A3),$K$3:$K$97)
</code>```

This function is not matching exact string as you can see in attached picture.

Sheet Link

```<code>=IF(RegExMatch(B2,'Match Criteria'!B:B),"YES","NO")
</code>```

答:
I have developed this solution but it is extremly slow.</p>
```<code>=OFFSET('Match Criteria'!$B$1,(SUMPRODUCT(--NOT(LEN(B3)=LEN(SUBSTITUTE(B3," "&'Match Criteria'!$B$2:$B&" ","")))*(ROW('Match Criteria'!$B$2:$B)-1))),)
</code>```

Body:
I am trying to create a function which match the exact value in the raw string if macthes then paste the value but here Lookup function is giving an wrong answer.

I know how to extract it using Left function but how to macth exact string like in VBA we use Criteria: "" & CellValue & "".

=LOOKUP(99^99,SEARCH($K$3:$K$97,A3),$K$3:$K$97)

This function is not matching exact string as you can see in attached picture.

Sheet Link

=IF(RegExMatch(B2,'Match Criteria'!B:B),"YES","NO")

Body:
I have developed this solution but it is extremly slow.

=OFFSET('Match Criteria'!$B$1,(SUMPRODUCT(--NOT(LEN(B3)=LEN(SUBSTITUTE(B3," "&'Match Criteria'!$B$2:$B&" ","")))*(ROW('Match Criteria'!$B$2:$B)-1))),)