问:
NoSuchMethodError: While integrating Firebase with app engine app
I was trying to integrate firebase real time database with google app engine app. I was getting this error when calling

```<code>> DatabaseReference ref = FirebaseDatabase
>                   .getInstance()
>                   .getReference("todoItems");
</code>```

Stacktrace is

03:21:01.450 Error for /productSync java.lang.NoSuchMethodError:
  com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
    at
  com.google.firebase.FirebaseApp.checkNotDeleted(FirebaseApp.java:314)
    at com.google.firebase.FirebaseApp.getOptions(FirebaseApp.java:260)
    at
  com.google.firebase.database.FirebaseDatabase.getInstance(FirebaseDatabase.java:80)
    at in.prago.servlet.ProductDataSync.doGet(ProductDataSync.java:83)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)     at
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)  at
  org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at
  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at
  com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
    at
  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at
  com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:37)
    at
  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at
  com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
    at
  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at
  com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
    at
  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at
  org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at
  org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at
  org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at
  org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at
  org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at
  com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:257)
    at
  org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)     at
  org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at
  org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at
  com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at
  com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:145)
    at
  com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:644)
    at
  com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:604)
    at
  com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:574)
    at
  com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:453)
    at
  com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:460)
    at
  com.google.tracing.CurrentContext.runInContext(CurrentContext.java:293)
    at
  com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:319)
    at
  com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:311)
    at
  com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:457)
    at
  com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:238)
    at java.lang.Thread.run(Thread.java:745)

This same problem has been discussed in many forums where people suggested to upgrade Guava 19.0 to Guava 20.0. In my case I was not using any such library, therefore I tried adding both, but it didn't worked out for me. Same error was there every time. I am also adding my pom.xml file just in case someone needs to have a look at it. Any help would be appreciated.

Here is a link to one such forum https://github.com/google/guava/issues/2380

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <packaging>war</packaging>
    <version>1.0</version>

    <properties>
        <appengine.app.version>1</appengine.app.version>
        <appengine.target.version>1.9.53</appengine.target.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>

     <dependency>
  <groupId>com.google.firebase</groupId>
  <artifactId>firebase-admin</artifactId>
  <version>5.0.0</version>
</dependency>

<dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>20.0</version>
    </dependency>

        <!-- Compile/runtime dependencies -->
        <dependency>
    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-framework</artifactId>
    <version>2.0.7</version>
</dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-endpoints</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.objectify</groupId>
            <artifactId>objectify</artifactId>
            <version>5.0</version>
        </dependency>

        <dependency>
    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-management-control-appengine</artifactId>
    <version>1.0.0-beta.11</version>
</dependency>
<dependency>
    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-framework-auth</artifactId>
    <version>1.0.0-beta.11</version>
</dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
        </dependency>

    </dependencies>

    <build>
        <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>2.5.1</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>endpoints-framework-maven-plugin</artifactId>
    <version>1.0.0-beta5</version>
    <configuration>
        <!-- plugin configuration -->
    </configuration>
</plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml>
                    <webResources>
                        <resource>
                            <!-- this is relative to the pom.xml directory -->
                            <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory>
                            <!-- the list has a default value of ** -->
                            <includes>
                                <include>WEB-INF/*.discovery</include>
                                <include>WEB-INF/*.api</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.target.version}</version>
                <configuration>
                    <enableJarClasses>false</enableJarClasses>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>endpoints_get_discovery_doc</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            com.google.appengine
                                        </groupId>
                                        <artifactId>
                                            appengine-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [1.9.3,)
                                        </versionRange>
                                        <goals>
                                            <goal>
                                                endpoints_get_discovery_doc
                                            </goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <groupId>in.prago</groupId>
    <artifactId>prago</artifactId>
</project>
</code>```

Update :

As suggested by Auberon I updated my pom.xml with new version of Objectify 5.1.17 and removed the guava depedency. I tried running the code but the same error coined up again. Here is my stacktrace

```<code>> com.google.api.server.spi.SystemService invokeServiceMethod: exception
> occurred while calling backend method (SystemService.java:398)
>
> java.lang.NoSuchMethodError:
> com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
>   at
> com.google.firebase.FirebaseApp.checkNotDeleted(FirebaseApp.java:314)
>   at com.google.firebase.FirebaseApp.getOptions(FirebaseApp.java:260)
>   at
> com.google.firebase.database.FirebaseDatabase.getInstance(FirebaseDatabase.java:80)
>   at
> in.prago.spi.PragoMerchantApi.saveProfile(PragoMerchantApi.java:189)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:42)  at
> com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:363)
>   at
> com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:113)
>   at
> com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:71)
>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)     at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)  at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
>   at
> com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>   at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
>   at
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>   at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>   at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>   at
> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
>   at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>   at org.mortbay.jetty.Server.handle(Server.java:326)     at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>   at
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
>   at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>   at
> com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:453)
>   at
> com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:460)
>   at
> com.google.tracing.CurrentContext.runInContext(CurrentContext.java:293)
>   at
> com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:319)
>   at
> com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:311)
>   at
> com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:457)
>   at java.lang.Thread.run(Thread.java:745)
</code>```

    http://maven.apache.org/xsd/maven-4.0.0.xsd">

```<code>    <modelVersion>4.0.0</modelVersion>
    <packaging>war</packaging>
    <version>1.0</version>

    <properties>
        <appengine.app.version>1</appengine.app.version>
        <appengine.target.version>1.9.53</appengine.target.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>

     <dependency>
  <groupId>com.google.firebase</groupId>
  <artifactId>firebase-admin</artifactId>
  <version>5.0.0</version>
</dependency>

<dependency>

    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-framework</artifactId>
    <version>2.0.7</version>
</dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-endpoints</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.objectify</groupId>
            <artifactId>objectify</artifactId>
            <version>5.1.17</version>
        </dependency>

        <dependency>
    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-management-control-appengine</artifactId>
    <version>1.0.0-beta.11</version>
</dependency>
<dependency>
    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-framework-auth</artifactId>
    <version>1.0.0-beta.11</version>
</dependency>

        <!-- Test Dependencies -->
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
        </dependency>

    </dependencies>

    <build>
        <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>2.5.1</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>endpoints-framework-maven-plugin</artifactId>
    <version>1.0.0-beta5</version>
    <configuration>
        <!-- plugin configuration -->
    </configuration>
</plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml>
                    <webResources>
                        <resource>
                            <!-- this is relative to the pom.xml directory -->
                            <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory>
                            <!-- the list has a default value of ** -->
                            <includes>
                                <include>WEB-INF/*.discovery</include>
                                <include>WEB-INF/*.api</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.target.version}</version>
                <configuration>
                    <enableJarClasses>false</enableJarClasses>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>endpoints_get_discovery_doc</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            com.google.appengine
                                        </groupId>
                                        <artifactId>
                                            appengine-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [1.9.3,)
                                        </versionRange>
                                        <goals>
                                            <goal>
                                                endpoints_get_discovery_doc
                                            </goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <groupId>in.prago</groupId>
    <artifactId>prago</artifactId>
</project>
</code>```

答:
I also ran into this error and I never used Guava either. Funnily enough, my Glassfish server was using it's Guava version over the imported one! Run this code before the error to find out where your problematic Guava is coming from.

System.out.println(com.google.common.base.Preconditions.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm());

Then download the most recent guava (currently Guava 22.0) and replace the old Guava file with the new one. This should fix your issue.

At this point, you should also be using the newer firebase version as well. I believe the developer also had the wrong Guava version in a previous firebase version.

```<code>        <dependency>
        <groupId>com.google.firebase</groupId>
        <artifactId>firebase-admin</artifactId>
        <version>5.2.0</version>
        </dependency>
</code>```

Body:
I was trying to integrate firebase real time database with google app engine app. I was getting this error when calling

> DatabaseReference ref = FirebaseDatabase
>                   .getInstance()
>                   .getReference("todoItems");

Stacktrace is

03:21:01.450 Error for /productSync java.lang.NoSuchMethodError:
  com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
    at
  com.google.firebase.FirebaseApp.checkNotDeleted(FirebaseApp.java:314)
    at com.google.firebase.FirebaseApp.getOptions(FirebaseApp.java:260)
    at
  com.google.firebase.database.FirebaseDatabase.getInstance(FirebaseDatabase.java:80)
    at in.prago.servlet.ProductDataSync.doGet(ProductDataSync.java:83)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)     at
  javax.servlet.http.HttpServlet.service(HttpServlet.java:717)  at
  org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
    at
  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
    at
  com.google.apphosting.utils.servlet.ParseBlobUploadFilter.doFilter(ParseBlobUploadFilter.java:125)
    at
  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at
  com.google.apphosting.runtime.jetty.SaveSessionFilter.doFilter(SaveSessionFilter.java:37)
    at
  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at
  com.google.apphosting.utils.servlet.JdbcMySqlConnectionCleanupFilter.doFilter(JdbcMySqlConnectionCleanupFilter.java:60)
    at
  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at
  com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:48)
    at
  org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
    at
  org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
    at
  org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
    at
  org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
    at
  org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
    at
  org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
    at
  com.google.apphosting.runtime.jetty.AppVersionHandlerMap.handle(AppVersionHandlerMap.java:257)
    at
  org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
    at org.mortbay.jetty.Server.handle(Server.java:326)     at
  org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
    at
  org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
    at
  com.google.apphosting.runtime.jetty.RpcRequestParser.parseAvailable(RpcRequestParser.java:76)
    at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
    at
  com.google.apphosting.runtime.jetty.JettyServletEngineAdapter.serviceRequest(JettyServletEngineAdapter.java:145)
    at
  com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchServletRequest(JavaRuntime.java:644)
    at
  com.google.apphosting.runtime.JavaRuntime$RequestRunnable.dispatchRequest(JavaRuntime.java:604)
    at
  com.google.apphosting.runtime.JavaRuntime$RequestRunnable.run(JavaRuntime.java:574)
    at
  com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:453)
    at
  com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:460)
    at
  com.google.tracing.CurrentContext.runInContext(CurrentContext.java:293)
    at
  com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:319)
    at
  com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:311)
    at
  com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:457)
    at
  com.google.apphosting.runtime.ThreadGroupPool$PoolEntry.run(ThreadGroupPool.java:238)
    at java.lang.Thread.run(Thread.java:745)

This same problem has been discussed in many forums where people suggested to upgrade Guava 19.0 to Guava 20.0. In my case I was not using any such library, therefore I tried adding both, but it didn't worked out for me. Same error was there every time. I am also adding my pom.xml file just in case someone needs to have a look at it. Any help would be appreciated.

Here is a link to one such forum https://github.com/google/guava/issues/2380

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <packaging>war</packaging>
    <version>1.0</version>

    <properties>
        <appengine.app.version>1</appengine.app.version>
        <appengine.target.version>1.9.53</appengine.target.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>

     <dependency>
  <groupId>com.google.firebase</groupId>
  <artifactId>firebase-admin</artifactId>
  <version>5.0.0</version>
</dependency>

<dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>20.0</version>
    </dependency>

        <dependency>
    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-framework</artifactId>
    <version>2.0.7</version>
</dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-endpoints</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.objectify</groupId>
            <artifactId>objectify</artifactId>
            <version>5.0</version>
        </dependency>

        <dependency>
    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-management-control-appengine</artifactId>
    <version>1.0.0-beta.11</version>
</dependency>
<dependency>
    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-framework-auth</artifactId>
    <version>1.0.0-beta.11</version>
</dependency>

        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
        </dependency>

    </dependencies>

    <build>
        <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>2.5.1</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>endpoints-framework-maven-plugin</artifactId>
    <version>1.0.0-beta5</version>
    <configuration>

    </configuration>
</plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml>
                    <webResources>
                        <resource>

                            <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory>

                            <includes>
                                <include>WEB-INF/*.discovery</include>
                                <include>WEB-INF/*.api</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.target.version}</version>
                <configuration>
                    <enableJarClasses>false</enableJarClasses>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>endpoints_get_discovery_doc</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>

                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            com.google.appengine
                                        </groupId>
                                        <artifactId>
                                            appengine-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [1.9.3,)
                                        </versionRange>
                                        <goals>
                                            <goal>
                                                endpoints_get_discovery_doc
                                            </goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <groupId>in.prago</groupId>
    <artifactId>prago</artifactId>
</project>

Update :

As suggested by Auberon I updated my pom.xml with new version of Objectify 5.1.17 and removed the guava depedency. I tried running the code but the same error coined up again. Here is my stacktrace

> com.google.api.server.spi.SystemService invokeServiceMethod: exception
> occurred while calling backend method (SystemService.java:398)
>
> java.lang.NoSuchMethodError:
> com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;)V
>   at
> com.google.firebase.FirebaseApp.checkNotDeleted(FirebaseApp.java:314)
>   at com.google.firebase.FirebaseApp.getOptions(FirebaseApp.java:260)
>   at
> com.google.firebase.database.FirebaseDatabase.getInstance(FirebaseDatabase.java:80)
>   at
> in.prago.spi.PragoMerchantApi.saveProfile(PragoMerchantApi.java:189)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:42)  at
> com.google.api.server.spi.SystemService.invokeServiceMethod(SystemService.java:363)
>   at
> com.google.api.server.spi.SystemServiceServlet.execute(SystemServiceServlet.java:113)
>   at
> com.google.api.server.spi.SystemServiceServlet.doPost(SystemServiceServlet.java:71)
>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)     at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:717)  at
> org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1166)
>   at
> com.googlecode.objectify.ObjectifyFilter.doFilter(ObjectifyFilter.java:48)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>   at
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>   at
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
>   at
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>   at
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>   at
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>   at
> org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
>   at
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>   at org.mortbay.jetty.Server.handle(Server.java:326)     at
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>   at
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
>   at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>   at
> com.google.tracing.TraceContext$TraceContextRunnable.runInContext(TraceContext.java:453)
>   at
> com.google.tracing.TraceContext$TraceContextRunnable$1.run(TraceContext.java:460)
>   at
> com.google.tracing.CurrentContext.runInContext(CurrentContext.java:293)
>   at
> com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContextNoUnref(TraceContext.java:319)
>   at
> com.google.tracing.TraceContext$AbstractTraceContextCallback.runInInheritedContext(TraceContext.java:311)
>   at
> com.google.tracing.TraceContext$TraceContextRunnable.run(TraceContext.java:457)
>   at java.lang.Thread.run(Thread.java:745)

    http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <packaging>war</packaging>
    <version>1.0</version>

    <properties>
        <appengine.app.version>1</appengine.app.version>
        <appengine.target.version>1.9.53</appengine.target.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>

     <dependency>
  <groupId>com.google.firebase</groupId>
  <artifactId>firebase-admin</artifactId>
  <version>5.0.0</version>
</dependency>

<dependency>

    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-framework</artifactId>
    <version>2.0.7</version>
</dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-endpoints</artifactId>
            <version>${appengine.target.version}</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.objectify</groupId>
            <artifactId>objectify</artifactId>
            <version>5.1.17</version>
        </dependency>

        <dependency>
    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-management-control-appengine</artifactId>
    <version>1.0.0-beta.11</version>
</dependency>
<dependency>
    <groupId>com.google.endpoints</groupId>
    <artifactId>endpoints-framework-auth</artifactId>
    <version>1.0.0-beta.11</version>
</dependency>

        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-testing</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-stubs</artifactId>
            <version>${appengine.target.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
        </dependency>

    </dependencies>

    <build>
        <outputDirectory>target/${project.artifactId}-${project.version}/WEB-INF/classes</outputDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <version>2.5.1</version>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>endpoints-framework-maven-plugin</artifactId>
    <version>1.0.0-beta5</version>
    <configuration>

    </configuration>
</plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <webXml>${project.build.directory}/generated-sources/appengine-endpoints/WEB-INF/web.xml</webXml>
                    <webResources>
                        <resource>

                            <directory>${project.build.directory}/generated-sources/appengine-endpoints</directory>

                            <includes>
                                <include>WEB-INF/*.discovery</include>
                                <include>WEB-INF/*.api</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>${appengine.target.version}</version>
                <configuration>
                    <enableJarClasses>false</enableJarClasses>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>endpoints_get_discovery_doc</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>

                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            com.google.appengine
                                        </groupId>
                                        <artifactId>
                                            appengine-maven-plugin
                                        </artifactId>
                                        <versionRange>
                                            [1.9.3,)
                                        </versionRange>
                                        <goals>
                                            <goal>
                                                endpoints_get_discovery_doc
                                            </goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
    <groupId>in.prago</groupId>
    <artifactId>prago</artifactId>
</project>

Body:
I also ran into this error and I never used Guava either. Funnily enough, my Glassfish server was using it's Guava version over the imported one! Run this code before the error to find out where your problematic Guava is coming from.

System.out.println(com.google.common.base.Preconditions.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm());

Then download the most recent guava (currently Guava 22.0) and replace the old Guava file with the new one. This should fix your issue.

At this point, you should also be using the newer firebase version as well. I believe the developer also had the wrong Guava version in a previous firebase version.

        <dependency>
        <groupId>com.google.firebase</groupId>
        <artifactId>firebase-admin</artifactId>
        <version>5.2.0</version>
        </dependency>


来源: stackexchange

问:
compare column of two rows of same table in mysql
I have a table name player_history containing history of player. in this table having column player_id, Final_position,meeting_code,race_no and beaten_time. If a player stood a first or second position the time will be same there are meeting code one day and in each meeting code there are maximum 10 races.

I want to select those records where 1st and second position beaten time are not same.

```<code>player_id Meeting_Code race_no final_position beaten_time
  1         0001          1         1             2
  2         0001          1         2             2
  1         0001          2         1             5
  2         0001          2         2             6
... so on
</code>```

Output should be:

```<code>player_id Meeting_Code race_no final_position beaten_time
  1         0001          2         1             5
  2         0001          2         2             6
</code>```

Also if it is not correct I want to update records of first position only.

答:
Let table name be Test. Try to put Self Join or something like this:

```<code>Select t1.player_id t1.Meeting_Code t1.race_no t1.final_position t1.beaten_time
From Test t1
LEFT JOIN Test t2 ON t1.beaten_time != t2.beaten_time.
</code>```

Try like this. It might work.

ContentLicense: CC BY-SA 3.0

Body:
I have a table name player_history containing history of player. in this table having column player_id, Final_position,meeting_code,race_no and beaten_time. If a player stood a first or second position the time will be same there are meeting code one day and in each meeting code there are maximum 10 races.

I want to select those records where 1st and second position beaten time are not same.

player_id Meeting_Code race_no final_position beaten_time
  1         0001          1         1             2
  2         0001          1         2             2
  1         0001          2         1             5
  2         0001          2         2             6
... so on

Output should be:

player_id Meeting_Code race_no final_position beaten_time
  1         0001          2         1             5
  2         0001          2         2             6

Also if it is not correct I want to update records of first position only.

Body:
Let table name be Test. Try to put Self Join or something like this:

Select t1.player_id t1.Meeting_Code t1.race_no t1.final_position t1.beaten_time
From Test t1
LEFT JOIN Test t2 ON t1.beaten_time != t2.beaten_time.

Try like this. It might work.


问:
style a textbox into the following format?
I have a field called WATER METER READING(Right now its a textbox to take 6 numbers) on my HTml page, but I need to change its format to display as  [][][][][][] (6 separate small (single digit forms)).... all 6 fields required and all need to be a number.

finally it should look like this.

Water Meter Reading:* [][][][][][]

Any suggestions how to display the values like this.

答:
You can have multiple span tags and set the background image of those span to the box look you want.
e.g. 09578
in css set the background image for this spans to your like.

ContentLicense: CC BY-SA 2.5

Body:
You can have multiple span tags and set the background image of those span to the box look you want.
e.g. <span>0</span><span>9</span><span>5</span><span>7</span><span>8</span>
in css set the background image for this spans to your like.


问:
How to create .appxupload for created appx using makeappx tool?
I have created appx for .Net Desktop application using makeappx tool.I had used this command to generate appx:
makeappx pack -d "C:\Centennial\PackageLayout"-p "C:\Centennial\Output\HelloCentennial.appx"
The package creation is succeeded and I am getting output as HelloCentennial.appx.The windows app certification kit test also passed.
But When I want to upload it on windows store it asks for .appxupload file.
I know .appxupload  is a zip-file contaning the .appx package and an .appxsym file.But I don't know how to manually create it or generate it using MakeAppx tool.It would be great If anyone can help on this.</p>

答:
But I don't know how to manually create it or generate it using MakeAppx tool

The .appxsym file cannot be created by MakeAppx.exe. You could use PDBCopy.exe to manually copy all PDB files related to all dll, exe or winmd libraries without private symbols. This tool takes a symbol file that contains both private symbol data and a public symbol table, and creates a copy of that file that contains only the public symbol table.

These PDB symbols can be zipped into .appxsym file. Then you can zip the .appx and .appxsym into the .appxupload file you need to upload.

There will be no crash analytic or debugging information available if you don't include the .appxsym.


问:
How to update /etc/hosts file in Docker image during "docker build"
I want to update my /etc/hosts file during "docker build".

I added below line in Dockerfile but it's neither updating /etc/hosts file nor giving any error.

```<code>RUN echo "192.168.33.11    mynginx" >> /etc/hosts
</code>```

I need to update /etc/hosts. Can anyone suggest on this?

答:
Just a quick answer to run your container using:

```<code>docker exec -it <container name> /bin/bash
</code>```

once the container is open:

```<code>cd ..
</code>```

then

```<code>`cd etc`
</code>```

and then you can

```<code>cat hosts
</code>```

or:

```<code>apt-get update
apt-get vim
</code>```

or any editor you like and open it in vim, here you can modify say your startup ip to 0.0.0.0

Body:
I want to update my /etc/hosts file during "docker build".

I added below line in Dockerfile but it's neither updating /etc/hosts file nor giving any error.

RUN echo "192.168.33.11    mynginx" >> /etc/hosts

I need to update /etc/hosts. Can anyone suggest on this?

Body:
Just a quick answer to run your container using:

docker exec -it <container name> /bin/bash

once the container is open:

cd ..

then

`cd etc`

and then you can

cat hosts

or:

apt-get update
apt-get vim

or any editor you like and open it in vim, here you can modify say your startup ip to 0.0.0.0


问:
overflow flag required in signed compares?
i am implementing a custom 16bit cpu (in verilog). I'm having trouble wrapping my head around if I need to implement an overflow flag to handle signed compares.

In my current implementation I am only checking the result for zero and the sign bit to determine the result of compares:

```<code>when comparing x to y the ALU calculates: x - y (2's compl)
If the sign bit is set and the result is not zero y > x
If the sign bit is not set and the result is not zero x > y
</code>```

I am not using an overflow flag to determine the outcome of the compares. I have tried many different values for x and y and they all come out correct.

Can signed compare be implemented without an overflow flag? If not, could you give me values for x and y that would give the wrong result this way?

答:
First of all:

The "sign" bit does not help you for checking if x > y. You need the "carry" bit as you can see using 8-bit unsigned arithmetic:

```<code>132 - 2 = 130 (sign bit set, carry clear)
132 - 6 = 126 (sign bit clear, carry clear)
6 - 132 = 130 (sign bit set, carry set)
2 - 132 = 126 (sign bit clear, carry set)
</code>```

(Replace "132" by "-124" and you see that it also won't work with signed arithmetic.)

Your actual question:

It depends, what exactly you want to ask:

If it is possible to design a CPU that can do signed comparison only having an instruction set allowing unsigned comparison:

In this case the answer is yes - as you can read in the comments to your answer. Simply invert the uppermost bit of both numbers (using a XOR operation) before doing the CMP operation.

If you want to know how many "flag" bits you need so a conditional jump based on a signed comparison is possible with (only) a CMP instruction and a conditional jump instruction:

You will need at least 3 flags: "Zero", "Carry" and a third one allowing you to calculate the value "Sign XOR Overflow".

(So you might use the "SignXorOverflow" flag.)

Because "Overflow" cannot be calculated from "Zero", "Carry" and "Sign" you will need the "Overflow" bit if you want to have the "Sign" bit.

Body:
i am implementing a custom 16bit cpu (in verilog). I'm having trouble wrapping my head around if I need to implement an overflow flag to handle signed compares.

In my current implementation I am only checking the result for zero and the sign bit to determine the result of compares:

when comparing x to y the ALU calculates: x - y (2's compl)
If the sign bit is set and the result is not zero y > x
If the sign bit is not set and the result is not zero x > y

I am not using an overflow flag to determine the outcome of the compares. I have tried many different values for x and y and they all come out correct.

Can signed compare be implemented without an overflow flag? If not, could you give me values for x and y that would give the wrong result this way?

Body:
First of all:

The "sign" bit does not help you for checking if x > y. You need the "carry" bit as you can see using 8-bit unsigned arithmetic:

132 - 2 = 130 (sign bit set, carry clear)
132 - 6 = 126 (sign bit clear, carry clear)
6 - 132 = 130 (sign bit set, carry set)
2 - 132 = 126 (sign bit clear, carry set)

(Replace "132" by "-124" and you see that it also won't work with signed arithmetic.)

Your actual question:

It depends, what exactly you want to ask:

If it is possible to design a CPU that can do signed comparison only having an instruction set allowing unsigned comparison:

In this case the answer is yes - as you can read in the comments to your answer. Simply invert the uppermost bit of both numbers (using a XOR operation) before doing the CMP operation.

If you want to know how many "flag" bits you need so a conditional jump based on a signed comparison is possible with (only) a CMP instruction and a conditional jump instruction:

You will need at least 3 flags: "Zero", "Carry" and a third one allowing you to calculate the value "Sign XOR Overflow".

(So you might use the "SignXorOverflow" flag.)

Because "Overflow" cannot be calculated from "Zero", "Carry" and "Sign" you will need the "Overflow" bit if you want to have the "Sign" bit.


问:
A nested INSERT, UPDATE, DELETE, or MERGE statement must have an OUTPUT clause in UPDATE
I'm trying to update some values based on every Id in the list. The logic I have seems to be what I want.

I want to populate a temporary table of Ids. Then for every ID I want to apply this query and output the deleted date and the ID into a new table I've created.

I keep getting the error:

Msg 10716, Level 15, State 1, Line 25
A nested INSERT, UPDATE, DELETE, or MERGE statement must have an OUTPUT clause.

What does this mean? I thought I am OUTPUTTING into the new table I've created.

```<code>USE datatemp

GO

DECLARE @idlist TABLE (id INT)
INSERT INTO @idlist (id) VALUES (3009099)

DECLARE @EndDate DATETIME
SET @EndDate = '2099-12-12'

IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TEMP_TABLE')
BEGIN
    CREATE TABLE  [TEMP_TABLE] (
        [id] INT,
        [thedatetoend] DATETIME);
END

BEGIN TRY
    SELECT  *
    FROM @idlist AS idlist
        OUTER APPLY(
                    UPDATE [custprofile]
                    SET thedatetoend = @EndDate
                    OUTPUT idlist.id, DELETED.thedatetoend
                        INTO [TEMP_TABLE]
                    FROM [custprofile] as bc
                    INNER JOIN [custinformation] as cc
                    ON cc.custengageid = bc.custengageid
                    WHERE cc.id = idlist.id
                                    AND bc.modifierid = 2
                                    AND bc.thedatetoend > GETDATE()
                                    AND cc.type = 1) o
</code>```

答:
I think you may have more success by using a CTE and avoiding the outer apply approach you are currently using. Updates made to the CTE cascade to the source table. It might look something like the following but as some columns don't reference the table aliases don't expect this to work "as is" (i.e. I'm not sure if you are outputting ccid or bcid and I don't know which table thedatetoend belongs to.)</p>

```<code>WITH
      CTE AS (
                  SELECT
                        cc.id AS ccid, bcid AS bcid, thedatetoend
                  FROM [custprofile] AS bc
                  INNER JOIN [custinformation] AS cc ON cc.custengageid = bc.custengageid
                  INNER JOIN @idlist AS idlist ON cc.id = idlist.id
                  WHERE bc.modifierid = 2
                  AND bc.thedatetoend > GETDATE()
                  AND cc.type = 1
            )
UPDATE CTE
SET thedatetoend = @EndDate
OUTPUT ccid, DELETED.thedatetoend
INTO [TEMP_TABLE]
</code>```

Body:
I'm trying to update some values based on every Id in the list. The logic I have seems to be what I want.

I want to populate a temporary table of Ids. Then for every ID I want to apply this query and output the deleted date and the ID into a new table I've created.

I keep getting the error:

Msg 10716, Level 15, State 1, Line 25
A nested INSERT, UPDATE, DELETE, or MERGE statement must have an OUTPUT clause.

What does this mean? I thought I am OUTPUTTING into the new table I've created.

USE datatemp

GO

DECLARE @idlist TABLE (id INT)
INSERT INTO @idlist (id) VALUES (3009099)

DECLARE @EndDate DATETIME
SET @EndDate = '2099-12-12'

IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TEMP_TABLE')
BEGIN
    CREATE TABLE  [TEMP_TABLE] (
        [id] INT,
        [thedatetoend] DATETIME);
END

BEGIN TRY
    SELECT  *
    FROM @idlist AS idlist
        OUTER APPLY(
                    UPDATE [custprofile]
                    SET thedatetoend = @EndDate
                    OUTPUT idlist.id, DELETED.thedatetoend
                        INTO [TEMP_TABLE]
                    FROM [custprofile] as bc
                    INNER JOIN [custinformation] as cc
                    ON cc.custengageid = bc.custengageid
                    WHERE cc.id = idlist.id
                                    AND bc.modifierid = 2
                                    AND bc.thedatetoend > GETDATE()
                                    AND cc.type = 1) o

Body:
I think you may have more success by using a CTE and avoiding the outer apply approach you are currently using. Updates made to the CTE cascade to the source table. It might look something like the following but as some columns don't reference the table aliases don't expect this to work "as is" (i.e. I'm not sure if you are outputting ccid or bcid and I don't know which table thedatetoend belongs to.)

WITH
      CTE AS (
                  SELECT
                        cc.id AS ccid, bcid AS bcid, thedatetoend
                  FROM [custprofile] AS bc
                  INNER JOIN [custinformation] AS cc ON cc.custengageid = bc.custengageid
                  INNER JOIN @idlist AS idlist ON cc.id = idlist.id
                  WHERE bc.modifierid = 2
                  AND bc.thedatetoend > GETDATE()
                  AND cc.type = 1
            )
UPDATE CTE
SET thedatetoend = @EndDate
OUTPUT ccid, DELETED.thedatetoend
INTO [TEMP_TABLE]


问:
Comparison between Javascript objects
I have made a simple accordion for my site using jQuery... It worked great, but I've recently started working on a change where if you click the currently opened segments title (the clickable area to slide up/down), it should close the current section.

```<code>var sideMenu = {
        activated: {},
        setup: function() {
        $('.menu-category-heading').bind('click', function() {
                                                      sideMenu.slideMenu($('ul', $(this).parent()));
                                                      });

        },

        slideMenu: function(menuObj) {

            if (sideMenu.activated == menuObj) {

                $(sideMenu.activated).slideUp(400);
                sideMenu.activated = null;
                console.log('same');

            } else {

                $(sideMenu.activated).slideUp(400);
                menuObj.slideDown(500);
                sideMenu.activated = menuObj;
                console.log('new');
            }
        }

    }
</code>```

For some reason the comparison is never working... it does if I add $(menuObj).attr('id') and the same for activated. But this is not ideal as not all items will have an id attribute.

Any suggestions as to make the object comparison work? Or any other tips?

Thank you!

答:
You are probably saving a jQuery object (the result of a $ call) rather than the native element.  Each time you do a $(myEl) a new object is created and the references will not match up, but the native element will.  Try:</p>

```<code>if (slideMenu.activated[0] == menuObj[0]) {
    ...
}
</code>```

OwnerDisplayName: alex

Title: Comparison between Javascript objects

Body:
I have made a simple accordion for my site using jQuery... It worked great, but I've recently started working on a change where if you click the currently opened segments title (the clickable area to slide up/down), it should close the current section.

var sideMenu = {
        activated: {},
        setup: function() {
        $('.menu-category-heading').bind('click', function() {
                                                      sideMenu.slideMenu($('ul', $(this).parent()));
                                                      });

        },

        slideMenu: function(menuObj) {

            if (sideMenu.activated == menuObj) {

                $(sideMenu.activated).slideUp(400);
                sideMenu.activated = null;
                console.log('same');

            } else {

                $(sideMenu.activated).slideUp(400);
                menuObj.slideDown(500);
                sideMenu.activated = menuObj;
                console.log('new');
            }
        }

    }

For some reason the comparison is never working... it does if I add $(menuObj).attr('id') and the same for activated. But this is not ideal as not all items will have an id attribute.

Any suggestions as to make the object comparison work? Or any other tips?

Thank you!

Body:
You are probably saving a jQuery object (the result of a $ call) rather than the native element.  Each time you do a $(myEl) a new object is created and the references will not match up, but the native element will.  Try:

if (slideMenu.activated[0] == menuObj[0]) {
    ...
}

OwnerDisplayName: Prestaul


问:
Learning C# prior to learning ASP.NET MVC?
With only mild programming experience in the past, I was wondering about C# and ASP.NET MVC..

Do you guys think it's a better idea to learn C# before learning ASP.NET MVC?  I've already delved a little into both of these already, but I still need some help deciding.

I think I would be a much stronger MVC user if I had more knowledge of the C# language itself.

What do you guys think?

Thanks!

答:
If you're going to use C# to code your ASP.NET MVC Models/Controllers/etc. then yes, learn C# before you dive into ASP.NET MVC.

That way, you'll be able to better handle the language issues you're going to run in to when composing your .NET MVC application. Otherwise you're going to be trying to learn two things at the same time and not get a good grasp on either one.


问:
How to use nested fragments with getChildFragmentManager()?
Edit: Hey guys I have deleted everything because I finally found the answer to my question (basically how to use a scrollview inside ViewPager inside a fragment). Here is my code for everything. I am a total noob so I don't really understand what is going on in my code but here it is:

Here is my pager adapter to make fragments go inside ViewPager(I think that is what happens) I took this code from online from CommonsGuy

import android.app.Fragment;
import android.app.FragmentManager;
import android.support.v13.app.FragmentPagerAdapter;
import java.util.List;

public class PagerAdapter extends FragmentPagerAdapter {

  private List < Fragment > fragments;

  public PagerAdapter(FragmentManager fm, List < Fragment > fragments) {
    super(fm);

    this.fragments = fragments;
  }

  @Override
  public Fragment getItem(int i) {
    return fragments.get(i);
  }

  @Override
  public int getCount() {
    return fragments.size();
  }
}```
</div>
</div>
</p>

<p><strong>Here is my code for the fragment that I will put the ViewPager on</strong></p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>public class RecipeFragment extends Fragment {

  public RecipeFragment() {
    // Required empty public constructor
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_recipe, container, false);

    List < Fragment > fragments = new Vector < > ();
    fragments.add(Fragment.instantiate(getActivity(), RecipeOverview.class.getName()));
    fragments.add(Fragment.instantiate(getActivity(), RecipeIngredients.class.getName()));
    fragments.add(Fragment.instantiate(getActivity(), RecipeProcedures.class.getName()));
    PagerAdapter adapter = new PagerAdapter(getChildFragmentManager(), fragments);
    ViewPager pager = (ViewPager) view.findViewById(R.id.pager);
    pager.setAdapter(adapter);

    return (view);
  }

}</code>```

And below are the xml files for RecipeFragment and the different fragments shown in the ViewPager respectively

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</android.support.v4.view.ViewPager>```
</div>
</div>
</p>

<p>Layout for mini fragments inside ViewPager. And the .java mini fragment file is just a normal fragment file. I also used nestedScrollView because scrollview say i am stupid person and not working properly.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".RecipeOverview">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_margin="10dp">

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:id="@+id/button"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Random Text"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Fragment1"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Random Text"
                android:textStyle="bold"/>

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

</android.support.constraint.ConstraintLayout></code>```

答:
Change these methods

```<code>public void toFirst(){
        FragmentTransaction ft = getChildFragmentManager().beginTransaction();
        Fragment1Page1 fragment = new Fragment1Page1();
        ft.replace(R.id.contentLayoutFragment1Page1, fragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.addToBackStack(null);
        ft.commit();
    }
    public void toSecond(){
        FragmentTransaction ft = getChildFragmentManager().beginTransaction();
        Fragment1Page2 fragment = new Fragment1Page2();
        ft.replace(R.id.contentLayoutFragment1Page2, fragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.addToBackStack(null);
        ft.commit();
    }
</code>```

to

```<code>public void toFirst(View view){
        FragmentTransaction ft = getChildFragmentManager().beginTransaction();
        Fragment1Page1 fragment = new Fragment1Page1();
        ft.replace(R.id.contentLayoutFragment1Page1, fragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.addToBackStack(null);
        ft.commit();
    }
    public void toSecond(View view){
        FragmentTransaction ft = getChildFragmentManager().beginTransaction();
        Fragment1Page2 fragment = new Fragment1Page2();
        ft.replace(R.id.contentLayoutFragment1Page2, fragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.addToBackStack(null);
        ft.commit();
    }
</code>```

as you are supplying this methods in the xml this will pass the view target to those method , since it is missing from your code you are getting the error as logcat says

Body:
Edit: Hey guys I have deleted everything because I finally found the answer to my question (basically how to use a scrollview inside ViewPager inside a fragment). Here is my code for everything. I am a total noob so I don't really understand what is going on in my code but here it is:

Here is my pager adapter to make fragments go inside ViewPager(I think that is what happens) I took this code from online from CommonsGuy

import android.app.Fragment;
import android.app.FragmentManager;
import android.support.v13.app.FragmentPagerAdapter;
import java.util.List;

public class PagerAdapter extends FragmentPagerAdapter {

  private List < Fragment > fragments;

  public PagerAdapter(FragmentManager fm, List < Fragment > fragments) {
    super(fm);

    this.fragments = fragments;
  }

  @Override
  public Fragment getItem(int i) {
    return fragments.get(i);
  }

  @Override
  public int getCount() {
    return fragments.size();
  }
}

Here is my code for the fragment that I will put the ViewPager on

public class RecipeFragment extends Fragment {

  public RecipeFragment() {
    // Required empty public constructor
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_recipe, container, false);

    List < Fragment > fragments = new Vector < > ();
    fragments.add(Fragment.instantiate(getActivity(), RecipeOverview.class.getName()));
    fragments.add(Fragment.instantiate(getActivity(), RecipeIngredients.class.getName()));
    fragments.add(Fragment.instantiate(getActivity(), RecipeProcedures.class.getName()));
    PagerAdapter adapter = new PagerAdapter(getChildFragmentManager(), fragments);
    ViewPager pager = (ViewPager) view.findViewById(R.id.pager);
    pager.setAdapter(adapter);

    return (view);
  }

}

And below are the xml files for RecipeFragment and the different fragments shown in the ViewPager respectively

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</android.support.v4.view.ViewPager>

Layout for mini fragments inside ViewPager. And the .java mini fragment file is just a normal fragment file. I also used nestedScrollView because scrollview say i am stupid person and not working properly.

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".RecipeOverview">

    <android.support.v4.widget.NestedScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_margin="10dp">

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:id="@+id/button"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Random Text"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Fragment1"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Random Text"
                android:textStyle="bold"/>

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <Button
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:text="Some Button" />

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

            <TextView
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="10dp"
                android:text="Ingredients"
                android:textStyle="bold"/>

        </LinearLayout>

    </android.support.v4.widget.NestedScrollView>

</android.support.constraint.ConstraintLayout>

Body:
Change these methods

public void toFirst(){
        FragmentTransaction ft = getChildFragmentManager().beginTransaction();
        Fragment1Page1 fragment = new Fragment1Page1();
        ft.replace(R.id.contentLayoutFragment1Page1, fragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.addToBackStack(null);
        ft.commit();
    }
    public void toSecond(){
        FragmentTransaction ft = getChildFragmentManager().beginTransaction();
        Fragment1Page2 fragment = new Fragment1Page2();
        ft.replace(R.id.contentLayoutFragment1Page2, fragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.addToBackStack(null);
        ft.commit();
    }

to

public void toFirst(View view){
        FragmentTransaction ft = getChildFragmentManager().beginTransaction();
        Fragment1Page1 fragment = new Fragment1Page1();
        ft.replace(R.id.contentLayoutFragment1Page1, fragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.addToBackStack(null);
        ft.commit();
    }
    public void toSecond(View view){
        FragmentTransaction ft = getChildFragmentManager().beginTransaction();
        Fragment1Page2 fragment = new Fragment1Page2();
        ft.replace(R.id.contentLayoutFragment1Page2, fragment);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.addToBackStack(null);
        ft.commit();
    }

as you are supplying this methods in the xml this will pass the view target to those method , since it is missing from your code you are getting the error as logcat says


问:
Bootstrap 3 fixed footer is breaking my mobile site
I'm using a fixed footer on my webpage.

On mobile, it is fixing to the bottom of the page and covering other content.

How can I change it so that the footer is fixed only on large/desktop screens?

答:
Or second solution is to add padding for container on mobiles:

```<code>@media only screen and (min-width: 320px) and (max-width: 991px) {
    .my_container{

      padding-bottom: 100px !important; //example

    }
}
</code>```

Padding must have at least footer height + some px for good looking.

ContentLicense: CC BY-SA 4.0

Body:
Or second solution is to add padding for container on mobiles:

@media only screen and (min-width: 320px) and (max-width: 991px) {
    .my_container{

      padding-bottom: 100px !important; //example

    }
}

Padding must have at least footer height + some px for good looking.


问:
Android Support Repo 46.0.0 with Android Studio 2.3
I updated today my support repository to 46.0.0 as the Android Studio notification popped up.

I go the error below :

Error:Execution failed for task ':app:processDevDebugManifest'.

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.0) from
    [com.android.support:support-v13:25.3.0] AndroidManifest.xml:27:9-31
      is also present at [com.android.support:preference-v7:26.0.0-alpha1]
    AndroidManifest.xml:24:9-38 value=(26.0.0-alpha1).    Suggestion: add
    'tools:replace="android:value"' to  element at
    AndroidManifest.xml:25:5-27:34 to override.

I updated all my dependencies to use Revision 26.0.0 Alpha 1 from 25.3.0, but it turns out I need to bump the compileSdk from 25 to 26.
You can't do that if you have AS 2.3, you need to get the unstable alpha/beta version from canary.

This link shows the changes:
https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0-alpha1

And concerning migrating to the new android O, that's the link:
https://developer.android.com/preview/migration.html

It seems using AS stable version will not work with new repository.

How can I go back to the Android Studio Repository Version 45 instead of the new 46?

** Update: The merged manifest shows one of the generated library manifest contains

```<code><meta-data
        android:name="android.support.VERSION"
        android:value="26.0.0-alpha1" />
</code>```

But since it's a generated file editing is useless, that's why for now I'd stick to rev 45 until the new AS is in stable build

答:
Step 1

To escape Gradle checking for incompatible com.android.support versions a quick fix is to add following code in app module build.gradle.

```<code>dependencies {
    //noinspection GradleCompatible
}
</code>```

This is a temporary fix that doesn't solve the underlying problems! It helped to continue develop your app with minimal modifications.

Step 2

Add this to the main manifest file AndroidManifest.xml.

```<code><meta-data
    tools:replace="android:value"
    android:name="android.support.VERSION"
    android:value="25.3.1" />
</code>```

This entry will be removed when one of the next updates of the support repository is available.

Step 3

Add the following code at the end of app module build.gradle file:

```<code>configurations.all {
    resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.1'
            }
        }
    }
}
</code>```

NB: It is recommended to make sure your Gradle libraries are updated and compatible to avoid runtime errors.

Body:
I updated today my support repository to 46.0.0 as the Android Studio notification popped up.

I go the error below :

Error:Execution failed for task ':app:processDevDebugManifest'.

Manifest merger failed : Attribute meta-data#android.support.VERSION@value value=(25.3.0) from
    [com.android.support:support-v13:25.3.0] AndroidManifest.xml:27:9-31
      is also present at [com.android.support:preference-v7:26.0.0-alpha1]
    AndroidManifest.xml:24:9-38 value=(26.0.0-alpha1).    Suggestion: add
    'tools:replace="android:value"' to  element at
    AndroidManifest.xml:25:5-27:34 to override.

I updated all my dependencies to use Revision 26.0.0 Alpha 1 from 25.3.0, but it turns out I need to bump the compileSdk from 25 to 26.
You can't do that if you have AS 2.3, you need to get the unstable alpha/beta version from canary.

This link shows the changes:
https://developer.android.com/topic/libraries/support-library/revisions.html#26-0-0-alpha1

And concerning migrating to the new android O, that's the link:
https://developer.android.com/preview/migration.html

It seems using AS stable version will not work with new repository.

How can I go back to the Android Studio Repository Version 45 instead of the new 46?

** Update: The merged manifest shows one of the generated library manifest contains

<meta-data
        android:name="android.support.VERSION"
        android:value="26.0.0-alpha1" />

But since it's a generated file editing is useless, that's why for now I'd stick to rev 45 until the new AS is in stable build

Body:
Step 1

To escape Gradle checking for incompatible com.android.support versions a quick fix is to add following code in app module build.gradle.

dependencies {
    //noinspection GradleCompatible
}

This is a temporary fix that doesn't solve the underlying problems! It helped to continue develop your app with minimal modifications.

Step 2

Add this to the main manifest file AndroidManifest.xml.

<meta-data
    tools:replace="android:value"
    android:name="android.support.VERSION"
    android:value="25.3.1" />

This entry will be removed when one of the next updates of the support repository is available.

Step 3

Add the following code at the end of app module build.gradle file:

configurations.all {
    resolutionStrategy.eachDependency { details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.1'
            }
        }
    }
}

NB: It is recommended to make sure your Gradle libraries are updated and compatible to avoid runtime errors.


问:
.includes() not working in Internet Explorer
This code does not work in internet explorer. Any alternative?</p>

```<code>"abcde".includes("cd")
</code>```

答:
Or just put this in a Javascript file and have a good day  :)</p>

```<code>String.prototype.includes = function (str) {
  var returnValue = false;

  if (this.indexOf(str) !== -1) {
    returnValue = true;
  }

  return returnValue;
}
</code>```

Body:
This code does not work in internet explorer. Any alternative?

"abcde".includes("cd")

Body:
Or just put this in a Javascript file and have a good day  :)

String.prototype.includes = function (str) {
  var returnValue = false;

  if (this.indexOf(str) !== -1) {
    returnValue = true;
  }

  return returnValue;
}


问:
How to return an array in c using pthreads?
I tried to write a program that a thread returns an array of numbers by passing a random vector to the thread and thread returns 2 times of the vector.
The program is running fine put I'm not getting the expected output.
The code is as follows:

```<code>#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <omp.h>
void *myThreaddouble();

int i,sum[10],first[10]={10,20,30,40,50};

void *myThreaddouble()
{

int *sum[10];
for(i=0;i<5;i++)
{
  sum[i]= first[i] + first[i];
}

   pthread_exit(sum[i]);
}

int main()
{

 double total = omp_get_wtime();

 printf("This is using PThread\n");

  pthread_t tid1;
  pthread_create(&tid1, NULL, myThreaddouble, NULL);
  printf("Double of the vector:-   \n");
  for ( i = 0 ; i < 5 ; i++ )
  {
    printf(" %d\n",(int) sum[i]);
  }
  pthread_join(tid1, sum[i]);

  total = omp_get_wtime() - total;
  printf("%lf is time to add\n",total);
  printf("\n");

  return 0;

}
</code>```

and the output is as follows:

```<code>This is using PThread
Double of the vector:-
 0
 0
 0
 0
 0
0.000188 is time to add
</code>```

Which is not the expected output, so can someone tell me what is the mistake in this code and how to return an array using pthread. In the i should be able to sum all the return values.

I used gcc q.c -lpthread -lrt -fopenmp command to compile this program.

Thank you in advance!

答:
There you go. I have taken liberty to comment out the time calculation part.</p>

```<code>#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <omp.h>
void *myThreaddouble();

int i,sum[10],first[10]={10,20,30,40,50};

void *myThreaddouble(void *a)
{

//int *sum[10];
for(i=0;i<5;i++)
{
  sum[i]= first[i] + first[i];
}

   //pthread_exit(sum[i]);
   pthread_exit(NULL);
}

int main()
{

// double total = omp_get_wtime();

 printf("This is using PThread\n");

  pthread_t tid1;
  pthread_create(&tid1, NULL, myThreaddouble, NULL);
  printf("Double of the vector:-   \n");

  //pthread_join(tid1, sum[i]);
  pthread_join(tid1, NULL);

  for ( i = 0 ; i < 5 ; i++ )
  {
    printf(" %d\n",(int) sum[i]);
  }
 // pthread_join(tid1, sum[i]);

  //total = omp_get_wtime() - total;
  //printf("%lf is time to add\n",total);
  printf("\n");

  return 0;

}
</code>```

Body:
I tried to write a program that a thread returns an array of numbers by passing a random vector to the thread and thread returns 2 times of the vector.
The program is running fine put I'm not getting the expected output.
The code is as follows:

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <omp.h>
void *myThreaddouble();

int i,sum[10],first[10]={10,20,30,40,50};

void *myThreaddouble()
{

int *sum[10];
for(i=0;i<5;i++)
{
  sum[i]= first[i] + first[i];
}

   pthread_exit(sum[i]);
}

int main()
{

 double total = omp_get_wtime();

 printf("This is using PThread\n");

  pthread_t tid1;
  pthread_create(&tid1, NULL, myThreaddouble, NULL);
  printf("Double of the vector:-   \n");
  for ( i = 0 ; i < 5 ; i++ )
  {
    printf(" %d\n",(int) sum[i]);
  }
  pthread_join(tid1, sum[i]);

  total = omp_get_wtime() - total;
  printf("%lf is time to add\n",total);
  printf("\n");

  return 0;

}

and the output is as follows:

This is using PThread
Double of the vector:-
 0
 0
 0
 0
 0
0.000188 is time to add

Which is not the expected output, so can someone tell me what is the mistake in this code and how to return an array using pthread. In the i should be able to sum all the return values.

I used gcc q.c -lpthread -lrt -fopenmp command to compile this program.

Thank you in advance!

Body:
There you go. I have taken liberty to comment out the time calculation part.

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <omp.h>
void *myThreaddouble();

int i,sum[10],first[10]={10,20,30,40,50};

void *myThreaddouble(void *a)
{

//int *sum[10];
for(i=0;i<5;i++)
{
  sum[i]= first[i] + first[i];
}

   //pthread_exit(sum[i]);
   pthread_exit(NULL);
}

int main()
{

// double total = omp_get_wtime();

 printf("This is using PThread\n");

  pthread_t tid1;
  pthread_create(&tid1, NULL, myThreaddouble, NULL);
  printf("Double of the vector:-   \n");

  //pthread_join(tid1, sum[i]);
  pthread_join(tid1, NULL);

  for ( i = 0 ; i < 5 ; i++ )
  {
    printf(" %d\n",(int) sum[i]);
  }
 // pthread_join(tid1, sum[i]);

  //total = omp_get_wtime() - total;
  //printf("%lf is time to add\n",total);
  printf("\n");

  return 0;

}


问:
Is there any remotely cross platform way to execute an external process?
I was looking for advice on how to execute a process that is somewhat cross platform.

I have written Java and Ruby implementations of my app, but its less of a language specific problem and more of a platform specific issue.

E.G on Ubuntu /usr/bin/ is searched for anything I do

```<code># Ruby

`HandBrakeCLI #{args}` # works on Ubuntu and likely other linux distros since HandBrakeCLI is in /usr/bin/
</code>```

For windows it will search the current directory I am running in. However, If copy the windows executable to the current directory a runtime linking error will cause it to crash (DLL not present)

The default install path for HandBrakeCLI is in "Program Files(x86)/HandBrake" (x86 only in 64 bit obviously), however Program Files isn't in the search path as far as I can tell.

For MacOSX I have no clue how to execute Mac "Application Folders" from the command line other than with the "open" command. But that is less of an issue since what I am really after is HandBrakeCLI which is just a normal executable. However HandBrakeCLI is not installed to /usr/bin or /usr/local/bin ( or any variation there of )

My best idea is to make a config file that has the path to HandBrakeCLI. If I go that route however it would be ideal to be able to detect what platform I am on, but that is another problem all together. One I have only done with C #ifdef sections and not in Ruby or Java.

I would appreciate any and all input.

答:
You can get the current OS in Java using

```<code>System.getProperty("os.name")
</code>```

In ruby:

```<code>require 'rbconfig'
puts Config::CONFIG['host_os']
</code>```

Hope this helps :)

Body:
I was looking for advice on how to execute a process that is somewhat cross platform.

I have written Java and Ruby implementations of my app, but its less of a language specific problem and more of a platform specific issue.

E.G on Ubuntu /usr/bin/ is searched for anything I do

# Ruby

`HandBrakeCLI #{args}` # works on Ubuntu and likely other linux distros since HandBrakeCLI is in /usr/bin/

For windows it will search the current directory I am running in. However, If copy the windows executable to the current directory a runtime linking error will cause it to crash (DLL not present)

The default install path for HandBrakeCLI is in "Program Files(x86)/HandBrake" (x86 only in 64 bit obviously), however Program Files isn't in the search path as far as I can tell.

For MacOSX I have no clue how to execute Mac "Application Folders" from the command line other than with the "open" command. But that is less of an issue since what I am really after is HandBrakeCLI which is just a normal executable. However HandBrakeCLI is not installed to /usr/bin or /usr/local/bin ( or any variation there of )

My best idea is to make a config file that has the path to HandBrakeCLI. If I go that route however it would be ideal to be able to detect what platform I am on, but that is another problem all together. One I have only done with C #ifdef sections and not in Ruby or Java.

I would appreciate any and all input.

Body:
You can get the current OS in Java using

System.getProperty("os.name")

In ruby:

require 'rbconfig'
puts Config::CONFIG['host_os']

Hope this helps :)