问:
Error in POM.xml file help in out for new coder
SEVERE: Servlet [spring] in web application [/RestControllerExample] threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

Spring MVC Framework and REST

Spring’s annotation based MVC framework simplifies the process of creating RESTful web services. The key difference between a traditional Spring MVC controller and the RESTful web service controller is the way the HTTP response body is created. While the traditional MVC controller relies on the View technology, the RESTful web service controller simply returns the object and the object data is written directly to the HTTP response as JSON/XML.  For a detailed description of creating RESTful web services using the Spring framework

`
web.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  id="WebApp_ID" version="3.0">

    <!-- Processes application requests -->
     <servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>

            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>

        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>

<context-param>
<param-name>AppliactionContext</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</context-param>

</web-app>`
</code>```

pom.xml

```<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>RestControllerExample</groupId>
  <artifactId>RestControllerExample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>

  <dependency>
 <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
   <version>3.1.0.RELEASE</version>
</dependency>
<dependency>
 <groupId>org.springframework</groupId>
  <artifactId>spring-webmvc</artifactId>
   <version>3.1.0.RELEASE</version>
</dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>4.2.3.RELEASE</version>
</dependency>

   <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>
   <!-- Set this to the respective version -->
   <version>3.0.5.RELEASE</version>
</dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>5.0.2.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.0.2.RELEASE</version>
</dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>5.0.2.RELEASE</version>
</dependency>

    <!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>5.0.2.RELEASE</version>
</dependency>

  <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>${spring.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.7.2</version>
    </dependency>
        <dependency>
      <groupId>commons-dbcp</groupId>
      <artifactId>commons-dbcp</artifactId>
      <version>1.4</version>
    </dependency>

     </dependencies>

</project>
</code>```

spring-servlet.xml

```<code>    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-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.0.xsd">

    <!-- Enable autowire -->
    <context:annotation-config />
    <context:component-scan base-package="com.example.spring" />

    </beans>
</code>```

答:
The problem is that you have a lot of duplicated dependecies in your pom file and the groupId in your pom file is different than the groupId in your spring-servlet.xml !  </p>

<p>I think this pom configuration will work for you ,but you have to set one goupId for the two files so if your classes java are in this package com.example.spring use it as a groupId in the pom </p>

```<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/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.example.spring</groupId>
      <artifactId>RestControllerExample</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>war</packaging>
      <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
          <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
              <warSourceDirectory>WebContent</warSourceDirectory>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </plugin>
        </plugins>
      </build>
    <properties>
        <compiler.plugin.version>2.5.1</compiler.plugin.version>
        <jstl.version>1.2</jstl.version>
        <servletapi.version>3.1.0</servletapi.version>
        <spring.version>4.1.1.RELEASE</spring.version>
        <jackson-version>2.4.3</jackson-version>
        <logback.version>1.1.3</logback.version>
        <slf4j.version>1.7.12</slf4j.version>
    </properties>
      <dependencies>
        <!-- SLF4J and Logback  -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>
        <!-- Spring dependecies  -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- compile only, deployed container will provide this -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${servletapi.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
         </dependencies>

    </project>
</code>```

Body:
SEVERE: Servlet [spring] in web application [/RestControllerExample] threw load() exception
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

Spring MVC Framework and REST

Spring’s annotation based MVC framework simplifies the process of creating RESTful web services. The key difference between a traditional Spring MVC controller and the RESTful web service controller is the way the HTTP response body is created. While the traditional MVC controller relies on the View technology, the RESTful web service controller simply returns the object and the object data is written directly to the HTTP response as JSON/XML.  For a detailed description of creating RESTful web services using the Spring framework

`
web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
 xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
  id="WebApp_ID" version="3.0">

     <servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>

            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>

        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>

<context-param>
<param-name>AppliactionContext</param-name>
<param-value>/WEB-INF/spring-servlet.xml</param-value>
</context-param>

</web-app>`

pom.xml

<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>RestControllerExample</groupId>
  <artifactId>RestControllerExample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>3.0.0</version>
        <configuration>
          <warSourceDirectory>WebContent</warSourceDirectory>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>

  <dependency>
 <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
   <version>3.1.0.RELEASE</version>
</dependency>
<dependency>
 <groupId>org.springframework</groupId>
  <artifactId>spring-webmvc</artifactId>
   <version>3.1.0.RELEASE</version>
</dependency>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>4.2.3.RELEASE</version>
</dependency>

   <dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-webmvc</artifactId>

   <version>3.0.5.RELEASE</version>
</dependency>

    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>5.0.2.RELEASE</version>
    </dependency>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.0.2.RELEASE</version>
</dependency>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-beans</artifactId>
    <version>5.0.2.RELEASE</version>
</dependency>

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>5.0.2.RELEASE</version>
</dependency>

  <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${spring.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>${spring.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.7.2</version>
    </dependency>
        <dependency>
      <groupId>commons-dbcp</groupId>
      <artifactId>commons-dbcp</artifactId>
      <version>1.4</version>
    </dependency>

     </dependencies>

</project>

spring-servlet.xml

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-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.0.xsd">

    <context:annotation-config />
    <context:component-scan base-package="com.example.spring" />

    </beans>

Body:
The problem is that you have a lot of duplicated dependecies in your pom file and the groupId in your pom file is different than the groupId in your spring-servlet.xml !

I think this pom configuration will work for you ,but you have to set one goupId for the two files so if your classes java are in this package com.example.spring use it as a groupId in the 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/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.example.spring</groupId>
      <artifactId>RestControllerExample</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>war</packaging>
      <build>
        <sourceDirectory>src</sourceDirectory>
        <plugins>
          <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
              <warSourceDirectory>WebContent</warSourceDirectory>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
              <source>1.8</source>
              <target>1.8</target>
            </configuration>
          </plugin>
        </plugins>
      </build>
    <properties>
        <compiler.plugin.version>2.5.1</compiler.plugin.version>
        <jstl.version>1.2</jstl.version>
        <servletapi.version>3.1.0</servletapi.version>
        <spring.version>4.1.1.RELEASE</spring.version>
        <jackson-version>2.4.3</jackson-version>
        <logback.version>1.1.3</logback.version>
        <slf4j.version>1.7.12</slf4j.version>
    </properties>
      <dependencies>
        <!-- SLF4J and Logback  -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>${logback.version}</version>
        </dependency>
        <!-- Spring dependecies  -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <!-- compile only, deployed container will provide this -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>${servletapi.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>${jstl.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
         </dependencies>

    </project>


来源: stackexchange

问:
Canvas scaler issue - displaying differently in browser and on phone
I have this issue with my canvas scaler. I'm designing in Unity on my PC where it correctly displays how it's supposed to look. However, it looks very different in both the browser on my PC and on my android phone.

PC - Unity:

PC browser / Android phone (OnePlus 5):

Unity scene:

Canvas scaler settings:

Everything is inside my canvas. I've tried tweaking the canvas scaler settings over and over again but with no luck. What could I be doing wrong? I'm using Unity 5.6.3p1.

答: İt can be caused by simply if your camera does not fit on device screen exactly. To prevent this change Render Mode of your Canvas to the Screen Space - Overlay.

ContentLicense: CC BY-SA 3.0


问:
Reduce config tables:SymmetricDS
Well i'm trying to migrate data from my in-memory DB1 to my DB2. For this I'm using SymmetricDS configured in such a way that, when SymmetricDS starts, it will perform an inital load from DB1 to DB2. Furthermore whenever some data modification occurs in DB1, the same is pulled to DB2.

Now this is where i have a problem. SymmetricDS requires configuration tables or Sym Tables to be present at both the DB1 side and DB2 side.

Since my DB1 is in-memory, these configuration tables are taking a lot of memory.

So what I would like to know is whether there is a way ,to keep the configuration tables entirely in a seperate on-disk db, from DB1 side, and yet retain the existing functionality?

Hope i was able to make myself clear.

Any and all suggestions would be appreciated.

答:
Option 1: Minimize runtime tables footprint.  You can aggressively purge the runtime tables.  For example, purge them every 10 minutes and only keep 10 minutes worth of activity:

```<code>purge.retention.minutes=10
job.purge.incoming.cron=0 */10 * * * *
job.purge.outgoing.cron=0 */10 * * * *
</code>```

Avoid recording the incoming_batch table altogether:

```<code>incoming.batches.record.ok.enabled=false
</code>```

Option 2: Put SymmetricDS in another database.  Setup SymmetricDS to point to a database, like H2 file-based database.  That's where all the "SYM" tables will go.  Then configure "jdbc" parameters to load into your in-memory database. For example, you could load into Apache Ignite:

```<code>jdbc.db.url=jdbc:ignite:thin://localhost
jdbc.db.driver=org.apache.ignite.IgniteJdbcThinDriver
jdbc.db.user=
jdbc.db.password=
</code>```

Then set the sym_channel.data_loader_type to "jdbc" for the channels you're using to load data (such as "default" and "reload" channels).

Title: Reduce config tables:SymmetricDS

Body:
Option 1: Minimize runtime tables footprint.  You can aggressively purge the runtime tables.  For example, purge them every 10 minutes and only keep 10 minutes worth of activity:

purge.retention.minutes=10
job.purge.incoming.cron=0 */10 * * * *
job.purge.outgoing.cron=0 */10 * * * *

Avoid recording the incoming_batch table altogether:

incoming.batches.record.ok.enabled=false

Option 2: Put SymmetricDS in another database.  Setup SymmetricDS to point to a database, like H2 file-based database.  That's where all the "SYM" tables will go.  Then configure "jdbc" parameters to load into your in-memory database. For example, you could load into Apache Ignite:

jdbc.db.url=jdbc:ignite:thin://localhost
jdbc.db.driver=org.apache.ignite.IgniteJdbcThinDriver
jdbc.db.user=
jdbc.db.password=

Then set the sym_channel.data_loader_type to "jdbc" for the channels you're using to load data (such as "default" and "reload" channels).


问:
How to resolve "This content cannot be displayed in a frame" error - CRM 2013 + Sharepoint 2013?
I am trying to display/embed a Power View report from Sharepoint 2013 'document library' into CRM 2013 dashboard.

CRM 2013 - On Premise, Sharepoint 2013 - On Premise.

Below are the steps I followed:

Developed a sample Power View report in Excel 2013 using CRM OData Feed

Uploaded the Power View report (.xlsx) to Sharepoint 2013 Document Library

In CRM, created a System Dashboard and added an IFrame.

Copied the Power View report URL and appended "&action=embedview" to the query string.

Updated the string above into the CRM Dashboard IFrame URL property. Un-ticked the 'Restrict cross-frame scripting ' check box. Saved and Published the dashboard.

(as suggested in - Embedding Power View reports in CRM 2013 , PowerView reports in CRM)

Opening the dashboard in CRM displays 'This content cannot be displayed in a frame' error.

What I have tried so far :
Changing IE settings  based on -- article

I've seen this one too -- IFraming Sharepoint hosted apps but couldn't to understand what needs to be done. When I tried opening my 'document library' using 'Open in Explorer' and changed the /Forms/AllItems.aspx to include the tag below, it broke the document library.

<WebPartPages:AllowFraming runat="server" />```

Please assist.

答:
I had to create an outbound rule in IIS for the SharePoint app holding the documents. These are the fields I used in creating the outbound rule:

Name

Any name you want, I used set x-frame-options

Match

Matching scope: Server Variable

Variable name: RESPONSE_X-FRAME-OPTIONS

Pattern: .*

Action type:

Rewrite Action properties Value: (LEAVE BLANK)

(CHECK) Replace existing server variable value

Then I just applied the rule. It's working for me at present. Let me know if it works for you.

Body:
I am trying to display/embed a Power View report from Sharepoint 2013 'document library' into CRM 2013 dashboard.

CRM 2013 - On Premise, Sharepoint 2013 - On Premise.

Below are the steps I followed:

Developed a sample Power View report in Excel 2013 using CRM OData Feed

Uploaded the Power View report (.xlsx) to Sharepoint 2013 Document Library

In CRM, created a System Dashboard and added an IFrame.

Copied the Power View report URL and appended "&action=embedview" to the query string.

Updated the string above into the CRM Dashboard IFrame URL property. Un-ticked the 'Restrict cross-frame scripting ' check box. Saved and Published the dashboard.

(as suggested in - Embedding Power View reports in CRM 2013 , PowerView reports in CRM)

Opening the dashboard in CRM displays 'This content cannot be displayed in a frame' error.

What I have tried so far :
Changing IE settings  based on -- article

I've seen this one too -- IFraming Sharepoint hosted apps but couldn't to understand what needs to be done. When I tried opening my 'document library' using 'Open in Explorer' and changed the /Forms/AllItems.aspx to include the tag below, it broke the document library.

<WebPartPages:AllowFraming runat="server" />

Please assist.


问:
Ammap lines Simulation from external JSON file
I am trying to insert external JSON data to my ammap using dataLoader and use those datas to animate the lines on the postProcess in the ammap map

```<code> var map = AmCharts.makeChart("chartdiv", {
    "type": "map",
    "theme": "light",
    "dataLoader": {
        "url": "/directory_to_json_file/json_file.json",
        "postProcess": function(data) {
            var dataProvider = {
                "map": "worldLow"
            };
        }
    },
...
}
</code>```

i want to insert the json file after loading worldLow map and add lines latitude and longitude and animations from the external json file.

json_file

```<code>{
 map: "worldLow",
  getAreasFromMap: true,
  linkToObject: "london",
  images: [{
    id: "london",
    color: "#000000",
    type: "circle",
    title: "London",
    latitude: 51.5002,
    longitude: -0.1262,
    scale: 1.5,
    zoomLevel: 1.74,
    lines: [{
      latitudes: [51.5002, 37.483577],
      longitudes: [-0.1262, -89.824219]
    }]
  },
    {
      svgPath: pcSVG,
      title: "London",
      latitude: 51.5002,
      longitude: -0.1262
    },
    {
      svgPath: pcSVG,
      title: "Prague",
      latitude: 37.483577,
      longitude: -89.824219
    }

  ]
}
</code>```

it alerts error.

答:
In addition to quoting your properties, you can't pass variables into your JSON. You need to expand the instances of pcSVG the SVG string the variable represents. Using the target SVG from the animation across lines demo:

```<code>{
        "map": "worldLow",
        "getAreasFromMap": true,
        "linkToObject": "london",
        "images": [{
                "id": "london",
                "color": "#000000",
                "type": "circle",
                "title": "London",
                "latitude": 51.5002,
                "longitude": -0.1262,
                "scale": 1.5,
                "zoomLevel": 1.74,
                "lines": [{
                        "latitudes": [51.5002, 37.483577],
                        "longitudes": [-0.1262, -89.824219]
                }]
        }, {
                "svgPath": "M9,0C4.029,0,0,4.029,0,9s4.029,9,9,9s9-4.029,9-9S13.971,0,9,0z M9,15.93 c-3.83,0-6.93-3.1-6.93-6.93S5.17,2.07,9,2.07s6.93,3.1,6.93,6.93S12.83,15.93,9,15.93 M12.5,9c0,1.933-1.567,3.5-3.5,3.5S5.5,10.933,5.5,9S7.067,5.5,9,5.5 S12.5,7.067,12.5,9z",
                "title": "London",
                "latitude": 51.5002,
                "longitude": -0.1262
        }, {
                "svgPath": "M9,0C4.029,0,0,4.029,0,9s4.029,9,9,9s9-4.029,9-9S13.971,0,9,0z M9,15.93 c-3.83,0-6.93-3.1-6.93-6.93S5.17,2.07,9,2.07s6.93,3.1,6.93,6.93S12.83,15.93,9,15.93 M12.5,9c0,1.933-1.567,3.5-3.5,3.5S5.5,10.933,5.5,9S7.067,5.5,9,5.5 S12.5,7.067,12.5,9z",
                "title": "Prague",
                "latitude": 37.483577,
                "longitude": -89.824219
        }]
}
</code>```

Demo

Also note that you don't need the postProcess callback if you're returning the correct map dataProvider object. postProcess is only needed if you're returning something that isn't compatible and need to convert your data into something the map library understands, so your postProcess call is unnecessary.

Body:
I am trying to insert external JSON data to my ammap using dataLoader and use those datas to animate the lines on the postProcess in the ammap map

 var map = AmCharts.makeChart("chartdiv", {
    "type": "map",
    "theme": "light",
    "dataLoader": {
        "url": "/directory_to_json_file/json_file.json",
        "postProcess": function(data) {
            var dataProvider = {
                "map": "worldLow"
            };
        }
    },
...
}

i want to insert the json file after loading worldLow map and add lines latitude and longitude and animations from the external json file.

json_file

{
 map: "worldLow",
  getAreasFromMap: true,
  linkToObject: "london",
  images: [{
    id: "london",
    color: "#000000",
    type: "circle",
    title: "London",
    latitude: 51.5002,
    longitude: -0.1262,
    scale: 1.5,
    zoomLevel: 1.74,
    lines: [{
      latitudes: [51.5002, 37.483577],
      longitudes: [-0.1262, -89.824219]
    }]
  },
    {
      svgPath: pcSVG,
      title: "London",
      latitude: 51.5002,
      longitude: -0.1262
    },
    {
      svgPath: pcSVG,
      title: "Prague",
      latitude: 37.483577,
      longitude: -89.824219
    }

  ]
}

it alerts error.

Body:
In addition to quoting your properties, you can't pass variables into your JSON. You need to expand the instances of pcSVG the SVG string the variable represents. Using the target SVG from the animation across lines demo:

{
        "map": "worldLow",
        "getAreasFromMap": true,
        "linkToObject": "london",
        "images": [{
                "id": "london",
                "color": "#000000",
                "type": "circle",
                "title": "London",
                "latitude": 51.5002,
                "longitude": -0.1262,
                "scale": 1.5,
                "zoomLevel": 1.74,
                "lines": [{
                        "latitudes": [51.5002, 37.483577],
                        "longitudes": [-0.1262, -89.824219]
                }]
        }, {
                "svgPath": "M9,0C4.029,0,0,4.029,0,9s4.029,9,9,9s9-4.029,9-9S13.971,0,9,0z M9,15.93 c-3.83,0-6.93-3.1-6.93-6.93S5.17,2.07,9,2.07s6.93,3.1,6.93,6.93S12.83,15.93,9,15.93 M12.5,9c0,1.933-1.567,3.5-3.5,3.5S5.5,10.933,5.5,9S7.067,5.5,9,5.5 S12.5,7.067,12.5,9z",
                "title": "London",
                "latitude": 51.5002,
                "longitude": -0.1262
        }, {
                "svgPath": "M9,0C4.029,0,0,4.029,0,9s4.029,9,9,9s9-4.029,9-9S13.971,0,9,0z M9,15.93 c-3.83,0-6.93-3.1-6.93-6.93S5.17,2.07,9,2.07s6.93,3.1,6.93,6.93S12.83,15.93,9,15.93 M12.5,9c0,1.933-1.567,3.5-3.5,3.5S5.5,10.933,5.5,9S7.067,5.5,9,5.5 S12.5,7.067,12.5,9z",
                "title": "Prague",
                "latitude": 37.483577,
                "longitude": -89.824219
        }]
}

Demo

Also note that you don't need the postProcess callback if you're returning the correct map dataProvider object. postProcess is only needed if you're returning something that isn't compatible and need to convert your data into something the map library understands, so your postProcess call is unnecessary.


问:
Error loading PHP modules
I'm running PHP 5.2.8 on Apache 2.2.11 on Windows XP SP 3. In php.ini,

```<code>extension_dir = "C:\Program Files\PHP\ext"
extension=php_mysql.dll
</code>```

In error.log:

```<code>PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\ext\\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0
</code>```

php_mysql.dll is definately located in the extension_dir, and is the version that PHP 5.2.8 is bundled with. What's up?

答:
You could try

extension_dir = "C:/Program Files/PHP/ext"

Edit: No, not that. Seems you need to add it to the PATH variable in Windows: http://us2.php.net/manual/en/install.windows.iis.php

ContentLicense: CC BY-SA 2.5

Title: Error loading PHP modules

Body:
I'm running PHP 5.2.8 on Apache 2.2.11 on Windows XP SP 3. In php.ini,

extension_dir = "C:\Program Files\PHP\ext"
extension=php_mysql.dll

In error.log:

PHP Warning:  PHP Startup: Unable to load dynamic library 'C:\\Program Files\\PHP\\ext\\php_mysql.dll' - The specified module could not be found.\r\n in Unknown on line 0

php_mysql.dll is definately located in the extension_dir, and is the version that PHP 5.2.8 is bundled with. What's up?

OwnerDisplayName: Erik


问:
How to handle dynamically changing JSESSIONID at server
We have a cloud environment which contains multiple load balances and tomcat servers serving single web application (single page application written in angularjs, spring-mvc and java).

Due to some unknown issue in network configuration even after enabling session persistence, I observed that the JSESSIONID cookie keeps on changing between subsequent requests.

This causes the login and authentication information to be lost since the values are stored as auth keys in session object.

What is the best practice to handle changing JSESSIONID at server side?

答:
It appears that you can never trust JSESSIONID on the server side in your cloud setup; so abandon it.

Instead use a database (shared between all servers) to store the session information.

Use userid or something like it (perhaps a UUID that you generate when they login) to identify the session in the database.

Track a "validUntil" datetime value in the database for each session,
update it every time a user accesses the session (both read and write);
this is how you will implement session timeout.

When accessing the session,
if now is after validUntil,
then the session has timed out.


问:
Pass additional arguments to the callback function in Celery chord
I need to pass additional arguments to my callback function in celery chords. (Celery version : 4.1.0 (latentcall) and Python 2.7)

Consider the below sample:

program.py

```<code>from tasks import get_stock_info, call_back
from celery import group, chord

def chord_queue():
    header = (get_stock_info.subtask((delay,)) for delay in [4, 5, 4])
    callback = call_back.subtask()
    header1 = (get_stock_info.subtask((delay,)) for delay in [4, 4, 4])
    res = chord(header,queue='susanoo_dev')(callback)
    res1 = chord(header1,queue='susanoo_core')(callback)
    print(res.get())
    print(res1.get())
    print("We are done")

if __name__ == '__main__':
    chord_queue()
</code>```

tasks.py

```<code>from pandas_datareader import data
from celery_app import app
import time

@app.task
def get_stock_info(delay):
    print('hello Celery--------')
    time.sleep(delay)
    print('Whats up')
    return 10

@app.task
def call_back(num):
    print("Everything is done------")
    print("Everything is done------")
    return sum(num)
</code>```

celery_app.py

```<code>from celery import Celery
from kombu import Queue

app = Celery('tasks', broker='amqp://my_user:my_pass@localhost/my_vhost', backend='redis://localhost:6379/0')

CELERY_CONFIG = {
    'CELERY_DEFAULT_QUEUE': 'default',
    'CELERY_QUEUES': (Queue('dev'), Queue('core'),)
}

app.conf.update(**CELERY_CONFIG)
</code>```

Now in this case, when the chord gets called and after all the 3 get_stock_info tasks are done, the call_back gets called, to which the value 10, which is the return value from the get_stock_info gets passed automatically.
Now along with the return values I would also want to pass an additional argument say a string as "abcd" to the callback function.

How do I do it ?

I have already tried doing this as suggested on some blogs/SO answers etc.

program.py

```<code>def chord_queue():
    header = (get_stock_info.subtask((delay,)) for delay in [4, 5, 4])
    callback = call_back.subtask(kwargs={'my_str' : 'abcd'})
    header1 = (get_stock_info.subtask((delay,)) for delay in [4, 4, 4])
    res = chord(header,queue='susanoo_dev' )(callback)
    res1 = chord(header1,queue='susanoo_core')(callback)
    print(res.get())
    print(res1.get())
    print("We are done")
</code>```

tasks.py

```<code>@app.task
def call_back(num, my_str):
    print("Everything is done------")
    print("Everything is done------")
    print my_str
    return my_str, sum(num)
</code>```

But this does not seem to work and throws the following error:

celery.backends.base.ChordError: Callback error: TypeError("call_back() got an unexpected keyword argument 'my_str'",)

答:
Got the answer. Thanks to a friend who helped me out with it.
All that was being done wrong in the above solution was to not define my_str as a keyword argument in the definition of the call_back().

So the working solution would be:

program.py

```<code>def chord_queue():
    header = (get_stock_info.subtask((delay,)) for delay in [4, 5, 4])
    callback = call_back.subtask(kwargs={'my_str' : 'abcd'})
    header1 = (get_stock_info.subtask((delay,)) for delay in [4, 4, 4])
    res = chord(header,queue='susanoo_dev' )(callback)
    res1 = chord(header1,queue='susanoo_core')(callback)
    print(res.get())
    print(res1.get())
    print("We are done")
</code>```

task.py

```<code>@app.task
def call_back(num, my_str=None):
    print("Everything is done------")
    print("Everything is done------")
    print my_str
    return my_str, sum(num)
</code>```

And it works as expected without any issues.

Body:
I need to pass additional arguments to my callback function in celery chords. (Celery version : 4.1.0 (latentcall) and Python 2.7)

Consider the below sample:

program.py

from tasks import get_stock_info, call_back
from celery import group, chord

def chord_queue():
    header = (get_stock_info.subtask((delay,)) for delay in [4, 5, 4])
    callback = call_back.subtask()
    header1 = (get_stock_info.subtask((delay,)) for delay in [4, 4, 4])
    res = chord(header,queue='susanoo_dev')(callback)
    res1 = chord(header1,queue='susanoo_core')(callback)
    print(res.get())
    print(res1.get())
    print("We are done")

if __name__ == '__main__':
    chord_queue()

tasks.py

from pandas_datareader import data
from celery_app import app
import time

@app.task
def get_stock_info(delay):
    print('hello Celery--------')
    time.sleep(delay)
    print('Whats up')
    return 10

@app.task
def call_back(num):
    print("Everything is done------")
    print("Everything is done------")
    return sum(num)

celery_app.py

from celery import Celery
from kombu import Queue

app = Celery('tasks', broker='amqp://my_user:my_pass@localhost/my_vhost', backend='redis://localhost:6379/0')

CELERY_CONFIG = {
    'CELERY_DEFAULT_QUEUE': 'default',
    'CELERY_QUEUES': (Queue('dev'), Queue('core'),)
}

app.conf.update(**CELERY_CONFIG)

Now in this case, when the chord gets called and after all the 3 get_stock_info tasks are done, the call_back gets called, to which the value 10, which is the return value from the get_stock_info gets passed automatically.
Now along with the return values I would also want to pass an additional argument say a string as "abcd" to the callback function.

How do I do it ?

I have already tried doing this as suggested on some blogs/SO answers etc.

program.py

def chord_queue():
    header = (get_stock_info.subtask((delay,)) for delay in [4, 5, 4])
    callback = call_back.subtask(kwargs={'my_str' : 'abcd'})
    header1 = (get_stock_info.subtask((delay,)) for delay in [4, 4, 4])
    res = chord(header,queue='susanoo_dev' )(callback)
    res1 = chord(header1,queue='susanoo_core')(callback)
    print(res.get())
    print(res1.get())
    print("We are done")

tasks.py

@app.task
def call_back(num, my_str):
    print("Everything is done------")
    print("Everything is done------")
    print my_str
    return my_str, sum(num)

But this does not seem to work and throws the following error:

celery.backends.base.ChordError: Callback error: TypeError("call_back() got an unexpected keyword argument 'my_str'",)

Body:
Got the answer. Thanks to a friend who helped me out with it.
All that was being done wrong in the above solution was to not define my_str as a keyword argument in the definition of the call_back().

So the working solution would be:

program.py

def chord_queue():
    header = (get_stock_info.subtask((delay,)) for delay in [4, 5, 4])
    callback = call_back.subtask(kwargs={'my_str' : 'abcd'})
    header1 = (get_stock_info.subtask((delay,)) for delay in [4, 4, 4])
    res = chord(header,queue='susanoo_dev' )(callback)
    res1 = chord(header1,queue='susanoo_core')(callback)
    print(res.get())
    print(res1.get())
    print("We are done")

task.py

@app.task
def call_back(num, my_str=None):
    print("Everything is done------")
    print("Everything is done------")
    print my_str
    return my_str, sum(num)

And it works as expected without any issues.


问:
R, analyzing a data set with a large parameter space and replicates
I've run experiments whereby I use a parameter combination, collect the average forces and torques (in the x,y, and z directions). I do four replicates for each parameter combo, and I have 432 parameter combinations in total.

The actual dataset is a bit too big to include here, so I've made a subset for testing purposes and uploaded it to dropbox, along with the relevant R script.

Here is a heavily parsed version:

```<code>> data2[1:20,1:8]
# A tibble: 20 x 8
   `Foil Color` `Flow Speed (rpm)` `Frequency (Hz)` StepTime Maxpress Minpress `Minpress Percentage`      FxMean
         <fctr>             <fctr>           <fctr>   <fctr>   <fctr>    <int>            <fctr>       <dbl>
 1        Black                  0             0.25      250       50        0                 0 0.014537062
 2        Black                  0             0.25      250       50        0                 0 0.014870256
 3        Black                  0             0.25      250       50        0                 0 0.013180870
 4        Black                  0             0.25      250       50        0                 0 0.013448804
 5        Black                  0             0.25      250       50        3              0.05 0.012996979
 6        Black                  0             0.25      250       50        3              0.05 0.012115166
 7        Black                  0             0.25      250       50        3              0.05 0.012427347
 8        Black                  0             0.25      250       50        3              0.05 0.012561253
 9        Black                  0             0.25      250       50        5               0.1 0.012480644
10        Black                  0             0.25      250       50        5               0.1 0.011603403
11        Black                  0             0.25      250       50        5               0.1 0.011427116
12        Black                  0             0.25      250       50        5               0.1 0.011545803
13        Black                  0             0.25      250       50       13              0.25 0.009891865
14        Black                  0             0.25      250       50       13              0.25 0.008465604
15        Black                  0             0.25      250       50       13              0.25 0.009089619
16        Black                  0             0.25      250       50       13              0.25 0.008560160
17        Black                  0             0.25      250       75        0                 0 0.025101186
18        Black                  0             0.25      250       75        0                 0 0.023611920
19        Black                  0             0.25      250       75        0                 0 0.026276007
20        Black                  0             0.25      250       75        0                 0 0.026593895
</code>```

I am trying to group the data by the parameter combinations and calculate the average FxMean, sd, and se, for that group of 4 replicates.

I have tried to follow tutorials and other examples where people try to summarize the data (example), but it doesn't work for me. It normally spits out an array that looks nothing like what I need.

For example:

```<code>fx_data2 <- ddply(data_csv, c(data_csv$`Frequency (Hz)`,data_csv$`Flow Speed (rpm)`, data_csv$StepTime, data_csv$Maxpress, data_csv$`Minpress Percentage`), summarise,
N    = length(data_csv$FxMean),
mean = mean(data_csv$FxMean),
sd   = sd(data_csv$FxMean),
se   = sd / sqrt(N)
</code>```

)

```<code>fx_data3 <- summaryBy(FxMean ~freq + foilColor+maxP+minPP, data=data_csv, FUN=c(length, mean, sd))
</code>```

fx_data2 looks just...abyssmal.

```<code>head(fx_data2)
....
Foil Color.2530 Foil Color.2531 Foil Length.2512 Foil Length.2513 Foil
Length.2514 Foil Length.2515 Flow Speed (rpm).2544 Flow Speed (rpm).2545
Flow Speed (rpm).2546 Flow Speed (rpm).2547 Frequency (Hz).800 Frequency
(Hz).801 Frequency (Hz).802 Frequency (Hz).803 Foil Color.2532 Foil Color.2533
Foil Color.2534 Foil Color.2535 Foil Length.2516 Foil Length.2517 Foil
Length.2518 Foil Length.2519 Flow Speed (rpm).2548 Flow Speed (rpm).2549
Flow Speed (rpm).2550 Flow Speed (rpm).2551 Frequency (Hz).804 Frequency
(Hz).805 Frequency (Hz).806 Frequency (Hz).807 Foil Color.2536 Foil Color.2537
</code>```

I mean. I have no idea what's going on with that. The dimensions are 24x8724. Just...what.

and fx_data3 looks like this:

```<code>> fx_data3
  FxMean.length FxMean.mean  FxMean.sd
 1          1744  0.01379712 0.01423244
>
</code>```

Ideally, these would look like the original data set, but each parameter combination is compressed to a single line, and the values on the far right would be the mean, sd, and se for the FxMean, FxStDev, etc. for the four replicates.

I've been struggling with this for a few days. I'd greatly appreciate some help.

Thank you,
Zane

Body:
I've run experiments whereby I use a parameter combination, collect the average forces and torques (in the x,y, and z directions). I do four replicates for each parameter combo, and I have 432 parameter combinations in total.

The actual dataset is a bit too big to include here, so I've made a subset for testing purposes and uploaded it to dropbox, along with the relevant R script.

Here is a heavily parsed version:

> data2[1:20,1:8]
# A tibble: 20 x 8
   `Foil Color` `Flow Speed (rpm)` `Frequency (Hz)` StepTime Maxpress Minpress `Minpress Percentage`      FxMean
         <fctr>             <fctr>           <fctr>   <fctr>   <fctr>    <int>            <fctr>       <dbl>
 1        Black                  0             0.25      250       50        0                 0 0.014537062
 2        Black                  0             0.25      250       50        0                 0 0.014870256
 3        Black                  0             0.25      250       50        0                 0 0.013180870
 4        Black                  0             0.25      250       50        0                 0 0.013448804
 5        Black                  0             0.25      250       50        3              0.05 0.012996979
 6        Black                  0             0.25      250       50        3              0.05 0.012115166
 7        Black                  0             0.25      250       50        3              0.05 0.012427347
 8        Black                  0             0.25      250       50        3              0.05 0.012561253
 9        Black                  0             0.25      250       50        5               0.1 0.012480644
10        Black                  0             0.25      250       50        5               0.1 0.011603403
11        Black                  0             0.25      250       50        5               0.1 0.011427116
12        Black                  0             0.25      250       50        5               0.1 0.011545803
13        Black                  0             0.25      250       50       13              0.25 0.009891865
14        Black                  0             0.25      250       50       13              0.25 0.008465604
15        Black                  0             0.25      250       50       13              0.25 0.009089619
16        Black                  0             0.25      250       50       13              0.25 0.008560160
17        Black                  0             0.25      250       75        0                 0 0.025101186
18        Black                  0             0.25      250       75        0                 0 0.023611920
19        Black                  0             0.25      250       75        0                 0 0.026276007
20        Black                  0             0.25      250       75        0                 0 0.026593895

I am trying to group the data by the parameter combinations and calculate the average FxMean, sd, and se, for that group of 4 replicates.

I have tried to follow tutorials and other examples where people try to summarize the data (example), but it doesn't work for me. It normally spits out an array that looks nothing like what I need.

For example:

fx_data2 <- ddply(data_csv, c(data_csv$`Frequency (Hz)`,data_csv$`Flow Speed (rpm)`, data_csv$StepTime, data_csv$Maxpress, data_csv$`Minpress Percentage`), summarise,
N    = length(data_csv$FxMean),
mean = mean(data_csv$FxMean),
sd   = sd(data_csv$FxMean),
se   = sd / sqrt(N)

)

fx_data3 <- summaryBy(FxMean ~freq + foilColor+maxP+minPP, data=data_csv, FUN=c(length, mean, sd))

fx_data2 looks just...abyssmal.

head(fx_data2)
....
Foil Color.2530 Foil Color.2531 Foil Length.2512 Foil Length.2513 Foil
Length.2514 Foil Length.2515 Flow Speed (rpm).2544 Flow Speed (rpm).2545
Flow Speed (rpm).2546 Flow Speed (rpm).2547 Frequency (Hz).800 Frequency
(Hz).801 Frequency (Hz).802 Frequency (Hz).803 Foil Color.2532 Foil Color.2533
Foil Color.2534 Foil Color.2535 Foil Length.2516 Foil Length.2517 Foil
Length.2518 Foil Length.2519 Flow Speed (rpm).2548 Flow Speed (rpm).2549
Flow Speed (rpm).2550 Flow Speed (rpm).2551 Frequency (Hz).804 Frequency
(Hz).805 Frequency (Hz).806 Frequency (Hz).807 Foil Color.2536 Foil Color.2537

I mean. I have no idea what's going on with that. The dimensions are 24x8724. Just...what.

and fx_data3 looks like this:

> fx_data3
  FxMean.length FxMean.mean  FxMean.sd
 1          1744  0.01379712 0.01423244
>

Ideally, these would look like the original data set, but each parameter combination is compressed to a single line, and the values on the far right would be the mean, sd, and se for the FxMean, FxStDev, etc. for the four replicates.

I've been struggling with this for a few days. I'd greatly appreciate some help.

Thank you,
Zane

Body:
url <- "https://www.dropbox.com/sh/vhf39uz4pol7sgl/AAAJ9Fr6OTEIgb_ZeSno-X5ea?dl=1"
download.file(url, destfile = "from-SO-via-dropbox")
unzip("from-SO-via-dropbox")
df <- readr::read_csv("Data_subset.csv")

library(dplyr)

df %>%
  group_by(`Frequency (Hz)`, `Foil Color`, StepTime, Maxpress, `Minpress Percentage`) %>%
  summarise_at(vars(FxMean), funs(N = length, mean, sd, se = sd(.) / sqrt(N)))

# # A tibble: 13 x 9
# # Groups:   Frequency (Hz), Foil Color, StepTime, Maxpress [?]
#    `Frequency (Hz)` `Foil Color` StepTime Maxpress `Minpress Percentage`     N        mean           sd           se
#               <dbl>        <chr>    <int>    <int>                 <dbl> <int>       <dbl>        <dbl>        <dbl>
#  1             0.25        Black      250       50                  0.00     4 0.014009248 0.0008206156 0.0004103078
#  2             0.25        Black      250       50                  0.05     4 0.012525186 0.0003658681 0.0001829340
#  3             0.25        Black      250       50                  0.10     4 0.011764241 0.0004832082 0.0002416041
#  4             0.25        Black      250       50                  0.25     4 0.009001812 0.0006538297 0.0003269149
#  5             0.25        Black      250       75                  0.00     4 0.025395752 0.0013514463 0.0006757231
#  6             0.25        Black      250       75                  0.05     4 0.020794212 0.0028703242 0.0014351621
#  7             0.25        Black      250       75                  0.10     4 0.018409500 0.0037305138 0.0018652569
#  8             0.25        Black      250       75                  0.25     4 0.016193536 0.0016200530 0.0008100265
#  9             0.25        Black      250      100                  0.00     4 0.035485324 0.0052513208 0.0026256604
# 10             0.25        Black      250      100                  0.05     4 0.050097709 0.0024123653 0.0012061827
# 11             0.25        Black      250      100                  0.10     4 0.051378181 0.0049857712 0.0024928856
# 12             0.25        Black      250      100                  0.25     4 0.039374874 0.0031421884 0.0015710942
# 13             0.50        Black      250       50                  0.00     2 0.014778494 0.0004683882 0.0003312005


问:
How to search for an entry by comparing two dates in Laravel?
I have a table with a column varchar "date_start" and a column varchar "date_end".

Here's an example of a date stored inside :

2016-01-05 00:00:00

I would like to collect all the elements between two dates. I tried this, but it does not work:

```<code>$dateStart = $request->get('date_start'); // Return 1990-01-01
$dateEnd = $request->get('date_end'); // Return 2017-12-06

$query = Event::published();

if ($dateStart != '') { $query->where('date_start', '<=', $dateStart); };
if ($dateEnd != '') { $query->where('date_end', '>=', $dateEnd); };

$items = $query->get();
</code>```

The returned query :

select * from `events` where `status` = 'PUBLIÉE' and `date_start` <= '1990-01-01' and `date_end` >= '2017-12-06' order by `updated_at` desc`

答:
This should work</p>

```<code>$query->where('date_start', '>', $dateStart)->where('date_end', '<=', $dateEnd)->get();
</code>```

Body:
I have a table with a column varchar "date_start" and a column varchar "date_end".

Here's an example of a date stored inside :

2016-01-05 00:00:00

I would like to collect all the elements between two dates. I tried this, but it does not work:

$dateStart = $request->get('date_start'); // Return 1990-01-01
$dateEnd = $request->get('date_end'); // Return 2017-12-06

$query = Event::published();

if ($dateStart != '') { $query->where('date_start', '<=', $dateStart); };
if ($dateEnd != '') { $query->where('date_end', '>=', $dateEnd); };

$items = $query->get();

The returned query :

select * from `events` where `status` = 'PUBLIÉE' and `date_start` <= '1990-01-01' and `date_end` >= '2017-12-06' order by `updated_at` desc`

Body:
This should work

$query->where('date_start', '>', $dateStart)->where('date_end', '<=', $dateEnd)->get();


问:
How would I change an equation to modulate a number on a line, to one that that modulates on a sine curve?
I'm trying to modulate an alpha value in a Java application I'm building on Android. Right now it goes like this:

```<code>if (goingUp) {
    newAlpha = oldAlpha + rateOfChange;
    if (newAlpha > maxAlpha) {
        newAlpha = maxAlpha;
        goingUp = false;
    }
} else {
    newAlpha = oldAlpha - rateOfChange;
    if (newAlpha < minAlpha) {
        newAlpha = minAlpha;
        goingUp = true;
    }
}
</code>```

Where rateOfChange is an arbitrary int that cannot be greater than maxAlpha. The equation is evaluate every tick in a thread and is independent of time.

Is there a way using only the variables given + Math.PI and other Math elements (I'm assuming Math.Sine will be in there) to get newAlpha to be a number on a Sine?

I'm thinking min and max would be the amp of the wave and rateOfChange would be a product of the Sine function, I just can't figure out how it all goes together.

答:
Why don't you consider this?

...at the top of your class definition, include:-

```<code>import java.lang.*;
</code>```

...and within your function, after the assignment to newAlpha,

```<code>newAlpha = Math.sin(newAlpha%(2*Math.PI));
</code>```

if you would like newAlpha to be in the range [-1,1] as the sin() function is

OR

...within your function, after the assignment to newAlpha,

```<code>newAlpha = Math.asin(newAlpha%3 - 1);
</code>```

if you would like newAlpha to be in the range [-1,1] as the sin() function is

I'm not sure what datatype your newAlpha is, but I'm going to assume it will not affect the answer for this expression - like newAlpha is of type double.

It is generally the way to get a number within a certain range that you apply modulus to whatever expression you have ie. expr%N results in a number in range [0,N-1].

Hope this helps.

Body:
I'm trying to modulate an alpha value in a Java application I'm building on Android. Right now it goes like this:

if (goingUp) {
    newAlpha = oldAlpha + rateOfChange;
    if (newAlpha > maxAlpha) {
        newAlpha = maxAlpha;
        goingUp = false;
    }
} else {
    newAlpha = oldAlpha - rateOfChange;
    if (newAlpha < minAlpha) {
        newAlpha = minAlpha;
        goingUp = true;
    }
}

Where rateOfChange is an arbitrary int that cannot be greater than maxAlpha. The equation is evaluate every tick in a thread and is independent of time.

Is there a way using only the variables given + Math.PI and other Math elements (I'm assuming Math.Sine will be in there) to get newAlpha to be a number on a Sine?

I'm thinking min and max would be the amp of the wave and rateOfChange would be a product of the Sine function, I just can't figure out how it all goes together.

Body:
Why don't you consider this?

...at the top of your class definition, include:-

import java.lang.*;

...and within your function, after the assignment to newAlpha,

newAlpha = Math.sin(newAlpha%(2*Math.PI));

if you would like newAlpha to be in the range [-1,1] as the sin() function is

OR

...within your function, after the assignment to newAlpha,

newAlpha = Math.asin(newAlpha%3 - 1);

if you would like newAlpha to be in the range [-1,1] as the sin() function is

I'm not sure what datatype your newAlpha is, but I'm going to assume it will not affect the answer for this expression - like newAlpha is of type double.

It is generally the way to get a number within a certain range that you apply modulus to whatever expression you have ie. expr%N results in a number in range [0,N-1].

Hope this helps.


问:
Sqlalchemy Unexpected Cascading Delete in Flask Application
I'm getting a strage cascading delete (that I haven't configured) when I delete an item from my database. The category entry corresponding to the deleted item is deleted. How do I stop this from happening?

Here's my database setup:

```<code>from sqlalchemy import Column, ForeignKey, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine

Base = declarative_base()

class User(Base):
    """Object holding information about individual registered users"""

    __tablename__ = 'user'
    id = Column(Integer, primary_key=True)
    name = Column(String(250), nullable=False)
    email = Column(String(250), nullable=False)
    picture = Column(String(250))

class Category(Base):
    """Object holding information about item categories"""

    __tablename__ = 'category'
    id = Column(Integer, primary_key=True)
    name = Column(String(250), nullable=False)

class Item(Base):
    """Object holding information about individual catalog items"""

    __tablename__ = 'item'
    id = Column(Integer, primary_key=True)
    name = Column(String(250), nullable=False)
    description = Column(String(5000), nullable=False)
    category_id = Column(Integer, ForeignKey('category.id'))
    category = relationship("Category")
    user_id = Column(Integer, ForeignKey('user.id'))
    user = relationship("User")

engine = create_engine('postgresql+psycopg2://********:********'
                       + '/itemcatalog.db', echo=False)
Base.metadata.create_all(engine)
</code>```

Here's the code the triggers the delete:

```<code>@app.route('/item/<int:item_id>/delete/', methods=['GET', 'POST'])

def delete_item(item_id):
    item = session.query(Item).filter_by(id=item_id).one()

    if request.method == 'POST':
        session.delete(item)
        session.commit()
        flash('Item Successfully Deleted')
        return redirect(url_for('show_catalog'))
    else:
        return render_template('deleteitem.html', item=item,
                               username=login_session['username'],
                               picture=login_session['picture'])
</code>```

The expected behavior is for only the item specified by its "id" to be deleted, and for there to be no changes to the other tables.

The actual result I get is for the item to be deleted, and the entry in the category table corresponding to this item is also deleted.

UPDATE:

The steps I'm taking are:

Creating a new item in the database

Deleting that item

The logs that show this, (and the delete) follow.

Adding the new item:

```<code>2017-12-06 19:32:16 UTC [5383-22] vagrant@itemcatalog.db LOG:  statement: SELECT category.id AS category_id, category.name AS category_name
    FROM category
2017-12-06 19:32:16 UTC [5383-23] vagrant@itemcatalog.db LOG:  statement: INSERT INTO item (name, description, category_id, user_id) VALUES ('Coffee', 'tasty beverage', 3, 2) RETURNING item.id
2017-12-06 19:32:16 UTC [5383-24] vagrant@itemcatalog.db LOG:  statement: COMMIT
2017-12-06 19:32:16 UTC [5383-25] vagrant@itemcatalog.db LOG:  statement: BEGIN
2017-12-06 19:32:16 UTC [5383-26] vagrant@itemcatalog.db LOG:  statement: SELECT category.id AS category_id, category.name AS category_name
    FROM category ORDER BY category.name ASC
2017-12-06 19:32:16 UTC [5383-27] vagrant@itemcatalog.db LOG:  statement: SELECT item.id AS item_id, item.name AS item_name, item.description AS item_description, item.category_id AS item_category_id, item.user_id AS item_user_id
    FROM item ORDER BY item.name ASC
</code>```

Deleting the new item:

```<code>2017-12-06 19:33:14 UTC [5383-30] vagrant@itemcatalog.db LOG:  statement: SELECT item.id AS item_id, item.name AS item_name, item.description AS item_description, item.category_id AS item_category_id, item.user_id AS item_user_id
    FROM item
    WHERE item.id = 7
2017-12-06 19:33:14 UTC [5383-31] vagrant@itemcatalog.db LOG:  statement: SELECT category.id AS category_id, category.name AS category_name
    FROM category
    WHERE category.id = 3
2017-12-06 19:33:14 UTC [5383-32] vagrant@itemcatalog.db LOG:  statement: SELECT item.id AS item_id, item.name AS item_name, item.description AS item_description, item.category_id AS item_category_id, item.user_id AS item_user_id
    FROM item
    WHERE 3 = item.category_id
2017-12-06 19:33:14 UTC [5383-33] vagrant@itemcatalog.db LOG:  statement: UPDATE item SET category_id=NULL WHERE item.id = 5
2017-12-06 19:33:14 UTC [5383-34] vagrant@itemcatalog.db LOG:  statement: UPDATE item SET category_id=NULL WHERE item.id = 6
2017-12-06 19:33:14 UTC [5383-35] vagrant@itemcatalog.db LOG:  statement: DELETE FROM item WHERE item.id = 7
2017-12-06 19:33:14 UTC [5383-36] vagrant@itemcatalog.db LOG:  statement: DELETE FROM category WHERE category.id = 3
2017-12-06 19:33:14 UTC [5383-37] vagrant@itemcatalog.db LOG:  statement: COMMIT
2017-12-06 19:33:14 UTC [5383-38] vagrant@itemcatalog.db LOG:  statement: BEGIN
2017-12-06 19:33:14 UTC [5383-39] vagrant@itemcatalog.db LOG:  statement: SELECT category.id AS category_id, category.name AS category_name
    FROM category ORDER BY category.name ASC
2017-12-06 19:33:14 UTC [5383-40] vagrant@itemcatalog.db LOG:  statement: SELECT item.id AS item_id, item.name AS item_name, item.description AS item_description, item.category_id AS item_category_id, item.user_id AS item_user_id
    FROM item ORDER BY item.name ASC
</code>```

From the logs I can see its not behaving the way I want it to, but I'm at a loss as to what to change to stop this behavior.

答:
I cannot reproduce the behavior you have described.  If I put your database setup into model.py and then run the following:

```<code>from model import engine, User, Category, Item
from sqlalchemy.orm import sessionmaker
Session = sessionmaker(bind=engine)

s = Session()

c = Category(id=1, name='Misc')
u = User(id=1, name='example', email='example@example.com')

s.add(c)
s.add(u)
s.commit()

i1 = Item(id=1, name='foo', description='foo desc', category=c,
          user=u)
i2 = Item(id=2, name='bar', description='bar desc', category=c,
          user=u)

s.add(i1)
s.add(i2)
s.commit()
</code>```

And then subsequently delete one of the items:

```<code>>>> item = s.query(Item).filter_by(id=2).one()
2017-12-06 12:11:34,608 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2017-12-06 12:11:34,609 INFO sqlalchemy.engine.base.Engine SELECT item.id AS item_id, item.name AS item_name, item.description AS item_description, item.category_id AS item_category_id, item.user_id AS item_user_id
FROM item
WHERE item.id = %(id_1)s
2017-12-06 12:11:34,609 INFO sqlalchemy.engine.base.Engine {'id_1': 2}
>>> s.delete(item)
>>> s.commit()
2017-12-06 12:11:44,915 INFO sqlalchemy.engine.base.Engine DELETE FROM item WHERE item.id = %(id)s
2017-12-06 12:11:44,916 INFO sqlalchemy.engine.base.Engine {'id': 2}
2017-12-06 12:11:45,014 INFO sqlalchemy.engine.base.Engine COMMIT
</code>```

You can see that there is only a single DELETE statement executed by postgresql, and if we check the referenced Category still exists:

```<code>>>> s.query(Category).get(1)
2017-12-06 12:12:58,968 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2017-12-06 12:12:58,970 INFO sqlalchemy.engine.base.Engine SELECT category.id AS category_id, category.name AS category_name
FROM category
WHERE category.id = %(param_1)s
2017-12-06 12:12:58,971 INFO sqlalchemy.engine.base.Engine {'param_1': 1}
<model.Category object at 0x7f42dfab1550>
</code>```

If you are seeing different behavior, can you update your question with a specific sequence of steps that will reproduce the problem?

Body:
I'm getting a strage cascading delete (that I haven't configured) when I delete an item from my database. The category entry corresponding to the deleted item is deleted. How do I stop this from happening?

Here's my database setup:

from sqlalchemy import Column, ForeignKey, Integer, String
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine

Base = declarative_base()

class User(Base):
    """Object holding information about individual registered users"""

    __tablename__ = 'user'
    id = Column(Integer, primary_key=True)
    name = Column(String(250), nullable=False)
    email = Column(String(250), nullable=False)
    picture = Column(String(250))

class Category(Base):
    """Object holding information about item categories"""

    __tablename__ = 'category'
    id = Column(Integer, primary_key=True)
    name = Column(String(250), nullable=False)

class Item(Base):
    """Object holding information about individual catalog items"""

    __tablename__ = 'item'
    id = Column(Integer, primary_key=True)
    name = Column(String(250), nullable=False)
    description = Column(String(5000), nullable=False)
    category_id = Column(Integer, ForeignKey('category.id'))
    category = relationship("Category")
    user_id = Column(Integer, ForeignKey('user.id'))
    user = relationship("User")

engine = create_engine('postgresql+psycopg2://********:********'
                       + '/itemcatalog.db', echo=False)
Base.metadata.create_all(engine)

Here's the code the triggers the delete:

@app.route('/item/<int:item_id>/delete/', methods=['GET', 'POST'])

def delete_item(item_id):
    item = session.query(Item).filter_by(id=item_id).one()

    if request.method == 'POST':
        session.delete(item)
        session.commit()
        flash('Item Successfully Deleted')
        return redirect(url_for('show_catalog'))
    else:
        return render_template('deleteitem.html', item=item,
                               username=login_session['username'],
                               picture=login_session['picture'])

The expected behavior is for only the item specified by its "id" to be deleted, and for there to be no changes to the other tables.

The actual result I get is for the item to be deleted, and the entry in the category table corresponding to this item is also deleted.

UPDATE:

The steps I'm taking are:

Creating a new item in the database

Deleting that item

The logs that show this, (and the delete) follow.

Adding the new item:

2017-12-06 19:32:16 UTC [5383-22] vagrant@itemcatalog.db LOG:  statement: SELECT category.id AS category_id, category.name AS category_name
    FROM category
2017-12-06 19:32:16 UTC [5383-23] vagrant@itemcatalog.db LOG:  statement: INSERT INTO item (name, description, category_id, user_id) VALUES ('Coffee', 'tasty beverage', 3, 2) RETURNING item.id
2017-12-06 19:32:16 UTC [5383-24] vagrant@itemcatalog.db LOG:  statement: COMMIT
2017-12-06 19:32:16 UTC [5383-25] vagrant@itemcatalog.db LOG:  statement: BEGIN
2017-12-06 19:32:16 UTC [5383-26] vagrant@itemcatalog.db LOG:  statement: SELECT category.id AS category_id, category.name AS category_name
    FROM category ORDER BY category.name ASC
2017-12-06 19:32:16 UTC [5383-27] vagrant@itemcatalog.db LOG:  statement: SELECT item.id AS item_id, item.name AS item_name, item.description AS item_description, item.category_id AS item_category_id, item.user_id AS item_user_id
    FROM item ORDER BY item.name ASC

Deleting the new item:

2017-12-06 19:33:14 UTC [5383-30] vagrant@itemcatalog.db LOG:  statement: SELECT item.id AS item_id, item.name AS item_name, item.description AS item_description, item.category_id AS item_category_id, item.user_id AS item_user_id
    FROM item
    WHERE item.id = 7
2017-12-06 19:33:14 UTC [5383-31] vagrant@itemcatalog.db LOG:  statement: SELECT category.id AS category_id, category.name AS category_name
    FROM category
    WHERE category.id = 3
2017-12-06 19:33:14 UTC [5383-32] vagrant@itemcatalog.db LOG:  statement: SELECT item.id AS item_id, item.name AS item_name, item.description AS item_description, item.category_id AS item_category_id, item.user_id AS item_user_id
    FROM item
    WHERE 3 = item.category_id
2017-12-06 19:33:14 UTC [5383-33] vagrant@itemcatalog.db LOG:  statement: UPDATE item SET category_id=NULL WHERE item.id = 5
2017-12-06 19:33:14 UTC [5383-34] vagrant@itemcatalog.db LOG:  statement: UPDATE item SET category_id=NULL WHERE item.id = 6
2017-12-06 19:33:14 UTC [5383-35] vagrant@itemcatalog.db LOG:  statement: DELETE FROM item WHERE item.id = 7
2017-12-06 19:33:14 UTC [5383-36] vagrant@itemcatalog.db LOG:  statement: DELETE FROM category WHERE category.id = 3
2017-12-06 19:33:14 UTC [5383-37] vagrant@itemcatalog.db LOG:  statement: COMMIT
2017-12-06 19:33:14 UTC [5383-38] vagrant@itemcatalog.db LOG:  statement: BEGIN
2017-12-06 19:33:14 UTC [5383-39] vagrant@itemcatalog.db LOG:  statement: SELECT category.id AS category_id, category.name AS category_name
    FROM category ORDER BY category.name ASC
2017-12-06 19:33:14 UTC [5383-40] vagrant@itemcatalog.db LOG:  statement: SELECT item.id AS item_id, item.name AS item_name, item.description AS item_description, item.category_id AS item_category_id, item.user_id AS item_user_id
    FROM item ORDER BY item.name ASC

From the logs I can see its not behaving the way I want it to, but I'm at a loss as to what to change to stop this behavior.

Body:
I cannot reproduce the behavior you have described.  If I put your database setup into model.py and then run the following:

from model import engine, User, Category, Item
from sqlalchemy.orm import sessionmaker
Session = sessionmaker(bind=engine)

s = Session()

c = Category(id=1, name='Misc')
u = User(id=1, name='example', email='example@example.com')

s.add(c)
s.add(u)
s.commit()

i1 = Item(id=1, name='foo', description='foo desc', category=c,
          user=u)
i2 = Item(id=2, name='bar', description='bar desc', category=c,
          user=u)

s.add(i1)
s.add(i2)
s.commit()

And then subsequently delete one of the items:

>>> item = s.query(Item).filter_by(id=2).one()
2017-12-06 12:11:34,608 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2017-12-06 12:11:34,609 INFO sqlalchemy.engine.base.Engine SELECT item.id AS item_id, item.name AS item_name, item.description AS item_description, item.category_id AS item_category_id, item.user_id AS item_user_id
FROM item
WHERE item.id = %(id_1)s
2017-12-06 12:11:34,609 INFO sqlalchemy.engine.base.Engine {'id_1': 2}
>>> s.delete(item)
>>> s.commit()
2017-12-06 12:11:44,915 INFO sqlalchemy.engine.base.Engine DELETE FROM item WHERE item.id = %(id)s
2017-12-06 12:11:44,916 INFO sqlalchemy.engine.base.Engine {'id': 2}
2017-12-06 12:11:45,014 INFO sqlalchemy.engine.base.Engine COMMIT

You can see that there is only a single DELETE statement executed by postgresql, and if we check the referenced Category still exists:

>>> s.query(Category).get(1)
2017-12-06 12:12:58,968 INFO sqlalchemy.engine.base.Engine BEGIN (implicit)
2017-12-06 12:12:58,970 INFO sqlalchemy.engine.base.Engine SELECT category.id AS category_id, category.name AS category_name
FROM category
WHERE category.id = %(param_1)s
2017-12-06 12:12:58,971 INFO sqlalchemy.engine.base.Engine {'param_1': 1}
<model.Category object at 0x7f42dfab1550>

If you are seeing different behavior, can you update your question with a specific sequence of steps that will reproduce the problem?


问:
Parse Form Data in Perl to remove all non alphanumeric / punctuation
In web form entries we are seeing  strange characters being used such as:

â€™ (windows 1252 encoded)

or

ðŸ’• (emoji)

or

Ã¢Â€Â¬ (no idea but think it's windows 1252)

For some of them I can use a regex to simply replace them with the utf-8 equivalent but I would prefer to use some sort of regex or encoding that efficiently removes them.

I've set the DB Table in MYSQL to utf-8

What is the best and most ideal solution for this in perl?  Or can I do it in the mysql table instead?

答:
This should remove all special characters. You can check ORD table to make sure nothing that you need gets removed.</p>

```<code>$line =~ s/(.)/(ord($1) > 127) ? "" : $1/egs;
</code>```

Body:
This should remove all special characters. You can check ORD table to make sure nothing that you need gets removed.

$line =~ s/(.)/(ord($1) > 127) ? "" : $1/egs;


问:
Project-Swift.h file not found
I have a new Swift project with a few files, I've needed to add some Objc code.

In Build Settings, my Objective-C Generated Interface Header Name is MyProject-Swift.h

Product Module Name and Product Name are both MyProject.

My Objective-C Bridging Header is MyProject/MyProject-Bridging-Header.h

The contents of my Bridging Header are:

```<code>#ifndef MyProject_Bridging_Header_h
#define MyProject_Bridging_Header_h

#import "Blakey.h"

#endif
</code>```

Blakey.h is pretty simple:

```<code>@import Foundation;

#import "MyProject-Swift.h"
@class KeyPair;

@interface Blakey: NSObject

- (void)createKeyPairForSeed:(NSString *)seed;

@end
</code>```

And Blakey.m

```<code>#import <Foundation/Foundation.h>
#import "Blakey.h"

@implementation Blakey

- (void)createKeyPairForSeed:(NSString *)seed;
{

}

@end
</code>```

(side note: I'm aware my function returns a void, that will be changed later once this issue is fixed so it returns an actual value)

Why is Xcode throwing an error at the #import "MyProject-Swift.h" in Blakey.h?

答:
Project-Swift.h is a file auto generated by Xcode on successful compilation of the project. Catch here is the word successful compilation If your project has any compilation error Project-Swift.h file will not be generated. So in a way it becomes a deadlock. Bestway comment out all the lines that have compilation error and then manage to get it compile without any errors. Only after that Project-Swift.h will be generated.

Additional information, Once the Project-Swift.h file is generated if you open it and if you happened to see that your swift class is not imported there thats because Project-Swift.h imports only the classes that extends from NSObject So plain Swift classes will not be imported.

ISSUE:

You need to import Project-Swift.h in .m file and not .h file. So modify your Blakey as

```<code>#import <Foundation/Foundation.h>
#import "Blakey.h"
#import "MyProject-Swift.h"

@implementation Blakey

- (void)createKeyPairForSeed:(NSString *)seed;
{

}
</code>```

Finally remove #import "MyProject-Swift.h" from Blakey.h

```<code>@import Foundation;

@class KeyPair;

@interface Blakey: NSObject

- (void)createKeyPairForSeed:(NSString *)seed;

@end
</code>```

Title: Project-Swift.h file not found

Body:
I have a new Swift project with a few files, I've needed to add some Objc code.

In Build Settings, my Objective-C Generated Interface Header Name is MyProject-Swift.h

Product Module Name and Product Name are both MyProject.

My Objective-C Bridging Header is MyProject/MyProject-Bridging-Header.h

The contents of my Bridging Header are:

#ifndef MyProject_Bridging_Header_h
#define MyProject_Bridging_Header_h

#import "Blakey.h"

#endif

Blakey.h is pretty simple:

@import Foundation;

#import "MyProject-Swift.h"
@class KeyPair;

@interface Blakey: NSObject

- (void)createKeyPairForSeed:(NSString *)seed;

@end

And Blakey.m

#import <Foundation/Foundation.h>
#import "Blakey.h"

@implementation Blakey

- (void)createKeyPairForSeed:(NSString *)seed;
{

}

@end

(side note: I'm aware my function returns a void, that will be changed later once this issue is fixed so it returns an actual value)

Why is Xcode throwing an error at the #import "MyProject-Swift.h" in Blakey.h?

Body:
Project-Swift.h is a file auto generated by Xcode on successful compilation of the project. Catch here is the word successful compilation If your project has any compilation error Project-Swift.h file will not be generated. So in a way it becomes a deadlock. Bestway comment out all the lines that have compilation error and then manage to get it compile without any errors. Only after that Project-Swift.h will be generated.

Additional information, Once the Project-Swift.h file is generated if you open it and if you happened to see that your swift class is not imported there thats because Project-Swift.h imports only the classes that extends from NSObject So plain Swift classes will not be imported.

ISSUE:

You need to import Project-Swift.h in .m file and not .h file. So modify your Blakey as

#import <Foundation/Foundation.h>
#import "Blakey.h"
#import "MyProject-Swift.h"

@implementation Blakey

- (void)createKeyPairForSeed:(NSString *)seed;
{

}

Finally remove #import "MyProject-Swift.h" from Blakey.h

@import Foundation;

@class KeyPair;

@interface Blakey: NSObject

- (void)createKeyPairForSeed:(NSString *)seed;

@end


问:
How do I center floated elements?
I'm implementing pagination, and it needs to be centered. The problem is that the links need to be displayed as block, so they need to be floated. But then, text-align: center; doesn't work on them. I could achieve it by giving the wrapper div padding of left, but every page will have a different number of pages, so that wouldn't work. Here's my code:

.pagination {
  text-align: center;
}
.pagination a {
  display: block;
  width: 30px;
  height: 30px;
  float: left;
  margin-left: 3px;
  background: url(/images/structure/pagination-button.png);
}
.pagination a.last {
  width: 90px;
  background: url(/images/structure/pagination-button-last.png);
}
.pagination a.first {
  width: 60px;
  background: url(/images/structure/pagination-button-first.png);
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class='pagination'>
  First
  1
  2
  3
  Last
</div>
<!-- end: .pagination --></code>```

To get the idea, what I want:

答:
Removing floats, and using inline-block may fix your problems:

```<code> .pagination a {
-    display: block;
+    display: inline-block;
     width: 30px;
     height: 30px;
-    float: left;
     margin-left: 3px;
     background: url(/images/structure/pagination-button.png);
 }
</code>```

(remove the lines starting with - and add the lines starting with +.)

.pagination {
  text-align: center;
}
.pagination a {
  + display: inline-block;
  width: 30px;
  height: 30px;
  margin-left: 3px;
  background: url(/images/structure/pagination-button.png);
}
.pagination a.last {
  width: 90px;
  background: url(/images/structure/pagination-button-last.png);
}
.pagination a.first {
  width: 60px;
  background: url(/images/structure/pagination-button-first.png);
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class='pagination'>
  First
  1
  2
  3
  Last
</div>
<!-- end: .pagination --></code>```

inline-block works cross-browser, even on IE6 as long as the element is originally an inline element.

Quote from quirksmode:

An inline block is placed inline (ie. on the same line as adjacent content), but it behaves as a block.

this often can effectively replace floats:

The real use of this value is when you want to give an inline element a width. In some circumstances some browsers don't allow a width on a real inline element, but if you switch to display: inline-block you are allowed to set a width.” ( http://www.quirksmode.org/css/display.html#inlineblock ).

From the W3C spec:

[inline-block] causes an element to generate an inline-level block container. The inside of an  inline-block is formatted as a block box, and the element itself is formatted as an atomic inline-level box.

ContentLicense: CC BY-SA 4.0

Title: How do I center floated elements?

Body:
I'm implementing pagination, and it needs to be centered. The problem is that the links need to be displayed as block, so they need to be floated. But then, text-align: center; doesn't work on them. I could achieve it by giving the wrapper div padding of left, but every page will have a different number of pages, so that wouldn't work. Here's my code:

.pagination {
  text-align: center;
}
.pagination a {
  display: block;
  width: 30px;
  height: 30px;
  float: left;
  margin-left: 3px;
  background: url(/images/structure/pagination-button.png);
}
.pagination a.last {
  width: 90px;
  background: url(/images/structure/pagination-button-last.png);
}
.pagination a.first {
  width: 60px;
  background: url(/images/structure/pagination-button-first.png);
}

  First
  1
  2
  3
  Last

To get the idea, what I want:

Body:
Removing floats, and using inline-block may fix your problems:

 .pagination a {
-    display: block;
+    display: inline-block;
     width: 30px;
     height: 30px;
-    float: left;
     margin-left: 3px;
     background: url(/images/structure/pagination-button.png);
 }

(remove the lines starting with - and add the lines starting with +.)

.pagination {
  text-align: center;
}
.pagination a {
  + display: inline-block;
  width: 30px;
  height: 30px;
  margin-left: 3px;
  background: url(/images/structure/pagination-button.png);
}
.pagination a.last {
  width: 90px;
  background: url(/images/structure/pagination-button-last.png);
}
.pagination a.first {
  width: 60px;
  background: url(/images/structure/pagination-button-first.png);
}

<div class='pagination'>
  <a class='first' href='#'>First</a>
  <a href='#'>1</a>
  <a href='#'>2</a>
  <a href='#'>3</a>
  <a class='last' href='#'>Last</a>
</div>
<!-- end: .pagination -->

inline-block works cross-browser, even on IE6 as long as the element is originally an inline element.

Quote from quirksmode:

An inline block is placed inline (ie. on the same line as adjacent content), but it behaves as a block.

this often can effectively replace floats:

The real use of this value is when you want to give an inline element a width. In some circumstances some browsers don't allow a width on a real inline element, but if you switch to display: inline-block you are allowed to set a width.” ( http://www.quirksmode.org/css/display.html#inlineblock ).

From the W3C spec:

[inline-block] causes an element to generate an inline-level block container. The inside of an  inline-block is formatted as a block box, and the element itself is formatted as an atomic inline-level box.


问:
ionic 3 get text from ion-textarea after clicking a button
I have an ion-textareain which user can write some content, and I would like to get this text after a button is clicked.

This is the html:

```<code><ion-row>
    <ion-item>
        <ion-textarea [(ngModel)]="myInput" (ionInput)="getItems($event)" placeholder="New Info"></ion-textarea>
    </ion-item>
</ion-row>
</code>```

```<code><button ion-button class="card-button" color="secondary"
 (click)="addInfo()"> <ion-icon name="add-circle" class="icona-bottone"></ion-
 icon>Add Info</button>
</code>```

I've tried doing this in my .ts file:

```<code>getItems(textarea) {
    // set q to the value of the textarea
    var q = textarea.srcElement.value;
    this.textSearch = q;
}
addInfo(){
    console.log("You wrote " + this.textSearch)
}
</code>```

but it prints "You wrote undefined ". What is the correct way to get the text as a string and use it?

答:
Since you have used 2-way data bind you can do as shown below.

.html

```<code><ion-row>
    <ion-item>
        <ion-textarea [(ngModel)]="myInput" placeholder="New Info"></ion-textarea>
    </ion-item>
</ion-row>
</code>```

.ts

```<code>console.log(this.myInput);//this is your textarea value
</code>```

Body:
I have an ion-textareain which user can write some content, and I would like to get this text after a button is clicked.

This is the html:

<ion-row>
    <ion-item>
        <ion-textarea [(ngModel)]="myInput" (ionInput)="getItems($event)" placeholder="New Info"></ion-textarea>
    </ion-item>
</ion-row>

<button ion-button class="card-button" color="secondary"
 (click)="addInfo()"> <ion-icon name="add-circle" class="icona-bottone"></ion-
 icon>Add Info</button>

I've tried doing this in my .ts file:

getItems(textarea) {
    // set q to the value of the textarea
    var q = textarea.srcElement.value;
    this.textSearch = q;
}
addInfo(){
    console.log("You wrote " + this.textSearch)
}

but it prints "You wrote undefined ". What is the correct way to get the text as a string and use it?

Body:
Since you have used 2-way data bind you can do as shown below.

.html

<ion-row>
    <ion-item>
        <ion-textarea [(ngModel)]="myInput" placeholder="New Info"></ion-textarea>
    </ion-item>
</ion-row>

.ts

console.log(this.myInput);//this is your textarea value


问:
String Filtering .. Any one..Contains only either of the selected characters or both
I have a array from 0 to 10000.
problem
And i need to filter only the numbers containing either 3 or 4 or both and none other than that...
eg., 3,4,33,44,333,444,343,434,334

I tried the do while technique but I have made some mistake in the code..\
I'm not getting the output still..:(
the improved code is

```<code>import java.util.*;
</code>```

import static java.lang.System.*;
public class numb {

```<code>public static void main(String[] args) {
    int num,c,cum;
    int i;
     Scanner in = new Scanner(System.in);
     out.println(3/10);

    out.println("How many elements u need to put in this array?");
    num=in.nextInt();
    int[] ray1 = new int[num];
    List<String> l1 = new LinkedList<String>();
    for (c=0;c<num;c++)
    {

        ray1[c]=c;
    }

            for(i=1;i<num;i++)
            {
         boolean baabu=true;
                do {
                    cum=ray1[i];
                    int lastdig = cum%10;
                    if(lastdig!=3||lastdig!=4)
                    {
                        baabu=false;
                    }
                    cum=cum/10;
                }
                while(cum>0&&baabu);
                if(baabu)
                {
                    String ad = String.valueOf(ray1[i]);
                    l1.add(ad);
                }

            }
            printme(l1);

}

public static void print (int[] array)
{
    for(int xc:array)
        out.println(xc);
}
public static void printme (List<String> l1)
{
    for(String yc:l1)
        out.println(yc);
}
</code>```

}

答:
Use this method for every int in the array (it worked for me):</p>

```<code>public static String myMethod(int num){

String str = String.valueOf(num);

String ns ="";
for (int i=0; i<str.length(); i++) {
if (str.substring(i, i+1).equals("3"))
{
  ns += 3;
}

if (str.substring(i, i+1).equals("4"))
{
  ns += 4;
}
}
return ns;

}
</code>```

Body:
I have a array from 0 to 10000.
problem
And i need to filter only the numbers containing either 3 or 4 or both and none other than that...
eg., 3,4,33,44,333,444,343,434,334

I tried the do while technique but I have made some mistake in the code..\
I'm not getting the output still..:(
the improved code is

import java.util.*;

import static java.lang.System.*;
public class numb {

public static void main(String[] args) {
    int num,c,cum;
    int i;
     Scanner in = new Scanner(System.in);
     out.println(3/10);

    out.println("How many elements u need to put in this array?");
    num=in.nextInt();
    int[] ray1 = new int[num];
    List<String> l1 = new LinkedList<String>();
    for (c=0;c<num;c++)
    {

        ray1[c]=c;
    }

            for(i=1;i<num;i++)
            {
         boolean baabu=true;
                do {
                    cum=ray1[i];
                    int lastdig = cum%10;
                    if(lastdig!=3||lastdig!=4)
                    {
                        baabu=false;
                    }
                    cum=cum/10;
                }
                while(cum>0&&baabu);
                if(baabu)
                {
                    String ad = String.valueOf(ray1[i]);
                    l1.add(ad);
                }

            }
            printme(l1);

}

public static void print (int[] array)
{
    for(int xc:array)
        out.println(xc);
}
public static void printme (List<String> l1)
{
    for(String yc:l1)
        out.println(yc);
}

}

Body:
Use this method for every int in the array (it worked for me):

public static String myMethod(int num){

String str = String.valueOf(num);

String ns ="";
for (int i=0; i<str.length(); i++) {
if (str.substring(i, i+1).equals("3"))
{
  ns += 3;
}

if (str.substring(i, i+1).equals("4"))
{
  ns += 4;
}
}
return ns;

}