问:
Remove Top and Bottom Padding
I have the following table: https://www.w3schools.com/code/tryit.asp?filename=FM993ZP563E4

I'm trying to figure out how to get rid of the distance between the lists. How would it be possible to get rid of the padding while still having the second column milliwatts align with the corresponding root list items?

Table for reference:

答:
If I understand you correctly you need to remove the padding (and margin for older browsers) from the ul element. Then you can get rid of the 20px top padding on the .parent class:

table,
th,
td {
  border: 1px solid black;
  border-collapse: collapse;
}
.used {
  text-align: right;
}
td ul {
  margin-top: 0;
  padding-top: 0;
}
.parent {
  text-align: right;
  vertical-align: top;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table style="width:80%;">
  <tr>
    <td class="td">
      <ul>
        <li>Some Module Name
          <ul>
            <li>Some Module Name <strong>(300mW)</strong>
              <li>Some Module Name <strong>(700mW)</strong>
                <ul>
                  <li>Some Module Name <strong>(300mW)</strong>
                </ul>
          </ul>
      </ul>
    </td>
    <td class="td parent">
      <strong>1000mW</strong>
    </td>
  </tr>
  <tr>
    <td class="td">
      <ul>
        <li>Some Module Name
          <ul>
            <li>Some Module Name <strong>(300mW)</strong>
              <li>Some Module Name <strong>(700mW)</strong>
                <ul>
                  <li>Some Module Name <strong>(300mW)</strong>
                </ul>
          </ul>
      </ul>
    </td>
    <td class="td parent">
      <strong>1000mW</strong>
    </td>
  </tr>
  <tr>

    <td class="td">
      <ul>
        <li>Some Module Name <strong>1000mW</strong>
      </ul>
    </td>
    <td class="td parent">
      <strong>1000mW</strong>
    </td>
  </tr>
  <tfoot>
    <tr>
      <th>John</th>
      <td class="used"><strong>1000mW</strong></td>
    </tr>
  </tfoot>
</table></code>```

Title: Remove Top and Bottom Padding

Body:
If I understand you correctly you need to remove the padding (and margin for older browsers) from the ul element. Then you can get rid of the 20px top padding on the .parent class:

table,
th,
td {
  border: 1px solid black;
  border-collapse: collapse;
}
.used {
  text-align: right;
}
td ul {
  margin-top: 0;
  padding-top: 0;
}
.parent {
  text-align: right;
  vertical-align: top;
}

<table style="width:80%;">
  <tr>
    <td class="td">
      <ul>
        <li>Some Module Name
          <ul>
            <li>Some Module Name <strong>(300mW)</strong>
              <li>Some Module Name <strong>(700mW)</strong>
                <ul>
                  <li>Some Module Name <strong>(300mW)</strong>
                </ul>
          </ul>
      </ul>
    </td>
    <td class="td parent">
      <strong>1000mW</strong>
    </td>
  </tr>
  <tr>
    <td class="td">
      <ul>
        <li>Some Module Name
          <ul>
            <li>Some Module Name <strong>(300mW)</strong>
              <li>Some Module Name <strong>(700mW)</strong>
                <ul>
                  <li>Some Module Name <strong>(300mW)</strong>
                </ul>
          </ul>
      </ul>
    </td>
    <td class="td parent">
      <strong>1000mW</strong>
    </td>
  </tr>
  <tr>

    <td class="td">
      <ul>
        <li>Some Module Name <strong>1000mW</strong>
      </ul>
    </td>
    <td class="td parent">
      <strong>1000mW</strong>
    </td>
  </tr>
  <tfoot>
    <tr>
      <th>John</th>
      <td class="used"><strong>1000mW</strong></td>
    </tr>
  </tfoot>
</table>


来源: stackexchange

答:
Because you have ul which has a default margin top and bottom, so you have to add:

```<code>ul {
  margin: 0;
}
</code>```

And it should work.

Check the updated example.

ContentLicense: CC BY-SA 3.0

Title: Remove Top and Bottom Padding

Body:
I have the following table: https://www.w3schools.com/code/tryit.asp?filename=FM993ZP563E4

I'm trying to figure out how to get rid of the distance between the lists. How would it be possible to get rid of the padding while still having the second column milliwatts align with the corresponding root list items?

Table for reference:

Body:
Because you have ul which has a default margin top and bottom, so you have to add:

ul {
  margin: 0;
}

And it should work.

Check the updated example.


问:
System.out.println(); is printing two lines
I've recently started studying Java and I already had my first problem. Currently I'm making a text adventure game (written in Java) and I can't continue because the program is printing out two lines but that I don't want it to. I don't how I can make it print out only one line.

In the last bit of the program there is a system.out.print("hello")

```<code>import java.util.Scanner;

public class TextAd2 {

Scanner sc = new Scanner(System.in);

//Name
String Pname;

public static void main(String[] args) {

    //connection
    TextAd2 con;
    con = new TextAd2();

    con.info();
    con.start1();
}

public void info() {

System.out.println("Hello!");
System.out.println("Your Name? ");
Pname = sc.nextLine();

System.out.println("Hello " + Pname);
System.out.println("Wana Start The Game or Stop?");
String text1 = sc.nextLine();

    switch (text1) {
    case "Start":
        start1();
        break;

    case "Stop":
        System.exit(0);
        break;
    default:
        System.out.println("Unknown Command.");
    }
}
public void start1()
{
    //it starts to print this twice
    System.out.println("hello");
}
}
</code>```

I actually don't think that the system.out.print is the problem, maybe the program is just reading the 'start1()' twice that's why it's printing "hello" two times. I did this in an if else statement and it's doing the same thing too. I don't know the code to how to prevent this either way. I am doing something wrong but I don't know what is the probelm

答:
At first, the execution reaches this line:

```<code>con.info();
</code>```

So info starts running. Then execution reached:

```<code>case "Start":
    start1();
    break;
</code>```

So start1 starts executing and prints Hello.

However, remember that the deepest call stack is still on the info method. After printing Hello, start1 returns it is popped from the call stack. break; then runs and info also pops from the call stack. Now, we will go to the next line after info(), which is start1!

That's why it is printing twice. To stop this, simply remove start1 from the main method,

Body:
I've recently started studying Java and I already had my first problem. Currently I'm making a text adventure game (written in Java) and I can't continue because the program is printing out two lines but that I don't want it to. I don't how I can make it print out only one line.

In the last bit of the program there is a system.out.print("hello")

import java.util.Scanner;

public class TextAd2 {

Scanner sc = new Scanner(System.in);

//Name
String Pname;

public static void main(String[] args) {

    //connection
    TextAd2 con;
    con = new TextAd2();

    con.info();
    con.start1();
}

public void info() {

System.out.println("Hello!");
System.out.println("Your Name? ");
Pname = sc.nextLine();

System.out.println("Hello " + Pname);
System.out.println("Wana Start The Game or Stop?");
String text1 = sc.nextLine();

    switch (text1) {
    case "Start":
        start1();
        break;

    case "Stop":
        System.exit(0);
        break;
    default:
        System.out.println("Unknown Command.");
    }
}
public void start1()
{
    //it starts to print this twice
    System.out.println("hello");
}
}

I actually don't think that the system.out.print is the problem, maybe the program is just reading the 'start1()' twice that's why it's printing "hello" two times. I did this in an if else statement and it's doing the same thing too. I don't know the code to how to prevent this either way. I am doing something wrong but I don't know what is the probelm

Body:
At first, the execution reaches this line:

con.info();

So info starts running. Then execution reached:

case "Start":
    start1();
    break;

So start1 starts executing and prints Hello.

However, remember that the deepest call stack is still on the info method. After printing Hello, start1 returns it is popped from the call stack. break; then runs and info also pops from the call stack. Now, we will go to the next line after info(), which is start1!

That's why it is printing twice. To stop this, simply remove start1 from the main method,


问:
"Execution of compression failed" error when building project in Android Studio 3.1
I'm trying to build https://github.com/neural-nuts/Cam2Caption in Android Studio 3.1 Preview, but either I use very old build.gradle, or it dies with

```<code>Error:Execution failed for task ':Application:packageDebug'.
Execution of compression failed.
</code>```

this happens after doing a project clean, or a rebuild.  OSX, latest most-everything.  I'm using what I think is a default latest-and-greatest build.gradle

```<code>classpath 'com.android.tools.build:gradle:3.0.0'
...
android {
    compileSdkVersion 26
    defaultConfig {
        minSdkVersion 26
        targetSdkVersion 26
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
....
        compile "com.android.support:support-v4:26.1.0"
        compile "com.android.support:support-v13:26.1.0"
        compile "com.android.support:cardview-v7:26.1.0"
        compile "com.android.support:appcompat-v7:26.1.0"
</code>```

With stacktrace, I get

```<code>FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Application:packageDebug'.
> java.io.IOException: Execution of compression failed.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':Application:packageDebug'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.tooling.BuildException: java.io.IOException: Execution of compression failed.
    at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$10(OutputScope.java:241)
    at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:236)
    at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:197)
    at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:181)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.doFullTaskAction(PackageAndroidArtifact.java:449)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 29 more
Caused by: java.lang.RuntimeException: java.io.IOException: Execution of compression failed.
Caused by: java.io.IOException: Execution of compression failed.
    at com.android.apkzlib.zip.CentralDirectoryHeader.getCompressionInfoWithWait(CentralDirectoryHeader.java:431)
    at com.android.apkzlib.zip.ZFile.processAllReadyEntriesWithWait(ZFile.java:1749)
    at com.android.apkzlib.zip.ZFile.hasPendingChangesWithWait(ZFile.java:2623)
    at com.android.apkzlib.zfile.ApkZFileCreator.hasPendingChangesWithWait(ApkZFileCreator.java:180)
    at com.android.builder.internal.packaging.IncrementalPackager.hasPendingChangesWithWait(IncrementalPackager.java:319)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:672)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:500)
    at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.java:186)
    at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.java:203)
    at com.android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.java:225)
    Suppressed: java.io.IOException: Failed to obtain compression information for entry
        at com.android.apkzlib.zip.ZFile.processAllReadyEntries(ZFile.java:1727)
        at com.android.apkzlib.zip.ZFile.processAllReadyEntriesWithWait(ZFile.java:1741)
        at com.android.apkzlib.zip.ZFile.update(ZFile.java:904)
        at com.android.apkzlib.zip.ZFile.close(ZFile.java:1196)
        at com.android.apkzlib.zfile.ApkZFileCreator.close(ApkZFileCreator.java:189)
        at com.google.common.io.Closer.close(Closer.java:216)
        at com.android.builder.internal.packaging.IncrementalPackager.close(IncrementalPackager.java:332)
        at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:678)
        at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:500)
        at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.java:186)
        at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.java:203)
        at com.android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.java:225)
        at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
    Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Self-suppression not permitted
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.apkzlib.zip.ZFile.processAllReadyEntries(ZFile.java:1722)
        ... 16 more
    Caused by: java.lang.IllegalArgumentException: Self-suppression not permitted
        at com.android.apkzlib.zip.compress.DeflateExecutionCompressor.immediateCompress(DeflateExecutionCompressor.java:72)
        at com.android.apkzlib.zip.compress.ExecutorCompressor.lambda$compress$0(ExecutorCompressor.java:54)
    Caused by: java.lang.OutOfMemoryError: Java heap space
Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Self-suppression not permitted
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at com.android.apkzlib.zip.CentralDirectoryHeader.getCompressionInfoWithWait(CentralDirectoryHeader.java:425)
    ... 9 more
    [CIRCULAR REFERENCE:java.lang.IllegalArgumentException: Self-suppression not permitted]

* Get more help at https://help.gradle.org
BUILD FAILED in 12s
</code>```

答:
I also ran into this problem. This happened because I included a very large zip file in the assets. So the JVM didn't had enough memory to build the project. I fixed this issue by adding dexoptions in app build.gradle

```<code>android {
    dexOptions {
        javaMaxHeapSize "4g"
    }
}
</code>```

And increasing JVM heap size

```<code>org.gradle.jvmargs=-Xmx4608M
</code>```

like this. Go to gradle.properties to find this option.

Body:
I'm trying to build https://github.com/neural-nuts/Cam2Caption in Android Studio 3.1 Preview, but either I use very old build.gradle, or it dies with

Error:Execution failed for task ':Application:packageDebug'.
Execution of compression failed.

this happens after doing a project clean, or a rebuild.  OSX, latest most-everything.  I'm using what I think is a default latest-and-greatest build.gradle

classpath 'com.android.tools.build:gradle:3.0.0'
...
android {
    compileSdkVersion 26
    defaultConfig {
        minSdkVersion 26
        targetSdkVersion 26
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
....
        compile "com.android.support:support-v4:26.1.0"
        compile "com.android.support:support-v13:26.1.0"
        compile "com.android.support:cardview-v7:26.1.0"
        compile "com.android.support:appcompat-v7:26.1.0"

With stacktrace, I get

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':Application:packageDebug'.
> java.io.IOException: Execution of compression failed.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':Application:packageDebug'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: org.gradle.tooling.BuildException: java.io.IOException: Execution of compression failed.
    at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$10(OutputScope.java:241)
    at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:236)
    at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:197)
    at com.android.build.gradle.internal.scope.OutputScope.parallelForEachOutput(OutputScope.java:181)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.doFullTaskAction(PackageAndroidArtifact.java:449)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 29 more
Caused by: java.lang.RuntimeException: java.io.IOException: Execution of compression failed.
Caused by: java.io.IOException: Execution of compression failed.
    at com.android.apkzlib.zip.CentralDirectoryHeader.getCompressionInfoWithWait(CentralDirectoryHeader.java:431)
    at com.android.apkzlib.zip.ZFile.processAllReadyEntriesWithWait(ZFile.java:1749)
    at com.android.apkzlib.zip.ZFile.hasPendingChangesWithWait(ZFile.java:2623)
    at com.android.apkzlib.zfile.ApkZFileCreator.hasPendingChangesWithWait(ApkZFileCreator.java:180)
    at com.android.builder.internal.packaging.IncrementalPackager.hasPendingChangesWithWait(IncrementalPackager.java:319)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:672)
    at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:500)
    at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.java:186)
    at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.java:203)
    at com.android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.java:225)
    Suppressed: java.io.IOException: Failed to obtain compression information for entry
        at com.android.apkzlib.zip.ZFile.processAllReadyEntries(ZFile.java:1727)
        at com.android.apkzlib.zip.ZFile.processAllReadyEntriesWithWait(ZFile.java:1741)
        at com.android.apkzlib.zip.ZFile.update(ZFile.java:904)
        at com.android.apkzlib.zip.ZFile.close(ZFile.java:1196)
        at com.android.apkzlib.zfile.ApkZFileCreator.close(ApkZFileCreator.java:189)
        at com.google.common.io.Closer.close(Closer.java:216)
        at com.android.builder.internal.packaging.IncrementalPackager.close(IncrementalPackager.java:332)
        at com.android.build.gradle.tasks.PackageAndroidArtifact.doTask(PackageAndroidArtifact.java:678)
        at com.android.build.gradle.tasks.PackageAndroidArtifact.splitFullAction(PackageAndroidArtifact.java:500)
        at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$6(OutputScope.java:186)
        at com.android.build.gradle.internal.scope.OutputScope.lambda$parallelForEachOutput$7(OutputScope.java:203)
        at com.android.build.gradle.internal.scope.OutputScope.lambda$null$8(OutputScope.java:225)
        at java.util.concurrent.ForkJoinTask$AdaptedCallable.exec(ForkJoinTask.java:1424)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
    Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Self-suppression not permitted
        at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
        at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
        at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
        at com.android.apkzlib.zip.ZFile.processAllReadyEntries(ZFile.java:1722)
        ... 16 more
    Caused by: java.lang.IllegalArgumentException: Self-suppression not permitted
        at com.android.apkzlib.zip.compress.DeflateExecutionCompressor.immediateCompress(DeflateExecutionCompressor.java:72)
        at com.android.apkzlib.zip.compress.ExecutorCompressor.lambda$compress$0(ExecutorCompressor.java:54)
    Caused by: java.lang.OutOfMemoryError: Java heap space
Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Self-suppression not permitted
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at com.android.apkzlib.zip.CentralDirectoryHeader.getCompressionInfoWithWait(CentralDirectoryHeader.java:425)
    ... 9 more
    [CIRCULAR REFERENCE:java.lang.IllegalArgumentException: Self-suppression not permitted]

* Get more help at https://help.gradle.org
BUILD FAILED in 12s

Body:
I also ran into this problem. This happened because I included a very large zip file in the assets. So the JVM didn't had enough memory to build the project. I fixed this issue by adding dexoptions in app build.gradle

android {
    dexOptions {
        javaMaxHeapSize "4g"
    }
}

And increasing JVM heap size

org.gradle.jvmargs=-Xmx4608M

like this. Go to gradle.properties to find this option.

ContentLicense: CC BY-SA 4.0


问:
datatable search option and paging not displaying in the mvc view
i have one data table . I'm fetching data from dataset and populating into the datatable. I'm referring https://datatables.net/examples/basic_init/zero_configuration.html.i have added references of data table and jquery still im facing issues to view the data table features. im not able to see the search box and paging option.

view

```<code>@using System.Data
@model DataSet
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

    <meta name="viewport" content="width=device-width" />
    <link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet" />
    <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script src="    https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css"></script>
    <title>Index</title>
    <table id="example" class="display" width="100%" cellspacing="0">
        <tr>
            <th>Date</th>
            <th>Use case</th>
            <th>Id</th>
            <th>SMS</th>
        </tr>
        @foreach (DataRow row in Model.Tables[0].Rows)
        {
            <tr>
                <td>@row["updtd_date"]</td>
                <td>@row["usecase"]</td>
                <td>@row["id"]</td>
                <td>@row["sms"]</td>

            </tr>
        }
    </table>

@section scripts{
    <script>
        $(document).ready(function () {
            $('#example').DataTable();
        });
</script>
    }
</code>```

答:
Please change your Script reference to:</p>

```<code><script src="    https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.js"></script>
</code>```

Body:
i have one data table . I'm fetching data from dataset and populating into the datatable. I'm referring https://datatables.net/examples/basic_init/zero_configuration.html.i have added references of data table and jquery still im facing issues to view the data table features. im not able to see the search box and paging option.

view

@using System.Data
@model DataSet
@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

    <meta name="viewport" content="width=device-width" />
    <link href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet" />

    <title>Index</title>

            Date
            Use case
            Id
            SMS

        @foreach (DataRow row in Model.Tables[0].Rows)
        {

                @row["updtd_date"]
                @row["usecase"]
                @row["id"]
                @row["sms"]

        }

@section scripts{

    }

Body:
Please change your Script reference to:

<script src="    https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.js"></script>


答:
You can do it like this:

table * {margin:0;padding:0 auto;box-sizing:border-box} /* to reset the defaults of all the elements inside the table */

table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}

.used {
  text-align: right;
}

.parent {
  text-align: right;
  vertical-align: top;
  /*padding-top: 20px;*/
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><table style="width:80%;">
 <tr>
     <td class="td">
         <ul>
             <li>Some Module Name
                <ul>
                 <li>Some Module Name <strong>(300mW)</strong>
                    <li>Some Module Name <strong>(700mW)</strong>
                    <ul>
                     <li>Some Module Name <strong>(300mW)</strong>
                    </ul>
                </ul>
            </ul>
          </td>
          <td class="td parent">
           <strong>1000mW</strong>
          </td>
    </tr>
    <tr>
     <td  class="td">
             <ul>
             <li>Some Module Name
                <ul>
                 <li>Some Module Name <strong>(300mW)</strong>
                    <li>Some Module Name <strong>(700mW)</strong>
                    <ul>
                     <li>Some Module Name <strong>(300mW)</strong>
                    </ul>
                </ul>
            </ul>
          </td>
          <td class="td parent">
           <strong>1000mW</strong>
          </td>
    </tr>
    <tr>
     <td  class="td">
            <ul>
             <li>Some Module Name <strong>1000mW</strong>
            </ul>
          </td>
          <td class="td parent">
           <strong>1000mW</strong>
          </td>
    </tr>
    <tfoot>
      <tr>
        <th>John</th>
        <td class="used"><strong>1000mW</strong></td>
      </tr>
      </tfoot>
    </table></code>```

Title: Remove Top and Bottom Padding

Body:
You can do it like this:

table * {margin:0;padding:0 auto;box-sizing:border-box} /* to reset the defaults of all the elements inside the table */

table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}

.used {
  text-align: right;
}

.parent {
  text-align: right;
  vertical-align: top;
  /*padding-top: 20px;*/
}

<table style="width:80%;">
 <tr>
     <td class="td">
         <ul>
             <li>Some Module Name
                <ul>
                 <li>Some Module Name <strong>(300mW)</strong>
                    <li>Some Module Name <strong>(700mW)</strong>
                    <ul>
                     <li>Some Module Name <strong>(300mW)</strong>
                    </ul>
                </ul>
            </ul>
          </td>
          <td class="td parent">
           <strong>1000mW</strong>
          </td>
    </tr>
    <tr>
     <td  class="td">
             <ul>
             <li>Some Module Name
                <ul>
                 <li>Some Module Name <strong>(300mW)</strong>
                    <li>Some Module Name <strong>(700mW)</strong>
                    <ul>
                     <li>Some Module Name <strong>(300mW)</strong>
                    </ul>
                </ul>
            </ul>
          </td>
          <td class="td parent">
           <strong>1000mW</strong>
          </td>
    </tr>
    <tr>
     <td  class="td">
            <ul>
             <li>Some Module Name <strong>1000mW</strong>
            </ul>
          </td>
          <td class="td parent">
           <strong>1000mW</strong>
          </td>
    </tr>
    <tfoot>
      <tr>
        <th>John</th>
        <td class="used"><strong>1000mW</strong></td>
      </tr>
      </tfoot>
    </table>


问:
Imputing missing character values in R
I have a dataset called credit_df with dimensions 32561*15. It has a column for native.country with 1843 missing values. missing values are given as ?

I have created a factor variable with the list of countries using the below code

```<code>country <- unique(credit_df$native.country)
</code>```

The above code also came with one ? value as it was part of the dataset. So i have removed that alone using the below

```<code>country <- as.data.frame(country)

country %>% filter(country != "?")
</code>```

Now the country factor variable has all the country names in the dataset. Now I would like to assign those to the missing values in the column randomly. How do i do it ?

I tried the below code per one of the suggested methods

```<code> credit_df$native.country[credit_df$native.country %in% c("?")] <-
      sample(country, NROW(credit_df$native.country[credit_df$native.country %in% c("?")]), replace = T)
</code>```

but all the "?" turned out to be missing values

```<code>sum(is.na(credit_df$native.country))
[1] 583
</code>```

NOTE: Even not considering this example if any of you could suggest how to impute character values randomly I am okay with it.

Example : if I have a column of country with missing values . and I have a vector/dataframe with a bunch of country names. How do i assign them randomly to the missing values in the country column

答:
You could try using sample()

```<code>credit_df$native.country[credit_df$native.country %in% c("?")] <-
  sample(country, NROW(credit_df$native.country[credit_df$native.country %in% c("?")]), replace = T)
</code>```

The sample command here creates a vector using random values form country. The length of the generated vector is the same length as the number of rows you want to replace. The replace = T argument is only needed if you want to take a sample larger than the population (didn't know how much rows there are to replace and how many values there are in country).

Title: Imputing missing character values in R

Body:
I have a dataset called credit_df with dimensions 32561*15. It has a column for native.country with 1843 missing values. missing values are given as ?

I have created a factor variable with the list of countries using the below code

country <- unique(credit_df$native.country)

The above code also came with one ? value as it was part of the dataset. So i have removed that alone using the below

country <- as.data.frame(country)

country %>% filter(country != "?")

Now the country factor variable has all the country names in the dataset. Now I would like to assign those to the missing values in the column randomly. How do i do it ?

I tried the below code per one of the suggested methods

 credit_df$native.country[credit_df$native.country %in% c("?")] <-
      sample(country, NROW(credit_df$native.country[credit_df$native.country %in% c("?")]), replace = T)

but all the "?" turned out to be missing values

sum(is.na(credit_df$native.country))
[1] 583

NOTE: Even not considering this example if any of you could suggest how to impute character values randomly I am okay with it.

Example : if I have a column of country with missing values . and I have a vector/dataframe with a bunch of country names. How do i assign them randomly to the missing values in the country column

Body:
You could try using sample()

credit_df$native.country[credit_df$native.country %in% c("?")] <-
  sample(country, NROW(credit_df$native.country[credit_df$native.country %in% c("?")]), replace = T)

The sample command here creates a vector using random values form country. The length of the generated vector is the same length as the number of rows you want to replace. The replace = T argument is only needed if you want to take a sample larger than the population (didn't know how much rows there are to replace and how many values there are in country).


问:
How to deal with entity relations when fetching data via REST API?
Suppose you have an entity User within a typical Java web application. E.g. Spring framework, Hibernate ORM, and etc. User has some relations e.g.:

```<code>public class User {
    // primitive fields
    private Team team;
    private Set<Group>;
    // ...
}
</code>```

You can easily browse user's graph, e.g. user.getTeam().getName()

What are the best practices of exposing such entities via REST API, and accessing them from Java client?

E.g. when I need to load a user by id. Should I get a response that also contains team, and groups? What if I don't need those relations each time user is fetched.

The question is more about designing a Java client.

答:
You could use GraphQL. This API Query Language permits a client to query only specific fields from your entities.

For example, in your case, the client would make the following query to load also the team:

```<code>{
  user {
    team
  }
}
</code>```

If the client needs only the user name then this could be the query:

```<code>{
  user {
    name
  }
}
</code>```

You can find a Java implementation here.

Body:
Suppose you have an entity User within a typical Java web application. E.g. Spring framework, Hibernate ORM, and etc. User has some relations e.g.:

public class User {
    // primitive fields
    private Team team;
    private Set<Group>;
    // ...
}

You can easily browse user's graph, e.g. user.getTeam().getName()

What are the best practices of exposing such entities via REST API, and accessing them from Java client?

E.g. when I need to load a user by id. Should I get a response that also contains team, and groups? What if I don't need those relations each time user is fetched.

The question is more about designing a Java client.

Body:
You could use GraphQL. This API Query Language permits a client to query only specific fields from your entities.

For example, in your case, the client would make the following query to load also the team:

{
  user {
    team
  }
}

If the client needs only the user name then this could be the query:

{
  user {
    name
  }
}

You can find a Java implementation here.


问:
Effective usage of dm_db_missing_index_details
How can i effectively use the dm_db_missing_index_details of SQL SERVER databases. Should i need to create all the missing indexes detailed in the table or not and what does equality_columns and inequality_columns means.
How can i utilize the equality_columns ,inequality_columns and included columns while creating an index out of it (non clustered index).

答:
Sure you don't  need to create all the index suggested by dm_db_missing_index_details    But it worths to pay attention and check for a possible performance improvement

Equality columns are fields to use for search operations with EQUAL "=" operator

Inequality columns are fields that better suit for range comparisons like BETWEEN or LESS or GREATER THAN etc.

According to your comment following statement can be executed to create a non-clustered index

```<code>CREATE NONCLUSTERED INDEX [INDEXNAME] ON [TABLENAME] (
    [EQUALITYCOLUMNNAME],
    [INEQUALITYCOLUMNNAME]
)
INCLUDE (
    [INCLUDECOLUMN]
);
</code>```

Although I added the equality columns and inequality columns in a single index definition, you can think of creating seperate indexes

As a rule, most selective and equality columns should be defined at the begining of the index columns list. Inequality columns follow equality columns in Create Index statement's field list

Please refer to create index statement description

Body:
Sure you don't  need to create all the index suggested by dm_db_missing_index_details    But it worths to pay attention and check for a possible performance improvement

Equality columns are fields to use for search operations with EQUAL "=" operator

Inequality columns are fields that better suit for range comparisons like BETWEEN or LESS or GREATER THAN etc.

According to your comment following statement can be executed to create a non-clustered index

CREATE NONCLUSTERED INDEX [INDEXNAME] ON [TABLENAME] (
    [EQUALITYCOLUMNNAME],
    [INEQUALITYCOLUMNNAME]
)
INCLUDE (
    [INCLUDECOLUMN]
);

Although I added the equality columns and inequality columns in a single index definition, you can think of creating seperate indexes

As a rule, most selective and equality columns should be defined at the begining of the index columns list. Inequality columns follow equality columns in Create Index statement's field list

Please refer to create index statement description


问:
What packages to install in Atom editor for python
I am new to python, and trying to set up my environment to start python builds. I am using Atom as an editor. What all should I do? Through some online tutorials, I got these recommendations, but I still get some errors when I open up a python project

Installed python

Installed pip

In Atom, installed the following packages:

linter

linter-flake8

linter-ui-default

busy-signal

intentions

I get this error:
Flake8 crashed!
linter-flake8:: Flake8 threw an error related to:
Failed to spawn command flake8. Make sure flake8 is installed and on your PATH
Please check Atom's Console for more details

答:
search for script package and install it.
You can run the code by using ctrl+shift+b

The good thing about script package is you can run any code e.g. filename.c, filename.py etc.


问:
prolog - check if item is somewhere on the right/left/between in a list
I have to figure out how to find out if the item is in between of two other items in the list. My thinking is that to have a somewhereleft and somewhereright functions and then use it in a way somewherebetween(X,Y,Z,L) :- somewhereleft(X,Y,L), somewhereright(Y,Z,L). I have implemented function to find out if the item is to the right right(X,Y, [X, Y|_]). right(X, Y, [_|T]) :-right(X, Y, T). and to the left left(X, Y, L) :- right(Y, X, L).; however, cannot wrap my head around finding out the recursive somewhereleft/right functions.

答:
append/3 may be your friend

```<code>in_order(X, Y, Z, Lst) :-
    append(_, [X|T1], Lst),
    append(_, [Y|T2], T1),
    append(_, [Z|_], T2).
</code>```

for example

```<code>?- in_order(a,b,c,[a,e,b,d,c]).
true .
</code>```

but

```<code>?- in_order(a,b,c,[c,b,a,b,c,b,a]).
true ;
false.
</code>```

Body:
append/3 may be your friend

in_order(X, Y, Z, Lst) :-
    append(_, [X|T1], Lst),
    append(_, [Y|T2], T1),
    append(_, [Z|_], T2).

for example

?- in_order(a,b,c,[a,e,b,d,c]).
true .

but

?- in_order(a,b,c,[c,b,a,b,c,b,a]).
true ;
false.


问:
Visual Studio 2008 on Windows 7 beta
I'm considering a full upgrade to Windows 7 Beta, thus wiping Vista from my HD.

Will Visual Studio 2008 run well on Windows 7? I've read some forum posts that there were problems.

答:
It seems to be working great for me with one (big) exception: any time I try to open a xaml file in the WPF designer, it crashes. Other than that, I love using the beta 7 - it seems a little more speedy than Vista.

Updated for anyone with same problem: solved it by uninstalling Silverlight. Can't say that was definitely the problem but worked for me...

LastEditorDisplayName: Kent Fredric

ContentLicense: CC BY-SA 2.5

Title: Visual Studio 2008 on Windows 7 beta


问:
Sleep breaks the script
I want simply to set a sleep in a loop. But it doesn't work as expected

```<code>for ($i = 1; $i <= 6; $i++) {
    echo $i;
    sleep(1);
}
</code>```

if the loop takes more than 5 seconds. It doesn't work (don't print at all).

I tested it in Teh Playground, and this error appears :

Execution took longer than 5 seconds, sent SIGTERM and terminated

Edit : Modifying set_time_limit doesn't change anything...

It seems it's related to my server's config...

答:
Set the second condition of for bigger, ie $i <= 60;

```<code>for ($i = 1; $i <= 60; $i++) {
    echo $i;
    sleep(1);
}
</code>```

The condition says "loop the block as many times as the $i is less than 6".

for is a function,

first you define value of $i equal to 1, $i = 1;

second you define the condition, ie do the block while $i is less then 6, $i <= 6;

third on each loop increase the $i by one (the double plus), $i++

Title: Sleep breaks the script

Body:
I want simply to set a sleep in a loop. But it doesn't work as expected

for ($i = 1; $i <= 6; $i++) {
    echo $i;
    sleep(1);
}

if the loop takes more than 5 seconds. It doesn't work (don't print at all).

I tested it in Teh Playground, and this error appears :

Execution took longer than 5 seconds, sent SIGTERM and terminated

Edit : Modifying set_time_limit doesn't change anything...

It seems it's related to my server's config...

Body:
Set the second condition of for bigger, ie $i <= 60;

for ($i = 1; $i <= 60; $i++) {
    echo $i;
    sleep(1);
}

The condition says "loop the block as many times as the $i is less than 6".

for is a function,

first you define value of $i equal to 1, $i = 1;

second you define the condition, ie do the block while $i is less then 6, $i <= 6;

third on each loop increase the $i by one (the double plus), $i++


问:
How create complex type for result set returned as temp table from stored procedure?
How to get Columns of a temp table which contains multiple table columns returned from stored procedure in entity framework  function import?.

thanks

答:
You have to provide the data contract to the sql server so that entity framework can use it to generate the complex object. So we will use a dummy select statement to provide the contract. The select statement will be unreachable, so there is no performance penalty for the block of code.

Let's look at an example now:

```<code>ALTER PROCEDURE [dbo].[Dummy_SP_Complex_Object_For_Temp_Table]
AS
BEGIN

      IF 1 = 2 BEGIN
       SELECT
       cast(null as int)  as WeekNumber,
       cast(null as date)    as FilterStartDate,
       cast(null as date)    as FilterEndDate,
       cast(null as int)    as OrderNumber
        WHERE 1 = 2
      END

  IF OBJECT_ID('tempdb.dbo.#T', '#OrderShipments') IS NOT NULL
  DROP TABLE #T;
  Create Table #OrderShipments
  (
    WeekNumber int,
    FilterStartDate date,
    FilterEndDate date,
    OrderNumber int
  )
  Select WeekNumber, FilterStartDate, FilterEndDate, OrderNumber FROM #OrderShipments order by WeekNumber
END
</code>```

The first block of code is unreachable by the entity framework but it provides necessary information for the EF to create the complex type object.

Body:
You have to provide the data contract to the sql server so that entity framework can use it to generate the complex object. So we will use a dummy select statement to provide the contract. The select statement will be unreachable, so there is no performance penalty for the block of code.

Let's look at an example now:

ALTER PROCEDURE [dbo].[Dummy_SP_Complex_Object_For_Temp_Table]
AS
BEGIN

      IF 1 = 2 BEGIN
       SELECT
       cast(null as int)  as WeekNumber,
       cast(null as date)    as FilterStartDate,
       cast(null as date)    as FilterEndDate,
       cast(null as int)    as OrderNumber
        WHERE 1 = 2
      END

  IF OBJECT_ID('tempdb.dbo.#T', '#OrderShipments') IS NOT NULL
  DROP TABLE #T;
  Create Table #OrderShipments
  (
    WeekNumber int,
    FilterStartDate date,
    FilterEndDate date,
    OrderNumber int
  )
  Select WeekNumber, FilterStartDate, FilterEndDate, OrderNumber FROM #OrderShipments order by WeekNumber
END

The first block of code is unreachable by the entity framework but it provides necessary information for the EF to create the complex type object.


问:
allowing only super user login
I have written a django page that requires only super users to login. So I have added

```<code>foo_view = staff_member_required(foo_view)
</code>```

but it doesn't cut, now I can control only allowing staff marked users to login but this doesn't cut. I have tried something like

```<code>def foo_view(request):
       if not request.user.is_superuser:
           #render some "not allowed page"
       #else render the page
</code>```

but it doesn't seem to help as giving me errors.

答:
Above answers seems to be for very early versions of django. They are bit complicated than for the more later version

for django 1.11 here is a bit similar but simpler strategy.
click here

Title: allowing only super user login

Body:
I have written a django page that requires only super users to login. So I have added

foo_view = staff_member_required(foo_view)

but it doesn't cut, now I can control only allowing staff marked users to login but this doesn't cut. I have tried something like

def foo_view(request):
       if not request.user.is_superuser:
           #render some "not allowed page"
       #else render the page

but it doesn't seem to help as giving me errors.


问:
Animating changes to presentingViewController during interactive dismissal
I'm working on a UIPresentationController subclass similar to Mail.app's open draft behavior.  When a view controller is presented, it doesn't go all the way to the top and the presenting view controller scales down as if it were falling back.

The basic gist of it is below:

```<code>class CustomPresentationController : UIPresentationController {

    // Create a 40pt space above the view.
    override func frameOfPresentedViewInContainerView() -> CGRect {
        let frame = super.frameOfPresentedViewInContainerView()
        let insets = UIEdgeInsets(top: 40, left: 0, bottom: 0, right: 0)
        return UIEdgeInsetsInsetRect(frame, insets)
    }

    // Scale down when expanded is true, otherwise identity.
    private func setScale(expanded expanded: Bool) {

        if expanded {
            let fromMeasurement = presentingViewController.view.bounds.width
            let fromScale = (fromMeasurement - 30) / fromMeasurement
            presentingViewController.view.transform = CGAffineTransformMakeScale(fromScale, fromScale)
        } else {
            presentingViewController.view.transform = CGAffineTransformIdentity
        }

    }

    // Scale down alongside the presentation.
    override func presentationTransitionWillBegin() {
        presentingViewController.transitionCoordinator()?.animateAlongsideTransition({ context in
            self.setScale(expanded: true)
        }, completion: { context in
            self.setScale(expanded: !context.isCancelled())
        })
    }

    // Scale up alongside the dismissal.
    override func dismissalTransitionWillBegin() {
        presentingViewController.transitionCoordinator()?.animateAlongsideTransition({ context in
            self.setScale(expanded: false)
        }, completion: { context in
            self.setScale(expanded: context.isCancelled())
        })
    }

    // Fix the scaled view's frame on orientation change.
    override func containerViewWillLayoutSubviews() {
        super.containerViewWillLayoutSubviews()
        guard let bounds = containerView?.bounds else { return }
        presentingViewController.view.bounds = bounds
    }
}
</code>```

This works fine for a non-interactive presentation or dismissal.  When performing an interactive dismissal, however, all animations on presentingViewController.view run non-interactively.  That is, the scaling will happen in the ~300ms it normally takes to dismiss rather than staying at 3% complete when 3% dismissed.

You can see this in a sample project is available on GitHub. and a video of the issue is on YouTube.

I've tried the following approaches but they all yield the same result:

A parallel animation as seen above.

Animating in the UIViewControllerAnimatedTransitioning.

Using a CABasicAnimation an manually adjusting the timing of the container view's layer.

答:
Thank you for the answer, had this issue on iOS 9.x and 10.x devices - using animateAlongsideTransition(in:animation:completion:) did the job.

Interestingly, on iOS 11.x animate(alongsideTransition:completion:) works correctly for presentingViewController too (there is no need to use animateAlongsideTransition(in:animation:completion:)) - looks like Apple lifted something under the hood in the latest iOS.

Body:
I'm working on a UIPresentationController subclass similar to Mail.app's open draft behavior.  When a view controller is presented, it doesn't go all the way to the top and the presenting view controller scales down as if it were falling back.

The basic gist of it is below:

class CustomPresentationController : UIPresentationController {

    // Create a 40pt space above the view.
    override func frameOfPresentedViewInContainerView() -> CGRect {
        let frame = super.frameOfPresentedViewInContainerView()
        let insets = UIEdgeInsets(top: 40, left: 0, bottom: 0, right: 0)
        return UIEdgeInsetsInsetRect(frame, insets)
    }

    // Scale down when expanded is true, otherwise identity.
    private func setScale(expanded expanded: Bool) {

        if expanded {
            let fromMeasurement = presentingViewController.view.bounds.width
            let fromScale = (fromMeasurement - 30) / fromMeasurement
            presentingViewController.view.transform = CGAffineTransformMakeScale(fromScale, fromScale)
        } else {
            presentingViewController.view.transform = CGAffineTransformIdentity
        }

    }

    // Scale down alongside the presentation.
    override func presentationTransitionWillBegin() {
        presentingViewController.transitionCoordinator()?.animateAlongsideTransition({ context in
            self.setScale(expanded: true)
        }, completion: { context in
            self.setScale(expanded: !context.isCancelled())
        })
    }

    // Scale up alongside the dismissal.
    override func dismissalTransitionWillBegin() {
        presentingViewController.transitionCoordinator()?.animateAlongsideTransition({ context in
            self.setScale(expanded: false)
        }, completion: { context in
            self.setScale(expanded: context.isCancelled())
        })
    }

    // Fix the scaled view's frame on orientation change.
    override func containerViewWillLayoutSubviews() {
        super.containerViewWillLayoutSubviews()
        guard let bounds = containerView?.bounds else { return }
        presentingViewController.view.bounds = bounds
    }
}

This works fine for a non-interactive presentation or dismissal.  When performing an interactive dismissal, however, all animations on presentingViewController.view run non-interactively.  That is, the scaling will happen in the ~300ms it normally takes to dismiss rather than staying at 3% complete when 3% dismissed.

You can see this in a sample project is available on GitHub. and a video of the issue is on YouTube.

I've tried the following approaches but they all yield the same result:

A parallel animation as seen above.

Animating in the UIViewControllerAnimatedTransitioning.

Using a CABasicAnimation an manually adjusting the timing of the container view's layer.


问:
If a then function doesn't return a promise, why the next then will be run immediately?
Inside of a then() function, if I didn't return a promise but calling the function directly.

```<code>doSomething().then(function () {
  doSomethingElse(); //I know I should return doSomethingElse()
}).then(finalHandler);
</code>```

I know doSomethingElse & finalHandler will run in parallel then instead of running sequentially. But I am still not sure why is that exactly?

```<code>doSomething
|-----------------|
                  doSomethingElse(undefined)
                  |------------------|
                  finalHandler(undefined)
                  |------------------|
</code>```

答:
When you run code in a .then() handler, you get the following design choices:

1. Return nothing.  That leaves the return value undefined and that is a signal to the parent promise that there is no additional asynchronous operation to wait for here so the promise chain can continue running the next steps in the chain.

2. Return a promise.  This tells the parent promise that you want to "insert" a promise into the chain and the following .then() handlers should not be called until this promise is resolved.  The chain will essentially wait for this promise.  If this new promise is ultimately resolved, the next .then() handler will get called.  If this new promise is ultimately rejected, the next .catch() handler will get called.

3. Throw an exception.  This tells the parent promise that the operation in the .then() handler failed and the parent promise chain immediately becomes rejected and the next .catch() handler will get called.

So, in your case, if doSomethingElse() is an asynchronous operation and you don't return a promise that is connected with that asynchronous operation, then you've just "branched" your promise chain into two separate chains.  The main parent chain will continue calling the next .then() handler because you returned nothing.  Meanwhile, your doSomethingElse() function is essentially its own parallel promise chain.  It could even have it's own .then() handlers as in:

```<code> doSomethingElse().then(...).then(...).catch(...)
</code>```

That would just be a completely separate promise chain that would have no connection at all to the other promise chain except for the timing of when this other promise chain was started.  Once it starts, it runs independently from the other chain.  This is typically referred to as "branching" in promise terminology.  You branch into a new chain.  The two run separate form one another.  If both branches use asynchronous operations (which they presumably do), those asynchronous operations would be interleaved and both in flight at the same time.  The timing of when they both finished would be completely indeterminate (since they have no programmatic relationship in their timing).

Branching to a completely independent promise chain like this is usually a programming error and some promise implementations may report a likely programming error in the console.  The reason this is usually an error is there is no way for anyone outside this code to have any way to monitor or catch errors in the branched and independent promise.  And promises without error handling are bad.  They eat errors silently.

There are certain cases where you legitimately don't change your program behavior if an error happens.  Often times when you're closing a file at the end of a long sequence or even just trying to close files after errors have occurred, you just want to make your best efforts to close the file and you don't really have anything more useful to do if the close fails (except perhaps log the failure) so there's no particular reason to try to propagate back that type of failure.  But, this should only be done in a very thoughtful way.  99.9999% of the time, errors should be propagated back to the caller and creating a new branched and independent promise chain like this does not propagate its errors back anywhere so it's usually not the right coding strategy.

Body:
Inside of a then() function, if I didn't return a promise but calling the function directly.

doSomething().then(function () {
  doSomethingElse(); //I know I should return doSomethingElse()
}).then(finalHandler);

I know doSomethingElse & finalHandler will run in parallel then instead of running sequentially. But I am still not sure why is that exactly?

doSomething
|-----------------|
                  doSomethingElse(undefined)
                  |------------------|
                  finalHandler(undefined)
                  |------------------|

Body:
When you run code in a .then() handler, you get the following design choices:

1. Return nothing.  That leaves the return value undefined and that is a signal to the parent promise that there is no additional asynchronous operation to wait for here so the promise chain can continue running the next steps in the chain.

2. Return a promise.  This tells the parent promise that you want to "insert" a promise into the chain and the following .then() handlers should not be called until this promise is resolved.  The chain will essentially wait for this promise.  If this new promise is ultimately resolved, the next .then() handler will get called.  If this new promise is ultimately rejected, the next .catch() handler will get called.

3. Throw an exception.  This tells the parent promise that the operation in the .then() handler failed and the parent promise chain immediately becomes rejected and the next .catch() handler will get called.

So, in your case, if doSomethingElse() is an asynchronous operation and you don't return a promise that is connected with that asynchronous operation, then you've just "branched" your promise chain into two separate chains.  The main parent chain will continue calling the next .then() handler because you returned nothing.  Meanwhile, your doSomethingElse() function is essentially its own parallel promise chain.  It could even have it's own .then() handlers as in:

 doSomethingElse().then(...).then(...).catch(...)

That would just be a completely separate promise chain that would have no connection at all to the other promise chain except for the timing of when this other promise chain was started.  Once it starts, it runs independently from the other chain.  This is typically referred to as "branching" in promise terminology.  You branch into a new chain.  The two run separate form one another.  If both branches use asynchronous operations (which they presumably do), those asynchronous operations would be interleaved and both in flight at the same time.  The timing of when they both finished would be completely indeterminate (since they have no programmatic relationship in their timing).

Branching to a completely independent promise chain like this is usually a programming error and some promise implementations may report a likely programming error in the console.  The reason this is usually an error is there is no way for anyone outside this code to have any way to monitor or catch errors in the branched and independent promise.  And promises without error handling are bad.  They eat errors silently.

There are certain cases where you legitimately don't change your program behavior if an error happens.  Often times when you're closing a file at the end of a long sequence or even just trying to close files after errors have occurred, you just want to make your best efforts to close the file and you don't really have anything more useful to do if the close fails (except perhaps log the failure) so there's no particular reason to try to propagate back that type of failure.  But, this should only be done in a very thoughtful way.  99.9999% of the time, errors should be propagated back to the caller and creating a new branched and independent promise chain like this does not propagate its errors back anywhere so it's usually not the right coding strategy.


问:
Too many redirect with pagination query string
I am trying to redirect pages

From:
mysite.com/cata/catb

To mysite.com/cata/catb?p=1

But it is ending up with so many p=1

i.e mysite.com/cata/catb?p=1?p=1?p=1?p=1?p=1?p=1?p=1?p=1?p=1

My .htaccess is

```<code>redirect 301 ^/cata/catb$ /cata/catb?p=1
</code>```

Can someone please tell me what is wrong here.

答:
Your code is redirecting /cats/catb to the same directory/file that is why you are getting the loop error. To fix this, you need to use mod-rewrite  and a RewriteCond that excludes the destination Query String.

Try :

```<code>RewriteEngine on

RewriteCond %{QUERY_STRING} !^p=1$
RewriteRule ^cata/catb/?$ /cata/catb?p=1 [L,R]
</code>```

Body:
I am trying to redirect pages

From:
mysite.com/cata/catb

To mysite.com/cata/catb?p=1

But it is ending up with so many p=1

i.e mysite.com/cata/catb?p=1?p=1?p=1?p=1?p=1?p=1?p=1?p=1?p=1

My .htaccess is

redirect 301 ^/cata/catb$ /cata/catb?p=1

Can someone please tell me what is wrong here.

Body:
Your code is redirecting /cats/catb to the same directory/file that is why you are getting the loop error. To fix this, you need to use mod-rewrite  and a RewriteCond that excludes the destination Query String.

Try :

RewriteEngine on

RewriteCond %{QUERY_STRING} !^p=1$
RewriteRule ^cata/catb/?$ /cata/catb?p=1 [L,R]


问:
Is there a way to override inline CSS for `overflow`?
If I want override inline css i must use !important or javascript.

But if I want to override, for example, inline width without important I can use max-width or min-width

Is there some way to override inline

```<code>  overflow:hidden
</code>```

答:
You can only override inline css with

```<code>!important
</code>```

or you have to use javascript to do so.

Body:
If I want override inline css i must use !important or javascript.

But if I want to override, for example, inline width without important I can use max-width or min-width

Is there some way to override inline

  overflow:hidden

Body:
You can only override inline css with

!important

or you have to use javascript to do so.


问:
Maximum sum such that no two elements are adjacent
Now the available solution every where is to have an include and exclude sum . At the end max of these two will give me the output.

Now initially I was having difficulty to understand this algorithm and I thought why not going in a simple way.

Algo:
Loop over the array by increasing array pointer two at a time

Calculate the odd positioned element sum in the array

Calculate the even positioned element sum

At the end, take max of this two sum.

in that way, I think complexity will be reduced to half O(n/2)

Is this algo correct?

答:
It's a case of dynamic programming. The algorithm is:

Do not take (sum up) any non-positive items

For positive numbers, split the problem in two: try taking and skiping the item and return the maximum of these choices:

Let's show the 2nd step, imagine we are given:

```<code>[1, 2, 3, 4, 5, 6, 10, 125, -8, 9]
</code>```

1 is positive, that's why

```<code>take_sum = max(1 + max_sum([3, 4, 5, 6, 10, 125, -8, 9])) // we take "1"
skip_sum = max_sum([2, 3, 4, 5, 6, 10, 125, -8, 9])       // we skip "1"
max_sum =  max(take_sum, skip_sum)
</code>```

C# implementation (the simplest code in order to show the naked idea, no further optimization):

```<code>private static int BestSum(int[] array, int index) {
  if (index >= array.Length)
    return 0;

  if (array[index] <= 0)
    return BestSum(array, index + 1);

  int take = array[index] + BestSum(array, index + 2);
  int skip = BestSum(array, index + 1);

  return Math.Max(take, skip);
}

private static int BestSum(int[] array) {
  return BestSum(array, 0);
}
</code>```

Test:

```<code>Console.WriteLine(BestSum(new int[] { 1, -2, -3, 100 }));
Console.WriteLine(BestSum(new int[] { 100, 8, 10, 20, 7 }))
</code>```

Outcome:

```<code>101
120
</code>```

Please, check, that your initial algorithm returns 98 and 117 which are suboptimal sums.

Edit: In real life you may want to add some optimization, e.g. memoization and special cases tests:

```<code>private static Dictionary<int, int> s_Memo = new Dictionary<int, int>();

private static int BestSum(int[] array, int index) {
  if (index >= array.Length)
    return 0;

  int result;

  if (s_Memo.TryGetValue(index, out result)) // <- Memoization
    return result;

  if (array[index] <= 0)
    return BestSum(array, index + 1);

  // Always take, when the last item to choose or when followed by non-positive item
  if (index >= array.Length - 1 || array[index + 1] <= 0) {
    result = array[index] + BestSum(array, index + 2);
  }
  else {
    int take = array[index] + BestSum(array, index + 2);
    int skip = BestSum(array, index + 1);

    result = Math.Max(take, skip);
  }

  s_Memo.Add(index, result); // <- Memoization

  return result;
}

private static int BestSum(int[] array) {
  s_Memo.Clear();

  return BestSum(array, 0);
}
</code>```

Test:

```<code>  using System.Linq;

  ...

  Random gen = new Random(0); // 0 - random, by repeatable (to reproduce the same result)

  int[] test = Enumerable
    .Range(1, 10000)
    .Select(i => gen.Next(100))
    .ToArray();

  int evenSum = test.Where((v, i) => i % 2 == 0).Sum();
  int oddSum = test.Where((v, i) => i % 2 != 0).Sum();
  int suboptimalSum = Math.Max(evenSum, oddSum); // <- Your initial algorithm
  int result = BestSum(test);

  Console.WriteLine(
    $"odd: {oddSum} even: {evenSum} suboptimal: {suboptimalSum} actual: {result}");
</code>```

Outcome:

```<code>  odd: 246117 even: 247137 suboptimal: 247137 actual: 290856
</code>```

Body:
It's a case of dynamic programming. The algorithm is:

Do not take (sum up) any non-positive items

For positive numbers, split the problem in two: try taking and skiping the item and return the maximum of these choices:

Let's show the 2nd step, imagine we are given:

[1, 2, 3, 4, 5, 6, 10, 125, -8, 9]

1 is positive, that's why

take_sum = max(1 + max_sum([3, 4, 5, 6, 10, 125, -8, 9])) // we take "1"
skip_sum = max_sum([2, 3, 4, 5, 6, 10, 125, -8, 9])       // we skip "1"
max_sum =  max(take_sum, skip_sum)

C# implementation (the simplest code in order to show the naked idea, no further optimization):

private static int BestSum(int[] array, int index) {
  if (index >= array.Length)
    return 0;

  if (array[index] <= 0)
    return BestSum(array, index + 1);

  int take = array[index] + BestSum(array, index + 2);
  int skip = BestSum(array, index + 1);

  return Math.Max(take, skip);
}

private static int BestSum(int[] array) {
  return BestSum(array, 0);
}

Test:

Console.WriteLine(BestSum(new int[] { 1, -2, -3, 100 }));
Console.WriteLine(BestSum(new int[] { 100, 8, 10, 20, 7 }))

Outcome:

101
120

Please, check, that your initial algorithm returns 98 and 117 which are suboptimal sums.

Edit: In real life you may want to add some optimization, e.g. memoization and special cases tests:

private static Dictionary<int, int> s_Memo = new Dictionary<int, int>();

private static int BestSum(int[] array, int index) {
  if (index >= array.Length)
    return 0;

  int result;

  if (s_Memo.TryGetValue(index, out result)) // <- Memoization
    return result;

  if (array[index] <= 0)
    return BestSum(array, index + 1);

  // Always take, when the last item to choose or when followed by non-positive item
  if (index >= array.Length - 1 || array[index + 1] <= 0) {
    result = array[index] + BestSum(array, index + 2);
  }
  else {
    int take = array[index] + BestSum(array, index + 2);
    int skip = BestSum(array, index + 1);

    result = Math.Max(take, skip);
  }

  s_Memo.Add(index, result); // <- Memoization

  return result;
}

private static int BestSum(int[] array) {
  s_Memo.Clear();

  return BestSum(array, 0);
}

Test:

  using System.Linq;

  ...

  Random gen = new Random(0); // 0 - random, by repeatable (to reproduce the same result)

  int[] test = Enumerable
    .Range(1, 10000)
    .Select(i => gen.Next(100))
    .ToArray();

  int evenSum = test.Where((v, i) => i % 2 == 0).Sum();
  int oddSum = test.Where((v, i) => i % 2 != 0).Sum();
  int suboptimalSum = Math.Max(evenSum, oddSum); // <- Your initial algorithm
  int result = BestSum(test);

  Console.WriteLine(
    $"odd: {oddSum} even: {evenSum} suboptimal: {suboptimalSum} actual: {result}");

Outcome:

  odd: 246117 even: 247137 suboptimal: 247137 actual: 290856


问:
Time Complexity of Fibonacci Algorithm
So, i've got a recursive method in Java for getting the 'n'th fibonacci number - The only question i have, is: what's the time complexity? I think it's O(2^n), but i may be mistaken? (I know that iterative is way better, but it's an exercise)</p>

```<code>public int fibonacciRecursive(int n)
{
    if(n == 1 || n == 2) return 1;
    else return fibonacciRecursive(n-2) + fibonacciRecursive(n-1);
}
</code>```

答:
You can use this

to calculate Fn in O(log n)

Title: Time Complexity of Fibonacci Algorithm

Body:
So, i've got a recursive method in Java for getting the 'n'th fibonacci number - The only question i have, is: what's the time complexity? I think it's O(2^n), but i may be mistaken? (I know that iterative is way better, but it's an exercise)

public int fibonacciRecursive(int n)
{
    if(n == 1 || n == 2) return 1;
    else return fibonacciRecursive(n-2) + fibonacciRecursive(n-1);
}


问:
laravel guzzle return iframe data with status code 200.
laravel guzzle return iframe data with status code 200

```<code><html style="height:100%"><head><META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><meta name="format-detection" content="telephone=no"><meta name="viewport" content="initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><script type="text/javascript" src="/_Incapsula_Resource?SWJIYLWA=719d34d31c8e3a6e6fffd425f7e032f3"></script></head><body style="margin:0px;height:100%"><iframe src="/_Incapsula_Resource?CWUDNSAI=18&xinfo=3-4046903-0%200NNN%20RT%281512629675030%20501%29%20q%280%20-1%20-1%200%29%20r%280%20-1%29%20B16%288%2c881023%2c0%29%20U10000&incident_id=406002440012479652-17972015798816579&edet=16&cinfo=08000000" frameborder=0 width="100%" height="100%" marginheight="0px" marginwidth="0px">Request unsuccessful. Incapsula incident ID: 406002440012479652-17972015798816579</iframe></body></html>
</code>```

But it work fine if we enter the url in browser or hit url via postman
url https://www.unocoin.com/trade?all

答:
Try this,</p>

```<code>    $client = new Client();
    $api_response = $client->get('https://www.unocoin.com/trade?all');
    $responses =  $api_response->getBody();
    $responses = json_decode($responses, true);
    // do stuff with response
</code>```

Body:
laravel guzzle return iframe data with status code 200

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW"><meta name="format-detection" content="telephone=no"><meta name="viewport" content="initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">Request unsuccessful. Incapsula incident ID: 406002440012479652-17972015798816579

But it work fine if we enter the url in browser or hit url via postman
url https://www.unocoin.com/trade?all

Body:
Try this,

    $client = new Client();
    $api_response = $client->get('https://www.unocoin.com/trade?all');
    $responses =  $api_response->getBody();
    $responses = json_decode($responses, true);
    // do stuff with response


问:
Setting IsHitTestVisible to false affects the cursor in wpf
I am having one grid. Inside that i am having some  controls.

Expected Behavior :

While mouse down occurs with one of the controls inside the grid i need to change my cursor to wait and need to prevent the next hit until particular time, so in the MouseDown event am setting the cursor to wait and IsHitTestVisible of image to false. but this is not working as expected.

Code Block

```<code><Grid x:Name="Grid1" Grid.Row="1" Grid.Column="1" Cursor="{Binding CurrentCursor}">
  <Canvas x:Name="canvasElement" Width="{Binding ElementName=pupilGrid, Path=ActualWidth}" Height="{Binding ElementName=pupilGrid, Path=ActualHeight}" IsManipulationEnabled="True">
    <Image x:Name="pupilSource" Width="{Binding ElementName=pupilGrid, Path=ActualWidth}" Height="{Binding ElementName=pupilGrid, Path=ActualHeight}" Source="{Binding ImageSource}"   MouseDown="Source_MouseDown" IsHitTestVisible="{Binding CanHitAxis}"/>
    <controls:Control x:Name="targetControl" Width="30" Height="30" ClipToBounds="False" Canvas.Left="0" Canvas.Top="0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
  </Canvas>
</Grid>
</code>```

What I am getting :

in the "Source_mousedown event" I am setting the current cursor to wait and IsHitTestVisible to false. but the wait cursor is not set to the image. if i removed IsHitTestVisible property of image in the sense wait cursor is get applied to the image also. Can any one help me on this?

答:
If you set the IsHitTestVisible property to false for a UIelement, it will no longer respond to mouse input and will not fire mouse-related events.
Bescuse with IsHitTestVisible set to false, the mouse could not able to see ur UIElement in the window. So the cursor property of your grid doesn't work.

You could use the IsEnabled property to prevent your mouse down event for a particular time rather than IsHitTestVisible.

I think this one will solve your problem.

Body:
I am having one grid. Inside that i am having some  controls.

Expected Behavior :

While mouse down occurs with one of the controls inside the grid i need to change my cursor to wait and need to prevent the next hit until particular time, so in the MouseDown event am setting the cursor to wait and IsHitTestVisible of image to false. but this is not working as expected.

Code Block

<Grid x:Name="Grid1" Grid.Row="1" Grid.Column="1" Cursor="{Binding CurrentCursor}">
  <Canvas x:Name="canvasElement" Width="{Binding ElementName=pupilGrid, Path=ActualWidth}" Height="{Binding ElementName=pupilGrid, Path=ActualHeight}" IsManipulationEnabled="True">
    <Image x:Name="pupilSource" Width="{Binding ElementName=pupilGrid, Path=ActualWidth}" Height="{Binding ElementName=pupilGrid, Path=ActualHeight}" Source="{Binding ImageSource}"   MouseDown="Source_MouseDown" IsHitTestVisible="{Binding CanHitAxis}"/>
    <controls:Control x:Name="targetControl" Width="30" Height="30" ClipToBounds="False" Canvas.Left="0" Canvas.Top="0" VerticalAlignment="Center" HorizontalAlignment="Center"/>
  </Canvas>
</Grid>

What I am getting :

in the "Source_mousedown event" I am setting the current cursor to wait and IsHitTestVisible to false. but the wait cursor is not set to the image. if i removed IsHitTestVisible property of image in the sense wait cursor is get applied to the image also. Can any one help me on this?


问:
PyAudio prints ALSA warnings and does not work
I am trying to run a basic python speech to text code. This is the code.

```<code>import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)

try:
   print("You said " + r.recognize(audio))
except LookupError:
   print("Could not understand audio")
</code>```

The code works fine until it reaches the print stage, then it throws this error. Is there anything that I have done wrong?

```<code>ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
</code>```

答:
if someone is still looking for getting rid of

```<code>ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
</code>```

I just commented out all pcm.surround* lines in "PCM interface" section in

```<code>/usr/share/alsa/alsa.conf
</code>```

file and it works fine for me.

Body:
I am trying to run a basic python speech to text code. This is the code.

import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
audio = r.listen(source)

try:
   print("You said " + r.recognize(audio))
except LookupError:
   print("Could not understand audio")

The code works fine until it reaches the print stage, then it throws this error. Is there anything that I have done wrong?

ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2266:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map

Body:
if someone is still looking for getting rid of

ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map

I just commented out all pcm.surround* lines in "PCM interface" section in

/usr/share/alsa/alsa.conf

file and it works fine for me.


问:
Visual Studio Team Services - Git Repo credentials
I have a project in GitHub, I've been a GitHHub user for years, but I now want to use some of the Visual Studio Team Services features so I create a free account and create a project along with a a new Git repo hosted on VS Team Services.  I want to add the new Team Services repository to the list of remotes in my existing repo but I can't authenticate to it from Git Bash using the HTTPS ref and my Team Services credentials.

Is it using some sort of funky auth. mechanism that won't work with standard mysysgit? Do I need to perform some sort of admin on my Team Services account?

答:
Alternate authentication credentials are not recommended

It's better to use personal access tokens. Keep in mind though that these expire after a set expiry date and time. In the git client, use any username you like (characters only, e.g. Bob, Chalkie, etc.) and use the token as the password.

Personal access tokens