问:
Can't Navigate Between Activities
I have two activities, trying to navigate from the first one to the second one by pressing a button. First one is like this:

```<code>protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_first);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_new_message);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(FirstActivity.this, SecondActivity.class);
            startActivity(myIntent);
        }
    });
}
</code>```

And the second one is like this:

```<code>protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_second);
   // other stuff
}
</code>```

When the Floating Action Button is pressed then, absolutely nothing happens. What is wrong with my code?

Update: This is the manifest:

```<code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="...">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".firstActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="secondActivity"></activity>

    </application>

</manifest>
</code>```

And this is the code for Floating Action Button:

```<code>FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    //Button button = (Button) findViewById(R.id.button);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast toast = Toast.makeText(getApplicationContext(), "Pressed!", Toast.LENGTH_LONG);
            toast.show();
                        }
    });
</code>```

In XML:

```<code> <android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:id="@+id/fab"
    android:tint="@android:color/white"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    app:fabSize="mini"
    android:layout_alignParentRight="true" />
</code>```

The whole layout:

```<code>    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:id="@+id/fab"
        android:tint="@android:color/white"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        app:fabSize="mini"
        android:layout_alignParentRight="true" />

    <ListView
        android:id="@+id/list_of_messages"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:clickable="true"
        android:divider="@android:color/transparent"
        android:dividerHeight="16dp"
        android:focusable="auto"
        android:focusableInTouchMode="true" />
</RelativeLayout>
</code>```

答:
Use Below code to resolve your problem, working for me :</p>

```<code>  FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    app:srcCompat="@android:drawable/ic_dialog_email" />
</code>```

Title: Can't Navigate Between Activities

Body:
I have two activities, trying to navigate from the first one to the second one by pressing a button. First one is like this:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_first);

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab_new_message);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent myIntent = new Intent(FirstActivity.this, SecondActivity.class);
            startActivity(myIntent);
        }
    });
}

And the second one is like this:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_second);
   // other stuff
}

When the Floating Action Button is pressed then, absolutely nothing happens. What is wrong with my code?

Update: This is the manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="...">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".firstActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="secondActivity"></activity>

    </application>

</manifest>

And this is the code for Floating Action Button:

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    //Button button = (Button) findViewById(R.id.button);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast toast = Toast.makeText(getApplicationContext(), "Pressed!", Toast.LENGTH_LONG);
            toast.show();
                        }
    });

In XML:

 <android.support.design.widget.FloatingActionButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:clickable="true"
    android:id="@+id/fab"
    android:tint="@android:color/white"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    app:fabSize="mini"
    android:layout_alignParentRight="true" />

The whole layout:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:id="@+id/fab"
        android:tint="@android:color/white"
        android:layout_alignParentBottom="true"
        android:layout_alignParentEnd="true"
        app:fabSize="mini"
        android:layout_alignParentRight="true" />

    <ListView
        android:id="@+id/list_of_messages"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:clickable="true"
        android:divider="@android:color/transparent"
        android:dividerHeight="16dp"
        android:focusable="auto"
        android:focusableInTouchMode="true" />
</RelativeLayout>

Body:
Use Below code to resolve your problem, working for me :

  FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                    .setAction("Action", null).show();
        }
    });

    <android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    app:srcCompat="@android:drawable/ic_dialog_email" />


来源: stackexchange

问:
continuously setting new local notification - ios
i am working on simulating an alarm.

in order to do so, i am trying to send a new local notification every X seconds while some condition is true and stopping while some condition is false (when the user cancels the alarm)

i have a Set button and a Stop button.

the following code is for when the Set button is pressed:

```<code>@IBAction func setNotification(_ sender: Any) {
//        timeEntered = time.text!
//        let hrMin = timeEntered.components(separatedBy: ":");
        let content = UNMutableNotificationContent()
        content.title = "How many days are there in one year"
        content.subtitle = "Do you know?"
        content.body = "Do you really know?"
        content.badge = 1
        content.sound = UNNotificationSound(named: "alarm.aiff");

        while (repeatNotifications) {
            trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false);

            let request = UNNotificationRequest(identifier: "timerDone", content: content, trigger: trigger)

            UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
        }
}
</code>```

when the Stop button is pressed:

```<code>@IBAction func stopRepeat(_ sender: Any) {
    repeatNotifications = false
    UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
    UNUserNotificationCenter.current().removeAllDeliveredNotifications()
}
</code>```

right now, when i press the Set button, it is stuck in pressed mode (its color changes) and i can't press anything else (i.e.: Stop button) besides the home button. also, no local notifications is being set.

any ideas how to accomplish this?

tl;dr: how to set new local notifications every X seconds until some button is pressed

答:
Your while condition is running more quickly then you think. It might be chocking your notification class by creating number of objects. Please use a timer to run every 5 seconds to push a notification.
You can use Instruments Tool to see the problem.

ContentLicense: CC BY-SA 3.0

Body:
i am working on simulating an alarm.

in order to do so, i am trying to send a new local notification every X seconds while some condition is true and stopping while some condition is false (when the user cancels the alarm)

i have a Set button and a Stop button.

the following code is for when the Set button is pressed:

@IBAction func setNotification(_ sender: Any) {
//        timeEntered = time.text!
//        let hrMin = timeEntered.components(separatedBy: ":");
        let content = UNMutableNotificationContent()
        content.title = "How many days are there in one year"
        content.subtitle = "Do you know?"
        content.body = "Do you really know?"
        content.badge = 1
        content.sound = UNNotificationSound(named: "alarm.aiff");

        while (repeatNotifications) {
            trigger = UNTimeIntervalNotificationTrigger(timeInterval: 5, repeats: false);

            let request = UNNotificationRequest(identifier: "timerDone", content: content, trigger: trigger)

            UNUserNotificationCenter.current().add(request, withCompletionHandler: nil)
        }
}

when the Stop button is pressed:

@IBAction func stopRepeat(_ sender: Any) {
    repeatNotifications = false
    UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
    UNUserNotificationCenter.current().removeAllDeliveredNotifications()
}

right now, when i press the Set button, it is stuck in pressed mode (its color changes) and i can't press anything else (i.e.: Stop button) besides the home button. also, no local notifications is being set.

any ideas how to accomplish this?

tl;dr: how to set new local notifications every X seconds until some button is pressed


问:
Automatic start of dask distributed scheduler and workers on Ubuntu 16.04
I am considering different methods to automatically start and control dask distributed scheduler and workers on Ubuntu 16.04.

Currently I think that the most relevant option is to use systemd daemon. This requires creation and installation of unit files.

Systemd requires that a unit file should have a command line to stop the service, set in ExecStop.

Command to reload configuration would also be useful, however, I'm not sure, how to make Python to reimport modules and if it is more simple than just restart the process.

Looks like currently it is not possible to stop scheduler/workers by running dask-scheduler or dask-worker command, isn't it? I haven't found any relevant command line switches.

Another option would be to create PID file and use standard kill command, however, Dask distributed doesn't seem to create PID files. Am I right?

答:
Finally, I've come to setting ExecStop=/bin/true. Systemd still successfully stops and restarts the services.

Current systemd manual says that ExecStop is optional.


问:
My Maven Module isn't generating a JAR
I have the following hierarchy:

```<code>my-app
  \__ pom.xml
  \__ jar-module
        \__ pom.xml
  \__ webapp-module
        \__ pom.xml
  \__ core-module
        \__ pom.xml
</code>```

Where core-module acts as a library providing common code for webapp-module and jar-module.

webapp-module works just fine, it's generating a war as expected and the code from core-module is being used.

The problem is with jar-module. I have no idea why, but jar-module isn't outputting a jar, even when I select to run (in IntelliJ IDEA) a simple main with a println() it does run, but there's no jar on the target folder.

How can I solve this and make the jar-module output a jar?

I am not very experienced with Maven, my goal is to be able to use the same Jersey code on a local Glassfish and in a jar to be deployed at AWS Lambda Serverless Java Container so I can easily test it locally before deployment.

I would appreciate any corrections on my hierarchy and on pom errors as well.

my-app pom.xml has a packaging of pom, but core-module and jar-module have a packaging of jar and webapp-module has a packaging of war.

here are the POMs:

my-app POM:

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example.myapp</groupId>
    <artifactId>myapp</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>core-module</module>
    </modules>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>
</code>```

core-module POM:
(I also tried it with <packaging>pom</packaging> and no jar skip properties, it didn't work)

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>myapp</artifactId>
        <groupId>com.example.myapp</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>webservice-core</artifactId>
    <packaging>jar</packaging>
    <modules>
        <module>../jar-module</module>
        <module>../webapp-module</module>
    </modules>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.deploy.skip>true</maven.deploy.skip>
        <jar.skipIfEmpty>true</jar.skipIfEmpty>
        <maven.install.skip>true</maven.install.skip>
        <javax-ws-rs-version.version>2.1</javax-ws-rs-version.version>
        <jersey.version>2.26</jersey.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>${javax-ws-rs-version.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>${jersey.version}</version>
        </dependency>
    </dependencies>
</project>
</code>```

webapp-module POM:

```<code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>core-module</artifactId>
        <groupId>com.example.myapp</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>webapp-module</artifactId>
    <packaging>war</packaging>
    <name>webapp Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <jersey.version>2.26</jersey.version>
    </properties>
    <dependencies>
        <dependency>
            <artifactId>core-module</artifactId>
            <groupId>com.example.myapp</groupId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet</artifactId>
            <version>${jersey.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>webapp</finalName>
    </build>
</project>
</code>```

jar-module POM:

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>core-module</artifactId>
        <groupId>com.example.myapp</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>jar-module</artifactId>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <jersey.version>2.26</jersey.version>
        <maven-shade-plugin.version>3.1.0</maven-shade-plugin.version>
    </properties>
    <dependencies>
        <dependency>
            <artifactId>core-module</artifactId>
            <groupId>com.example.myapp</groupId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws.serverless</groupId>
            <artifactId>aws-serverless-java-container-jersey</artifactId>
            <version>0.8</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>${maven-shade-plugin.version}</version>
                <configuration>                    <createDependencyReducedPom>false</createDependencyReducedPom>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
</code>```

答:
my-app

```<code><modules>
    <module>core-module</module>
    <module>jar-module</module>
    <module>web-module</module>
</modules>
</code>```

core-module

```<code>no <modules>
</code>```

This is a clean hierarchy, mirrored by the directory hierarchy.

There is a difference between modules and there container and the parent relation, and other subtleties. So maybe this helps.

Title: My Maven Module isn't generating a JAR

Body:
I have the following hierarchy:

my-app
  \__ pom.xml
  \__ jar-module
        \__ pom.xml
  \__ webapp-module
        \__ pom.xml
  \__ core-module
        \__ pom.xml

Where core-module acts as a library providing common code for webapp-module and jar-module.

webapp-module works just fine, it's generating a war as expected and the code from core-module is being used.

The problem is with jar-module. I have no idea why, but jar-module isn't outputting a jar, even when I select to run (in IntelliJ IDEA) a simple main with a println() it does run, but there's no jar on the target folder.

How can I solve this and make the jar-module output a jar?

I am not very experienced with Maven, my goal is to be able to use the same Jersey code on a local Glassfish and in a jar to be deployed at AWS Lambda Serverless Java Container so I can easily test it locally before deployment.

I would appreciate any corrections on my hierarchy and on pom errors as well.

my-app pom.xml has a packaging of pom, but core-module and jar-module have a packaging of jar and webapp-module has a packaging of war.

here are the POMs:

my-app POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example.myapp</groupId>
    <artifactId>myapp</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <modules>
        <module>core-module</module>
    </modules>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

core-module POM:
(I also tried it with <packaging>pom</packaging> and no jar skip properties, it didn't work)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>myapp</artifactId>
        <groupId>com.example.myapp</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>webservice-core</artifactId>
    <packaging>jar</packaging>
    <modules>
        <module>../jar-module</module>
        <module>../webapp-module</module>
    </modules>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.deploy.skip>true</maven.deploy.skip>
        <jar.skipIfEmpty>true</jar.skipIfEmpty>
        <maven.install.skip>true</maven.install.skip>
        <javax-ws-rs-version.version>2.1</javax-ws-rs-version.version>
        <jersey.version>2.26</jersey.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>javax.ws.rs-api</artifactId>
            <version>${javax-ws-rs-version.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-json-jackson</artifactId>
            <version>${jersey.version}</version>
        </dependency>
    </dependencies>
</project>

webapp-module POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>core-module</artifactId>
        <groupId>com.example.myapp</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>webapp-module</artifactId>
    <packaging>war</packaging>
    <name>webapp Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <jersey.version>2.26</jersey.version>
    </properties>
    <dependencies>
        <dependency>
            <artifactId>core-module</artifactId>
            <groupId>com.example.myapp</groupId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet</artifactId>
            <version>${jersey.version}</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>webapp</finalName>
    </build>
</project>

jar-module POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>core-module</artifactId>
        <groupId>com.example.myapp</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <artifactId>jar-module</artifactId>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <jersey.version>2.26</jersey.version>
        <maven-shade-plugin.version>3.1.0</maven-shade-plugin.version>
    </properties>
    <dependencies>
        <dependency>
            <artifactId>core-module</artifactId>
            <groupId>com.example.myapp</groupId>
            <version>1.0-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws.serverless</groupId>
            <artifactId>aws-serverless-java-container-jersey</artifactId>
            <version>0.8</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>${maven-shade-plugin.version}</version>
                <configuration>                    <createDependencyReducedPom>false</createDependencyReducedPom>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Body:
my-app

<modules>
    <module>core-module</module>
    <module>jar-module</module>
    <module>web-module</module>
</modules>

core-module

no <modules>

This is a clean hierarchy, mirrored by the directory hierarchy.

There is a difference between modules and there container and the parent relation, and other subtleties. So maybe this helps.


问:
NEVPNManager check is connected after restart the app?
I coding a VPN tool, using the NetworkExtension framework. I can connect IPSec through NEVPNManager.sharedManager, and can grab the notification when VPN connect status changed. But when I kill the app, and reopen it, the NEVPNManager.Connect.Status always Zero, than means can't display the correct connect state. How to solve it?

答:
William Sterling comment does make sense, & it works for me,

Before adding observer for NEVPNStatusDidChange load preferences for VPN Manager object like bellow,

```<code>override func viewDidLoad() {

        super.viewDidLoad()

        self.vpnManager.loadFromPreferences { (error) in
            if error != nil {
                print(error.debugDescription)
            }
            else{
                print("No error from loading VPN viewDidLoad")
            }
        }

        NotificationCenter.default.addObserver(self, selector: #selector(ViewController.VPNStatusDidChange(_:)), name: NSNotification.Name.NEVPNStatusDidChange, object: nil)

     }
</code>```

Body:
William Sterling comment does make sense, & it works for me,

Before adding observer for NEVPNStatusDidChange load preferences for VPN Manager object like bellow,

override func viewDidLoad() {

        super.viewDidLoad()

        self.vpnManager.loadFromPreferences { (error) in
            if error != nil {
                print(error.debugDescription)
            }
            else{
                print("No error from loading VPN viewDidLoad")
            }
        }

        NotificationCenter.default.addObserver(self, selector: #selector(ViewController.VPNStatusDidChange(_:)), name: NSNotification.Name.NEVPNStatusDidChange, object: nil)

     }


问:
Document Interaction not always triggered from Safari
Through Document Interaction, my iOS app registers itself as an editor of .sgf and .ugi files. So I can open such files from - let's say - attachements in Mail.

However, when trying the same from Safari, I get inconsistent behavior. I try to open .sgf documents that are available via HTTP into my App.

Some http links trigger the gray box with "Open in..." button... Good.

http://gtl.xmp.net/reviews/data/82/8201-DavidB-mukai-jettero.sgf

Other links open as a text file in Safari... Unwanted.

http://learngo.world-go.org/golibrary/samplelessons/studygroup30k/2004-06-11_20-30k.sgf

Is there a way to get the "open in..." button on all?

答:
After some research I got most of the answer from this page:

https://developer.mozilla.org/en/Properly_Configuring_Server_MIME_Types

And this web tool:

http://www.rexswain.com/httpview.html

SafariMobile looks at the MIME-type that is returned by the web server to determine what to do with the link (view within Safari or offer 'Open In...'.

Supported types like 'text/plain', 'text/html', 'image/gif' are all displayed within Safari. Whereas an unsupported type like 'application/zip' will trigger the 'Open in...' interface.

But Safari will even try to display a link of the type 'application/octet-stream', which is the mime-type typically used for unknown binary formats. I suppose Apple did this to overcome web servers that fail to provide the proper mime-type.

Supplying the type along within the HTML code is ignored by Safari.

```<code><a href='file.sgf' type='application/x-go-sgf'>
</code>```

The only (I think) solution is to change the configuration of the web server.

ContentLicense: CC BY-SA 2.5

Body:
After some research I got most of the answer from this page:

https://developer.mozilla.org/en/Properly_Configuring_Server_MIME_Types

And this web tool:

http://www.rexswain.com/httpview.html

SafariMobile looks at the MIME-type that is returned by the web server to determine what to do with the link (view within Safari or offer 'Open In...'.

Supported types like 'text/plain', 'text/html', 'image/gif' are all displayed within Safari. Whereas an unsupported type like 'application/zip' will trigger the 'Open in...' interface.

But Safari will even try to display a link of the type 'application/octet-stream', which is the mime-type typically used for unknown binary formats. I suppose Apple did this to overcome web servers that fail to provide the proper mime-type.

Supplying the type along within the HTML code is ignored by Safari.

<a href='file.sgf' type='application/x-go-sgf'>

The only (I think) solution is to change the configuration of the web server.


问:
BlueJ - BlueJ freezes when reading in from a text file
So for my computer science class we had to create a program that will read in from a text file named "compact.txt" and have the integers inside stored into an int[]. After that we have to print the numbers to the terminal with the 0s contained in the text file and then without the 0s contained in the text file. The code compiles and runs, but when it runs it does not print anything to the terminal and it completely freezes all of BlueJ. After the freeze I can't even copy the code from inside the main and have to force close it from task manager. FileInput is what my class uses to read in files. Here is my code:

```<code>import chn.util.*;
public class compact
{
    public static void main(String [] args)
    {
        FileInput fI = new FileInput("compact.txt");
        int[] ar = new int[100];
        String line = fI.readLine();
        fI.close();
        System.out.println(line);
        int count = 0;
        int x = 0;
        while(x < line.length())
        {
            if(!line.substring(x, x+1).equals(" "))
            {
                if(!line.substring(x + 1, x + 2).equals(" ") && !
(line.length() - 1 == x))
                {
                    ar[count] = Integer.parseInt(line.substring(x + 1, x+2));
                }
                else
                {
                    ar[count] = Integer.parseInt(line.substring(x, x+1));
                }
                count++;
            }
            x++;
        }
        System.out.print("Before: " + ar[0]);
        for(int i = 1; i < count; i++)
        {
            System.out.print(", " + ar[i]);
        }
        System.out.print("\n");
        System.out.println("After: ");
        for(int i = 0; i < count; i++)
        {
            if(ar[i] == 0)
            {
                System.out.print("");
            }
            else
            {
                if(i == count - 1)
                {
                    System.out.print(ar[i]);
                }
                System.out.print(ar[i] + ", ");
            }
        }
    }
}
</code>```

And this is what is contained inside of the "compact.txt" file:

0  6  13  0  0  75  33  0  0  0  4  29  21  0  86  0  32  66  0  0

答:
So, I get a StringIndexOutOfBoundsException because when x is equal to line.length() - 1, x + 1 or x + 2 exceeds the length of the String.

This generally means your logic is broken. While you could go back with pen a paper and nut it out, a better approach might be to use:

java.util.Scanner...

```<code>String line = "0 6 13 0 0 75 33 0 0 0 4 29 21 0 86 0 32 66 0 0";
Scanner scan = new Scanner(line);
while (scan.hasNextInt()) {
    System.out.println(scan.nextInt());
}
</code>```

This will allow you to get each individual int element from the original String

Or String#split...

```<code>String line = "0 6 13 0 0 75 33 0 0 0 4 29 21 0 86 0 32 66 0 0";
String[] parts = line.split(" ");
</code>```

which will give you an array of Strings split by the space.

From there you can decide how best to approach separating the 0s (or, simply filter the output using a if statement)

Body:
So for my computer science class we had to create a program that will read in from a text file named "compact.txt" and have the integers inside stored into an int[]. After that we have to print the numbers to the terminal with the 0s contained in the text file and then without the 0s contained in the text file. The code compiles and runs, but when it runs it does not print anything to the terminal and it completely freezes all of BlueJ. After the freeze I can't even copy the code from inside the main and have to force close it from task manager. FileInput is what my class uses to read in files. Here is my code:

import chn.util.*;
public class compact
{
    public static void main(String [] args)
    {
        FileInput fI = new FileInput("compact.txt");
        int[] ar = new int[100];
        String line = fI.readLine();
        fI.close();
        System.out.println(line);
        int count = 0;
        int x = 0;
        while(x < line.length())
        {
            if(!line.substring(x, x+1).equals(" "))
            {
                if(!line.substring(x + 1, x + 2).equals(" ") && !
(line.length() - 1 == x))
                {
                    ar[count] = Integer.parseInt(line.substring(x + 1, x+2));
                }
                else
                {
                    ar[count] = Integer.parseInt(line.substring(x, x+1));
                }
                count++;
            }
            x++;
        }
        System.out.print("Before: " + ar[0]);
        for(int i = 1; i < count; i++)
        {
            System.out.print(", " + ar[i]);
        }
        System.out.print("\n");
        System.out.println("After: ");
        for(int i = 0; i < count; i++)
        {
            if(ar[i] == 0)
            {
                System.out.print("");
            }
            else
            {
                if(i == count - 1)
                {
                    System.out.print(ar[i]);
                }
                System.out.print(ar[i] + ", ");
            }
        }
    }
}

And this is what is contained inside of the "compact.txt" file:

0  6  13  0  0  75  33  0  0  0  4  29  21  0  86  0  32  66  0  0

Body:
So, I get a StringIndexOutOfBoundsException because when x is equal to line.length() - 1, x + 1 or x + 2 exceeds the length of the String.

This generally means your logic is broken. While you could go back with pen a paper and nut it out, a better approach might be to use:

java.util.Scanner...

String line = "0 6 13 0 0 75 33 0 0 0 4 29 21 0 86 0 32 66 0 0";
Scanner scan = new Scanner(line);
while (scan.hasNextInt()) {
    System.out.println(scan.nextInt());
}

This will allow you to get each individual int element from the original String

Or String#split...

String line = "0 6 13 0 0 75 33 0 0 0 4 29 21 0 86 0 32 66 0 0";
String[] parts = line.split(" ");

which will give you an array of Strings split by the space.

From there you can decide how best to approach separating the 0s (or, simply filter the output using a if statement)


问:
Re-cloning a mercurial repository without generaldelta
I'm trying to do a hg clone on an Internet facing machine for later use on an offline build machine. Unfortunately mercurial is 3.9.1 on the Internet machine, but 1.4 on the offline machine.

I get the error abort: requirement 'generaldelta' not supported! and also abort: requirement 'dotencode' not supported!

I found this is becuase generaldelta feature was added in 1.9, and dotencode in 1.7. I've used instructions from the MissingRequirement wiki page to downgrade this repo using the following.

```<code>hg clone -U --config format.generaldelta=0 --config format.dotencode=0 --pull /tmp/foo /tmp/bar
</code>```

However the new repo at /tmp/bar still uses generaldelta, although dotencode require has gone. i.e.

```<code>cat /tmp/bar/.hg/requires

fncache
generaldelta  <=== still there
revlogv1
store

store
</code>```

How can I rewrite the repo with both generaldelta and dotencode disabled?

答:
The config option should have been format.usegeneraldelta not format.generaldelta. i.e.

```<code>hg clone -U --config format.usegeneraldelta=0 --config format.dotencode=0 --pull /tmp/foo /tmp/bar
</code>```

Note the config. options are all config.use<feature-name> apart from config.dotencode see Mercurial format options. Beware as there is not any error checking either.

Body:
I'm trying to do a hg clone on an Internet facing machine for later use on an offline build machine. Unfortunately mercurial is 3.9.1 on the Internet machine, but 1.4 on the offline machine.

I get the error abort: requirement 'generaldelta' not supported! and also abort: requirement 'dotencode' not supported!

I found this is becuase generaldelta feature was added in 1.9, and dotencode in 1.7. I've used instructions from the MissingRequirement wiki page to downgrade this repo using the following.

hg clone -U --config format.generaldelta=0 --config format.dotencode=0 --pull /tmp/foo /tmp/bar

However the new repo at /tmp/bar still uses generaldelta, although dotencode require has gone. i.e.

cat /tmp/bar/.hg/requires

fncache
generaldelta  <=== still there
revlogv1
store

store

How can I rewrite the repo with both generaldelta and dotencode disabled?

Body:
The config option should have been format.usegeneraldelta not format.generaldelta. i.e.

hg clone -U --config format.usegeneraldelta=0 --config format.dotencode=0 --pull /tmp/foo /tmp/bar

Note the config. options are all config.use<feature-name> apart from config.dotencode see Mercurial format options. Beware as there is not any error checking either.


问:
Need to Add multiple Pages in tcpdf using for or if loop for dynamic content
i am working with tcpdf, need to generate pdf,
i need help in displaying multiple pages.
the 1st page will contain client details,
after the 1st page other pages will be added according to the for loop.
and how can i add a fix header and footer to this pdf.
i need to show the below logo in the header and the phone and email of agent in the footer.
here is my code

if(isset($_GET['packid']))
{
$id=$_GET['packid'];
include_once 'db_connect.php';
include_once 'functions.php';
sec_session_start();
/*if(login_check($mysqli) == false)
{
header('location:../index.php');
exit();
}*/

require_once('tcpdf/tcpdf.php');
$obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$obj_pdf->SetProtection(array('copy','modify'), '', 'RAVIjordan!@#$)(*&15789537447344789', 0, null);
$obj_pdf->SetCreator(PDF_CREATOR);
$obj_pdf->SetTitle('Export HTML Table data to PDF using TCPDF in PHP');
$obj_pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
$obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$obj_pdf->SetDefaultMonospacedFont('helvetica');
$obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf->SetMargins(PDF_MARGIN_LEFT, '5', PDF_MARGIN_RIGHT);
$obj_pdf->setPrintHeader(false);
$obj_pdf->setPrintFooter(false);
$obj_pdf->SetAutoPageBreak(TRUE, 10);
$obj_pdf->SetFont('helvetica', '', 12);
$obj_pdf->AddPage();
$content = '';

$content .='

';

$content .='
';

$content .='

';
//this is the agent details
$agent = $_SESSION['username'];
$pic= mysqli_query($mysqli,"SELECT * FROM rmt_users where rmt_uname = '$agent'");
//page 1 agent with client details
while($pp=mysqli_fetch_array($pic))
{
    $image = '../'.$pp['rmt_ulogo'];
    $phone = $pp['rmt_uemail'];
    $email = $pp['rmt_uphone'];
}
$content .= '
TOUR DETAILS

';
$content .='
	Email : '.$email.'
Phone : '.$phone.'
';
//agent detials ends

$queryagent= mysqli_query($mysqli,"SELECT * FROM rmt_bookings where b_id='$id'");

//ineed this section here to be page 1
while($rs=mysqli_fetch_array($queryagent))
{

$content .= '

Client Name	 '.$rs["b_cname"].'

Client Address	 '.$rs["b_caddress"].'

Client Phone	 '.$rs["b_cphone"].'

Client Email	 '.$rs["b_cemail"].'

No of Persons	No of Adults :'.$rs["b_cadult"].'
No of Child : '.$rs["b_cchild"].'
No of Infants : '.$rs["b_cinfant"].'

Package Name	 '.$rs["b_pname"].'

Tour Location	 '.$rs["b_location"].'

Depature Date	 '.$rs["b_date"].'

Destination Details

';

$b_destinations = unserialize( base64_decode( $rs['b_destinations'] ) );
$b_nights = unserialize( base64_decode( $rs['b_nights'] ) );

foreach (array_combine($b_destinations[0], $b_nights[0]) as $desti=>$nights)
{
$content .='
 '.$desti.'	Nights : '.$nights.'

';
}
//page1 ends here

$b_hdest = unserialize($rs['b_hdest']);
$b_hname = unserialize($rs['b_hname']);
$b_hadd = unserialize($rs['b_hadd'] );
$b_hphone = unserialize($rs['b_hphone']);
$b_hin = unserialize($rs['b_hin']);
$b_hout = unserialize( $rs['b_hout']);
$b_hroom = unserialize( $rs['b_hroom'] );
$b_hmeal = unserialize( $rs['b_hmeal'] );
$b_haextra = unserialize( $rs['b_haextra'] );
$b_hcextra = unserialize( $rs['b_hcextra'] );
$b_hspecial = unserialize( $rs['b_hspecial'] );
$b_hincl = unserialize( $rs['b_hincl'] );

for($i=0;$i<count($b_hdest[0]);$i++){
//here multiple page will be add bcoz, the page will be added according this for loop.
$content .= '
';
$content .='
	Email : '.$email.'
Phone : '.$phone.'
';
$content .='

Hotel details

';
$content .='
Hotel Details '.($i+1).' : '.$b_hname[0][$i].'
';
$content .='
Destination	Address	Phone	Check Out Time
';
$content .='
'.$b_hdest[0][$i].'	'.$b_hadd[0][$i].'	'.$b_hphone[0][$i].'	10 AM
';
$content .='
Chekc In	Check Out	Rooms	Meals
';
$content .='
'.$b_hin[0][$i].'	'.$b_hout[0][$i].'	'.$b_hroom[0][$i].'	'.$b_hmeal[0][$i].'
';
$content .='
Extra Adult	Extra Child	Special	Inclusions
';
$content .='
'.$b_haextra[0][$i].'	'.$b_hcextra[0][$i].'	'.$b_hspecial[0][$i].'	'.$b_hincl[0][$i].'
';
//page ends here
}

$content .='
';

$content .='';
$obj_pdf->writeHTML($content);
ob_end_clean();
$obj_pdf->Output('tourdetails.pdf', 'I');
}
}```

please i need help in this.

答:
There is a
 tag which will help you to add new page from your HTML code. But you have to make your own conditions.

```<code><br pagebreak="true"/>
</code>```

I got this answer from below link.

https://stackoverflow.com/a/3158583/4003956

Hope it helps.

Body:
i am working with tcpdf, need to generate pdf,
i need help in displaying multiple pages.
the 1st page will contain client details,
after the 1st page other pages will be added according to the for loop.
and how can i add a fix header and footer to this pdf.
i need to show the below logo in the header and the phone and email of agent in the footer.
here is my code

if(isset($_GET['packid']))
{
$id=$_GET['packid'];
include_once 'db_connect.php';
include_once 'functions.php';
sec_session_start();
/*if(login_check($mysqli) == false)
{
header('location:../index.php');
exit();
}*/

require_once('tcpdf/tcpdf.php');
$obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$obj_pdf->SetProtection(array('copy','modify'), '', 'RAVIjordan!@#$)(*&15789537447344789', 0, null);
$obj_pdf->SetCreator(PDF_CREATOR);
$obj_pdf->SetTitle('Export HTML Table data to PDF using TCPDF in PHP');
$obj_pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
$obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$obj_pdf->SetDefaultMonospacedFont('helvetica');
$obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf->SetMargins(PDF_MARGIN_LEFT, '5', PDF_MARGIN_RIGHT);
$obj_pdf->setPrintHeader(false);
$obj_pdf->setPrintFooter(false);
$obj_pdf->SetAutoPageBreak(TRUE, 10);
$obj_pdf->SetFont('helvetica', '', 12);
$obj_pdf->AddPage();
$content = '';

$content .='

';

$content .='
';

$content .='

';
//this is the agent details
$agent = $_SESSION['username'];
$pic= mysqli_query($mysqli,"SELECT * FROM rmt_users where rmt_uname = '$agent'");
//page 1 agent with client details
while($pp=mysqli_fetch_array($pic))
{
    $image = '../'.$pp['rmt_ulogo'];
    $phone = $pp['rmt_uemail'];
    $email = $pp['rmt_uphone'];
}
$content .= '
TOUR DETAILS

';
$content .='
	Email : '.$email.'
Phone : '.$phone.'
';
//agent detials ends

$queryagent= mysqli_query($mysqli,"SELECT * FROM rmt_bookings where b_id='$id'");

//ineed this section here to be page 1
while($rs=mysqli_fetch_array($queryagent))
{

$content .= '

Client Name	 '.$rs["b_cname"].'

Client Address	 '.$rs["b_caddress"].'

Client Phone	 '.$rs["b_cphone"].'

Client Email	 '.$rs["b_cemail"].'

No of Persons	No of Adults :'.$rs["b_cadult"].'
No of Child : '.$rs["b_cchild"].'
No of Infants : '.$rs["b_cinfant"].'

Package Name	 '.$rs["b_pname"].'

Tour Location	 '.$rs["b_location"].'

Depature Date	 '.$rs["b_date"].'

Destination Details

';

$b_destinations = unserialize( base64_decode( $rs['b_destinations'] ) );
$b_nights = unserialize( base64_decode( $rs['b_nights'] ) );

foreach (array_combine($b_destinations[0], $b_nights[0]) as $desti=>$nights)
{
$content .='
 '.$desti.'	Nights : '.$nights.'

';
}
//page1 ends here

$b_hdest = unserialize($rs['b_hdest']);
$b_hname = unserialize($rs['b_hname']);
$b_hadd = unserialize($rs['b_hadd'] );
$b_hphone = unserialize($rs['b_hphone']);
$b_hin = unserialize($rs['b_hin']);
$b_hout = unserialize( $rs['b_hout']);
$b_hroom = unserialize( $rs['b_hroom'] );
$b_hmeal = unserialize( $rs['b_hmeal'] );
$b_haextra = unserialize( $rs['b_haextra'] );
$b_hcextra = unserialize( $rs['b_hcextra'] );
$b_hspecial = unserialize( $rs['b_hspecial'] );
$b_hincl = unserialize( $rs['b_hincl'] );

for($i=0;$i<count($b_hdest[0]);$i++){
//here multiple page will be add bcoz, the page will be added according this for loop.
$content .= '
';
$content .='
	Email : '.$email.'
Phone : '.$phone.'
';
$content .='

Hotel details

';
$content .='
Hotel Details '.($i+1).' : '.$b_hname[0][$i].'
';
$content .='
Destination	Address	Phone	Check Out Time
';
$content .='
'.$b_hdest[0][$i].'	'.$b_hadd[0][$i].'	'.$b_hphone[0][$i].'	10 AM
';
$content .='
Chekc In	Check Out	Rooms	Meals
';
$content .='
'.$b_hin[0][$i].'	'.$b_hout[0][$i].'	'.$b_hroom[0][$i].'	'.$b_hmeal[0][$i].'
';
$content .='
Extra Adult	Extra Child	Special	Inclusions
';
$content .='
'.$b_haextra[0][$i].'	'.$b_hcextra[0][$i].'	'.$b_hspecial[0][$i].'	'.$b_hincl[0][$i].'
';
//page ends here
}

$content .='
';

$content .='';
$obj_pdf->writeHTML($content);
ob_end_clean();
$obj_pdf->Output('tourdetails.pdf', 'I');
}
}

please i need help in this.

Body:
There is a <br> tag which will help you to add new page from your HTML code. But you have to make your own conditions.

<br pagebreak="true"/>

I got this answer from below link.

https://stackoverflow.com/a/3158583/4003956

Hope it helps.


问:
How to autowire a class which is in another project
I have two java projects as epService and epEntity (factory classes for db access). And there is another Spring project as epWeb which contains controllers and this is a Rest API.
Now, I want to autowire a class which is inside epEntity to the spring project epWeb.
I have successfully autowired classes within that epWeb project but I was unable to autowire a class from another project
Anyone have a suggestion for doing that, please let me know.
If this is an irrelevant question for stackoverflow, please delete this.

The class where I autowire
public class Mapper {

```<code>@Autowired
private SessionFactory sessionFactory;

public void setSessionFactory(SessionFactory sessionFactory) {
    this.sessionFactory = sessionFactory;
}
@Autowired
private AppointmentFactory af;
@Autowired
private AppointmentController ac;
}
</code>```

mvc-dispatcher-servlet.xml

```<code><beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

    <context:component-scan base-package="com.mobios.ep.web.controllers" />
    <!-- <context:component-scan base-package="com.mobios.ep.services" />
    <context:component-scan base-package="com.ombios.ep.entity.factory" /> -->
    <mvc:annotation-driven />
    <mvc:resources mapping="/resources/**" location="/resources/" />

    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/pages/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
     <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
     <property name="maxUploadSize" value="1048576"/>
    </bean>
</beans>
</code>```

答:
You can use @ComponentScan annotation in your main application epWeb in order to register in Spring context classes which live in epEntity project as Beans (Controllers, Services etc).

```<code>@ComponentScan({"com.example.service", "com.example.controller"})
</code>```

Also, make sure that Service implementations are annotated with @Service in epEntity project.

Body:
I have two java projects as epService and epEntity (factory classes for db access). And there is another Spring project as epWeb which contains controllers and this is a Rest API.
Now, I want to autowire a class which is inside epEntity to the spring project epWeb.
I have successfully autowired classes within that epWeb project but I was unable to autowire a class from another project
Anyone have a suggestion for doing that, please let me know.
If this is an irrelevant question for stackoverflow, please delete this.

The class where I autowire
public class Mapper {

@Autowired
private SessionFactory sessionFactory;

public void setSessionFactory(SessionFactory sessionFactory) {
    this.sessionFactory = sessionFactory;
}
@Autowired
private AppointmentFactory af;
@Autowired
private AppointmentController ac;
}

mvc-dispatcher-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">

    <context:component-scan base-package="com.mobios.ep.web.controllers" />

    <mvc:annotation-driven />
    <mvc:resources mapping="/resources/**" location="/resources/" />

    <bean
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/pages/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
     <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
     <property name="maxUploadSize" value="1048576"/>
    </bean>
</beans>

Body:
You can use @ComponentScan annotation in your main application epWeb in order to register in Spring context classes which live in epEntity project as Beans (Controllers, Services etc).

@ComponentScan({"com.example.service", "com.example.controller"})

Also, make sure that Service implementations are annotated with @Service in epEntity project.


问:
How to write this PHP regex?
I have a string of numbers surrounded by parenthesis:

```<code>(2)(56)(9)(12)(2)
</code>```

I was given the following regex by someone to split the numbers out of their parentheses:

```<code><?php

$string = '(2)(56)(9)(12)(2)';

$pattern = "/\\)\\(|\\(|\\)?/";

$numbers = preg_split($pattern, $string);

foreach ($numbers as $number) {
    echo $number.'<br />';
}

?>
</code>```

This outputs:

```<code><br />
<br />
2<br />
<br />
5<br />
6<br />
<br />
9<br />
<br />
1<br />
2<br />
<br />
2<br />
<br />
<br />
</code>```

When I really need it to output:

```<code>2<br />
56<br />
9<br />
12<br />
2<br />
</code>```

How can the regex be altered to make it work?

p.s. each number in between the parenthesis can be of an unlimited length.

答:
First, there's an error in the regex.  It should be:

```<code>$pattern = "/\\)\\(|\\(|\\)/";
</code>```

Note the last ? is removed.

The easy answer is to just check for empty numbers:

```<code>foreach ($numbers as $number) {
    if ($number !== '') {
        echo $number.'<br />';
    }
}
</code>```

Note the strict !== test since 0 may be a valid number...

Or, add the PREG_SPLIT_NO_EMPTY option to the preg_split call:

```<code>$numbers = preg_split($pattern, $string, -1, PREG_SPLIT_NO_EMPTY);
</code>```

Another option is to use preg_match_all with the simple regex: /\d+/:

```<code>$matches = array();
preg_match_all('/\d+/', $string, $matches);

$numbers = $matches[0];
</code>```

Title: How to write this PHP regex?

Body:
I have a string of numbers surrounded by parenthesis:

(2)(56)(9)(12)(2)

I was given the following regex by someone to split the numbers out of their parentheses:

<?php

$string = '(2)(56)(9)(12)(2)';

$pattern = "/\\)\\(|\\(|\\)?/";

$numbers = preg_split($pattern, $string);

foreach ($numbers as $number) {
    echo $number.'
';
}

?>

This outputs:

2

5

6

9

1

2

2

When I really need it to output:

2

56

9

12

2

How can the regex be altered to make it work?

p.s. each number in between the parenthesis can be of an unlimited length.

Body:
First, there's an error in the regex.  It should be:

$pattern = "/\\)\\(|\\(|\\)/";

Note the last ? is removed.

The easy answer is to just check for empty numbers:

foreach ($numbers as $number) {
    if ($number !== '') {
        echo $number.'<br />';
    }
}

Note the strict !== test since 0 may be a valid number...

Or, add the PREG_SPLIT_NO_EMPTY option to the preg_split call:

$numbers = preg_split($pattern, $string, -1, PREG_SPLIT_NO_EMPTY);

Another option is to use preg_match_all with the simple regex: /\d+/:

$matches = array();
preg_match_all('/\d+/', $string, $matches);

$numbers = $matches[0];


问:
Updating a table joining another table
Update a table joining 1 more table.

```<code>UPDATE t1 SET  t1.col1 =1 FROM table1 t1 JOIN  table2 t2
ON t1.ID=t2.ID
WHERE t1.Name='Test' AND t2.Age=25;
</code>```

i get this error,You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM table1 t1 JOIN  table2 t2 ...

Any thoughts?

Thanks.

答:
I have a problem in update join. in table1 i saved username instead of userid.
And for username datatype was varchar(10). When name exceeds 10 then name is saved with 10 character only. Now when i try to update using join query it doesn't works on those fields that have not exact unername in users table,
Notice name bill gat in table1 but the name in users field was bill gates
-es missing.

```<code>SELECT * FROM table1;
+------+------+---------+
| id   | col1 | created_by|
+------+------+---------+
|    1 |    0 | steve jobs|
|    2 |    1 | bill gat  |
|    3 |    0 | Jones   |
+------+------+---------+
3 rows in set (0.00 sec)
</code>```

===I solved this way

```<code>    UPDATE table1 AS tr
JOIN users AS u ON u.name LIKE CONCAT('%', tr.created_by, '%')
SET tr.created_by=u.id
WHERE tr.created_by IS NOT NULL
</code>```

Title: Updating a table joining another table

Body:
Update a table joining 1 more table.

UPDATE t1 SET  t1.col1 =1 FROM table1 t1 JOIN  table2 t2
ON t1.ID=t2.ID
WHERE t1.Name='Test' AND t2.Age=25;

i get this error,You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM table1 t1 JOIN  table2 t2 ...

Any thoughts?

Thanks.

Body:
I have a problem in update join. in table1 i saved username instead of userid.
And for username datatype was varchar(10). When name exceeds 10 then name is saved with 10 character only. Now when i try to update using join query it doesn't works on those fields that have not exact unername in users table,
Notice name bill gat in table1 but the name in users field was bill gates
-es missing.

SELECT * FROM table1;
+------+------+---------+
| id   | col1 | created_by|
+------+------+---------+
|    1 |    0 | steve jobs|
|    2 |    1 | bill gat  |
|    3 |    0 | Jones   |
+------+------+---------+
3 rows in set (0.00 sec)

===I solved this way

    UPDATE table1 AS tr
JOIN users AS u ON u.name LIKE CONCAT('%', tr.created_by, '%')
SET tr.created_by=u.id
WHERE tr.created_by IS NOT NULL


问:
Navigation Bar Failure
So I have an navigation bar for my website that is pretty basic, you click on the word and it takes you to that page. Well after putting a drop down on my page the navigation menu suddenly stopped working. Can anyone see a problem here that I am missing that would allowing the navigation menu to suddenly stop working after a drop down menu occurs?

<!DOCTYPE html>

        Welcome to All About History

Home

About Me

People in History

Contact Me

```

答:
```<code><!doctype html>
<html>
<body>
<div class="dropdown-notification text-center"> Welcome to All About History </div>
<nav>
  <ul>
    <li><a class="active" href="website.html">Home</a></li>
    <li><a href="about.html">About Me</a></li>
    <li><a href="people.html">People in History</a></li>
    <li><a href="contact.html">Contact Me</a></li>
  </ul>
</nav>
<style>
ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #333;
}
li {
    float: left;
}
li a {
    display: block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}
li a:hover:not(.active) {
    background-color: #111;
}
.active {
    background-color: #4CAF50;
}
.dropdown-notification {
    height: 25vh;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    line-height: 40px;
    background-color: #4CAF50;
    animation: welcome-dropdown 2s ease, welcome-fadeout 2s 4s forwards;
    text-align: center;
    vertical-align: middle;
    line-height: 25vh;
    font-size: 70px;
}
@keyframes welcome-dropdown {
    from {
        transform: translateY(calc(-100vh));
    }
    to {
        transform: translateY(0vh);
    }
}
@keyframes welcome-fadeout {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        height: 0vh;
    }
}
</style>
</body>
</html>
</code>```

Title: Navigation Bar Failure


问:
How to create delay function in QML?
I would like to create a delay function in javascript that takes a parameter of amount of time to delay, so that I could use it do introduce delay between execution of JavaScript lines in my QML application. It would perhaps look like this:

```<code>function delay(delayTime) {
  // code to create delay
}
</code>```

I need the body of the function delay(). Note that setTimeout() of JavaScript doesn't work in QML.

答:
you can use QtTest  </p>

```<code>import QtTest 1.0
import QtQuick 2.9

ApplicationWindow{
    id: window

    TestEvent {
        id: test
    }

    function delay_ms(delay_time) {
        test.mouseClick(window, 0, 0, Qt.NoButton, Qt.NoModifier, delay_time)
    }
}
</code>```

ContentLicense: CC BY-SA 4.0

Title: How to create delay function in QML?

Body:
I would like to create a delay function in javascript that takes a parameter of amount of time to delay, so that I could use it do introduce delay between execution of JavaScript lines in my QML application. It would perhaps look like this:

function delay(delayTime) {
  // code to create delay
}

I need the body of the function delay(). Note that setTimeout() of JavaScript doesn't work in QML.

Body:
you can use QtTest

import QtTest 1.0
import QtQuick 2.9

ApplicationWindow{
    id: window

    TestEvent {
        id: test
    }

    function delay_ms(delay_time) {
        test.mouseClick(window, 0, 0, Qt.NoButton, Qt.NoModifier, delay_time)
    }
}


问:
How do I hide the status bar in a Swift iOS app?
I'd like to remove the status bar at the top of the screen.

This does not work:

```<code>func application
(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: NSDictionary?)
-> Bool
{
        application.statusBarHidden = true
        return true
}
</code>```

I've also tried:

```<code>func application
(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: NSDictionary?)
-> Bool
{
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

    var controller = UIViewController()
    application.statusBarHidden = true
    controller.setNeedsStatusBarAppearanceUpdate()

    var view = UIView(frame: CGRectMake(0, 0, 320, 568))
    view.backgroundColor = UIColor.redColor()
    controller.view = view

    var label = UILabel(frame: CGRectMake(0, 0, 200, 21))
    label.center = CGPointMake(160, 284)
    label.textAlignment = NSTextAlignment.Center
    label.text = "Hello World"
    controller.view.addSubview(label)

    self.window!.rootViewController = controller
    self.window!.makeKeyAndVisible()
    return true
}
</code>```

答:
In your Project->General->Deployment info

Statusbar Style:--

just marked Hide status Bar(iOS 10)

Body:
I'd like to remove the status bar at the top of the screen.

This does not work:

func application
(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: NSDictionary?)
-> Bool
{
        application.statusBarHidden = true
        return true
}

I've also tried:

func application
(application: UIApplication,
didFinishLaunchingWithOptions launchOptions: NSDictionary?)
-> Bool
{
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)

    var controller = UIViewController()
    application.statusBarHidden = true
    controller.setNeedsStatusBarAppearanceUpdate()

    var view = UIView(frame: CGRectMake(0, 0, 320, 568))
    view.backgroundColor = UIColor.redColor()
    controller.view = view

    var label = UILabel(frame: CGRectMake(0, 0, 200, 21))
    label.center = CGPointMake(160, 284)
    label.textAlignment = NSTextAlignment.Center
    label.text = "Hello World"
    controller.view.addSubview(label)

    self.window!.rootViewController = controller
    self.window!.makeKeyAndVisible()
    return true
}


答:
Use preg_match instead of split and use /\\d+/ as your expression

Try

```<code>$string = '(2)(56)(9)(12)(2)';

$pattern = "/\d+/";

preg_match_all($pattern, $string, $numbers);

foreach ($numbers as $number) {
    echo $number.'<br />';
}
</code>```

I'm not sure on PHP regex syntax either \\d or \d

Title: How to write this PHP regex?

Body:
Use preg_match instead of split and use /\\d+/ as your expression

Try

$string = '(2)(56)(9)(12)(2)';

$pattern = "/\d+/";

preg_match_all($pattern, $string, $numbers);

foreach ($numbers as $number) {
    echo $number.'<br />';
}

I'm not sure on PHP regex syntax either \\d or \d


问:
how the event bubbling and phases occurred in html
How are events and phases triggered according to the events?

like every objects created in tree with their handles and if you click on one button all events linked in that div are triggered.

I have made program which have different sub div and having one paragraph and button.

I have came across different theories for event bubbling like event bubbling explained

答:
        <title>Event Bubble and Phases</title>

            This is div at level1

                This is div at level2

                    <button id="button1" onclick="f4()" style="background-color: beige;padding:20px">
                        Click
                    </button>

```

Body:
<html>
    <head>
        <title>Event Bubble and Phases</title>
        <script>
            function f1() {
                console.log("f1");
                console.log("Current Element " + event.currentTarget.id);
                console.log("Target "+event.target.id);
                console.log("Event Phase "+event.eventPhase);
                console.log("Bubble Status "+event.bubbles);
                console.log("Cancelable Status "+event.cancelable);
            }
            function f2() {
                console.log("f2");
                console.log("Current Element " + event.currentTarget.id);
                console.log("Target "+event.target.id);
                console.log("Event Phase "+event.eventPhase);
                console.log("Bubble Status "+event.bubbles);
                console.log("Cancelable Status "+event.cancelable);
            }
            function f3() {
                console.log("f3");
                console.log("Current Element " + event.currentTarget.id);
                console.log("Target "+event.target.id);
                console.log("Event Phase "+event.eventPhase);
                console.log("Bubble Status "+event.bubbles);
                console.log("Cancelable Status "+event.cancelable);
            }
            function f4() {
                console.log("f4");
                console.log("Current Element " + event.currentTarget.id);
                console.log("Target "+event.target.id);
                console.log("Event Phase "+event.eventPhase);
                console.log("Bubble Status "+event.bubbles);
                console.log("Cancelable Status "+event.cancelable);
            }
        </script>
    </head>
    <body>
        <div id="div1" onclick="f1()" style="background-color: brown; color: aliceblue;padding:20px">
            This is div at level1
            <div id="div2" onclick="f2()" style="background-color: burlywood;padding:20px">
                This is div at level2
                <p id="paragraph1" onclick="f3()" style="background-color: appworkspace;padding:20px">
                    <button id="button1" onclick="f4()" style="background-color: beige;padding:20px">
                        Click
                    </button>
                </p>
            </div>
        </div>
    </body>
</html>


问:
Bootstrap dashboard
I'm new to bootstrapping, HTML and everything that has to do with web development. I am building a dashboard using bootstrap and I managed to get the basic layout correct. My dashboard has a top and side navigation bar.

I now want to navigate between the different pages without having to reload the side and top navigation bars. So I just want the center part of the page to load content whenever the links on the navigation bar are clicked and have the clicked links change background colour to indicate the user is currently on the respective page. This is my content div

```<code><div class="section">
    <div class="container" id="content">
     </div>
</div>
</code>```

I have been trying to Google some tutorials but I am battling to get the appropriate results because I think my search key words are kind of vague. Is there anywhere I can read to learn such stuff or is there anyone in here to help me out.

Here is my code

```<code><body>
    <div id="wrapper">
      <nav class="navbar navbar-default navbar-static-top" style="background:white">
        <div class="container">
          <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-ex-collapse">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#"><img alt="Dijo_logo" src="https://dijoapp.co.za/dashboard_resources/logos/dijo8.png"></a>
          </div>
          <div class="collapse navbar-collapse" id="navbar-ex-collapse">
            <ul class="nav navbar-nav navbar-left">
              <li class="active">
                <a href="#">Dashboard</a>
              </li>
              <li>
                <a href="dijoapp.co.za">Admin</a>
              </li>
            </ul>
            <ul class="nav navbar-top-links navbar-right">
              <li class="dropdown">
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                        <i class="fa fa-user fa-fw"></i>  <i class="fa fa-caret-down"></i>
                    </a>
                <ul class="dropdown-menu dropdown-user">
                  <li>
                    <a href="#"><i class="fa fa-user fa-fw"></i> User Profile</a>
                  </li>
                  <li>
                    <a href="#"><i class="fa fa-gear fa-fw"></i> Settings</a>
                  </li>
                  <li class="divider"></li>
                  <li>
                    <a href="login.html"><i class="fa fa-sign-out fa-fw"></i> Logout</a>
                  </li>
                </ul>
              </li>
            </ul>
          </div>
        </div>
      </nav>
      <div class="container-fluid">
        <div class="row">
          <div class="col-sm-3 col-md-2 sidebar">
            <ul class="nav nav-sidebar">
              <li class="active">
                <a href="#">Statistics<span class="sr-only">(current)</span></a>
              </li>
              <li>
                <a href="#">Ratings and Reviews</a>
              </li>
            </ul>
          </div>
          <div class="section">
            <div class="container" id="content">
              <div class="side-body"></div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </body>
</code>```

答:
I suppose what you are trying to achieve is a single page application.

You can create a dashboard with navigation that only changes the content area without reloading the page using JavaScript, jQuery, or AJAX.

Here is an article that can guide you through to create an SPA -(Single Page Application) Create a Single Page App with jQuery

However, a much easier way to achieve this is to use a JavaScript framework like Angular.

If you are a beginner in Angular, This article can help you start with Bootstrap and Angular - How to Use Bootstrap 4 with Angular

Title: Bootstrap dashboard

Body:
I'm new to bootstrapping, HTML and everything that has to do with web development. I am building a dashboard using bootstrap and I managed to get the basic layout correct. My dashboard has a top and side navigation bar.

I now want to navigate between the different pages without having to reload the side and top navigation bars. So I just want the center part of the page to load content whenever the links on the navigation bar are clicked and have the clicked links change background colour to indicate the user is currently on the respective page. This is my content div

I have been trying to Google some tutorials but I am battling to get the appropriate results because I think my search key words are kind of vague. Is there anywhere I can read to learn such stuff or is there anyone in here to help me out.

Here is my code

            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-ex-collapse">
              Toggle navigation

            </button>

                Dashboard

                Admin

                     User Profile

                     Settings

                     Logout

                Statistics(current)

                Ratings and Reviews


问:
What is the structure of IQueryable?
```<code>using (var nosql = new DbHelper("Feed"))
{
    var watch = Stopwatch.StartNew();
    nosql.CollectionName = "rawhi";
    var x = nosql.GetRecords<Event>(p => true, 0, 1000000);
    //GridView1.DataSource = x;
    //GridView1.DataBind();
    watch.Stop();
    long milliseconds = watch.ElapsedMilliseconds;
    Response.Write(milliseconds);
}
</code>```

x is a variable of type IQueryable.

When I run this code the result is: 0

So I'm wondering if the data is stored in the x var or not?

答:
The query will be lazily evaluated, so until something tries to enumerate the results, the query is not actually executed or the results returned. In your code example you have set the query up, but you have not actually run it. If you put your databinding code back in, that will actually enumerate the result and so execute it.

For testing purposes you can force enumeration as follows:

```<code>x.ToList();
</code>```

Title: What is the structure of IQueryable?

Body:
using (var nosql = new DbHelper("Feed"))
{
    var watch = Stopwatch.StartNew();
    nosql.CollectionName = "rawhi";
    var x = nosql.GetRecords<Event>(p => true, 0, 1000000);
    //GridView1.DataSource = x;
    //GridView1.DataBind();
    watch.Stop();
    long milliseconds = watch.ElapsedMilliseconds;
    Response.Write(milliseconds);
}

x is a variable of type IQueryable.

When I run this code the result is: 0

So I'm wondering if the data is stored in the x var or not?

Body:
The query will be lazily evaluated, so until something tries to enumerate the results, the query is not actually executed or the results returned. In your code example you have set the query up, but you have not actually run it. If you put your databinding code back in, that will actually enumerate the result and so execute it.

For testing purposes you can force enumeration as follows:

x.ToList();


问:
Is it possible to get a window of another application from another one?
I have two projects (TestVisual and RecordPlayBack). TestVisual has two windows (MainWindow and TestWindow). I can get the TestWindow instance by using below code,

```<code>var windows = System.Windows.Application.Current.Windows;
IntPtr twHandle = new System.Windows.Interop.WindowInteropHelper(windows[2]).Handle;
</code>```

Now, i run the RecordPlayBack.exe from TestVisual.wpf application. So, the Application.Current holds RecordPlayBack application where the TestWindow is not available. In this case, how to get the TestWindow instance of TestVisual application?

i have tried this below code,

```<code>[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

IntPtr twHandle =(IntPtr) User32.FindWindow("test", null);
</code>```

Please suggest me any ideas.

Note:
RecordPlayBack project is added as referrence to TestVisual project.

Thanks,

答:
I can get the window handle in another application by using below code,</p>

```<code>System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcesses();
foreach(System.Diagnostics.Process p in processes)
{
    if(p.MainWindowTitle == "Test Window")
    {
        twHandle = p.MainWindowHandle;
        break;
    }
}
</code>```

Body:
I have two projects (TestVisual and RecordPlayBack). TestVisual has two windows (MainWindow and TestWindow). I can get the TestWindow instance by using below code,

var windows = System.Windows.Application.Current.Windows;
IntPtr twHandle = new System.Windows.Interop.WindowInteropHelper(windows[2]).Handle;

Now, i run the RecordPlayBack.exe from TestVisual.wpf application. So, the Application.Current holds RecordPlayBack application where the TestWindow is not available. In this case, how to get the TestWindow instance of TestVisual application?

i have tried this below code,

[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

IntPtr twHandle =(IntPtr) User32.FindWindow("test", null);

Please suggest me any ideas.

Note:
RecordPlayBack project is added as referrence to TestVisual project.

Thanks,

Body:
I can get the window handle in another application by using below code,

System.Diagnostics.Process[] processes = System.Diagnostics.Process.GetProcesses();
foreach(System.Diagnostics.Process p in processes)
{
    if(p.MainWindowTitle == "Test Window")
    {
        twHandle = p.MainWindowHandle;
        break;
    }
}


问:
Mysql SUM based on condition
I need help to formulate a query to calculate points based on user action.
There is a user table which stores user info and each user belongs to a specific category (User category). Each category has different levels (say level1, level2 etc..)  and each level has a set of tasks(Task1,Task2...) to be completed. Each task can be performed multiple times. But points is calculated based on a maximum limit field.

Task 1 - 10 points ( Max:2 - Means user can perform this task N times but for point calculation it will be only counted twice )

Task 2 - 5 points  ( Max:1 )

For example lets say User1 performs Task1 5 times, but for point calculation Task1 will only be counted 2 times , so total points is 20. This is similar for all tasks.

On completing each task the user gains N points and get upgraded to next level.
 Please find below the table structure and query:

users

uid , uname , uc_id ( References User Category ) , ul_id (References user level and indicates current level of user )

user_category

uc_id  ....

user_level

ul_id, uc_id (References User Category)
 ...

level_tasks

lt_id , ul_id (References User level) , lt_point, lt_max

user_tasks

ut_id, lt_id (References level task), uid (References user)

The below is the query i have tried so far :

SELECT uid, SUM(LT.lt_point/LT.lt_max) as TotalLevelPoints
FROM users AS U
INNER JOIN  user_tasks AS UT ON UT.ut_user_id = U.id
INNER JOIN  level_tasks AS LT ON LT.lt_id = UT.lt_id
INNER JOIN  user_level AS UL ON UL.ul_id = LT.ul_id
INNER JOIN  user_category AS UC ON UC.uc_id = UL.uc_id
WHERE UT.ut_status = 1 AND U.uid = 1 AND UL.ul_id = 1
GROUP BY U.uid

This gives all the sum without considering the max limit, how should i write so that sum is calculated on that column also.
Hope my question is clear enough.. Any help would be really appreciated.

答:
There is some discrepancy between column names in schema and query you have provided. I have gone with schema.

Query is not tested. But this approach should work.

```<code>SELECT uid, SUM(LevelPoints) TotalLevelPoints
FROM ( SELECT U.uid, LT.lt_id, SUM((CASE WHEN COUNT(*) > lt_max THEN lt_max ELSE COUNT(*) END)*lt_point) LevelPoints
       FROM users U
       INNER JOIN user_tasks UT
       ON U.uid = UT.uid
       INNER JOIN level_tasks LT
       ON UT.lt_id = LT.lt_id
       GROUP BY U.uid, LT.lt_id
      )
GROUP BY uid
</code>```

Title: Mysql SUM based on condition

Body:
There is some discrepancy between column names in schema and query you have provided. I have gone with schema.

Query is not tested. But this approach should work.

SELECT uid, SUM(LevelPoints) TotalLevelPoints
FROM ( SELECT U.uid, LT.lt_id, SUM((CASE WHEN COUNT(*) > lt_max THEN lt_max ELSE COUNT(*) END)*lt_point) LevelPoints
       FROM users U
       INNER JOIN user_tasks UT
       ON U.uid = UT.uid
       INNER JOIN level_tasks LT
       ON UT.lt_id = LT.lt_id
       GROUP BY U.uid, LT.lt_id
      )
GROUP BY uid


问:
Import third party C library into swift causes error "Include of non-modular header inside framework module"
This question is a continuation of a previous one I'm currently migrating this (https://github.com/emilwojtaszek/leveldb-swift) library from swift 2 to swift 3/4. Here is the link to my fork https://github.com/lu4/leveldb-swift/tree/MigrationFromSwift2ToSwift3 (please note that the target branch is MigrationFromSwift2ToSwift3)

I was able to resolve (with many thanks to @Ruslan Serebriakov) all of the issues with initial code base and check that the code is running.

However after trying to update LevelDB C code to latest master I got new type of error which I don't understand how to resolve:

Include of non-modular header inside framework module 'LevelDB.c': '/Path/to/Project/leveldb-swift-migration/vendor/leveldb/include/leveldb/export.h'

I've did some research on the internet but the issues described there seem non-related with one I've stumbled on. Here is an image of the issue

Any help is appreciated, thank you in advance!

答:
I'm never 100% certain with mixed language frameworks. But an error like this happens in Swift projects when:

since you cannot use a Bridging Header in frameworks,

you #import a C header in the Foo-Framework.h to expose it so the Swift code, and

the header is not itself marked "Public" to the target.

"Non-modular" seems to indicate "not part of the published module interface". At least with Swift--C mixes, you can only combine both through making the C headers public; no way to import private header files there, which is weird.

Give it a shot: Since you are obviously importing the file in non-Swift code, try to locate the export.h header file in your Xcode project, open the File inspector (⌘⌥1), and ensure public visibility in the framework target:


问:
Passing MAVEN_OPTS in Pipeline
I'm trying to convert a free-style job to pipeline code. following are the MAVEN_OPTS got declared along with maven goals under "Invoke Artifactory Maven 3" in job.

Maven Goals: clean install

MAVEN_OPTS: -Xmx2048m

-Xms512m

-XX:PermSize=256m

-XX:MaxPermSize=1024m

-Denv.build-timestamp=${BUILD_TIMESTAMP}

-Denv.build-job=${JOB_NAME}

-Denv.build-number=${BUILD_NUMBER}

-Denv.build-url=${BUILD_URL}

-Denv.git-commit=${GIT_COMMIT}

-Denv.git-branch=${GIT_BRANCH}

My trial in pipeline:

```<code>node('node1') {

    def javaHome = tool name: 'JDK 1.8', type: 'hudson.model.JDK'
    def mvnHome = tool name: 'M3', type: 'hudson.tasks.Maven$MavenInstallation'
    sh "$mvnHome/bin/mvn -f pom.xml clean install -U -Dmaven.repo.local=$WORKSPACE/.m2/repository -Xmx2048m -Xms512m -XX:PermSize=256m -XX:MaxPermSize=1024m -Dtimestamp=${BUILD_TIMESTAMP} ..."

    }

Error:
Could not find metadata org.apache.maven.plugins/maven-metadata.xml in local
</code>```

I'm sure that I'm passing MAVEN_OPTS in a wrong way. Can someone guide me the right systax to declare MAVEN_OPTS in Pipeline

答:
You can set the mavenOpts in the withMaven call in a pipeline stage:

```<code>node('node1') {

    stage ('MavenGoals') {
        withMaven(jdk: 'JDK 1.8',
                maven: 'M3',
                mavenLocalRepo: '$WORKSPACE/.m2/repository',
                mavenOpts: '-Xmx2048m -Xms512m -XX:PermSize=256m ....') {
            sh 'mvn clean install'
        }
    }
}
</code>```

Title: Passing MAVEN_OPTS in Pipeline

Body:
I'm trying to convert a free-style job to pipeline code. following are the MAVEN_OPTS got declared along with maven goals under "Invoke Artifactory Maven 3" in job.

Maven Goals: clean install

MAVEN_OPTS: -Xmx2048m

-Xms512m

-XX:PermSize=256m

-XX:MaxPermSize=1024m

-Denv.build-timestamp=${BUILD_TIMESTAMP}

-Denv.build-job=${JOB_NAME}

-Denv.build-number=${BUILD_NUMBER}

-Denv.build-url=${BUILD_URL}

-Denv.git-commit=${GIT_COMMIT}

-Denv.git-branch=${GIT_BRANCH}

My trial in pipeline:

node('node1') {

    def javaHome = tool name: 'JDK 1.8', type: 'hudson.model.JDK'
    def mvnHome = tool name: 'M3', type: 'hudson.tasks.Maven$MavenInstallation'
    sh "$mvnHome/bin/mvn -f pom.xml clean install -U -Dmaven.repo.local=$WORKSPACE/.m2/repository -Xmx2048m -Xms512m -XX:PermSize=256m -XX:MaxPermSize=1024m -Dtimestamp=${BUILD_TIMESTAMP} ..."

    }

Error:
Could not find metadata org.apache.maven.plugins/maven-metadata.xml in local

I'm sure that I'm passing MAVEN_OPTS in a wrong way. Can someone guide me the right systax to declare MAVEN_OPTS in Pipeline

Body:
You can set the mavenOpts in the withMaven call in a pipeline stage:

node('node1') {

    stage ('MavenGoals') {
        withMaven(jdk: 'JDK 1.8',
                maven: 'M3',
                mavenLocalRepo: '$WORKSPACE/.m2/repository',
                mavenOpts: '-Xmx2048m -Xms512m -XX:PermSize=256m ....') {
            sh 'mvn clean install'
        }
    }
}


问:
CORS. Presigned URL. S3
I've generated a presigned S3 POST URL. Using the return parameters, I then pass it into my code, but I keep getting this error Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource..

Whereas on Postman, I'm able to submit the form-data with one attached file.

On PostMan, I manually entered the parameters

The same parameters are then entered into my code.

答:
You must edit the CORS Configuration to be public , something like:

```<code>   <?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>POST</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>
</code>```

Title: CORS. Presigned URL. S3

Body:
You must edit the CORS Configuration to be public , something like:

   <?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>POST</AllowedMethod>
    <MaxAgeSeconds>3000</MaxAgeSeconds>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>


问:
Removing images by clicking on delete button
How can I remove specific image with complete division by clicking on the respective DELETE button, below is the source code. kindly assist me on this.

```<code><div class="slide">
   <img class="photo" src="img001.jpg">
   <p>image description</p>
   <button id="del">Delete</button>
</div>
<div class="slide">
   <img src="img002.jpg">
   <p>image description</p>
   <button>Delete</button>
</div>
</code>```

答:
You need to do it like below:-

```<code>$('.slide button').on('click',function(){ // on click of button
  $(this).parent('.slide').remove(); // find the parent div and remove it
});
</code>```

Working example:-

$('.slide button').on('click',function(){
  $(this).parent('.slide').remove();
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="slide">
  <img class="photo" src="https://vignette.wikia.nocookie.net/siivagunner/images/9/92/Twitter_Icon.png/revision/latest?cb=20170513181034">
  <p>image description</p>
  <button id="del">Delete</button>
</div>
<div class="slide">
  <img src="https://bunnymedia-8962.kxcdn.com/media/catalog/product/cache/2/small_image/50x/1c9c639f71c92c9f6b86bd79f5f4d9d6/1/6/1654.7-dizzy-icon-iconbunny.jpg">
  <p>image description</p>
  <button>Delete</button>
</div></code>```

Body:
How can I remove specific image with complete division by clicking on the respective DELETE button, below is the source code. kindly assist me on this.

image description

   <button id="del">Delete</button>

image description

   <button>Delete</button>

Body:
You need to do it like below:-

$('.slide button').on('click',function(){ // on click of button
  $(this).parent('.slide').remove(); // find the parent div and remove it
});

Working example:-

$('.slide button').on('click',function(){
  $(this).parent('.slide').remove();
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="slide">
  <img class="photo" src="https://vignette.wikia.nocookie.net/siivagunner/images/9/92/Twitter_Icon.png/revision/latest?cb=20170513181034">
  <p>image description</p>
  <button id="del">Delete</button>
</div>
<div class="slide">
  <img src="https://bunnymedia-8962.kxcdn.com/media/catalog/product/cache/2/small_image/50x/1c9c639f71c92c9f6b86bd79f5f4d9d6/1/6/1654.7-dizzy-icon-iconbunny.jpg">
  <p>image description</p>
  <button>Delete</button>
</div>


问:
Getting build history from jenkins from rest service
Presently i am developing a angular application which shows the data of the builds from jenkins. So how to get that data from jenkins as a rest service.present i am using http://YOUR_JENKINS:8080/job/YOUR_JOB/api/xml?%20tree=jobs[name]{0,10}. but i am getting 403 unautharized. please can anybody help me in this issue.</p>

答:
you need to use the jenkins user token in-order to make the rest call to jenkins api.

For csrf / crumb issues.
Need to get crumb from Jenkins using below command

wget -q --auth-no-challenge --user admin --password admin --output-document - 'http://192.168.99.20:8080/crumbIssuer/api/xml?xpath=concat(//crumbRequestField,":",//crumb)'

This will return crumb value, then add this to Jenkins rest API

curl -I -X POST http://admin:85703fb68927f04968630e192e4927cb@192.168.99.20:8080/job/Football/build -H "Jenkins-Crumb:44e7033af70da95a47403c3bed5c10f8"

Below link explains in-detail
http://www.inanzzz.com/index.php/post/jnrg/running-jenkins-build-via-command-line


问:
Why exec() is not working in foreach loop?
See, for testing purpose if I am trying to run PHP exec() statically with only one video file, then its compressing video perfectly(please see first line line).

Later when I am compressing dynamically in the loop, then exec function is not working. Please tell me why it's not working in the loop?

```<code>// echo shell_exec("/usr/local/bin/ffmpeg -i /home4/machine/public_html/riyaz/check_video/video_1494453415.mp4 -strict -2 -crf 20 /home4/machine/public_html/riyaz/zcompress/video_1494453415.mp4");

@include_once("start.php");

$directory_path = FILEPATH.'/';

$video_mp4 = glob("/home4/machine/public_html/riyaz/check_video/*.mp4");

/*video size will show in mb*/
foreach ($video_mp4 as $video_mp4_list){

    $video_size = filesize($video_mp4_list);
    $video_size_in_mb = round(($video_size/1048576), 2);

    $get_file_name = explode('/',$video_mp4_list);
    $get_file_name_for_destination = $get_file_name[6];

    $getSourceFileNamePath = '/home4/machine/public_html/riyaz/check_video/'.$get_file_name_for_destination;
    $getDestFileNamePath = '/home4/machine/public_html/riyaz/zcompress/'.$get_file_name_for_destination;

    if ($video_size_in_mb >= 1000 ){

        echo exec("/usr/local/bin/ffmpeg -i ". $getSourceFileNamePath ." -strict -2 -crf 20 ".$getDestFileNamePath);
    }
}
</code>```

答:
shell_exec() returns the full output: PHP shell_exec() however

exec() returns only the last line from the outptut that might be empty.. So you have to provide second $output and third parameter $return_var to get more useful data: PHP exec()

```<code>if ($video_size_in_mb >= 1000 ){
  $command = "/usr/local/bin/ffmpeg -y -i ". $getSourceFileNamePath ." -strict -2 -crf 20 ".$getDestFileNamePath . ' 2>&1';
  echo PHP_EOL ."Executing command: ". $command;
  if(file_exists($getDestFileNamePath)) echo "File already exists!";
  $output = null;
  $return_var = null;
  exec($command, $output, $return_var);
  print_r($command);
  print_r($return_var);
  print_r($output);
  echo PHP_EOL;
} else {
  echo "video too small to proceed';
}
</code>```

php shell_exec() vs exec()

EDIT: The problem is that the destination file exists and ffmpeg exits without any action. One solution is to use attribute -y to overwrite the output file 5.4 Main options -y (global) Overwrite output files without asking.

Body:
See, for testing purpose if I am trying to run PHP exec() statically with only one video file, then its compressing video perfectly(please see first line line).

Later when I am compressing dynamically in the loop, then exec function is not working. Please tell me why it's not working in the loop?

// echo shell_exec("/usr/local/bin/ffmpeg -i /home4/machine/public_html/riyaz/check_video/video_1494453415.mp4 -strict -2 -crf 20 /home4/machine/public_html/riyaz/zcompress/video_1494453415.mp4");

@include_once("start.php");

$directory_path = FILEPATH.'/';

$video_mp4 = glob("/home4/machine/public_html/riyaz/check_video/*.mp4");

/*video size will show in mb*/
foreach ($video_mp4 as $video_mp4_list){

    $video_size = filesize($video_mp4_list);
    $video_size_in_mb = round(($video_size/1048576), 2);

    $get_file_name = explode('/',$video_mp4_list);
    $get_file_name_for_destination = $get_file_name[6];

    $getSourceFileNamePath = '/home4/machine/public_html/riyaz/check_video/'.$get_file_name_for_destination;
    $getDestFileNamePath = '/home4/machine/public_html/riyaz/zcompress/'.$get_file_name_for_destination;

    if ($video_size_in_mb >= 1000 ){

        echo exec("/usr/local/bin/ffmpeg -i ". $getSourceFileNamePath ." -strict -2 -crf 20 ".$getDestFileNamePath);
    }
}

Body:
shell_exec() returns the full output: PHP shell_exec() however

exec() returns only the last line from the outptut that might be empty.. So you have to provide second $output and third parameter $return_var to get more useful data: PHP exec()

if ($video_size_in_mb >= 1000 ){
  $command = "/usr/local/bin/ffmpeg -y -i ". $getSourceFileNamePath ." -strict -2 -crf 20 ".$getDestFileNamePath . ' 2>&1';
  echo PHP_EOL ."Executing command: ". $command;
  if(file_exists($getDestFileNamePath)) echo "File already exists!";
  $output = null;
  $return_var = null;
  exec($command, $output, $return_var);
  print_r($command);
  print_r($return_var);
  print_r($output);
  echo PHP_EOL;
} else {
  echo "video too small to proceed';
}

php shell_exec() vs exec()

EDIT: The problem is that the destination file exists and ffmpeg exits without any action. One solution is to use attribute -y to overwrite the output file 5.4 Main options -y (global) Overwrite output files without asking.