问:
Spring Boot : Error - "Method execute from jdbcTemplate referes to missing DataAccessException"
I am new to spring boot and trying out few examples demonstrated on Spring's site.
I get above error while trying this simple example - https://spring.io/guides/gs/relational-data-access/ .

I am facing a compiler error saying - 'The method execute(String) from the type JdbcTemplate refers to the missing type DataAccessException'.

Image -

https://i.stack.imgur.com/8PL0m.jpg

I did search other resources to get rid of this issue where spring-tx/ spring.transations such jars were suggested to attach. Nothing has worked in my case.

POM.xml has following dependancy -

```<code><parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
    </parent>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Added for COnsuming Restful services guide -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <!-- Following three Added for Validating form validate with spring -->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-el</artifactId>
        </dependency>

        <!-- Following two are Added for relational data access using spring guide -->

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->

    </dependencies>

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

    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
  </pluginRepositories>
</project>
</code>```

Please help me out if anyone can ? Thanks a ton!

Updating the maven dependency tree for spring-boot-starter-jdbc:

```<code>com.kurshit.springrest:SpringRest:war:0.0.1-SNAPSHOT
+- org.springframework.boot:spring-boot-starter-web:jar:1.5.9.RELEASE:compile
|  +- org.springframework.boot:spring-boot-starter:jar:1.5.9.RELEASE:compile
|  |  +- org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:compile
|  |  |  +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  |  \- (org.springframework:spring-context:jar:4.3.13.RELEASE:compile - omitted for duplicat
|  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.9.RELEASE:compile
|  |  |  \- (org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:compile - omitted for duplica
|  |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.9.RELEASE:compile
|  |  |  +- ch.qos.logback:logback-classic:jar:1.1.11:compile
|  |  |  |  +- ch.qos.logback:logback-core:jar:1.1.11:compile
|  |  |  |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.6.6; omitted for
|  |  |  +- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
|  |  |  |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.22; omitted for
|  |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
|  |  |  |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.22; omitted for
|  |  |  \- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile
|  |  |     \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.22; omitted for
|  |  +- org.springframework:spring-core:jar:4.3.13.RELEASE:compile
|  |  \- org.yaml:snakeyaml:jar:1.17:runtime
|  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.9.RELEASE:compile
|  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.23:compile
|  |  |  \- org.apache.tomcat:tomcat-annotations-api:jar:8.5.23:compile
|  |  +- (org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.23:compile - omitted for duplicate)
|  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.23:compile
|  |     \- (org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.23:compile - omitted for duplicate
|  +- (org.hibernate:hibernate-validator:jar:5.3.6.Final:compile - omitted for duplicate)
|  +- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile - omitted for duplicate)
|  +- org.springframework:spring-web:jar:4.3.13.RELEASE:compile
|  |  +- org.springframework:spring-aop:jar:4.3.13.RELEASE:compile
|  |  |  +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  |  \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  +- org.springframework:spring-beans:jar:4.3.13.RELEASE:compile
|  |  |  \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  +- org.springframework:spring-context:jar:4.3.13.RELEASE:compile
|  |  |  +- (org.springframework:spring-aop:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  |  +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  |  +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  |  \- (org.springframework:spring-expression:jar:4.3.13.RELEASE:compile - omitted for dupli
|  |  \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  \- org.springframework:spring-webmvc:jar:4.3.13.RELEASE:compile
|     +- (org.springframework:spring-aop:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     +- (org.springframework:spring-context:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     +- org.springframework:spring-expression:jar:4.3.13.RELEASE:compile
|     |  \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     \- (org.springframework:spring-web:jar:4.3.13.RELEASE:compile - omitted for duplicate)
+- org.springframework.boot:spring-boot-starter-test:jar:1.5.9.RELEASE:test
|  +- org.springframework.boot:spring-boot-test:jar:1.5.9.RELEASE:test
|  |  \- (org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:test - omitted for duplicate)
|  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.9.RELEASE:test
|  |  +- (org.springframework.boot:spring-boot-test:jar:1.5.9.RELEASE:test - omitted for duplicat
|  |  \- (org.springframework.boot:spring-boot-autoconfigure:jar:1.5.9.RELEASE:test - omitted for
|  +- (com.jayway.jsonpath:json-path:jar:2.2.0:test - omitted for duplicate)
|  +- junit:junit:jar:4.12:test
|  |  \- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplica
|  +- org.assertj:assertj-core:jar:2.6.0:test
|  +- org.mockito:mockito-core:jar:1.10.19:test
|  |  +- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplica
|  |  \- org.objenesis:objenesis:jar:2.1:test
|  +- org.hamcrest:hamcrest-core:jar:1.3:test
|  +- org.hamcrest:hamcrest-library:jar:1.3:test
|  |  \- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplica
|  +- org.skyscreamer:jsonassert:jar:1.4.0:test
|  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
|  +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - scope updated from test; omit
|  \- org.springframework:spring-test:jar:4.3.13.RELEASE:test
|     \- (org.springframework:spring-core:jar:4.3.13.RELEASE:test - omitted for duplicate)
+- com.jayway.jsonpath:json-path:jar:2.2.0:test
|  +- net.minidev:json-smart:jar:2.2.1:test
|  |  \- net.minidev:accessors-smart:jar:1.1:test
|  |     \- org.ow2.asm:asm:jar:5.0.3:test
|  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.16; scope updated from t
+- com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile
|  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
|  \- com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile
+- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.5.9.RELEASE:compile
|  +- (org.springframework.boot:spring-boot-starter:jar:1.5.9.RELEASE:compile - omitted for dupli
|  +- (org.springframework.boot:spring-boot-starter-web:jar:1.5.9.RELEASE:compile - omitted for d
|  +- org.thymeleaf:thymeleaf-spring4:jar:2.1.6.RELEASE:compile
|  |  +- org.thymeleaf:thymeleaf:jar:2.1.6.RELEASE:compile
|  |  |  +- ognl:ognl:jar:3.0.8:compile
|  |  |  +- org.javassist:javassist:jar:3.21.0-GA:compile (version managed from 3.16.1-GA)
|  |  |  +- org.unbescape:unbescape:jar:1.1.0.RELEASE:compile
|  |  |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.6.6; omitted for dup
|  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
|  \- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.4.0:compile
|     +- org.codehaus.groovy:groovy:jar:2.4.13:compile (version managed from 2.4.3)
|     \- (org.thymeleaf:thymeleaf:jar:2.1.6.RELEASE:compile - version managed from 2.1.4.RELEASE;
+- org.hibernate:hibernate-validator:jar:5.3.6.Final:compile
|  +- javax.validation:validation-api:jar:1.1.0.Final:compile
|  +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile (version managed from 3.3.0.Final)
|  \- com.fasterxml:classmate:jar:1.3.4:compile (version managed from 1.3.1)
+- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.23:compile
+- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.9.RELEASE:compile
|  +- (org.springframework.boot:spring-boot-starter:jar:1.5.9.RELEASE:compile - omitted for dupli
|  +- org.apache.tomcat:tomcat-jdbc:jar:8.5.23:compile
|  |  \- org.apache.tomcat:tomcat-juli:jar:8.5.23:compile
|  \- org.springframework:spring-jdbc:jar:4.3.13.RELEASE:compile
|     +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     \- org.springframework:spring-tx:jar:4.3.13.RELEASE:compile
|        +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|        \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
\- com.h2database:h2:jar:1.4.196:compile
</code>```

答:
Add the following dependency (you might have to adjust the version to be compatible with your Spring Boot version)

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

Edited:
  Deleting the conflicting dependancies from maven repo got me rid of this compilation error.

Body:
I am new to spring boot and trying out few examples demonstrated on Spring's site.
I get above error while trying this simple example - https://spring.io/guides/gs/relational-data-access/ .

I am facing a compiler error saying - 'The method execute(String) from the type JdbcTemplate refers to the missing type DataAccessException'.

Image -

https://i.stack.imgur.com/8PL0m.jpg

I did search other resources to get rid of this issue where spring-tx/ spring.transations such jars were suggested to attach. Nothing has worked in my case.

POM.xml has following dependancy -

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

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.jayway.jsonpath</groupId>
            <artifactId>json-path</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-el</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>

    </dependencies>

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

    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
  </pluginRepositories>
</project>

Please help me out if anyone can ? Thanks a ton!

Updating the maven dependency tree for spring-boot-starter-jdbc:

com.kurshit.springrest:SpringRest:war:0.0.1-SNAPSHOT
+- org.springframework.boot:spring-boot-starter-web:jar:1.5.9.RELEASE:compile
|  +- org.springframework.boot:spring-boot-starter:jar:1.5.9.RELEASE:compile
|  |  +- org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:compile
|  |  |  +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  |  \- (org.springframework:spring-context:jar:4.3.13.RELEASE:compile - omitted for duplicat
|  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.5.9.RELEASE:compile
|  |  |  \- (org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:compile - omitted for duplica
|  |  +- org.springframework.boot:spring-boot-starter-logging:jar:1.5.9.RELEASE:compile
|  |  |  +- ch.qos.logback:logback-classic:jar:1.1.11:compile
|  |  |  |  +- ch.qos.logback:logback-core:jar:1.1.11:compile
|  |  |  |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.6.6; omitted for
|  |  |  +- org.slf4j:jcl-over-slf4j:jar:1.7.25:compile
|  |  |  |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.22; omitted for
|  |  |  +- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
|  |  |  |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.22; omitted for
|  |  |  \- org.slf4j:log4j-over-slf4j:jar:1.7.25:compile
|  |  |     \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.22; omitted for
|  |  +- org.springframework:spring-core:jar:4.3.13.RELEASE:compile
|  |  \- org.yaml:snakeyaml:jar:1.17:runtime
|  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.5.9.RELEASE:compile
|  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.23:compile
|  |  |  \- org.apache.tomcat:tomcat-annotations-api:jar:8.5.23:compile
|  |  +- (org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.23:compile - omitted for duplicate)
|  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.23:compile
|  |     \- (org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.23:compile - omitted for duplicate
|  +- (org.hibernate:hibernate-validator:jar:5.3.6.Final:compile - omitted for duplicate)
|  +- (com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile - omitted for duplicate)
|  +- org.springframework:spring-web:jar:4.3.13.RELEASE:compile
|  |  +- org.springframework:spring-aop:jar:4.3.13.RELEASE:compile
|  |  |  +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  |  \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  +- org.springframework:spring-beans:jar:4.3.13.RELEASE:compile
|  |  |  \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  +- org.springframework:spring-context:jar:4.3.13.RELEASE:compile
|  |  |  +- (org.springframework:spring-aop:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  |  +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  |  +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  |  |  \- (org.springframework:spring-expression:jar:4.3.13.RELEASE:compile - omitted for dupli
|  |  \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|  \- org.springframework:spring-webmvc:jar:4.3.13.RELEASE:compile
|     +- (org.springframework:spring-aop:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     +- (org.springframework:spring-context:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     +- org.springframework:spring-expression:jar:4.3.13.RELEASE:compile
|     |  \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     \- (org.springframework:spring-web:jar:4.3.13.RELEASE:compile - omitted for duplicate)
+- org.springframework.boot:spring-boot-starter-test:jar:1.5.9.RELEASE:test
|  +- org.springframework.boot:spring-boot-test:jar:1.5.9.RELEASE:test
|  |  \- (org.springframework.boot:spring-boot:jar:1.5.9.RELEASE:test - omitted for duplicate)
|  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.5.9.RELEASE:test
|  |  +- (org.springframework.boot:spring-boot-test:jar:1.5.9.RELEASE:test - omitted for duplicat
|  |  \- (org.springframework.boot:spring-boot-autoconfigure:jar:1.5.9.RELEASE:test - omitted for
|  +- (com.jayway.jsonpath:json-path:jar:2.2.0:test - omitted for duplicate)
|  +- junit:junit:jar:4.12:test
|  |  \- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplica
|  +- org.assertj:assertj-core:jar:2.6.0:test
|  +- org.mockito:mockito-core:jar:1.10.19:test
|  |  +- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplica
|  |  \- org.objenesis:objenesis:jar:2.1:test
|  +- org.hamcrest:hamcrest-core:jar:1.3:test
|  +- org.hamcrest:hamcrest-library:jar:1.3:test
|  |  \- (org.hamcrest:hamcrest-core:jar:1.3:test - version managed from 1.1; omitted for duplica
|  +- org.skyscreamer:jsonassert:jar:1.4.0:test
|  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
|  +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - scope updated from test; omit
|  \- org.springframework:spring-test:jar:4.3.13.RELEASE:test
|     \- (org.springframework:spring-core:jar:4.3.13.RELEASE:test - omitted for duplicate)
+- com.jayway.jsonpath:json-path:jar:2.2.0:test
|  +- net.minidev:json-smart:jar:2.2.1:test
|  |  \- net.minidev:accessors-smart:jar:1.1:test
|  |     \- org.ow2.asm:asm:jar:5.0.3:test
|  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.7.16; scope updated from t
+- com.fasterxml.jackson.core:jackson-databind:jar:2.8.10:compile
|  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.0:compile
|  \- com.fasterxml.jackson.core:jackson-core:jar:2.8.10:compile
+- org.springframework.boot:spring-boot-starter-thymeleaf:jar:1.5.9.RELEASE:compile
|  +- (org.springframework.boot:spring-boot-starter:jar:1.5.9.RELEASE:compile - omitted for dupli
|  +- (org.springframework.boot:spring-boot-starter-web:jar:1.5.9.RELEASE:compile - omitted for d
|  +- org.thymeleaf:thymeleaf-spring4:jar:2.1.6.RELEASE:compile
|  |  +- org.thymeleaf:thymeleaf:jar:2.1.6.RELEASE:compile
|  |  |  +- ognl:ognl:jar:3.0.8:compile
|  |  |  +- org.javassist:javassist:jar:3.21.0-GA:compile (version managed from 3.16.1-GA)
|  |  |  +- org.unbescape:unbescape:jar:1.1.0.RELEASE:compile
|  |  |  \- (org.slf4j:slf4j-api:jar:1.7.25:compile - version managed from 1.6.6; omitted for dup
|  |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
|  \- nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:jar:1.4.0:compile
|     +- org.codehaus.groovy:groovy:jar:2.4.13:compile (version managed from 2.4.3)
|     \- (org.thymeleaf:thymeleaf:jar:2.1.6.RELEASE:compile - version managed from 2.1.4.RELEASE;
+- org.hibernate:hibernate-validator:jar:5.3.6.Final:compile
|  +- javax.validation:validation-api:jar:1.1.0.Final:compile
|  +- org.jboss.logging:jboss-logging:jar:3.3.1.Final:compile (version managed from 3.3.0.Final)
|  \- com.fasterxml:classmate:jar:1.3.4:compile (version managed from 1.3.1)
+- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.23:compile
+- org.springframework.boot:spring-boot-starter-jdbc:jar:1.5.9.RELEASE:compile
|  +- (org.springframework.boot:spring-boot-starter:jar:1.5.9.RELEASE:compile - omitted for dupli
|  +- org.apache.tomcat:tomcat-jdbc:jar:8.5.23:compile
|  |  \- org.apache.tomcat:tomcat-juli:jar:8.5.23:compile
|  \- org.springframework:spring-jdbc:jar:4.3.13.RELEASE:compile
|     +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     +- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|     \- org.springframework:spring-tx:jar:4.3.13.RELEASE:compile
|        +- (org.springframework:spring-beans:jar:4.3.13.RELEASE:compile - omitted for duplicate)
|        \- (org.springframework:spring-core:jar:4.3.13.RELEASE:compile - omitted for duplicate)
\- com.h2database:h2:jar:1.4.196:compile

Body:
Add the following dependency (you might have to adjust the version to be compatible with your Spring Boot version)

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

Edited:
  Deleting the conflicting dependancies from maven repo got me rid of this compilation error.


来源: stackexchange

问:
Filtering data in R
I have a CSV of file of data that I can load in R using read.csv()

Some of the data is missing, so I want to reduce the data frame down to set that consists entirely of non-missing data, i.e. if a NULL appears anywhere, I want to exclude that column and row from the filtered data set.

I know I can probably do this fairly simply with the inbuilt R vector operations, but I am not quite sure how to do this exactly?

To make my question a little more concrete, here is a quick sample of the data so you can see what I want to do.

```<code>DocID       Anno1    Anno7  Anno8
1           7        NULL   8
2           8        NULL   3
44          10       2      3
45          6        6      6
46          1        3      4
49          3        8      5
62          4        NULL   9
63          2        NULL   4
67          11       NULL   3
91          NULL     9      7
92          NULL     7      5
93          NULL     8      8
</code>```

So given this input, I need some code that will reduce the output to this.

```<code>DocID       Anno8
44          3
45          6
46          4
49          5
</code>```

As Anno8 is the only column with non-NULL data, and there are only four rows with non-NULL data.

答:
You can drop any row containing a missing using na.omit(), however that's not what you want.  Moreover, the currently accepted answer is wrong.  It gives you complete columns, but does not drop the rows that have one or more missing values, which is what was asked for.  The correct answer can be obtained as:

```<code>> a <- data.frame(a=c(1,2),b=c(NA,1), c=c(3,4))
> a
  a  b c
1 1 NA 3
2 2  1 4
> na.omit(a)[,colSums(is.na(a))==0]
  a c
2 2 4
</code>```

To see that the above answer is wrong:

```<code>> a[ ,apply(a, 2, function(z) !any(is.na(z)))]
  a c
1 1 3
2 2 4
</code>```

Row 1 should be dropped because of the NA in column 2.

OwnerDisplayName: kaybenleroll

ContentLicense: CC BY-SA 3.0

Title: Filtering data in R

Body:
I have a CSV of file of data that I can load in R using read.csv()

Some of the data is missing, so I want to reduce the data frame down to set that consists entirely of non-missing data, i.e. if a NULL appears anywhere, I want to exclude that column and row from the filtered data set.

I know I can probably do this fairly simply with the inbuilt R vector operations, but I am not quite sure how to do this exactly?

To make my question a little more concrete, here is a quick sample of the data so you can see what I want to do.

DocID       Anno1    Anno7  Anno8
1           7        NULL   8
2           8        NULL   3
44          10       2      3
45          6        6      6
46          1        3      4
49          3        8      5
62          4        NULL   9
63          2        NULL   4
67          11       NULL   3
91          NULL     9      7
92          NULL     7      5
93          NULL     8      8

So given this input, I need some code that will reduce the output to this.

DocID       Anno8
44          3
45          6
46          4
49          5

As Anno8 is the only column with non-NULL data, and there are only four rows with non-NULL data.

Body:
You can drop any row containing a missing using na.omit(), however that's not what you want.  Moreover, the currently accepted answer is wrong.  It gives you complete columns, but does not drop the rows that have one or more missing values, which is what was asked for.  The correct answer can be obtained as:

> a <- data.frame(a=c(1,2),b=c(NA,1), c=c(3,4))
> a
  a  b c
1 1 NA 3
2 2  1 4
> na.omit(a)[,colSums(is.na(a))==0]
  a c
2 2 4

To see that the above answer is wrong:

> a[ ,apply(a, 2, function(z) !any(is.na(z)))]
  a c
1 1 3
2 2 4

Row 1 should be dropped because of the NA in column 2.

OwnerDisplayName: john

LastEditorDisplayName: john

ContentLicense: CC BY-SA 2.5


问:
Change the text in a NSTextField programmatically?
I am used to doing this in Cocoa-touch, so I assumed it would be quite simple. I have already tried:

```<code>field.text = [nsstring stringwithformat:@"%i", number];
[field setText:@"%i", number];
</code>```

and setString, all to no avail.

答:
This will work:

```<code>[field setStringValue:[NSString stringWithFormat:@"%i",number]];
</code>```

If it doesn't do anything, it probably means field isn't set to point to the field (e.g. by making a connection in Interface Builder).

ContentLicense: CC BY-SA 4.0

Body:
I am used to doing this in Cocoa-touch, so I assumed it would be quite simple. I have already tried:

field.text = [nsstring stringwithformat:@"%i", number];
[field setText:@"%i", number];

and setString, all to no avail.

Body:
This will work:

[field setStringValue:[NSString stringWithFormat:@"%i",number]];

If it doesn't do anything, it probably means field isn't set to point to the field (e.g. by making a connection in Interface Builder).


问:
Weird characters in Jenkins Job Configuration
What are these weird characters? Anyone has faced this? How can these be deleted?

答: Remember that Jenkins is just a web app, so presumably the version you're on has some additional < in the markup for that particular form. Unless it's causing a problem, I'd just ignore it.


问:
How will _Exit behave in a C++ program?
C99 offers the _Exit function, which exits "immediately", although it does may close file descriptors. Unix/POSIX extends this behavior by mandating the closing of all fd's without flushing (and offers the synonym _exit).

Will these functions call destructors for static objects when called from a C++ program? Does the C++ standard make any guarantees about _Exit?

(Inspired by this question; I suddenly wondered what happens in the typical fork-exec-_exit idiom in C++.)

答:
First, no form of program exit will automatically call destructors for heap objects (implied in ISO/IEC 14882:1998(E) 12.4.10).

Calling exit() will not call destructors for objects with automatic duration, as it does not return through their enclosing scopes (3.6.1.4). However, destructors for static objects will be called, in reverse order of construction (18.3.8).

Calling abort() does not call any destructors for any type of object, nor does it call atexit() registered functions (18.3.3). The C++ standard copy I have here is a bit dated and does not mention _exit or _Exit directly, but I'd imagine that, if present, they should behave the same - that is, not calling any destructors. In particular, in the C99 standard, _Exit() skips atexit handlers (it is implementation defined whether stream buffers are flushed, open streams are closed, or temporary files removed).

Further note that abort() can be cancelled by trapping signal SIGABRT (ISO/IEC 9899:1999 (E) 7.20.4.1.2 - I only have C99 here but I expect it would be the same in the version referenced by C++). _Exit() cannot.

On a more practical note, on most unix implementations of abort() and _exit(), abort() raises a SIGABRT while _exit() simply calls an operating system call to terminate the process immediately. This means that the main differences are:

You can specify an exit code for _exit()

abort() may be trapped by a signal handler

Depending on system configuration, OS, and ulimits, abort() may result in a core dump or similar

In a fork()/exec() pattern, _exit() would probably be preferable, to avoid the possibility of core dump.

Title: How will _Exit behave in a C++ program?


问:
How to create nested object in MongoDB schema, nested object and array MEAN stack
I'm trying to design a nested MongoDB schema.

Currently, I have this schema and it's working:

```<code>var CompanySchema = new mongoose.Schema({
    name: String,
    rate: number
    date: Date
})
</code>```

But I wanna expend it to get:

```<code>var CompanySchema = new mongoose.Schema({
    name: String,
    currency: {
        mxn: Number,
        php: Number,
    },
    source: [String],
    deliveryMethod: [String],
    date: Date
})
</code>```

For source, I want to get an array of inputs ex. ["bank", "debit card", "agent"]
and almost samething for deliverymethod.

But either my input is wrong or my schema, because the value for source saves as one long string, not a separated value.

Also, I think the way I designed the currency to have more currency rate is correct but I don't know how my input json should suppose to be.

I tried it in postman:

```<code>{
    "name": "google",
    "currency": {
        "mxn": 20,
        "php": 30
    }
}
</code>```

and this is the result i got:

```<code>{
"status": 201,
"data": {
    "__v": 0,
    "name": "google",
    "date": "2017-12-06T22:38:45.896Z",
    "_id": "5a2871752e3b7343dc388549",
    "deliveryMethod": [
        null
    ],
    "source": [
        null
    ]
},
"message": "Succesfully Created  Company"
}
</code>```

1- if my currency nested schema is correct how should be my post json file be?

2- how can I get source and deliveryMethod as an array of string?

答:
The JSON in the request body should look like this:

```<code>{
    "name": "google",
    "currency": {
        "mxn": 20,
        "php": 30
    },
    "source": ["source1", "source 2", "source 3"],
    "deliveryMethod": ["delMetd 1", "delMetd 2", "delMetd 3"],
    "date": "2015-11-27T23:00:00Z"
}
</code>```

I copy/pasted your code and tried with Postman. The response I got back was:

```<code>{
    "__v": 0,
    "name": "google",
    "date": "2015-11-27T23:00:00.000Z",
    "_id": "5a2915295c5f714f7cb25d90",
    "deliveryMethod": [
        "delMetd 1",
        "delMetd 2",
        "delMetd 3"
    ],
    "source": [
        "source1",
        "source 2",
        "source 3"
    ],
    "currency": {
        "mxn": 20,
        "php": 30
    }
}
</code>```

If I connect to the database with the mongo shell and run db.companies.find().pretty() I get this result:

```<code>{
        "_id" : ObjectId("5a2915295c5f714f7cb25d90"),
        "name" : "google",
        "date" : ISODate("2015-11-27T23:00:00Z"),
        "deliveryMethod" : [
                "delMetd 1",
                "delMetd 2",
                "delMetd 3"
        ],
        "source" : [
                "source1",
                "source 2",
                "source 3"
        ],
        "currency" : {
                "mxn" : 20,
                "php" : 30
        },
        "__v" : 0
}
</code>```

Your schema is fine. You can try dropping the collection (db.companies.drop()) if you can't get it to work. Start with a fresh one if you don't have any important data in it.

Body:
I'm trying to design a nested MongoDB schema.

Currently, I have this schema and it's working:

var CompanySchema = new mongoose.Schema({
    name: String,
    rate: number
    date: Date
})

But I wanna expend it to get:

var CompanySchema = new mongoose.Schema({
    name: String,
    currency: {
        mxn: Number,
        php: Number,
    },
    source: [String],
    deliveryMethod: [String],
    date: Date
})

For source, I want to get an array of inputs ex. ["bank", "debit card", "agent"]
and almost samething for deliverymethod.

But either my input is wrong or my schema, because the value for source saves as one long string, not a separated value.

Also, I think the way I designed the currency to have more currency rate is correct but I don't know how my input json should suppose to be.

I tried it in postman:

{
    "name": "google",
    "currency": {
        "mxn": 20,
        "php": 30
    }
}

and this is the result i got:

{
"status": 201,
"data": {
    "__v": 0,
    "name": "google",
    "date": "2017-12-06T22:38:45.896Z",
    "_id": "5a2871752e3b7343dc388549",
    "deliveryMethod": [
        null
    ],
    "source": [
        null
    ]
},
"message": "Succesfully Created  Company"
}

1- if my currency nested schema is correct how should be my post json file be?

2- how can I get source and deliveryMethod as an array of string?

Body:
The JSON in the request body should look like this:

{
    "name": "google",
    "currency": {
        "mxn": 20,
        "php": 30
    },
    "source": ["source1", "source 2", "source 3"],
    "deliveryMethod": ["delMetd 1", "delMetd 2", "delMetd 3"],
    "date": "2015-11-27T23:00:00Z"
}

I copy/pasted your code and tried with Postman. The response I got back was:

{
    "__v": 0,
    "name": "google",
    "date": "2015-11-27T23:00:00.000Z",
    "_id": "5a2915295c5f714f7cb25d90",
    "deliveryMethod": [
        "delMetd 1",
        "delMetd 2",
        "delMetd 3"
    ],
    "source": [
        "source1",
        "source 2",
        "source 3"
    ],
    "currency": {
        "mxn": 20,
        "php": 30
    }
}

If I connect to the database with the mongo shell and run db.companies.find().pretty() I get this result:

{
        "_id" : ObjectId("5a2915295c5f714f7cb25d90"),
        "name" : "google",
        "date" : ISODate("2015-11-27T23:00:00Z"),
        "deliveryMethod" : [
                "delMetd 1",
                "delMetd 2",
                "delMetd 3"
        ],
        "source" : [
                "source1",
                "source 2",
                "source 3"
        ],
        "currency" : {
                "mxn" : 20,
                "php" : 30
        },
        "__v" : 0
}

Your schema is fine. You can try dropping the collection (db.companies.drop()) if you can't get it to work. Start with a fresh one if you don't have any important data in it.


问:
Bootstrap Simple Navigation bar not working in my page
I have a Simple Bootstrap navigation bar in my page, but it is not working. the JavaScript and CSS Files are working properly. i checked it. when i copy the navigation code from  to  and pasts it in a new file, then it is working fine, but not working in my actual file . and looks something like This
and I am expecting some thing like This

My Page Source Code is here  .....

```<code><!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Information Panel for Students</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="../include/css/bootstrap.css" rel="stylesheet" type="text/css">
    <link href="../include/css/footer.css" rel="stylesheet" type="text/css">
</head>

<body>
<div class="container">

<!--    header start from here -->

    <header>
      <nav class="navbar navbar-default">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a href="index.php" class="navbar-brand">Department Dashboard</a>
        </div>
        <!-- Collection of nav links and other content for toggling -->
        <div id="navbarCollapse" class="collapse navbar-collapse">
          <ul class="nav navbar-nav">
            <li class="active"><a href="index.php">Home</a></li>
            <li><a href="update_password.php">Update Password</a></li>
            </ul>
          <ul class="nav navbar-nav navbar-right">
            <li><a href="logout.php">Logout</a></li>
            </ul>
        </div>
        </nav>
  </header>

    <h3>Teachers:</h3>
  <div class="row">
    <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541379-5412-5a278cc30963e-NOKIA_RM-1030_206834512-206835569_000.JPG" width="180" height="220"/><br>Person Name : Shaida Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541601-6654-5a278da1bf564-NOKIA_X2-02_215986488-215987862_000.JPG" width="180" height="220"/><br>Person Name : Nausheen Fayaz<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541663-4311-5a278ddfa5374-NOKIA_X2-02_215461832-215462529_000.JPG" width="180" height="220"/><br>Person Name : Javed Chaudry<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512541718-9653-5a278e1617035-NOKIA_RM-1030_206827192-206828288_000.JPG" width="180" height="220"/><br>Person Name : Khan Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512563517-6727-5a27e33d9dc39-NOKIA_E5-00_202194584-202196971_000.JPG" width="180" height="220"/><br>Person Name : Farsil Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512563572-2715-5a27e374a3c1d-NOKIA_RM-1030_202261216-202265107_000.JPG" width="180" height="220"/><br>Person Name : Ek Aur Teacher Ke Data<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512216690-8783-5a229872e2564-NOKIA_5233_244851632-244851959_000.JPG" width="180" height="220"/><br>Person Name : Azhar Rauf<br>Current Place : Class Room<br>Status Date : 02-12-2017<br>Status Time : 05:15:21 PM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512217027-6925-5a2299c3d363f-NOKIA_E5-00_202038176-202041197_000.JPG" width="180" height="220"/><br>Person Name : Fatima Zuhra<br>Current Place : Class Room<br>Status Date : 02-12-2017<br>Status Time : 05:19:28 PM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../teacher/images/resized_1512217504-2845-5a229ba0c8635-NOKIA_E5-00_202201816-202204433_000.JPG" width="180" height="220"/><br>Person Name : Khan Lala<br>Current Place : Class Room<br>Status Date : 02-12-2017<br>Status Time : 05:33:17 PM<br><br></div>  </div>

    <h3>Chairman:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../chairman/images/resized_1512141619-1363-5a2173335d788-NOKIA_5233_244851632-244851959_000.JPG" width="180" height="220"/><br>Person Name : Shah Khusro<br>Current Place : Chairman Office<br>Status Date : 01-12-2017<br>Status Time : 08:26:40 PM<br><br></div>    </div>

    <h3>Clerks:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512562768-5527-5a27e0506acd1-HUAWEI_HUAWEI_611272384-611272979_000.JPG" width="180" height="220"/><br>Person Name : Demo Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512562854-8274-5a27e0a675bb8-HUAWEI_CHM-U01_183017224-183021314_000.JPG" width="180" height="220"/><br>Person Name : Galaxy Khan<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563316-1142-5a27e2744dc95-NOKIA_5233_244851632-244851959_000.JPG" width="180" height="220"/><br>Person Name : Asdf Adf<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563366-8649-5a27e2a6bb78c-NOKIA_E5-00_202083984-202086713_000.JPG" width="180" height="220"/><br>Person Name : Sdfasd Adfdsf<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563389-3596-5a27e2bdc3ff7-NOKIA_E5-00_202186392-202189391_000.JPG" width="180" height="220"/><br>Person Name : Sdf Fsd<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512563480-2752-5a27e3185f05f-NOKIA_RM-1030_194996488-194998710_000.JPG" width="180" height="220"/><br>Person Name : Dfasdf Sdalfksd<br>Current Place : Default<br>Status Date : 00-00-0000<br>Status Time : 12:00:00 AM<br><br></div><div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../clerk/images/resized_1512145551-9397-5a21828fc4953-NOKIA_E5-00_202038176-202041197_000.JPG" width="180" height="220"/><br>Person Name : Faris Khan<br>Current Place : Clerk Office<br>Status Date : 02-12-2017<br>Status Time : 09:46:40 AM<br><br></div>    </div>

    <h3>Lab Staff:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../lab_staff/images/resized_1512218344-7079-5a229ee8b9e5a-NOKIA_RM-1030_206846160-206847834_000.JPG" width="180" height="220"/><br>Person Name : Samin Jan<br>Current Place : Laboratory<br>Status Date : 02-12-2017<br>Status Time : 05:39:47 PM<br><br></div>    </div>

    <h3>PN Staff:</h3>
    <div class="row">
      <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"><img src="../pn/images/resized_1512145738-2830-5a21834a6d1d7-NOKIA_E5-00_202048056-202051887_000.JPG" width="180" height="220"/><br>Person Name : Penis Khan<br>Current Place : Outside<br>Status Date : 02-12-2017<br>Status Time : 06:09:47 PM<br><br></div>    </div>
    <footer>
        <div class="container">
            <div class="row">
                <div class="col-sm-4">
                    <div class="footer-block">
                        <ul class="list-inline footer-menu">
                            <li><a href="">Term of Use</a></li>
                            <li><a href="">Privacy Policy</a></li>
                        </ul>
                    </div>
                </div>
                <div class="col-sm-4">
                  <div class="footer-block text-center">
                    <p class="copyright">
                        © 2018 Department Dashboard.<br>
                        All rights reserved.<br>
                        Developed By:<br>
                        Shaida Muhammad Sherpao
                      </p>
                    </div>
                </div>
                <div class="col-sm-4">
                    <div class="footer-block">
                        <ul class="list-inline pull-right social-icon">
                            <li><a href="https://facebook.com/sh3rpao"><i class="fa fa-facebook"></i></a></li>
                            <li><a href="https://twitter.com/shaidasherpao"><i class="fa fa-twitter"></i></a></li>
                            <li><a href="https://pk.linkedin.com/in/shaida-muhammad-sherpao-a3388a103"><i class="fa fa-linkedin"></i></a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </footer>
</div>
<script src="../include/js/jquery-1.11.3.min.js"></script>
<script src="../include/js/bootstrap.js"></script>
</body>
</html>
</code>```

答:
if i am not mistaken you are using Bootstrap 3.

There is a detailed documentation about Navbar component in getBootstrap :
https://getbootstrap.com/docs/3.3/components/#navbar

I did not see an error in your code. if you have another CSS file, could you please share them too?

Body:
I have a Simple Bootstrap navigation bar in my page, but it is not working. the JavaScript and CSS Files are working properly. i checked it. when i copy the navigation code from  to  and pasts it in a new file, then it is working fine, but not working in my actual file . and looks something like This
and I am expecting some thing like This

My Page Source Code is here  .....

<!doctype html>

<meta charset="utf-8">
<title>Information Panel for Students</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="../include/css/bootstrap.css" rel="stylesheet" type="text/css">
    <link href="../include/css/footer.css" rel="stylesheet" type="text/css">

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

          </button>
          Department Dashboard

Home

Update Password

Logout

Teachers:

Person Name : Shaida Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Nausheen Fayaz
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Javed Chaudry
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Khan Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Farsil Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Ek Aur Teacher Ke Data
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Azhar Rauf
Current Place : Class Room
Status Date : 02-12-2017
Status Time : 05:15:21 PM

Person Name : Fatima Zuhra
Current Place : Class Room
Status Date : 02-12-2017
Status Time : 05:19:28 PM

Person Name : Khan Lala
Current Place : Class Room
Status Date : 02-12-2017
Status Time : 05:33:17 PM

Chairman:

Person Name : Shah Khusro
Current Place : Chairman Office
Status Date : 01-12-2017
Status Time : 08:26:40 PM

Clerks:

Person Name : Demo Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Galaxy Khan
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Asdf Adf
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Sdfasd Adfdsf
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Sdf Fsd
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Dfasdf Sdalfksd
Current Place : Default
Status Date : 00-00-0000
Status Time : 12:00:00 AM

Person Name : Faris Khan
Current Place : Clerk Office
Status Date : 02-12-2017
Status Time : 09:46:40 AM

Lab Staff:

Person Name : Samin Jan
Current Place : Laboratory
Status Date : 02-12-2017
Status Time : 05:39:47 PM

PN Staff:

Person Name : Penis Khan
Current Place : Outside
Status Date : 02-12-2017
Status Time : 06:09:47 PM

Term of Use

Privacy Policy

                        © 2018 Department Dashboard.

                        All rights reserved.

                        Developed By:

                        Shaida Muhammad Sherpao


问:
Javascript compare two datetimes
I need to compare two datetimes. Format of datetimes is: DD-MM-YYYY hh:mm:ss.

Here is my code:

```<code>expirationDate = someDate;
var now = moment().format("DD-MM-YYYY hh:mm:ss");

if(moment(expirationDate).isBefore(now)){
    console.log("Past");
} else {
    console.log("Future");
}
</code>```

for this datetimes it work great:

```<code>Now: 07-12-2017 11:15:09
Expiration date: 07-12-2017 10:14:10
it return Past
</code>```

but for this it doesn't work:

```<code>Now: 07-12-2017 11:15:03
Expiration date: 15-12-2016 05:59:00
it return Future
</code>```

I've also tried with if (Date.parse(expireDate) < Date.parse(now)) it also doesn't work properly.
Does anyone know where is the problem or is there any other way to compare two datetimes?

答:
You need to specify the format of the date string.</p>

```<code>if (moment().isAfter(moment(expirationDate, 'DD-MM-YYYY HH:mm:ss'))) {
  console.log("Past");
} else {
  console.log("Future");
}
</code>```

Title: Javascript compare two datetimes

Body:
I need to compare two datetimes. Format of datetimes is: DD-MM-YYYY hh:mm:ss.

Here is my code:

expirationDate = someDate;
var now = moment().format("DD-MM-YYYY hh:mm:ss");

if(moment(expirationDate).isBefore(now)){
    console.log("Past");
} else {
    console.log("Future");
}

for this datetimes it work great:

Now: 07-12-2017 11:15:09
Expiration date: 07-12-2017 10:14:10
it return Past

but for this it doesn't work:

Now: 07-12-2017 11:15:03
Expiration date: 15-12-2016 05:59:00
it return Future

I've also tried with if (Date.parse(expireDate) < Date.parse(now)) it also doesn't work properly.
Does anyone know where is the problem or is there any other way to compare two datetimes?

Body:
You need to specify the format of the date string.

if (moment().isAfter(moment(expirationDate, 'DD-MM-YYYY HH:mm:ss'))) {
  console.log("Past");
} else {
  console.log("Future");
}


问:
angularJS how to $eval the function with parameter
I am trying to implement the directive, in the directive, I want to $eval the values which contains the function name and parameter value:

Html page:

```<code><select mydirective="action('pValue')">
</code>```

AngularJS directive code:

```<code>app.directive('mydirective', function ($timeout) {
return {
    restrict: 'A',
    link: function ($scope, element, attr) {
            $timeout(function () {
                $scope.$eval(attr.mydirective);
        });
    }
}
</code>```

What I am expected is it will invoke the action function define in scope and pass the pValue as function parameter. How can I make it work please?

答:
For those whom looking for a way to pass $event info to custom directive method see example below:

TEMPLATE:

```<code><div on-touch-end="onTouchEnd( 'some data' )">
   TOUCH ME!
</div>
</code>```

CONTROLLER:

```<code>$scope.onTouchEnd = function( data ) {
    console.log("onTouchEnd event with data", data, event );
};
</code>```

DIRECTIVE:

```<code>.directive('onTouchEnd', function() {
    return {
        restrict    : 'A',
        link        : function( $scope, $element, $attr ) {
            $element.on('touchend', function( event ) {
                $scope.$apply(function() {
                    $scope.$eval( $attr.onTouchEnd );
                });
            });
        }
    }
})
</code>```

Body:
I am trying to implement the directive, in the directive, I want to $eval the values which contains the function name and parameter value:

Html page:

<select mydirective="action('pValue')">

AngularJS directive code:

app.directive('mydirective', function ($timeout) {
return {
    restrict: 'A',
    link: function ($scope, element, attr) {
            $timeout(function () {
                $scope.$eval(attr.mydirective);
        });
    }
}

What I am expected is it will invoke the action function define in scope and pass the pValue as function parameter. How can I make it work please?

Body:
For those whom looking for a way to pass $event info to custom directive method see example below:

TEMPLATE:

<div on-touch-end="onTouchEnd( 'some data' )">
   TOUCH ME!
</div>

CONTROLLER:

$scope.onTouchEnd = function( data ) {
    console.log("onTouchEnd event with data", data, event );
};

DIRECTIVE:

.directive('onTouchEnd', function() {
    return {
        restrict    : 'A',
        link        : function( $scope, $element, $attr ) {
            $element.on('touchend', function( event ) {
                $scope.$apply(function() {
                    $scope.$eval( $attr.onTouchEnd );
                });
            });
        }
    }
})


问:
Firebase Type 'AppDelegate' does not conform to protocol 'FUIAuthDelegate'
I'm using Firebase 4.6.0, Xcode 9.1, Swift 4.

When I implement the FUIAuthDelegate protocol and its required function authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?), I still get a compile error "Type 'AppDelegate' does not conform to protocol 'FUIAuthDelegate'". Why?

答:
for me this was resolved by the adding method     </p>

```<code>func authUI(_ authUI: FUIAuth, didSignInWith user: FirebaseAuth.User?, error: Error?) {
    print("did sign In")
}
</code>```

<p>instead of using    </p>

```<code>func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?) {

}
</code>```

Body:
for me this was resolved by the adding method

func authUI(_ authUI: FUIAuth, didSignInWith user: FirebaseAuth.User?, error: Error?) {
    print("did sign In")
}

instead of using

func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?) {

}


问:
Flexbox media query overflowing divs
I got a problem that I need to solve. I am coding an admin panel. I am using flexbox and I have 3 divs next to each other. Code looks like this:

```<code><div class="content-boxes">
    <div class="content-box">
      <span>Something</span>
      <img src="image.png">
      <p>
        Number<br>
      </p>
    </div>

    <div class="content-box">
      <span>Something</span>
      <img src="image.png">
      <p>
        Number<br>
      </p>
    </div>

    <div class="content-box">
      <span>Something</span>
      <img src="image.png">
      <p>
        Number<br>
      </p>
    </div>
  </div>
</code>```

And CSS code (SASS):

```<code>.content-boxes{
  position: relative;
  @include flexbox();
  flex-flow: row wrap;
  width: 100%;
  height: 18%;
  justify-content: space-around;
  margin: 1vw 1vw 1vw 1vw;
  .content-box{
    @include flexbox();
    flex-flow: row wrap;
    width:23%;
    height:100%;
    background-color: $oc-red-8;
    justify-content: space-between;
    flex: 1;
    span{
      padding: 0.2vw;
      font-size: 3vh;
      color: $oc-gray-2;
      overflow: hidden;
      font-family: CaviarDreams;
      width: 100%;
    }
    p{
      padding: 1vw;
      font-size: 4vh;
      color: $oc-gray-2;
      overflow: hidden;
      font-family: CaviarDreams;
      text-align: right;
      align-self: center;
      margin-left: auto;
    }
    img{
      height: 50%;
      align-self: flex-start;
      margin-left: 1vw;
    }
  }
}
</code>```

My problem is that when I use media query and wants the boxes to be width: 100%; the other divs as flex are overflowing this one.

Media query code:

```<code>@media screen and (max-width: 650px){
  .content-boxes{
    .content-box{
       width: 100%;
    }
  }
}
</code>```

I wants all my divs under each other with width: 100%;

I hope I made myself clear, any suggestions ?

答:
the solution will be like that

you define flex: 1

for the content box which is mean :

```<code>flex-grow: 1;
flex-shrink: 1;
flex-basis: 0%;
</code>```

and you want the width 100% in the media query then you have to define this

```<code>flex-grow: 1;
flex-shrink: 1;
flex-basis: auto;
</code>```

which is shortcut flex: auto as you define already width 100%

```<code>@media screen and (max-width: 650px){
  .content-boxes{
    .content-box{
      flex: auto;
      width: 100%;
    }
  }
}
</code>```

so it will be under each other

and here the codepen link

Title: Flexbox media query overflowing divs

Body:
I got a problem that I need to solve. I am coding an admin panel. I am using flexbox and I have 3 divs next to each other. Code looks like this:

      Something

        Number

      Something

        Number

      Something

        Number

And CSS code (SASS):

.content-boxes{
  position: relative;
  @include flexbox();
  flex-flow: row wrap;
  width: 100%;
  height: 18%;
  justify-content: space-around;
  margin: 1vw 1vw 1vw 1vw;
  .content-box{
    @include flexbox();
    flex-flow: row wrap;
    width:23%;
    height:100%;
    background-color: $oc-red-8;
    justify-content: space-between;
    flex: 1;
    span{
      padding: 0.2vw;
      font-size: 3vh;
      color: $oc-gray-2;
      overflow: hidden;
      font-family: CaviarDreams;
      width: 100%;
    }
    p{
      padding: 1vw;
      font-size: 4vh;
      color: $oc-gray-2;
      overflow: hidden;
      font-family: CaviarDreams;
      text-align: right;
      align-self: center;
      margin-left: auto;
    }
    img{
      height: 50%;
      align-self: flex-start;
      margin-left: 1vw;
    }
  }
}

My problem is that when I use media query and wants the boxes to be width: 100%; the other divs as flex are overflowing this one.

Media query code:

@media screen and (max-width: 650px){
  .content-boxes{
    .content-box{
       width: 100%;
    }
  }
}

I wants all my divs under each other with width: 100%;

I hope I made myself clear, any suggestions ?

Body:
the solution will be like that

you define flex: 1

for the content box which is mean :

flex-grow: 1;
flex-shrink: 1;
flex-basis: 0%;

and you want the width 100% in the media query then you have to define this

flex-grow: 1;
flex-shrink: 1;
flex-basis: auto;

which is shortcut flex: auto as you define already width 100%

@media screen and (max-width: 650px){
  .content-boxes{
    .content-box{
      flex: auto;
      width: 100%;
    }
  }
}

so it will be under each other

and here the codepen link


问:
Getting Android activity reference in unity 3d
See this link.

Tried this one but it's not getting the reference of the activity

答:
Try below snippet, from this github repo:</p>

```<code>public static AndroidJavaObject GetAndroidActivity()
{
    AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
    return jo;
}
</code>```

Body:
Try below snippet, from this github repo:

public static AndroidJavaObject GetAndroidActivity()
{
    AndroidJavaClass jc = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
    AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity");
    return jo;
}


问:
My code is running but not inserting any value
I have this segment of code running while looping through files in an folder.
Code does run but, is not having any output on this segment.

```<code>Dim LastRow As Long
Dim rng1 As Range
wb.Worksheets(1).Activate
Set rng1 = Range("B15:E81,N15:O81")

With ThisWorkbook.Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
.Range("E" & LastRow + 1).Value = rng1
End With
</code>```

I'm using this segment of code to extract data from B15 to E81 & N15 to O 81 from all the excel workbook in the folder.

Upon copying range into variable, it will activate the workbook where this code lie

Select last entry from column E, Offset by 1 row

Input range variable to the next blank cell.

Appreciate all the help I could find. Thanks in advance.

答:
It is not working, because you have to refer to the same amount of cells. In your case here .Range("E" & LastRow + 1).Value = rng1 you are refering to one cell on the left and many on the right.

If you change your line to:

.Range("E" & LastRow + 1).Value = rng1.Cells(1, 1)

It will show you the first cell correctly.
A clean way to increase your left range is to use Resize() as in the answer of @CallumDA.

Body:
I have this segment of code running while looping through files in an folder.
Code does run but, is not having any output on this segment.

Dim LastRow As Long
Dim rng1 As Range
wb.Worksheets(1).Activate
Set rng1 = Range("B15:E81,N15:O81")

With ThisWorkbook.Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
.Range("E" & LastRow + 1).Value = rng1
End With

I'm using this segment of code to extract data from B15 to E81 & N15 to O 81 from all the excel workbook in the folder.

Upon copying range into variable, it will activate the workbook where this code lie

Select last entry from column E, Offset by 1 row

Input range variable to the next blank cell.

Appreciate all the help I could find. Thanks in advance.


问:
C# Recursive Permutation is Possible? (beginner)
Hi guys im trying to learn permutation and recurtion. And im looking for a way how can i use bought at the same time.

MAIN:

```<code>namespace Recursive_Permutation
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = new int[5] { 0, 0, 0, 0, 0 };
            CalPermutations CP = new CalPermutations();
            CP.Run(array, array.Length-1);

        }
    }
}
</code>```

Here is my Simple code:

```<code>namespace Recursive_Permutation
{
    public class CalPermutations
    {
        public int Run(int[] array,int indexer)
        {
            if (indexer > array.Length)
            {
                return 1;
            }
            else
            {
                for (int i = 0; i <= array.Length; i++)
                {
                    array[indexer] = i;
                    Display(array);
                }
                Run(array, indexer-1);

            }
            return indexer;
        }
        public void Display(int[] array)
        {
            foreach (int num in array)
            {
                Console.Write(num);
            }
            Console.WriteLine();
        }

    }
}
</code>```

And here is the Output of the program:

Question:
it might be simple to other but im kind of confuse now in how can i manipulate it that it still count the first digit (position [0]) 1 to 5 and go next position and (position 1) and add 1 and go back to [0] and start count again till it reaches 5.

i hope that my explanation is understandable.. thx.

答:
I put together this simpler example of using recursion and permutation. It uses strings internally, but produces the same result.

Its for proof of concept only, since nobody will us recursion for this simple stuff in a professional environment. Recursion can have a big memory impact, but makes describing some problems in a simple way possible.

If I had to choose between iterative and recursive solutions, I would take the iterative one most of the time.

```<code>// Main entrance
public void DoStuff()
{
    // define variations
    List<string> possibilities = new List<string>() { "0", "1", "2", "3", "4", "5" };
    // resultlist, will be filled later
    List<string> permutations = new List<string>();
    // how many values will be taken from the possibilities
    int digits = 5;
    //do the work
    Permute(permutations, possibilities, digits, "");
    // display the work
    foreach (var item in permutations)
    {
        Console.WriteLine(item);
    }
}
/// <summary>
/// generates a List of permuted strings
/// </summary>
/// <param name="permutations">resultlist</param>
/// <param name="possibilities">possible values of the digit</param>
/// <param name="digitsLeft">how many digits shall be appended</param>
/// <param name="current">the current value of the unfinished result</param>
private void Permute(List<string> permutations, List<string> possibilities, int digitsLeft, string current)
{
    // uncomment to see how it works in detail
    //Console.WriteLine("step:"+current);

    // most important: define Stop conditions for the recursion
    // safety stop
    if (digitsLeft < 0)
    {// end of digits :), normally we never end up here
        return;
    }
    // normal stop
    if (digitsLeft == 0)
    {// normal endpoint, add the found permutation to the resultlist
        permutations.Add(current);
        return;
    }

    // now prepare the recursion, try each possibility
    foreach (var item in possibilities)
    {
        // digitsLeft need to be decreased, since we add a concrete digit to the current value (current+item)
        // important: (current + item) generates a new string in memory, the old values won't be touched, permutations possibilities are references, so no memory impact here
        Permute(permutations, possibilities, digitsLeft - 1, current + item);
    }
}
</code>```

Body:
Hi guys im trying to learn permutation and recurtion. And im looking for a way how can i use bought at the same time.

MAIN:

namespace Recursive_Permutation
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = new int[5] { 0, 0, 0, 0, 0 };
            CalPermutations CP = new CalPermutations();
            CP.Run(array, array.Length-1);

        }
    }
}

Here is my Simple code:

namespace Recursive_Permutation
{
    public class CalPermutations
    {
        public int Run(int[] array,int indexer)
        {
            if (indexer > array.Length)
            {
                return 1;
            }
            else
            {
                for (int i = 0; i <= array.Length; i++)
                {
                    array[indexer] = i;
                    Display(array);
                }
                Run(array, indexer-1);

            }
            return indexer;
        }
        public void Display(int[] array)
        {
            foreach (int num in array)
            {
                Console.Write(num);
            }
            Console.WriteLine();
        }

    }
}

And here is the Output of the program:

Question:
it might be simple to other but im kind of confuse now in how can i manipulate it that it still count the first digit (position [0]) 1 to 5 and go next position and (position 1) and add 1 and go back to [0] and start count again till it reaches 5.

i hope that my explanation is understandable.. thx.

Body:
I put together this simpler example of using recursion and permutation. It uses strings internally, but produces the same result.

Its for proof of concept only, since nobody will us recursion for this simple stuff in a professional environment. Recursion can have a big memory impact, but makes describing some problems in a simple way possible.

If I had to choose between iterative and recursive solutions, I would take the iterative one most of the time.

// Main entrance
public void DoStuff()
{
    // define variations
    List<string> possibilities = new List<string>() { "0", "1", "2", "3", "4", "5" };
    // resultlist, will be filled later
    List<string> permutations = new List<string>();
    // how many values will be taken from the possibilities
    int digits = 5;
    //do the work
    Permute(permutations, possibilities, digits, "");
    // display the work
    foreach (var item in permutations)
    {
        Console.WriteLine(item);
    }
}
/// <summary>
/// generates a List of permuted strings
/// </summary>
/// <param name="permutations">resultlist</param>
/// <param name="possibilities">possible values of the digit</param>
/// <param name="digitsLeft">how many digits shall be appended</param>
/// <param name="current">the current value of the unfinished result</param>
private void Permute(List<string> permutations, List<string> possibilities, int digitsLeft, string current)
{
    // uncomment to see how it works in detail
    //Console.WriteLine("step:"+current);

    // most important: define Stop conditions for the recursion
    // safety stop
    if (digitsLeft < 0)
    {// end of digits :), normally we never end up here
        return;
    }
    // normal stop
    if (digitsLeft == 0)
    {// normal endpoint, add the found permutation to the resultlist
        permutations.Add(current);
        return;
    }

    // now prepare the recursion, try each possibility
    foreach (var item in possibilities)
    {
        // digitsLeft need to be decreased, since we add a concrete digit to the current value (current+item)
        // important: (current + item) generates a new string in memory, the old values won't be touched, permutations possibilities are references, so no memory impact here
        Permute(permutations, possibilities, digitsLeft - 1, current + item);
    }
}


问:
Can't access cookies from document.cookie in JS, but browser shows cookies exist
I can't access any cookie from JavaScript. I need to read some value and send them via JSON for my custom checks.

I've tried to access cookies from JS, like it was described at:

http://www.w3schools.com/js/js_cookies.asp

Get cookie by name

As you can see at the code, it's seen as clear as a crystal the next:

```<code>var c_value = document.cookie;
</code>```

When I'm trying to access the document.cookie value from the Chrome's web-debugger, I see only the empty string at the Watch expressions:

So I can't read cookies value, which I need.

I've checked the cookie name, which I'm sending to get an associated value IS correct.
Also, I'm using the W3Schools source code for getting cookies, if you're interested (but from the 2nd link, the technique is similar).

How can I fix my issue?

答: keep an eye also to the cookie's Path attribute, as the cookie is only visible to subdirectories under Path. I had your issue and I solved setting Path "/"</p>

Body:
I can't access any cookie from JavaScript. I need to read some value and send them via JSON for my custom checks.

I've tried to access cookies from JS, like it was described at:

http://www.w3schools.com/js/js_cookies.asp

Get cookie by name

As you can see at the code, it's seen as clear as a crystal the next:

var c_value = document.cookie;

When I'm trying to access the document.cookie value from the Chrome's web-debugger, I see only the empty string at the Watch expressions:

So I can't read cookies value, which I need.

I've checked the cookie name, which I'm sending to get an associated value IS correct.
Also, I'm using the W3Schools source code for getting cookies, if you're interested (but from the 2nd link, the technique is similar).

How can I fix my issue?


问:
How to define that function result is possibly undefined in typescript
consider

```<code>const funct = (t: number): string | undefined => (t > 0 ? 'asd' : undefined);
</code>```

the inferred type for the result of funct is string, but should be string | undefined. Am I doing something wrong here?

答:
Updated after lajos-gallay's comments.

I think you're doing it right, but you need enable strictNullChecks.

I tried your code like this:

```<code>const funct = (t: number): string | undefined => (t > 0 ? 'asd' : undefined);
const result = funct(15);
console.log(result.length);
</code>```

and the inferred type of result was string | undefined,

so the last line throws [ts] Object is possibly undefined.

I have "strictNullChecks": true under compilerOptions in my tsconfig.json.

Body:
consider

const funct = (t: number): string | undefined => (t > 0 ? 'asd' : undefined);

the inferred type for the result of funct is string, but should be string | undefined. Am I doing something wrong here?

Body:
Updated after lajos-gallay's comments.

I think you're doing it right, but you need enable strictNullChecks.

I tried your code like this:

const funct = (t: number): string | undefined => (t > 0 ? 'asd' : undefined);
const result = funct(15);
console.log(result.length);

and the inferred type of result was string | undefined,

so the last line throws [ts] Object is possibly undefined.

I have "strictNullChecks": true under compilerOptions in my tsconfig.json.


问:
See Mercurial changeset summary/user/date
Given a Mercurial changeset 123, how can yous see the summary, user, and date associated with the changeset?  Figured there was an hg log option but couldn't see it..

答:
you can also try Mercurial Templates to get just the output you're after. Several keywords are supported, but in your example this command would work:</p>

```<code>hg log -r 123 --template '{author}\n{date}\n{desc}\n'
</code>```

Body:
you can also try Mercurial Templates to get just the output you're after. Several keywords are supported, but in your example this command would work:

hg log -r 123 --template '{author}\n{date}\n{desc}\n'


问:
opposite of object destructuring
Given the following example. Is there a shorthand for the field asignment </p>

```<code>let myObj = {someField: 'someValue'}
let foo = 'value'

myObj.foo = foo // I would like to do the opposite of object destructuring: const {foo} = myObj. I don't want to repeat foo twice.
</code>```

答:
If you switch around your statements, you could do it:

```<code>const foo = 'value';
const myObject = { foo };
</code>```

or if you change from const to var so you can assign a new object to your myObj:

```<code>var myObj = {};
const foo = 'value';
myObj = { foo }
</code>```

Title: opposite of object destructuring

Body:
Given the following example. Is there a shorthand for the field asignment

let myObj = {someField: 'someValue'}
let foo = 'value'

myObj.foo = foo // I would like to do the opposite of object destructuring: const {foo} = myObj. I don't want to repeat foo twice.

Body:
If you switch around your statements, you could do it:

const foo = 'value';
const myObject = { foo };

or if you change from const to var so you can assign a new object to your myObj:

var myObj = {};
const foo = 'value';
myObj = { foo }


问:
How to create data frame of random floating point numbers with Pandas
```<code>pd.DataFrame(np.random.randint(0,253,size=(253, 830)), columns=list_cols)
</code>```

I used this for getting random integers but i needed floating point numbers instead. Any idea how?

答:
randint generates random integers, use rand to get random numbers between 0 and 1. You can then multply that by the maximum value you want. (which I guess is 254 rather than 253).

```<code>pd.DataFrame(np.random.rand(253, 830) * 254, columns=list_cols)
</code>```

Body:
pd.DataFrame(np.random.randint(0,253,size=(253, 830)), columns=list_cols)

I used this for getting random integers but i needed floating point numbers instead. Any idea how?

Body:
randint generates random integers, use rand to get random numbers between 0 and 1. You can then multply that by the maximum value you want. (which I guess is 254 rather than 253).

pd.DataFrame(np.random.rand(253, 830) * 254, columns=list_cols)


问:
Testing product import to Magento 1.9, "Product Type is invalid or not supported" NO MATTER WHAT?
So I'm new to Magento but from what I gather Product Type is a required field for importing. My csv reads as follows:

```<code>store,websites,attribute_set,type,sku,has_options,name,image,small_image,thumbnail,url_key,url_path,options_container,gift_message_available,page_layout,country_of_manufacture,msrp_enabled,msrp_display_actual_price_type,price,special_price,weight,status,tax_class_id,visibility,is_recurring,linen_type,enable_tabs,description,short_description,special_from_date,qty,min_qty,use_config_min_qty,is_qty_decimal,backorders,use_config_backorders,min_sale_qty,use_config_min_sale_qty,max_sale_qty,use_config_max_sale_qty,is_in_stock,low_stock_date,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,stock_status_changed_auto,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,stock_status_changed_automatically,use_config_enable_qty_increments,product_name,store_id,type_id,categories,gallery,img_label,has_color_picked,additional_catoverride,meta_title,meta_description
admin,base,Default,simple,111-1-BK-GG,0,HERCULES,Imperial,Series,Black,Leather,Chair,,,,,,Block,after,Info,Column,No,No,layout,updates,China,Use,config,Use,config,583,185.75,54,Disabled,Taxable,Goods,"Catalog, Search",No,UNKNOWN,No,"<ul class=""disc"">Your lobby or reception area is the forefront of your business and providing distinguished and comfortable seating is the first step towards making a great impression. The modern appeal of this chair will make a lasting impression with your visitors. Reception chairs are perfect for the office and as waiting room seating. The contemporary design of this furniture adapts in several different settings. This chair features streamlined stitching and elevated, curved hardwood feet. Not only will this chair fit in a professional environment, but will add a modern look to your home.<li>Contemporary Design<li>Office or Home Office Seating<li>Sloping Arms<li>Slightly Curved Seat and Back<li>Fixed Seat Cushion<li>1.8 High Density Foam<li>Sturdy Hardwood Construction<li>Cherry Stained Wood Feet<li>Black LeatherSoft Upholstery<li>LeatherSoft is leather and polyurethane for added Softness and Durability<li>CA117 Fire Retardant Foam</ul>","<ul class=""disc""><b>Black Leather Chair</b><li>Overall Dimensions: 33.50""W x 31""D x 29""H<li>Availability: In Stock. Usually ships within 24 business hours.</ul>",,0,0,1,0,0,1,1,1,0,1,0,,1,0,1,1,1,0,1,0
</code>```

This was provided by a separate entity, originally with a number of columns per product more than there are headers. With those, Check Data returned "Column names have duplicates". That content deleted returned

```<code>Product Type is invalid or not supported in rows: 1

File is totally invalid. Please fix errors and re-upload file
Checked rows: 1, checked entities: 1, invalid rows: 1, total errors: 1
</code>```

totally invalid.

Originally the type_id column read instead product_type, with the same value in the product row as there is now, 1. Note that there is also a type column, with the value "simple". Before even realizing that, I tried values "Simple Product", "Simple", and "simple" for product_type. I also tried combining those values with variations on the column header, such as the current type_id, and _type, both of which I came across while researching this issue online.

I have also tried removing that column altogether. Nothing makes any difference. What can I do, short of writing my own tedious import script?

UPDATE: that error has given way to another now, who would've thought... (type_id=1 ok)

Now it tells me

```<code>Can not find required columns: sku
Please fix errors and re-upload file
</code>```

when said column does very much exist verbatim. I tried moving the column. I tried changing the [albeit valid] value. I even tried setting the field sku to not be required in Catalog > Attributes > Manage Attributes. Still I get the same sad result.

I am hating Magento, but that still does me nor anyone else any good. How can I resolve to import ONE SIMPLE PRODUCT into this stupid system?

I even tried via the MageBees module and it's giving Error: Product SKU field "sku" is empty. No it's not empty; it's 111-1-BK-GG. Goddamn.

答:
Stop trying solution for these issues, once you found solution, mostly you willl end up in getting one more issue & so on.

So, how to fix ? go for Magmi , learn it & once you finalize the pattern, you can upload millions of products easily....

Body:
So I'm new to Magento but from what I gather Product Type is a required field for importing. My csv reads as follows:

store,websites,attribute_set,type,sku,has_options,name,image,small_image,thumbnail,url_key,url_path,options_container,gift_message_available,page_layout,country_of_manufacture,msrp_enabled,msrp_display_actual_price_type,price,special_price,weight,status,tax_class_id,visibility,is_recurring,linen_type,enable_tabs,description,short_description,special_from_date,qty,min_qty,use_config_min_qty,is_qty_decimal,backorders,use_config_backorders,min_sale_qty,use_config_min_sale_qty,max_sale_qty,use_config_max_sale_qty,is_in_stock,low_stock_date,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,stock_status_changed_auto,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,stock_status_changed_automatically,use_config_enable_qty_increments,product_name,store_id,type_id,categories,gallery,img_label,has_color_picked,additional_catoverride,meta_title,meta_description
admin,base,Default,simple,111-1-BK-GG,0,HERCULES,Imperial,Series,Black,Leather,Chair,,,,,,Block,after,Info,Column,No,No,layout,updates,China,Use,config,Use,config,583,185.75,54,Disabled,Taxable,Goods,"Catalog, Search",No,UNKNOWN,No,"
Your lobby or reception area is the forefront of your business and providing distinguished and comfortable seating is the first step towards making a great impression. The modern appeal of this chair will make a lasting impression with your visitors. Reception chairs are perfect for the office and as waiting room seating. The contemporary design of this furniture adapts in several different settings. This chair features streamlined stitching and elevated, curved hardwood feet. Not only will this chair fit in a professional environment, but will add a modern look to your home.
Contemporary Design
Office or Home Office Seating
Sloping Arms
Slightly Curved Seat and Back
Fixed Seat Cushion
1.8 High Density Foam
Sturdy Hardwood Construction
Cherry Stained Wood Feet
Black LeatherSoft Upholstery
LeatherSoft is leather and polyurethane for added Softness and Durability
CA117 Fire Retardant Foam
","
Black Leather Chair
Overall Dimensions: 33.50""W x 31""D x 29""H
Availability: In Stock. Usually ships within 24 business hours.
",,0,0,1,0,0,1,1,1,0,1,0,,1,0,1,1,1,0,1,0

This was provided by a separate entity, originally with a number of columns per product more than there are headers. With those, Check Data returned "Column names have duplicates". That content deleted returned

Product Type is invalid or not supported in rows: 1

File is totally invalid. Please fix errors and re-upload file
Checked rows: 1, checked entities: 1, invalid rows: 1, total errors: 1

totally invalid.

Originally the type_id column read instead product_type, with the same value in the product row as there is now, 1. Note that there is also a type column, with the value "simple". Before even realizing that, I tried values "Simple Product", "Simple", and "simple" for product_type. I also tried combining those values with variations on the column header, such as the current type_id, and _type, both of which I came across while researching this issue online.

I have also tried removing that column altogether. Nothing makes any difference. What can I do, short of writing my own tedious import script?

UPDATE: that error has given way to another now, who would've thought... (type_id=1 ok)

Now it tells me

Can not find required columns: sku
Please fix errors and re-upload file

when said column does very much exist verbatim. I tried moving the column. I tried changing the [albeit valid] value. I even tried setting the field sku to not be required in Catalog > Attributes > Manage Attributes. Still I get the same sad result.

I am hating Magento, but that still does me nor anyone else any good. How can I resolve to import ONE SIMPLE PRODUCT into this stupid system?

I even tried via the MageBees module and it's giving Error: Product SKU field "sku" is empty. No it's not empty; it's 111-1-BK-GG. Goddamn.


答:
Can't you use Copy ? Then the target size does not have to be calculated.

```<code>dim target as range
With ThisWorkbook.Worksheets("Sheet1")
   set target = .Range("E" & .Cells(.Rows.Count, "E").End(xlUp).Row+1 )
end With
wb.Worksheets(1).Range("B15:E81,N15:O81").Copy target
</code>```

Title: My code is running but not inserting any value

Body:
Can't you use Copy ? Then the target size does not have to be calculated.

dim target as range
With ThisWorkbook.Worksheets("Sheet1")
   set target = .Range("E" & .Cells(.Rows.Count, "E").End(xlUp).Row+1 )
end With
wb.Worksheets(1).Range("B15:E81,N15:O81").Copy target


问:
How to put activityindicator middle of a tableview
I have put activity indicator

```<code> spinner.center = CGPointMake( [UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
[self.view addSubview:spinner];
</code>```

But this is not properly centered in the table view. Because table view can scroll.
How can i put a spinner in the center of the screen.

答:
Please find below code:</p>

```<code>UIActivityIndicatorView* spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinner.center = CGPointMake( [UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[spinner startAnimating];
[appDelegate.window addSubview:spinner];
</code>```

Body:
I have put activity indicator

 spinner.center = CGPointMake( [UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
[self.view addSubview:spinner];

But this is not properly centered in the table view. Because table view can scroll.
How can i put a spinner in the center of the screen.

Body:
Please find below code:

UIActivityIndicatorView* spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
spinner.center = CGPointMake( [UIScreen mainScreen].bounds.size.width/2,[UIScreen mainScreen].bounds.size.height/2);
AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
[spinner startAnimating];
[appDelegate.window addSubview:spinner];


问:
php string in a string with double and single quotes as 1 string

Hello, I am trying to make a array in php that looks like this:

```<code>$array= array("test"2"", "'test"2"'");
</code>```

Of course this doesn't work because of the two strings, but is there a way in php to get is to ignore all quotes in such a string so it sees it as a valid string? The problem being that I need the quotes in my string and it are double quotes and single quotes.

EDIT:
Thanks for the quick response! I was wondering if there is a way of doing this with code? I have a huge string to do this with?

```<code>$array= array("test\"2\"", "'test\"2\"'");
</code>```

答:
You have to escape quotes in strings.</p>

```<code>$array= array("test\"2\"", "'test\"2\"'");
</code>```

Body:
Hello, I am trying to make a array in php that looks like this:

$array= array("test"2"", "'test"2"'");

Of course this doesn't work because of the two strings, but is there a way in php to get is to ignore all quotes in such a string so it sees it as a valid string? The problem being that I need the quotes in my string and it are double quotes and single quotes.

EDIT:
Thanks for the quick response! I was wondering if there is a way of doing this with code? I have a huge string to do this with?

$array= array("test\"2\"", "'test\"2\"'");

Body:
You have to escape quotes in strings.

$array= array("test\"2\"", "'test\"2\"'");


问:
how can we know, by what user the sql is executed in jmeter
I'm executing the sqls with different jdbc-connection strings. Each sql will run on respective database-user. Sqls are executing fine. But, I need confirmation like, the sql is executed with the user mentioned in connection-string. Is there any option which will emit the user involved to execute the sql to jtl ?</p>

答:
We can make it possible by . Parse the username using regex and read the variable through BeanShellPostprocessor and put same to the jtl.

```<code><hashTree /><RegexExtractor enabled="true" guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="Regular Expression Extractor">
            <stringProp name="RegexExtractor.useHeaders">true</stringProp>
            <stringProp name="RegexExtractor.refname">UserName</stringProp>
            <stringProp name="RegexExtractor.regex">UserName=(\w+), </stringProp>
            <stringProp name="RegexExtractor.template">$1$</stringProp>
            <stringProp name="RegexExtractor.default" />
            <stringProp name="RegexExtractor.match_number" />
</RegexExtractor><hashTree />
</code>```

In Beanshell postprocessor read it:

```<code>String db_user = vars.get("UserName");
vars.put("db_user", db_user);
</code>```

Note: Also, need to mention the variable name used here at jmeter/bin/jmeter.properties file.

```<code>sample_variables=db_user
</code>```

By above way, we can achieve this.

Body:
We can make it possible by . Parse the username using regex and read the variable through BeanShellPostprocessor and put same to the jtl.

<hashTree /><RegexExtractor enabled="true" guiclass="RegexExtractorGui" testclass="RegexExtractor" testname="Regular Expression Extractor">
            <stringProp name="RegexExtractor.useHeaders">true</stringProp>
            <stringProp name="RegexExtractor.refname">UserName</stringProp>
            <stringProp name="RegexExtractor.regex">UserName=(\w+), </stringProp>
            <stringProp name="RegexExtractor.template">$1$</stringProp>
            <stringProp name="RegexExtractor.default" />
            <stringProp name="RegexExtractor.match_number" />
</RegexExtractor><hashTree />

In Beanshell postprocessor read it:

String db_user = vars.get("UserName");
vars.put("db_user", db_user);

Note: Also, need to mention the variable name used here at jmeter/bin/jmeter.properties file.

sample_variables=db_user

By above way, we can achieve this.


问:
Starting AVD Emulator always gives "Android Emulator Closed unexpectedly"
My sincere thanks for your reading this.

I have just installed Android Studio and am attempting to run the default Hello World! script that is present when you create a new project.

Every time I try to run the the program in an Android Emulator my Emulator crashes and I get the error "Android Emulator Closed Unexpectedly" Every. Single. Time.

I have the Intel x86 Emulator Accelerator (HAXM installer) installed as suggested:

I try to run a Nexus 4 emulator with 512 mb of Ram and it never works:

When I run this I get:

During this, my system physical memory peaks at 80% but never goes to 100 (which I would expect if it were crashing).

I have searched similar questions including

Android emulator crashing on Windows 7 64 Bit Android 4.0 emulator always has a crashing Launcher? Android studio emulator fails to start with memory limit related error message and they say to lower the memory size (which is what I am trying to do). Unfortunately this isn't working

Any idea how I can solve this issue?

My computer specs are as follows:
64 Bit Windows
6gb Ram
Intel Core i3

I downloaded and installed all correct versions as instructed here: https://developer.android.com/studio/install.html

答:
I was also having the same problem, Every time I was starting Emulator, it was closing unexpectedly. then I tried to change the Emulator Performance in settings of AVD Managers; In Software it's not working but in Hardware it was showing blank black screen.
Then I realized, there might be some issue with Graphics Card(mine NVIDIA GeForce 940MX), It was showing this error

After Updating/Restarting the problem was not resolving, then I Disabled then Enabled the Graphics Card Driver in the Device Manager and It worked!!

LONG STORY SHORT: Check, the problem might be due to your Graphics Card!


问:
Django + WSGI: When is wsgi.py called?
I deployed my Django-project via Apache2 on a server.

The problem I have is that I have two setting-modules: settings.py which are my local development settings and settingsprod.py which are my productive settings.

I found the following line in the WSGI.py:

```<code>os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings")
</code>```

Is this module only called when using WSGI? And if yes is this a good place to use my production settings like so?

```<code>os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settingsprod")
</code>```

For local development I use the development server like so:

```<code>python3 manage.py runserver
</code>```

Does this still defaults to settings.py then?

答:
Yes, your setup works as expected. Though if you use extra tools like celery, you might need to also specify the settingsprod for those setups aswell.

The way I handle such a situation is exactly the other way around: I use settings.py for my production settings and have an additional settings_development.py that I use for all development tasks. This way I don't have to remember setting the production settings in all production relevant files, but instead simply use the development settings for development like so:

```<code>python3 manage.py runserver --settings=proj.settings_development
</code>```

If you often use manage.py commands and want to save some time typing, you can make a copy of your manage.py e.g. as manage_dev.py and change the settings module line like so:

```<code>os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings_development")
</code>```

and then call your manage functions with:

```<code>python3 manage_dev.py runserver
</code>```

Title: Django + WSGI: When is wsgi.py called?

Body:
I deployed my Django-project via Apache2 on a server.

The problem I have is that I have two setting-modules: settings.py which are my local development settings and settingsprod.py which are my productive settings.

I found the following line in the WSGI.py:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings")

Is this module only called when using WSGI? And if yes is this a good place to use my production settings like so?

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settingsprod")

For local development I use the development server like so:

python3 manage.py runserver

Does this still defaults to settings.py then?

Body:
Yes, your setup works as expected. Though if you use extra tools like celery, you might need to also specify the settingsprod for those setups aswell.

The way I handle such a situation is exactly the other way around: I use settings.py for my production settings and have an additional settings_development.py that I use for all development tasks. This way I don't have to remember setting the production settings in all production relevant files, but instead simply use the development settings for development like so:

python3 manage.py runserver --settings=proj.settings_development

If you often use manage.py commands and want to save some time typing, you can make a copy of your manage.py e.g. as manage_dev.py and change the settings module line like so:

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings_development")

and then call your manage functions with:

python3 manage_dev.py runserver


问:
What nhibernate mapping is used for string[] in an entity?
I have a strange situation I need to persist:

```<code>public class Person
{
  public string[] Nicknames { get; set; }
}
</code>```

What mapping and table structure would be best to persist this string array?

答:
You can map arrays directly, but you'll need a few additional columns:

```<code><!-- can live w/o orderby -->
<array name="Nicknames" table="Nicknames" order-by="indexColumn ASC">
  <key column="keyColumn"/>
  <index column="indexColumn"/> <!-- position in array -->
  <element column="nickname" type="String"/>
</array>
</code>```

If you don't have the other columns you need, I would probably persist it as a normal bag or list and expose it as an array from that in the entity.

Body:
I have a strange situation I need to persist:

public class Person
{
  public string[] Nicknames { get; set; }
}

What mapping and table structure would be best to persist this string array?

Body:
You can map arrays directly, but you'll need a few additional columns:

<!-- can live w/o orderby -->
<array name="Nicknames" table="Nicknames" order-by="indexColumn ASC">
  <key column="keyColumn"/>
  <index column="indexColumn"/> <!-- position in array -->
  <element column="nickname" type="String"/>
</array>

If you don't have the other columns you need, I would probably persist it as a normal bag or list and expose it as an array from that in the entity.