问:
How can I center a specific item within a table?
I create one Sign Up form where it will be connected afterwards with SQL Database using PHP. The problem is that I can not center the submit button within the table. As far as I know HTML5 does not support table functionality. All HTML code it's in PHP file.

<!DOCTYPE html>

        <link rel="stylesheet" type="text/css" href="main.css">
        <meta charset="UTF-8">
        <title></title>

            <form action="#" method="post">

                Full Name:
                <input type="text" placeholder="Full Name" name="name" >

                E-mail:
                <input type="email" placeholder="E-mail" name="email" >

                Username:
                <input type="text" placeholder="Username" name="username" >

                Password:
                <input type="password" placeholder="Password" name="password" >

                <input type="submit" name="Registration" value="Submit" >

        </form>

```

<pre class="lang-css prettyprint-override"><code>body {
    background: #40E0D0;
    background: -webkit-linear-gradient(to right, #FF0080, #FF8C00, #40E0D0);
    background: linear-gradient(to right, #FF0080, #FF8C00, #40E0D0);
}
form {
    text-align: center;
    display: flex;
    justify-content: center;
}
table {
    display: flex;
    background-color: lightcyan;
    margin: 15px;
    padding: 15px;
}
tr {
    text-align:center;
}
td {
    margin-right: 10px;
}
input {
    width: 300px;
    height: 25px;
}
</code>```

答:
1). You should add a colspan to the last td.
2). Make sure the closing tags are formatted correctly -> you should use 	, when you close a "td" tag. See the updated HTML below:

```<code>    <!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="main.css">
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <section>
            <form action="#" method="post">
            <table>
            <tr>
                <td><label>Full Name:</label></td>
                <td><input type="text" placeholder="Full Name" name="name" ></td>
            </tr>
            <tr>
                <td><label>E-mail:</label></td>
                <td><input type="email" placeholder="E-mail" name="email" ></td>
            </tr>
            <tr>
                <td><label>Username:</label></td>
                <td><input type="text" placeholder="Username" name="username" ></td>
            </tr>
            <tr>
                <td><label>Password:</label></td>
                <td><input type="password" placeholder="Password" name="password" ></td>
            </tr>
            <tr>
                <td colspan="2"><input type="submit" name="Registration" value="Submit" ></td>
            </tr>
            </table>
        </form>
        </section>
    </body>
</html>
</code>```

Body:
I create one Sign Up form where it will be connected afterwards with SQL Database using PHP. The problem is that I can not center the submit button within the table. As far as I know HTML5 does not support table functionality. All HTML code it's in PHP file.

<!DOCTYPE html>

        <link rel="stylesheet" type="text/css" href="main.css">
        <meta charset="UTF-8">
        <title></title>

            <form action="#" method="post">

                Full Name:
                <input type="text" placeholder="Full Name" name="name" >

                E-mail:
                <input type="email" placeholder="E-mail" name="email" >

                Username:
                <input type="text" placeholder="Username" name="username" >

                Password:
                <input type="password" placeholder="Password" name="password" >

                <input type="submit" name="Registration" value="Submit" >

        </form>

body {
    background: #40E0D0;
    background: -webkit-linear-gradient(to right, #FF0080, #FF8C00, #40E0D0);
    background: linear-gradient(to right, #FF0080, #FF8C00, #40E0D0);
}
form {
    text-align: center;
    display: flex;
    justify-content: center;
}
table {
    display: flex;
    background-color: lightcyan;
    margin: 15px;
    padding: 15px;
}
tr {
    text-align:center;
}
td {
    margin-right: 10px;
}
input {
    width: 300px;
    height: 25px;
}

Body:
1). You should add a colspan to the last td.
2). Make sure the closing tags are formatted correctly -> you should use </td>, when you close a "td" tag. See the updated HTML below:

    <!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="main.css">
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <section>
            <form action="#" method="post">
            <table>
            <tr>
                <td><label>Full Name:</label></td>
                <td><input type="text" placeholder="Full Name" name="name" ></td>
            </tr>
            <tr>
                <td><label>E-mail:</label></td>
                <td><input type="email" placeholder="E-mail" name="email" ></td>
            </tr>
            <tr>
                <td><label>Username:</label></td>
                <td><input type="text" placeholder="Username" name="username" ></td>
            </tr>
            <tr>
                <td><label>Password:</label></td>
                <td><input type="password" placeholder="Password" name="password" ></td>
            </tr>
            <tr>
                <td colspan="2"><input type="submit" name="Registration" value="Submit" ></td>
            </tr>
            </table>
        </form>
        </section>
    </body>
</html>


来源: stackexchange

问:
Python, I want to convert a specific column type after importing a csv file
```<code>import numpy as np

data_arr = np.loadtxt("asset.csv", delimiter = ",", dtype = 'str')
data_arr
</code>```

Result:

```<code>array([['G1', '1', '100', '5', '0'],

['G1', '1', '21', '538', '0'],

['G1', '1', '22', '6000', '0'],

...,

['G2', '8', '61', '241908', '8800'],

['G2', '8', '70', '57341', '16800'],

['G2', '9', '51', '1340', '0']], dtype='<U7')
</code>```

But I want to convert 2,3,4,5 columns(The '1', '100', '5', and '0' fields in the first row) to int type

because I want to try

```<code>family_number = np.array([1,2,3,4,100])

capital = data_arr[data_arr[:,0]=="G1"]

for i, number in enumerate(family_number):

    family_numbers = capital[capital[:,1]>i] & capital[capital[:,1]<=number]

    print("\t" + len(family_numbers))
</code>```

How can I convert type of columns? Please help!

答:
Try something like:</p>

```<code>df[col_bame]=df[can l_name].astype(int)
</code>```

ContentLicense: CC BY-SA 4.0

Body:
import numpy as np

data_arr = np.loadtxt("asset.csv", delimiter = ",", dtype = 'str')
data_arr

Result:

array([['G1', '1', '100', '5', '0'],

['G1', '1', '21', '538', '0'],

['G1', '1', '22', '6000', '0'],

...,

['G2', '8', '61', '241908', '8800'],

['G2', '8', '70', '57341', '16800'],

['G2', '9', '51', '1340', '0']], dtype='<U7')

But I want to convert 2,3,4,5 columns(The '1', '100', '5', and '0' fields in the first row) to int type

because I want to try

family_number = np.array([1,2,3,4,100])

capital = data_arr[data_arr[:,0]=="G1"]

for i, number in enumerate(family_number):

    family_numbers = capital[capital[:,1]>i] & capital[capital[:,1]<=number]

    print("\t" + len(family_numbers))

How can I convert type of columns? Please help!

Body:
Try something like:

df[col_bame]=df[can l_name].astype(int)


问:
Can somebody please point out what is wrong with my Dockerfile? Also, please advise how can I convert this file to Alpine Linux?
```<code>> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project myproject: Failed to clean project: Failed to delete /home/automation/myproject/target/generated-test-sources/test-annotations -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project myproject: Failed to clean project: Failed to delete /home/automation/myproject/target/generated-test-sources/test-annotations
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to clean project: Failed to delete /home/automation/thanos/target/generated-test-sources/test-annotations
    at org.apache.maven.plugin.clean.CleanMojo.execute (CleanMojo.java:215)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.io.IOException: Failed to delete /home/automation/myproject/target/generated-test-sources/test-annotations
    at org.apache.maven.plugin.clean.Cleaner.delete (Cleaner.java:249)
    at org.apache.maven.plugin.clean.Cleaner.delete (Cleaner.java:191)
    at org.apache.maven.plugin.clean.Cleaner.delete (Cleaner.java:158)
    at org.apache.maven.plugin.clean.Cleaner.delete (Cleaner.java:158)
    at org.apache.maven.plugin.clean.Cleaner.delete (Cleaner.java:117)
    at org.apache.maven.plugin.clean.CleanMojo.execute (CleanMojo.java:193)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
The command '/bin/sh -c cd /home/automation/myproject/ && mvn clean test-compile -e' returned a non-zero code: 1
</code>```

I need to execute my Selenium tests in Docker containers. I know Selenium provides hub and nodes containers but I have to write my own Dockerfile that will build a container which will execute tests with no grid configuration. Basically, I cannot use grid for some reason. I have written a Dockerfile. It fails at build stage and says unable to clean project.

I have tried opening firefox and chrome without adding any user i.e. tried to execute via root user but it didn't work. Then I added a user and still it does not work. Looks like permission is granted. Please point me where permission is needed and which one that is? Below is my Dockerfile.

```<code>FROM ubuntu:latest
LABEL name="Project short intro" \
            author="TAFSEER HAIDER" \
            version="1.0" \
            description="my project description"

# Install Java JDK8, Maven, and Wget
RUN apt-get update \
    && apt-get install firefox  -y \
    && apt-get -y install openjdk-8-jdk \
    && apt-get install -y maven \
    && apt-get install -y wget \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/ /tmp/* /var/tmp/*

# Install Chrome
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install

# Add a user for running applications.
RUN apt-get update && apt-get install sudo -y \
    && adduser --disabled-password --gecos '' automation \
    && adduser automation sudo \
    && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/ /tmp/* /var/tmp/*

USER automation

# Copy myproject project to the specified directory in containerized Ubuntu Linux
COPY . /home/automation/myproject/

# Set working directory
WORKDIR /home/automation/myproject/

# Clean & compile myproject
RUN cd /home/automation/myproject/ && mvn clean test-compile -e

# Execute tests on microservices and fronted GUI by specifying the required test suite file
CMD ["mvn", "failsafe:integration-test", "-DtestSuite=frontend.xml"]
</code>```

It should execute my tests in headless mode.

答:
It might be ur automation user have no permission to delete some file, i saw u use automation user context to copy file

```<code>COPY . /home/automation/myproject/
</code>```

but i saw another error at folder /home/automation/thanos....

```<code>Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to clean project: Failed to delete /home/automation/thanos/target/generated-test-sources/test-annotations
</code>```

You can try to change ownership or file permission for ur user

```<code>chown -R $YOUR_USER /home/automation/
</code>```

Body:
> [ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project myproject: Failed to clean project: Failed to delete /home/automation/myproject/target/generated-test-sources/test-annotations -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.5:clean (default-clean) on project myproject: Failed to clean project: Failed to delete /home/automation/myproject/target/generated-test-sources/test-annotations
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to clean project: Failed to delete /home/automation/thanos/target/generated-test-sources/test-annotations
    at org.apache.maven.plugin.clean.CleanMojo.execute (CleanMojo.java:215)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
Caused by: java.io.IOException: Failed to delete /home/automation/myproject/target/generated-test-sources/test-annotations
    at org.apache.maven.plugin.clean.Cleaner.delete (Cleaner.java:249)
    at org.apache.maven.plugin.clean.Cleaner.delete (Cleaner.java:191)
    at org.apache.maven.plugin.clean.Cleaner.delete (Cleaner.java:158)
    at org.apache.maven.plugin.clean.Cleaner.delete (Cleaner.java:158)
    at org.apache.maven.plugin.clean.Cleaner.delete (Cleaner.java:117)
    at org.apache.maven.plugin.clean.CleanMojo.execute (CleanMojo.java:193)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
    at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
    at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
    at org.apache.maven.cli.MavenCli.execute (MavenCli.java:956)
    at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main (MavenCli.java:192)
    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke (Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:356)
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
The command '/bin/sh -c cd /home/automation/myproject/ && mvn clean test-compile -e' returned a non-zero code: 1

I need to execute my Selenium tests in Docker containers. I know Selenium provides hub and nodes containers but I have to write my own Dockerfile that will build a container which will execute tests with no grid configuration. Basically, I cannot use grid for some reason. I have written a Dockerfile. It fails at build stage and says unable to clean project.

I have tried opening firefox and chrome without adding any user i.e. tried to execute via root user but it didn't work. Then I added a user and still it does not work. Looks like permission is granted. Please point me where permission is needed and which one that is? Below is my Dockerfile.

FROM ubuntu:latest
LABEL name="Project short intro" \
            author="TAFSEER HAIDER" \
            version="1.0" \
            description="my project description"

# Install Java JDK8, Maven, and Wget
RUN apt-get update \
    && apt-get install firefox  -y \
    && apt-get -y install openjdk-8-jdk \
    && apt-get install -y maven \
    && apt-get install -y wget \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/ /tmp/* /var/tmp/*

# Install Chrome
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
RUN dpkg -i google-chrome-stable_current_amd64.deb; apt-get -fy install

# Add a user for running applications.
RUN apt-get update && apt-get install sudo -y \
    && adduser --disabled-password --gecos '' automation \
    && adduser automation sudo \
    && echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/ /tmp/* /var/tmp/*

USER automation

# Copy myproject project to the specified directory in containerized Ubuntu Linux
COPY . /home/automation/myproject/

# Set working directory
WORKDIR /home/automation/myproject/

# Clean & compile myproject
RUN cd /home/automation/myproject/ && mvn clean test-compile -e

# Execute tests on microservices and fronted GUI by specifying the required test suite file
CMD ["mvn", "failsafe:integration-test", "-DtestSuite=frontend.xml"]

It should execute my tests in headless mode.

Body:
It might be ur automation user have no permission to delete some file, i saw u use automation user context to copy file

COPY . /home/automation/myproject/

but i saw another error at folder /home/automation/thanos....

Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to clean project: Failed to delete /home/automation/thanos/target/generated-test-sources/test-annotations

You can try to change ownership or file permission for ur user

chown -R $YOUR_USER /home/automation/


问:
Add DIV/0 exception handling. I did something wrong but can't pin point where
This is a simple weight conversion program. The purpose is to divide EnglishWeight1 5 pounds 12 ounces by number.
I use the try-throw-catch method to handle division by 0.

Please help.

```<code>//Class Declaration
class EnglishWeight
{
    private:
        int pounds, ounces;
    public:
        EnglishWeight(void); //0-argument constructor
        EnglishWeight(int lbs, int oz);
        EnglishWeight ScalarDivision(const int &s, int *check) const;
};
</code>```

```<code>//Member Function Definition
EnglishWeight::EnglishWeight(void)
{
    pounds = ounces = 0;
}
EnglishWeight::EnglishWeight(int lbs, int oz)
{
    pounds = lbs;
    ounces = oz;
}

EnglishWeight EnglishWeight::ScalarDivision(const int &s, int *check) const //Scalar Division function
{
    EnglishWeight sdivide; //Declare variable
    try
    {
        if (s == 0) //DIV/0 check
            throw 0;
        else
        {
            sdivide.ounces = (pounds * 16) + ounces;
            sdivide.pounds = sdivide.ounces / (16 * s);
            sdivide.ounces = sdivide.ounces % 16;
            return sdivide;
        }
    }
    catch (int x)
    {
        *check = x;
    }
}

void EnglishWeight::Show() const
{
    std::cout << pounds << " pounds, " << ounces << " ounces";
}
</code>```

```<code>//Main Driver
int main(void)
{
    EnglishWeight EnglishWeight1(5, 12);
    EnglishWeight sdiv1;
    int number = 0;
    int flag = 1;

        sdiv1 = EnglishWeight1.ScalarDivision(number, &flag);
    if (flag == 0)
        std::cout << "EnglishWeight1 / number = DIV/0" << std::endl;
    else
    {
        std::cout << "EnglishWeight1 / number = ";
        sdiv1.Show();
        std::cout << std::endl;
    }
}
</code>```

Error: 0xC0000005: Access violation reading location 0x0000000000000000 which probably means the compiler is reading garbage value somewhere. I just don't know how to fix it.

答:
@WhozCraig suggestion works. Thanks!

"There is no return specified in the case where the div-0 exception happens. Therefore you're basically lying to the caller of EnglishWeight1.ScalarDivision in claiming you'll return a EnglishWeight on all code paths. Frankly, I cannot fathom how your compiler did not emit some sort of warning about "not all code paths provide return value" or some similar phrasing."

"Just return sdivide as-is. Your caller isn't going to use it regardless"

Body:
This is a simple weight conversion program. The purpose is to divide EnglishWeight1 5 pounds 12 ounces by number.
I use the try-throw-catch method to handle division by 0.

Please help.

//Class Declaration
class EnglishWeight
{
    private:
        int pounds, ounces;
    public:
        EnglishWeight(void); //0-argument constructor
        EnglishWeight(int lbs, int oz);
        EnglishWeight ScalarDivision(const int &s, int *check) const;
};

//Member Function Definition
EnglishWeight::EnglishWeight(void)
{
    pounds = ounces = 0;
}
EnglishWeight::EnglishWeight(int lbs, int oz)
{
    pounds = lbs;
    ounces = oz;
}

EnglishWeight EnglishWeight::ScalarDivision(const int &s, int *check) const //Scalar Division function
{
    EnglishWeight sdivide; //Declare variable
    try
    {
        if (s == 0) //DIV/0 check
            throw 0;
        else
        {
            sdivide.ounces = (pounds * 16) + ounces;
            sdivide.pounds = sdivide.ounces / (16 * s);
            sdivide.ounces = sdivide.ounces % 16;
            return sdivide;
        }
    }
    catch (int x)
    {
        *check = x;
    }
}

void EnglishWeight::Show() const
{
    std::cout << pounds << " pounds, " << ounces << " ounces";
}

//Main Driver
int main(void)
{
    EnglishWeight EnglishWeight1(5, 12);
    EnglishWeight sdiv1;
    int number = 0;
    int flag = 1;

        sdiv1 = EnglishWeight1.ScalarDivision(number, &flag);
    if (flag == 0)
        std::cout << "EnglishWeight1 / number = DIV/0" << std::endl;
    else
    {
        std::cout << "EnglishWeight1 / number = ";
        sdiv1.Show();
        std::cout << std::endl;
    }
}

Error: 0xC0000005: Access violation reading location 0x0000000000000000 which probably means the compiler is reading garbage value somewhere. I just don't know how to fix it.


问:
Authorization error when connecting an app to a service
I'm following https://github.com/ibm/predictive-model-on-watson-ml

Created the app (step 1) and the ML service (step 2).

The instruction is: Verify this service is being created in the same space as the app in Step 1, and click Create.

That was not possible, I could only choose a resource group, default or my own.

Wenn I try to connect the app in an org/space to the service I get the error:

[403, Forbidden] You are not authorized to perform the requested action

答: @jpsstack can you/did you try changing the region? i.e. from Washington to Dallas. That should give new org and space opt</p>


问:
Can't build an official example from Google
I clone repository:
https://github.com/googlevr/gvr-android-sdk/

I try to run in Android Studio, did not change anything, but I getting errors:

```<code>Error:(39, 13) Failed to resolve: com.google.vr:sdk-base:1.60.
<a href="openFile:C:/Users/Vesbat/Documents/KODE/gvr-android-sdk/samples/sdk-controllerclient/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog

Error:(40, 13) Failed to resolve: com.google.vr:sdk-controller:1.60.1
<a href="openFile:C:/Users/Vesbat/Documents/KODE/gvr-android-sdk/samples/sdk-controllerclient/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog

Error:(39, 13) Failed to resolve: com.google.vr:sdk-panowidget:1.60.1
<a href="openFile:C:/Users/Vesbat/Documents/KODE/gvr-android-sdk/samples/sdk-simplepanowidget/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

Error:(39, 13) Failed to resolve: com.google.vr:sdk-videowidget:1.60.1
<a href="openFile:C:/Users/Vesbat/Documents/KODE/gvr-android-sdk/samples/sdk-simplevideowidget/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

Error:(40, 13) Failed to resolve: com.google.vr:sdk-base:1.60.1
<a href="openFile:C:/Users/Vesbat/Documents/KODE/gvr-android-sdk/samples/sdk-treasurehunt/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

Error:(39, 13) Failed to resolve: com.google.vr:sdk-audio:1.60.1
<a href="openFile:C:/Users/Vesbat/Documents/KODE/gvr-android-sdk/samples/sdk-treasurehunt/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

Error:(43, 13) Failed to resolve: com.google.vr:sdk-common:1.60.1
<a href="openFile:C:/Users/Vesbat/Documents/KODE/gvr-android-sdk/samples/sdk-videoplayer/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>

Error:(42, 13) Failed to resolve: com.google.vr:sdk-base:1.60.1
<a href="openFile:C:/Users/Vesbat/Documents/KODE/gvr-android-sdk/samples/sdk-videoplayer/build.gradle">Show in File</a><br><a href="open.dependency.in.project.structure">Show in Project Structure dialog</a>
</code>```

答:
you can add the vr sdk dependencies using the aar file sdk-base-1.200.0.aar downloaded from the github repository. the file is located in the libraries folder. please refer this link if you are new to androidstudio
http://docs.onemobilesdk.aol.com/android-ad-sdk/adding-aar-files.html</p>

ContentLicense: CC BY-SA 3.0

Body:
I clone repository:
https://github.com/googlevr/gvr-android-sdk/

I try to run in Android Studio, did not change anything, but I getting errors:

Error:(39, 13) Failed to resolve: com.google.vr:sdk-base:1.60.
Show in File
Show in Project Structure dialog

Error:(40, 13) Failed to resolve: com.google.vr:sdk-controller:1.60.1
Show in File
Show in Project Structure dialog

Error:(39, 13) Failed to resolve: com.google.vr:sdk-panowidget:1.60.1
Show in File
Show in Project Structure dialog

Error:(39, 13) Failed to resolve: com.google.vr:sdk-videowidget:1.60.1
Show in File
Show in Project Structure dialog

Error:(40, 13) Failed to resolve: com.google.vr:sdk-base:1.60.1
Show in File
Show in Project Structure dialog

Error:(39, 13) Failed to resolve: com.google.vr:sdk-audio:1.60.1
Show in File
Show in Project Structure dialog

Error:(43, 13) Failed to resolve: com.google.vr:sdk-common:1.60.1
Show in File
Show in Project Structure dialog

Error:(42, 13) Failed to resolve: com.google.vr:sdk-base:1.60.1
Show in File
Show in Project Structure dialog


问:
What are some good ways to delete files with blank(invisible) names?
I discovered some files with blank names in my code repository, but I don't know how to find them all and delete them.</p>

答:
Use the -regex option to find:

```<code>touch " " "  a  b"
find . -maxdepth 1 -regex "^.*/[[:blank:]][[:blank:]]*$" -ls
# find . -maxdepth 1 -regex "^.*/[[:blank:]][[:blank:]]*$" -delete
</code>```

Body:
Use the -regex option to find:

touch " " "  a  b"
find . -maxdepth 1 -regex "^.*/[[:blank:]][[:blank:]]*$" -ls
# find . -maxdepth 1 -regex "^.*/[[:blank:]][[:blank:]]*$" -delete


问:
HTML anchor within Javascript variable assigned dynamically to a dataTable cell is not rendered by the browser
I have implemented a dataTable on dynamic set of data.  There is a javascript variable that contains the following:

```<code>var path = "/<a href="http://demo.example.com/first.html">First</a>/<a href="http://demo.example.com/second.html">Second</a>/";
</code>```

This variable is supposed to have two anchors.  When I assign this variable dynamically to a cell of a dataTable as follows:

```<code>var tab = document.getElementById("sample_table");
var objCells = tab.rows.item(i).cells;
objCells[0].innerHTML = path;
</code>```

It is shown as plain text within the table cell and is not rendered as HTML by the browser:

```<code>/<a href="http://demo.example.com/first.html">First</a>/<a href="http://demo.example.com/second.html">Second</a>/
</code>```

and I want it like this:

/First/Second/

What should be done to render it correctly in the browser?

答:
var path = "First/Second/";

document.querySelector('div').innerHTML = path;```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div></div></code>```

Body:
I have implemented a dataTable on dynamic set of data.  There is a javascript variable that contains the following:

var path = "/First/Second/";

This variable is supposed to have two anchors.  When I assign this variable dynamically to a cell of a dataTable as follows:

var tab = document.getElementById("sample_table");
var objCells = tab.rows.item(i).cells;
objCells[0].innerHTML = path;

It is shown as plain text within the table cell and is not rendered as HTML by the browser:

/First/Second/

and I want it like this:

/First/Second/

What should be done to render it correctly in the browser?

Body:
var path = "<a href='http://demo.example.com/first.html'>First</a>/<a href='http://demo.example.com/second.html'>Second</a>/";

document.querySelector('div').innerHTML = path;

<div></div>


问:
Python, openpyxl column with adjustment
Hopefully someone can help explain a line of code for me in the block blow. I got this from another post but was unable to ask the question using comments because I'm a new user and do not have enough reputation points..

Anyways, Python noob here, please forgive me. How did the poster know col[0].column will get the column name? I couldn't find in the openpyxl docs where the .column properties came from.

```<code>for col in worksheet.columns:
     max_length = 0
     column = col[0].column # Get the column name
     for cell in col:
         try: # Necessary to avoid error on empty cells
             if len(str(cell.value)) > max_length:
                 max_length = len(cell.value)
         except:
             pass
     adjusted_width = (max_length + 2) * 1.2
     worksheet.column_dimensions[column].width = adjusted_width
</code>```

答:
col[0].column is returning number while worksheet.column_dimensions[column] accepts only character such as 'A', 'B', 'C' in place of column. I've modified the code and it is working fine now.</p>

```<code>import re

for col in _ws.columns:
max_lenght = 0
print(col[0])
col_name = re.findall('\w\d', str(col[0]))
col_name = col_name[0]
col_name = re.findall('\w', str(col_name))[0]
print(col_name)
for cell in col:
    try:
        if len(str(cell.value)) > max_lenght:
            max_lenght = len(cell.value)
    except:
        pass
adjusted_width = (max_lenght+2)
_ws.column_dimensions[col_name].width = adjusted_width
</code>```

Title: Python, openpyxl column with adjustment

Body:
Hopefully someone can help explain a line of code for me in the block blow. I got this from another post but was unable to ask the question using comments because I'm a new user and do not have enough reputation points..

Anyways, Python noob here, please forgive me. How did the poster know col[0].column will get the column name? I couldn't find in the openpyxl docs where the .column properties came from.

for col in worksheet.columns:
     max_length = 0
     column = col[0].column # Get the column name
     for cell in col:
         try: # Necessary to avoid error on empty cells
             if len(str(cell.value)) > max_length:
                 max_length = len(cell.value)
         except:
             pass
     adjusted_width = (max_length + 2) * 1.2
     worksheet.column_dimensions[column].width = adjusted_width

Body:
col[0].column is returning number while worksheet.column_dimensions[column] accepts only character such as 'A', 'B', 'C' in place of column. I've modified the code and it is working fine now.

import re

for col in _ws.columns:
max_lenght = 0
print(col[0])
col_name = re.findall('\w\d', str(col[0]))
col_name = col_name[0]
col_name = re.findall('\w', str(col_name))[0]
print(col_name)
for cell in col:
    try:
        if len(str(cell.value)) > max_lenght:
            max_lenght = len(cell.value)
    except:
        pass
adjusted_width = (max_lenght+2)
_ws.column_dimensions[col_name].width = adjusted_width


问:
Multiple Paths confusion when designing REST API
We have a resources named Games and Players

```<code>/games -> Get all Games available

/games/{game-id} -> Get the game details of specific Game with game-id

/players/me -> Get logged in Player details
</code>```

There will be Games played by the player which can be tagged under Games or Players

Scenario 1

/games/me -> Fetches games played by the current logged in player

This groups the request under Games tag. I'm using Swagger API so this call will be going to GamesAPI controller on the client generated code. I see its fair to be in the Games api rather than player as its related to games.

Problem : It looks too odd to consider "me" as a special id as it looks it is one form of {game-id} which I can't digest.

Scenario 2

```<code>/players/me/games -> Fetches games played by the current logged in player
</code>```

This groups it under Player tag which goes to PlayerAPI after code generation. The path has a meaning which is good but, its more relevant to have it in GamesAPI (by my choice - I could be wrong, please suggest)

Among these two scenarios which is the better way to design this problem?

答:
Relationship design is driven in API's how your schema's are designed .So, in your case

1 Player can play 1 or Many games - So 1 to Many relationship

Hence, you should be grouping game data based of players . So, 2 scenarios arise for an API to have better performance

Scenario 1

Is it easier to search in Games for the player id and then group them?

Scenario 2

Is it easier to search Players on the basis of the Game id and then group them?

Logically, speaking and considering scenario 1 makes more sense , hence

```<code>/games/{player-id} -> Fetches games played by the current logged in player
</code>```

Body:
We have a resources named Games and Players

/games -> Get all Games available

/games/{game-id} -> Get the game details of specific Game with game-id

/players/me -> Get logged in Player details

There will be Games played by the player which can be tagged under Games or Players

Scenario 1

/games/me -> Fetches games played by the current logged in player

This groups the request under Games tag. I'm using Swagger API so this call will be going to GamesAPI controller on the client generated code. I see its fair to be in the Games api rather than player as its related to games.

Problem : It looks too odd to consider "me" as a special id as it looks it is one form of {game-id} which I can't digest.

Scenario 2

/players/me/games -> Fetches games played by the current logged in player

This groups it under Player tag which goes to PlayerAPI after code generation. The path has a meaning which is good but, its more relevant to have it in GamesAPI (by my choice - I could be wrong, please suggest)

Among these two scenarios which is the better way to design this problem?

Body:
Relationship design is driven in API's how your schema's are designed .So, in your case

1 Player can play 1 or Many games - So 1 to Many relationship

Hence, you should be grouping game data based of players . So, 2 scenarios arise for an API to have better performance

Scenario 1

Is it easier to search in Games for the player id and then group them?

Scenario 2

Is it easier to search Players on the basis of the Game id and then group them?

Logically, speaking and considering scenario 1 makes more sense , hence

/games/{player-id} -> Fetches games played by the current logged in player


问:
Save value of checkbox located in popup window when user closes out of the popup window
I am trying to create a chrome extension that only records user data when the checkbox is checked (visually, it is a slider but a checkbox nonetheless). However, I am having trouble saving the value of the checkbox after a user has clicked it. Whenever the popup closes the checkbox (or slider) goes back to unchecked.

I have tried adding (from background.js) the attribute 'checked' to the checkbox in popup.html when the value is true (checked) and then removing the attribute when the value is false (unchecked).

Then, I read something that the .attr in jquery is no longer supported and the new way to do it (as of jquery 3+) is to use .prop('checked', true);

```<code>//background.js
var switchStatus;
chrome.storage.onChanged.addListener(function(changes, areaName){
    console.log('received');
    chrome.storage.local.get('sS', function(status){
        switchStatus = status.sS;
        console.log(switchStatus);

        if(switchStatus === true) {
            $('#togBtn').prop('checked', true);
            chrome.storage.local.set({'sS': true});
            console.log('when checked ' + switchStatus);
        }
        if(switchStatus === false) {
            $('#togBtn').prop('checked', false);
            chrome.storage.local.set({'sS': false});
            console.log('unchecked ' + switchStatus);
         }
    });
});
</code>```

```<code>//popup.js
$(function() {
    var switchStatus;
    $("#togBtn").on('change', function() {
         chrome.storage.local.get('sS', function(status){
             switchStatus = status.sS;
         });
        if(($('#togBtn').is(':checked')) === true) {
            switchStatus = $("#togBtn").is(':checked');
            alert(switchStatus); //to verify

            chrome.storage.local.set({'sS': true}, function(){
                alert('saved' + ' : ' + switchStatus);
            });
        }
        if(($('#togBtn').is(':checked')) === false) {
            switchStatus = $("#togBtn").is(':checked');
            alert(switchStatus); //to verify

            chrome.storage.local.set({'sS': false}, function(){
                alert('saved' + ' : ' + switchStatus);
            });
        }
    });
});
</code>```

```<code>//popup.html
<label class="switch">
            <input type="checkbox" id="togBtn">
            <div class="slider round" id="thisthing">
                <span class="on">ON</span>
                <span class="off">OFF</span>
            </div>
        </label>
</code>```

Again, I'm trying to save the value of the checkbox after the popup is closed. So when a user clicks the checkbox, and the slider switches to green and 'on', if the user were to click out of the popup window or go to a new tab, the checkbox would still show green and 'on'

答:
It looks like you can simplify your code a little bit.

```<code>// background.js
chrome.storage.onChanged.addListener(function(changes, areaName){
    chrome.storage.local.get('sS', function(status){
        var switchStatus = status.sS;

        if(switchStatus) {
            $('#togBtn').prop('checked', true);
        } else {
            $('#togBtn').prop('checked', false);
        }
    });
});
</code>```

and

```<code>// popup.js
$(function() {
    $("#togBtn").on('change', function(e) {
        if (e.target.checked){
            chrome.storage.local.set({'sS': true}, function(){
                alert('saved: True');
            });
        } else {
            chrome.storage.local.set({'sS': false}, function(){
                alert('saved: False');
            });
        }
    });

    // I think that you may need to include this to initialize the checkbox.
    // I could be wrong though.
    chrome.storage.local.get('sS', function(status){
        var switchStatus = status.sS;

        if(switchStatus) {
            $('#togBtn').prop('checked', true);
        } else {
            $('#togBtn').prop('checked', false);
        }
    });
});
</code>```

Body:
I am trying to create a chrome extension that only records user data when the checkbox is checked (visually, it is a slider but a checkbox nonetheless). However, I am having trouble saving the value of the checkbox after a user has clicked it. Whenever the popup closes the checkbox (or slider) goes back to unchecked.

I have tried adding (from background.js) the attribute 'checked' to the checkbox in popup.html when the value is true (checked) and then removing the attribute when the value is false (unchecked).

Then, I read something that the .attr in jquery is no longer supported and the new way to do it (as of jquery 3+) is to use .prop('checked', true);

//background.js
var switchStatus;
chrome.storage.onChanged.addListener(function(changes, areaName){
    console.log('received');
    chrome.storage.local.get('sS', function(status){
        switchStatus = status.sS;
        console.log(switchStatus);

        if(switchStatus === true) {
            $('#togBtn').prop('checked', true);
            chrome.storage.local.set({'sS': true});
            console.log('when checked ' + switchStatus);
        }
        if(switchStatus === false) {
            $('#togBtn').prop('checked', false);
            chrome.storage.local.set({'sS': false});
            console.log('unchecked ' + switchStatus);
         }
    });
});

//popup.js
$(function() {
    var switchStatus;
    $("#togBtn").on('change', function() {
         chrome.storage.local.get('sS', function(status){
             switchStatus = status.sS;
         });
        if(($('#togBtn').is(':checked')) === true) {
            switchStatus = $("#togBtn").is(':checked');
            alert(switchStatus); //to verify

            chrome.storage.local.set({'sS': true}, function(){
                alert('saved' + ' : ' + switchStatus);
            });
        }
        if(($('#togBtn').is(':checked')) === false) {
            switchStatus = $("#togBtn").is(':checked');
            alert(switchStatus); //to verify

            chrome.storage.local.set({'sS': false}, function(){
                alert('saved' + ' : ' + switchStatus);
            });
        }
    });
});

//popup.html

            <input type="checkbox" id="togBtn">

                ON
                OFF

Again, I'm trying to save the value of the checkbox after the popup is closed. So when a user clicks the checkbox, and the slider switches to green and 'on', if the user were to click out of the popup window or go to a new tab, the checkbox would still show green and 'on'

Body:
It looks like you can simplify your code a little bit.

// background.js
chrome.storage.onChanged.addListener(function(changes, areaName){
    chrome.storage.local.get('sS', function(status){
        var switchStatus = status.sS;

        if(switchStatus) {
            $('#togBtn').prop('checked', true);
        } else {
            $('#togBtn').prop('checked', false);
        }
    });
});

and

// popup.js
$(function() {
    $("#togBtn").on('change', function(e) {
        if (e.target.checked){
            chrome.storage.local.set({'sS': true}, function(){
                alert('saved: True');
            });
        } else {
            chrome.storage.local.set({'sS': false}, function(){
                alert('saved: False');
            });
        }
    });

    // I think that you may need to include this to initialize the checkbox.
    // I could be wrong though.
    chrome.storage.local.get('sS', function(status){
        var switchStatus = status.sS;

        if(switchStatus) {
            $('#togBtn').prop('checked', true);
        } else {
            $('#togBtn').prop('checked', false);
        }
    });
});


问:
can I split some text on python?
I want to split text on python and take some part, for example:

let the blue sky meet the blue sea

I want this for the result:

blue sky

this is my code

text = "let the blue sky meet the blue sea"
bluee = text.split("the", 1)[1]
print bluee
```

and the result from the code is
blue sky meet the blue sea

答:
```<code>text = "let the blue sky meet the blue sea"
text=text.split()
</code>```

You don't need any arguments here as split defaults to whitespace

```<code>result = ' '.join(text[2:])
print(result)
</code>```

Using .join is faster and is more pythonic than the + operator

Title: can I split some text on python?

Body:
I want to split text on python and take some part, for example:

let the blue sky meet the blue sea

I want this for the result:

blue sky

this is my code

text = "let the blue sky meet the blue sea"
bluee = text.split("the", 1)[1]
print bluee

and the result from the code is
blue sky meet the blue sea

Body:
text = "let the blue sky meet the blue sea"
text=text.split()

You don't need any arguments here as split defaults to whitespace

result = ' '.join(text[2:])
print(result)

Using .join is faster and is more pythonic than the + operator


问:
kNN to predict LPR
I am doing a License Plate Recognition system using python. I browsed through the net and I found many people have done the recognition of characters in the license plate using kNN algorithm.

Can anyone explain how we predict the characters in the License Plate using kNN ?

Is there any other algorithm or method that can do the prediction better ?

I am referring to this Git repo https://github.com/MicrocontrollersAndMore/OpenCV_3_License_Plate_Recognition_Python

答:
Well, I did this 5 years ago. I will suggest you that, maybe right now is so much better to do this using ML Classifier Models, but if you want to use OpenCV. OpenCV has a pretty cool way to make ANPR using an OCR.

When I did it, I used a RasberryPi for processing and capture images and with c++ run openCV in another computer. I recommend you check this repo and if you're interested look for the book reference there. I hope my answer helps you to find your solution.

https://github.com/MasteringOpenCV/code.

Title: kNN to predict LPR


问:
bash_profile Powerline setup
I am learning the command line and trying to customize my environment to have Powerline functionality.

I have installed the Powerline file from GitHub and am trying to add to my path variable.

My .bash_profile is set as follows:

```<code>export PATH=$PATH:$HOME/Library/Python/2.7/bin

export PATH=$PATH:$HOME/Library/Python/2.7/binpowerline-daemon -qPOWERLINE_BASH_CONTINUATION=1POWERLINE_BASH_SELECT=1. /Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh
</code>```

I receive the following error messages when launching terminal.

-bash: export: `-qPOWERLINE_BASH_CONTINUATION=1POWERLINE_BASH_SELECT=1': not a valid
  identifier

-bash: export: `/Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh':
  not a valid identifier

I would appreciate any guidance in the right direction on this issue. Thank you.

答:
The stuff you added needs to be broken up on individual lines with newlines between them. I can only guess where the newlines are supposed to go, but something like</p>

```<code>export PATH=$PATH:$HOME/Library/Python/2.7/bin
# No need to repeat this
# export PATH=$PATH:$HOME/Library/Python/2.7/bin
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh
</code>```

Title: bash_profile Powerline setup

Body:
I am learning the command line and trying to customize my environment to have Powerline functionality.

I have installed the Powerline file from GitHub and am trying to add to my path variable.

My .bash_profile is set as follows:

export PATH=$PATH:$HOME/Library/Python/2.7/bin

export PATH=$PATH:$HOME/Library/Python/2.7/binpowerline-daemon -qPOWERLINE_BASH_CONTINUATION=1POWERLINE_BASH_SELECT=1. /Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh

I receive the following error messages when launching terminal.

-bash: export: `-qPOWERLINE_BASH_CONTINUATION=1POWERLINE_BASH_SELECT=1': not a valid
  identifier

-bash: export: `/Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh':
  not a valid identifier

I would appreciate any guidance in the right direction on this issue. Thank you.

Body:
The stuff you added needs to be broken up on individual lines with newlines between them. I can only guess where the newlines are supposed to go, but something like

export PATH=$PATH:$HOME/Library/Python/2.7/bin
# No need to repeat this
# export PATH=$PATH:$HOME/Library/Python/2.7/bin
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /Users/johnmyers/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh


问:
What's the difference between distributed computing and cloud computing?
What is the difference between distributed computing and cloud computing?</p>

答:
Let’s start with defining what these two terms mean exactly. The difference will start becoming apparent from the definitions itself.

Cloud computing is a system where different things like software applications, infrastructure resources, or development tools are provided to the user via the Internet. Traditionally, if a user wanted to run a software application, it was mandatory for them to make sure that they fulfill all the extensive software and hardware requirements that are necessary for running that single application.
But, with cloud, that’s not the case anymore since the application can be accessed simply through an Internet connection. The user no longer has to worry about any software or hardware installation on their personal system to avail the application.

It’s not only software applications that can be accessed over the Internet, but many other things too like databases, servers, software development resources, data centers, etc. In fact, cloud offerings are of three types, software as a service (SaaS), infrastructure as a service (IaaS), and platform as a service (PaaS).

Next, let’s define distributed computing. This is a kind of system where a single software system has components distributed across a number of computers, but they all execute as a consolidated system. These distributed components of the software are connected with each other through a network. Therefore, the computers over which the software components are spread across will have a way for communicating with each other and ensuring that there is synchronization between the software components. Depending on whether the computers are located nearby in same location or away from each other in different locations, the network connecting the computers could be a local area network or a wide area network. Distributed computing systems can be of three kinds: distributed computing systems, distributed pervasive systems, and distributed information systems.

Now, that we understand the definitions of distributed computing and cloud computing, hopefully the distinction between these two computing models has become clearer already. While cloud computing refers to the delivery of necessary resources via the Internet, distributed computing refers to sharing of resources between the systems via a connecting network. Each of these computing models has unique set of benefits to offer.

Scalability is one of the most prominent advantages of cloud computing solutions. Depending upon increasing or decreasing resource demands, it is possible to get access to more or less software, storage, network, and other computing resources over the Internet.

Cost-efficiency and simplicity are some other advantages of this model.

Distributed computing too offers scalability, in the sense that you can add or remove computer systems in the network depending on the current requirements. Distributed software applications also ensure better performance and resilience.


问:
Is there a better way to compare dictionary values
I am currently using the following function to compare dictionary values and display all the values that don't match. Is there a faster or better way to do it?

```<code>match = True
for keys in dict1:
    if dict1[keys] != dict2[keys]:
        match = False
        print keys
        print dict1[keys],
        print  '->' ,
        print dict2[keys]
</code>```

Edit: Both the dicts contain the same keys.

答:
If the true intent of the question is the comparison between dicts (rather than printing differences), the answer is

```<code>dict1 == dict2
</code>```

This has been mentioned before, but I felt it was slightly drowning in other bits of information. It might appear superficial, but the value comparison of dicts has actually powerful semantics. It covers

number of keys (if they don't match, the dicts are not equal)

names of keys (if they don't match, they're not equal)

value of each key (they have to be '==', too)

The last point again appears trivial, but is acutally interesting as it means that all of this applies recursively to nested dicts as well. E.g.

```<code> m1 = {'f':True}
 m2 = {'f':True}
 m3 = {'a':1, 2:2, 3:m1}
 m4 = {'a':1, 2:2, 3:m2}
 m3 == m4  # True
</code>```

Similar semantics exist for the comparison of lists. All of this makes it a no-brainer to e.g. compare deep Json structures, alone with a simple "==".

Body:
I am currently using the following function to compare dictionary values and display all the values that don't match. Is there a faster or better way to do it?

match = True
for keys in dict1:
    if dict1[keys] != dict2[keys]:
        match = False
        print keys
        print dict1[keys],
        print  '->' ,
        print dict2[keys]

Edit: Both the dicts contain the same keys.

Body:
If the true intent of the question is the comparison between dicts (rather than printing differences), the answer is

dict1 == dict2

This has been mentioned before, but I felt it was slightly drowning in other bits of information. It might appear superficial, but the value comparison of dicts has actually powerful semantics. It covers

number of keys (if they don't match, the dicts are not equal)

names of keys (if they don't match, they're not equal)

value of each key (they have to be '==', too)

The last point again appears trivial, but is acutally interesting as it means that all of this applies recursively to nested dicts as well. E.g.

 m1 = {'f':True}
 m2 = {'f':True}
 m3 = {'a':1, 2:2, 3:m1}
 m4 = {'a':1, 2:2, 3:m2}
 m3 == m4  # True

Similar semantics exist for the comparison of lists. All of this makes it a no-brainer to e.g. compare deep Json structures, alone with a simple "==".


问:
create multidimensional json array from a json in php
I have a json data. Now I want to reform it. In my json data there is a property like person_on_zone I want to make a property named person_info and store them which person under this area.

Here is my data any code. Thanks in advance

My json data

```<code>$val = [
    {
     'city':'xx',
     'zone':'yy',
     'person_on_zone':'p1'
    },
    {
     'city':'xx',
     'zone':'yy',
     'person_on_zone':'p2'
    },
    {
     'city':'xx',
     'zone':'yy',
     'person_on_zone':'p3'
    },
    {
     'city':'xx',
     'zone':'ww',
     'person_on_zone':'p1'
    },
  ]
</code>```

My expectation is

```<code>[
 {
  'city':'xx',
  'zone':'yy',
  'person_info':{
                  'person_on_zone':'p1',
                  'person_on_zone':'p2',
                  'person_on_zone':'p3',
                }
 },
 {
  'city':'xx',
  'zone':'ww',
  'person_info':{
                  'person_on_zone':'p1'
                }
 },
]
</code>```

Here I tried

```<code>foreach ($val as $v) {
    $new_array['city'] = $v['city'];
    $new_array['zone'] = $v['zone'];
    foreach ($val as $v2) {
        $new_array['person_info'] = $v['person_on_zone'];
    }
}
json_encode($new_array);
</code>```

答:
Correct Code</p>

```<code>  foreach ($val as $v){
                    $new_array['city'] = $v['city'];
                    $new_array['zone'] = $v['zone'];
                    foreach ($val as $v2){
                        $new_array['person_info'] = $v2['person_on_zone'];
                    }
                }
                json_encode($new_array);
</code>```

Body:
I have a json data. Now I want to reform it. In my json data there is a property like person_on_zone I want to make a property named person_info and store them which person under this area.

Here is my data any code. Thanks in advance

My json data

$val = [
    {
     'city':'xx',
     'zone':'yy',
     'person_on_zone':'p1'
    },
    {
     'city':'xx',
     'zone':'yy',
     'person_on_zone':'p2'
    },
    {
     'city':'xx',
     'zone':'yy',
     'person_on_zone':'p3'
    },
    {
     'city':'xx',
     'zone':'ww',
     'person_on_zone':'p1'
    },
  ]

My expectation is

[
 {
  'city':'xx',
  'zone':'yy',
  'person_info':{
                  'person_on_zone':'p1',
                  'person_on_zone':'p2',
                  'person_on_zone':'p3',
                }
 },
 {
  'city':'xx',
  'zone':'ww',
  'person_info':{
                  'person_on_zone':'p1'
                }
 },
]

Here I tried

foreach ($val as $v) {
    $new_array['city'] = $v['city'];
    $new_array['zone'] = $v['zone'];
    foreach ($val as $v2) {
        $new_array['person_info'] = $v['person_on_zone'];
    }
}
json_encode($new_array);

Body:
Correct Code

  foreach ($val as $v){
                    $new_array['city'] = $v['city'];
                    $new_array['zone'] = $v['zone'];
                    foreach ($val as $v2){
                        $new_array['person_info'] = $v2['person_on_zone'];
                    }
                }
                json_encode($new_array);


问:
How do I upload a file to a REST endpoint?
Using Twitter as an example: Twitter has an endpoint for uploading file data. https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload-append

Can anyone provide an example of a real HTTP message containing, for example, image file data, showing how it is supposed to be structured? I'm fairly sure Twitter's documentation is nonsense, as their "example request" is the following:

POST https://upload.twitter.com/1.1/media/upload.json?command=APPEND&media_id=123&segment_index=2&media_data=123

Is the media_data really supposed to go in the URL? What if you have raw binary media data? Would it go in the body? How is the REST service to know how the data is encoded?

答:
to upload a file, you need to send it in a form, in node.js server you save accept the incoming file using formidable.

You can also use express-fileupload or multer


问:
Error while trying out touch actions using Appium
Below is my code:

```<code>package AppiumPackage;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.touch.TouchActions;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileBrowserType;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.service.local.AppiumDriverLocalService;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

public class AppiumClass {
    AppiumDriver driver;
    WebDriverWait wait;
    String AppURL = "https://www.ndtv.com/";

    @BeforeTest
    public void setup() throws MalformedURLException {

        // Create an object for Desired Capabilities
        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability("chromedriverExecutable", "C:/Users/Madankumar/Desktop/Chrome Driver/chromedriver.exe");

        // Name of mobile web browser to automate. ‘Safari’ for iOS and ‘Chrome’
        // or ‘Browser’ for Android
        //capabilities.setCapability("browsername", "Chrome");
        capabilities.setCapability(MobileCapabilityType.BROWSER_NAME,MobileBrowserType.CHROME);

        // The kind of mobile device or emulator to use - iPad Simulator, iPhone
        // Retina 4-inch, Android Emulator, Galaxy S4 etc
        capabilities.setCapability("deviceName", "919d8316");

        // Which mobile OS platform to use - iOS, Android, or FirefoxOS
        capabilities.setCapability("platformName", "Android");

        // Java package of the Android app you want to run- Ex:
        // com.example.android.myApp
        capabilities.setCapability("appPackage", "com.android.chrome");

        // Activity name for the Android activity you want to launch from your
        // package
        capabilities.setCapability("appActivity", "com.google.android.apps.chrome.Main");
        capabilities.setCapability("autoAcceptAlerts", false);

        // Initialize the driver object with the URL to Appium Server and
        // passing the capabilities
        driver = new AppiumDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
        wait = new WebDriverWait(driver, 5);
    }

    @Test
    public void testSearchAppium() throws Throwable {

        driver.get(AppURL);
        Thread.sleep(2000);
        driver.findElement(By.xpath("//a[@class='notnow']")).click();
        Thread.sleep(2000);
        TouchActions actions=new TouchActions(driver);
        actions.longPress(driver.findElement(By.xpath("//a[@class='scroll__nav-link active-nav']"))).perform();
        Thread.sleep(3000);
        actions.flick(20, 0);

    }

    /*
    @AfterTest
    public void tearDown() {
        driver.quit();
    }
    */

}
</code>```

On running the class from Eclipse IDE getting below error:

May 12, 2018 12:12:25 PM org.openqa.selenium.remote.ProtocolHandshake createSession
  INFO: Detected dialect: OSSenter code here
  FAILED: testSearchAppium
  java.lang.ClassCastException: io.appium.java_client.AppiumDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
      at org.openqa.selenium.interactions.touch.TouchActions.(TouchActions.java:38)
      at AppiumPackage.AppiumClass.testSearchAppium(AppiumClass.java:77)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:580)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
      at org.testng.TestRunner.privateRun(TestRunner.java:648)
      at org.testng.TestRunner.run(TestRunner.java:505)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
      at org.testng.SuiteRunner.run(SuiteRunner.java:364)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
      at org.testng.TestNG.runSuites(TestNG.java:1049)
      at org.testng.TestNG.run(TestNG.java:1017)
      at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
      at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)

答:
The working solution for this issue is in the following link.

ClassCastException with new Appium-java TouchActions

Re-writing the solution here again

Use io.appium.java_client.TouchAction class.

Step 1

```<code>TouchAction action = new TouchAction(driver);
</code>```

Here driver is an instance of AppiumDriver.

Step 2

```<code>WebElement ele = driver.findElement(By.id("locator"));

action.tap(new TapOptions().withElement(new ElementOption().withElement(ele))).perform();
</code>```

With the new implementation of TouchAction you cannot directly pass weblement.

dependency used

```<code><dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>7.0.0</version>
</dependency>
</code>```

Hope it helps.

Body:
Below is my code:

package AppiumPackage;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.touch.TouchActions;
import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.remote.MobileBrowserType;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.service.local.AppiumDriverLocalService;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;

public class AppiumClass {
    AppiumDriver driver;
    WebDriverWait wait;
    String AppURL = "https://www.ndtv.com/";

    @BeforeTest
    public void setup() throws MalformedURLException {

        // Create an object for Desired Capabilities
        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setCapability("chromedriverExecutable", "C:/Users/Madankumar/Desktop/Chrome Driver/chromedriver.exe");

        // Name of mobile web browser to automate. ‘Safari’ for iOS and ‘Chrome’
        // or ‘Browser’ for Android
        //capabilities.setCapability("browsername", "Chrome");
        capabilities.setCapability(MobileCapabilityType.BROWSER_NAME,MobileBrowserType.CHROME);

        // The kind of mobile device or emulator to use - iPad Simulator, iPhone
        // Retina 4-inch, Android Emulator, Galaxy S4 etc
        capabilities.setCapability("deviceName", "919d8316");

        // Which mobile OS platform to use - iOS, Android, or FirefoxOS
        capabilities.setCapability("platformName", "Android");

        // Java package of the Android app you want to run- Ex:
        // com.example.android.myApp
        capabilities.setCapability("appPackage", "com.android.chrome");

        // Activity name for the Android activity you want to launch from your
        // package
        capabilities.setCapability("appActivity", "com.google.android.apps.chrome.Main");
        capabilities.setCapability("autoAcceptAlerts", false);

        // Initialize the driver object with the URL to Appium Server and
        // passing the capabilities
        driver = new AppiumDriver(new URL("http://0.0.0.0:4723/wd/hub"), capabilities);
        wait = new WebDriverWait(driver, 5);
    }

    @Test
    public void testSearchAppium() throws Throwable {

        driver.get(AppURL);
        Thread.sleep(2000);
        driver.findElement(By.xpath("//a[@class='notnow']")).click();
        Thread.sleep(2000);
        TouchActions actions=new TouchActions(driver);
        actions.longPress(driver.findElement(By.xpath("//a[@class='scroll__nav-link active-nav']"))).perform();
        Thread.sleep(3000);
        actions.flick(20, 0);

    }

    /*
    @AfterTest
    public void tearDown() {
        driver.quit();
    }
    */

}

On running the class from Eclipse IDE getting below error:

May 12, 2018 12:12:25 PM org.openqa.selenium.remote.ProtocolHandshake createSession
  INFO: Detected dialect: OSSenter code here
  FAILED: testSearchAppium
  java.lang.ClassCastException: io.appium.java_client.AppiumDriver cannot be cast to org.openqa.selenium.interactions.HasTouchScreen
      at org.openqa.selenium.interactions.touch.TouchActions.(TouchActions.java:38)
      at AppiumPackage.AppiumClass.testSearchAppium(AppiumClass.java:77)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:498)
      at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
      at org.testng.internal.Invoker.invokeMethod(Invoker.java:580)
      at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
      at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
      at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
      at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
      at org.testng.TestRunner.privateRun(TestRunner.java:648)
      at org.testng.TestRunner.run(TestRunner.java:505)
      at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
      at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
      at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
      at org.testng.SuiteRunner.run(SuiteRunner.java:364)
      at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
      at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
      at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
      at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
      at org.testng.TestNG.runSuites(TestNG.java:1049)
      at org.testng.TestNG.run(TestNG.java:1017)
      at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
      at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:230)
      at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:76)

Body:
The working solution for this issue is in the following link.

ClassCastException with new Appium-java TouchActions

Re-writing the solution here again

Use io.appium.java_client.TouchAction class.

Step 1

TouchAction action = new TouchAction(driver);

Here driver is an instance of AppiumDriver.

Step 2

WebElement ele = driver.findElement(By.id("locator"));

action.tap(new TapOptions().withElement(new ElementOption().withElement(ele))).perform();

With the new implementation of TouchAction you cannot directly pass weblement.

dependency used

<dependency>
    <groupId>io.appium</groupId>
    <artifactId>java-client</artifactId>
    <version>7.0.0</version>
</dependency>

Hope it helps.


问:
How to multiply/divide one function to another ? How to use parameters?
How do I multiply a function to another function? and how do I properly use parameters?

I'm not exactly sure, I am really new to C++ with only about 14 weeks of class time.

Something I've tried would be creating a new function meant to multiply other functions and in the arguments I would put in the functions names.

For example:

```<code>float mealMath(numberOfAdults, mealChoosing){
   //Rest of function
}
</code>```

but I always get an error.Please explain how to fix this, this is a big obstacle in programming for me and I can't seem to grasp how to fix this or go about doing these things. Don't be to harsh on me for this.Thanks!

```<code>int numberOfAdults(){
    int totalAdults;
            cout << "Now how many adults will there be?: ";
            cin >> totalAdults;
                cout << "It seems there will be: " <<                      totalAdults << " Adults." << endl;
                    while(totalAdults < 1){
                        cout << "Sorry there has to be a minimum of 1 adult!" << endl;
                            cout << "How many adults: ";
                                cin >>  totalAdults;
                    }
                    return 0;
}

int numberOfKids(){
    int totalKids;
        cout << "Now how many Kids will there be?: ";
            cin >> totalKids;
                cout << "It seems there will be: " <<   totalKids << " kids." << endl;
                    while(totalKids < 0){
                        cout << "Sorry there has   to be a minimum of 1 Kid!" << endl;
                            cout << "How many   Kids: ";
                            cin >>   totalKids;
                    }
                    return 0;
                  }

float mealChoosing(){
    float cost;
        string mealChoise;
            cout << "   " << endl;
                cout << "Now, What meal will you be    getting(D/S): ";
                    cin >> mealChoise;
                        if(mealChoise == "D"){
                            cout << "It seems you have selected the Deluxe Meal plan for everyone!" << endl;
                                cost = 25.95;
                        }
                                    if(mealChoise == "S"){
                                        cout << "It seems you have selected the Standard Meal plan for everyone!" <<     endl;
                                            cost = 21.75;
                            }
                                                cout << "   " << endl;

                                                return cost;
}
</code>```

One expected result is I want to multiply the input that the user gives in function "numberOfAdults" to the input a user gives for "mealChoosing"

So I want numberOfAdults * mealChoosing but I want that done in a different function so

```<code>"float total(){
   float totalBill;
     totalBill = numberOfAdults * mealChoosing;
       cout << totalBill;"
</code>```

or something along those lines. I can't complete this project because I can't for some reason properly give the functions the proper information needed in parameters.

答:
Like mealChoosing() return totalAdults and totalKids (although its not needed here) from  numberOfAdults(), numberOfKids() respectively.

```<code>int numberOfAdults() {
  //...
  return totalAdults;
}

int numberOfKids() {
    //..
    return totalKids;
}

float mealChoosing() {
 //..

  return cost;
}
</code>```

Now on  mealMath(numberOfAdults, mealChoosing)

```<code>float mealMathOutput = mealMath(numberOfAdults(), mealChoosing());
</code>```

Body:
How do I multiply a function to another function? and how do I properly use parameters?

I'm not exactly sure, I am really new to C++ with only about 14 weeks of class time.

Something I've tried would be creating a new function meant to multiply other functions and in the arguments I would put in the functions names.

For example:

float mealMath(numberOfAdults, mealChoosing){
   //Rest of function
}

but I always get an error.Please explain how to fix this, this is a big obstacle in programming for me and I can't seem to grasp how to fix this or go about doing these things. Don't be to harsh on me for this.Thanks!

int numberOfAdults(){
    int totalAdults;
            cout << "Now how many adults will there be?: ";
            cin >> totalAdults;
                cout << "It seems there will be: " <<                      totalAdults << " Adults." << endl;
                    while(totalAdults < 1){
                        cout << "Sorry there has to be a minimum of 1 adult!" << endl;
                            cout << "How many adults: ";
                                cin >>  totalAdults;
                    }
                    return 0;
}

int numberOfKids(){
    int totalKids;
        cout << "Now how many Kids will there be?: ";
            cin >> totalKids;
                cout << "It seems there will be: " <<   totalKids << " kids." << endl;
                    while(totalKids < 0){
                        cout << "Sorry there has   to be a minimum of 1 Kid!" << endl;
                            cout << "How many   Kids: ";
                            cin >>   totalKids;
                    }
                    return 0;
                  }

float mealChoosing(){
    float cost;
        string mealChoise;
            cout << "   " << endl;
                cout << "Now, What meal will you be    getting(D/S): ";
                    cin >> mealChoise;
                        if(mealChoise == "D"){
                            cout << "It seems you have selected the Deluxe Meal plan for everyone!" << endl;
                                cost = 25.95;
                        }
                                    if(mealChoise == "S"){
                                        cout << "It seems you have selected the Standard Meal plan for everyone!" <<     endl;
                                            cost = 21.75;
                            }
                                                cout << "   " << endl;

                                                return cost;
}

One expected result is I want to multiply the input that the user gives in function "numberOfAdults" to the input a user gives for "mealChoosing"

So I want numberOfAdults * mealChoosing but I want that done in a different function so

"float total(){
   float totalBill;
     totalBill = numberOfAdults * mealChoosing;
       cout << totalBill;"

or something along those lines. I can't complete this project because I can't for some reason properly give the functions the proper information needed in parameters.

Body:
Like mealChoosing() return totalAdults and totalKids (although its not needed here) from  numberOfAdults(), numberOfKids() respectively.

int numberOfAdults() {
  //...
  return totalAdults;
}

int numberOfKids() {
    //..
    return totalKids;
}

float mealChoosing() {
 //..

  return cost;
}

Now on  mealMath(numberOfAdults, mealChoosing)

float mealMathOutput = mealMath(numberOfAdults(), mealChoosing());


问:
combining rows into one column in sql
I have a list of rows with name leader name and manager name but these records are coming after joining few tables

```<code>SELECT DISTINCT
    (leader.name), manager.Name
FROM
    ref, leader, orgList, manager, modules
WHERE
    leader.id = orgList.leaderCode
    AND orgList.dept = ref.id
    AND orgList.manager = manager.id
    AND orgList.id = modules.orgListId
    AND ref.id = 'xyzzz123'
    AND ref.month = 'august'
    AND modules.year = '2018'
</code>```

I get result like this

```<code>leader_name       manager_name
---------------------------------
 John              Jim
 John              Hiko
 John              Sevu
 John              Celi
 Kerst             Newon
 Kerst             Dollace
</code>```

But I actually want result like this

```<code>leader_name       manager_name
------------------------------------
John              Jim;Hiko;Sevu;Celi
Kerst             Newon;Dollace
</code>```

I tried pivot and other things but that works only with one table.

答:
Check this-

Note: Use Standard JOIN instead of comma separated JOIN

```<code>WITH CTE(leader_name,manager_name)
AS
(
    SELECT DISTINCT
        (leader.name) leader_name, manager.Name  manager_name
    FROM
        ref, leader, orgList, manager, modules
    WHERE
        leader.id = orgList.leaderCode
        AND orgList.dept = ref.id
        AND orgList.manager = manager.id
        AND orgList.id = modules.orgListId
        AND ref.id = 'xyzzz123'
        AND ref.month = 'august'
        AND modules.year = '2018'
)

SELECT
leader_name ,
manager_name =
    STUFF
    (
            (
                SELECT ';' + manager_name
                FROM CTE B
                WHERE A.leader_name = B.leader_name
                FOR XML PATH ('')), 1, 1, ''
    )
FROM CTE A
GROUP BY leader_name
</code>```

Title: combining rows into one column in sql

Body:
I have a list of rows with name leader name and manager name but these records are coming after joining few tables

SELECT DISTINCT
    (leader.name), manager.Name
FROM
    ref, leader, orgList, manager, modules
WHERE
    leader.id = orgList.leaderCode
    AND orgList.dept = ref.id
    AND orgList.manager = manager.id
    AND orgList.id = modules.orgListId
    AND ref.id = 'xyzzz123'
    AND ref.month = 'august'
    AND modules.year = '2018'

I get result like this

leader_name       manager_name
---------------------------------
 John              Jim
 John              Hiko
 John              Sevu
 John              Celi
 Kerst             Newon
 Kerst             Dollace

But I actually want result like this

leader_name       manager_name
------------------------------------
John              Jim;Hiko;Sevu;Celi
Kerst             Newon;Dollace

I tried pivot and other things but that works only with one table.

Body:
Check this-

Note: Use Standard JOIN instead of comma separated JOIN

WITH CTE(leader_name,manager_name)
AS
(
    SELECT DISTINCT
        (leader.name) leader_name, manager.Name  manager_name
    FROM
        ref, leader, orgList, manager, modules
    WHERE
        leader.id = orgList.leaderCode
        AND orgList.dept = ref.id
        AND orgList.manager = manager.id
        AND orgList.id = modules.orgListId
        AND ref.id = 'xyzzz123'
        AND ref.month = 'august'
        AND modules.year = '2018'
)

SELECT
leader_name ,
manager_name =
    STUFF
    (
            (
                SELECT ';' + manager_name
                FROM CTE B
                WHERE A.leader_name = B.leader_name
                FOR XML PATH ('')), 1, 1, ''
    )
FROM CTE A
GROUP BY leader_name


问:
[HTTP]how to change "www.example.com" to "localhost:3000"
hi I'm create test use cucumber in my rails apps. in my step scenario I used http basic authenticate, so far it pass the basic authenticate, but when I wanna to call method on controller and post some params, I had problem :

first I use this code in step but failed not cross to method on controller :

```<code>post some_admin_url, @params
</code>```

second I used this code, and failed also, the error is when running the URI.parse redirect to "www.example.com" I want to go "localhost:3000/admin", so I can match the data :

```<code>Net::HTTP.post_form(URI.parse(some_admin_url), {'from' => '2005-01-01','to' => '2005-03-31'}) { |i|  }
</code>```

FUTURE :

@selenium

  Scenario: Admin want to activate user

    Given one user logged in as admin

    And admin page

STEPS :

Given /^one user logged in as admin$/ do

    create_user_admin

    visit '/user_sessions/new'

    fill_in 'user_session[login]', :with=>'siadmin'

    fill_in 'user_session[password]', :with=>'12345'

    click_button 'Anmelden'

  end

Given /^admin page$/ do

    require "net/http"

    require "uri"

```<code>uri = URI.parse(user_action_admin_users_url)<br/>
http = Net::HTTP.new(uri.host, uri.port)<br/>
request = Net::HTTP::Get.new(uri.request_uri)<br/>
request.basic_auth("username", "password")<br/>
response = http.request(request)<br/>
</code>```

end

```<code>enter code here
</code>```

HELP !!!

THANKS

答:
try to change url to path

```<code>post some_admin_path, @params
</code>```

or

```<code>post "http://localhost:3000/#{some_admin_url}", @params
</code>```

Body:
hi I'm create test use cucumber in my rails apps. in my step scenario I used http basic authenticate, so far it pass the basic authenticate, but when I wanna to call method on controller and post some params, I had problem :

first I use this code in step but failed not cross to method on controller :

post some_admin_url, @params

second I used this code, and failed also, the error is when running the URI.parse redirect to "www.example.com" I want to go "localhost:3000/admin", so I can match the data :

Net::HTTP.post_form(URI.parse(some_admin_url), {'from' => '2005-01-01','to' => '2005-03-31'}) { |i|  }

FUTURE :

@selenium

  Scenario: Admin want to activate user

    Given one user logged in as admin

    And admin page

STEPS :

Given /^one user logged in as admin$/ do

    create_user_admin

    visit '/user_sessions/new'

    fill_in 'user_session[login]', :with=>'siadmin'

    fill_in 'user_session[password]', :with=>'12345'

    click_button 'Anmelden'

  end

Given /^admin page$/ do

    require "net/http"

    require "uri"

uri = URI.parse(user_action_admin_users_url)

http = Net::HTTP.new(uri.host, uri.port)

request = Net::HTTP::Get.new(uri.request_uri)

request.basic_auth("username", "password")

response = http.request(request)

end

enter code here

HELP !!!

THANKS

Body:
try to change url to path

post some_admin_path, @params

or

post "http://localhost:3000/#{some_admin_url}", @params


问:
Python, I want to convert a specific column type after importing a csv file
```<code>import numpy as np

data_arr = np.loadtxt("asset.csv", delimiter = ",", dtype = 'str')
data_arr
</code>```

Result:

```<code>array([['G1', '1', '100', '5', '0'],

['G1', '1', '21', '538', '0'],

['G1', '1', '22', '6000', '0'],

...,

['G2', '8', '61', '241908', '8800'],

['G2', '8', '70', '57341', '16800'],

['G2', '9', '51', '1340', '0']], dtype='<U7')
</code>```

But I want to convert 2,3,4,5 columns(The '1', '100', '5', and '0' fields in the first row) to int type

because I want to try

```<code>family_number = np.array([1,2,3,4,100])

capital = data_arr[data_arr[:,0]=="G1"]

for i, number in enumerate(family_number):

    family_numbers = capital[capital[:,1]>i] & capital[capital[:,1]<=number]

    print("\t" + len(family_numbers))
</code>```

How can I convert type of columns? Please help!

答:
Give the proper types of columns:

```<code>np.loadtxt('asset.csv', delimiter=",", dtype='S20,int64,int64,int64,int64')
</code>```

EDIT: list the maximum string length alongside. E.g. this should now work assuming your first column doesn't exceed 20 characters.

Body:
import numpy as np

data_arr = np.loadtxt("asset.csv", delimiter = ",", dtype = 'str')
data_arr

Result:

array([['G1', '1', '100', '5', '0'],

['G1', '1', '21', '538', '0'],

['G1', '1', '22', '6000', '0'],

...,

['G2', '8', '61', '241908', '8800'],

['G2', '8', '70', '57341', '16800'],

['G2', '9', '51', '1340', '0']], dtype='<U7')

But I want to convert 2,3,4,5 columns(The '1', '100', '5', and '0' fields in the first row) to int type

because I want to try

family_number = np.array([1,2,3,4,100])

capital = data_arr[data_arr[:,0]=="G1"]

for i, number in enumerate(family_number):

    family_numbers = capital[capital[:,1]>i] & capital[capital[:,1]<=number]

    print("\t" + len(family_numbers))

How can I convert type of columns? Please help!

Body:
Give the proper types of columns:

np.loadtxt('asset.csv', delimiter=",", dtype='S20,int64,int64,int64,int64')

EDIT: list the maximum string length alongside. E.g. this should now work assuming your first column doesn't exceed 20 characters.