问:
R10K puppetfile install without clearing custom modules
I made a few custom modules.

These custom modules are stored in my R10K control-repo. So If I run R10K deploy environment the modules are in /etc/puppetlabs/code/environments/MY_BRANCH/modules/ and working.

I'm now wanting to use a few modules from Puppet Forge so I'm adding them to my Puppetfile, but when I run r10k puppetfile install the modules directory is completely cleared out and only the puppet forge modules are left.

What is the best solution to this?

Before:

```<code>-modules/
  -custom_facts/
  -custom_files/
</code>```

After:

```<code>-modules/
  -certregen/
  -inifile/
</code>```

Desired:

```<code> -modules/
  -custom_facts/
  -custom_files/
  -certregen/
  -inifile/
</code>```

答:
There is a not very well-known option for a module install in a Puppetfile. It is the local option: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#local.

You can set it to true in your Puppetfile to avoid purging modules stored inside your control repo:

```<code>mod 'custom_facts', local: true
mod 'custom_files', local: true
</code>```

After modifying the Puppetfile like above, use r10k deploy display to confirm the satisfactory results.

Note that another option is to move the local modules into another module directory. For example:

```<code>repo root dir
|── Puppetfile
|── local_modules
|   |── custom_facts
|   |── custom_files
</code>```

R10k will ignore that directory during module deployments (but not during environment deployments of your control repo) and the modules will not be purged. However, you will need to setup your enviroment.conf to look for modules in that additional path: https://docs.puppet.com/puppet/5.0/config_file_environment.html#modulepath

Body:
I made a few custom modules.

These custom modules are stored in my R10K control-repo. So If I run R10K deploy environment the modules are in /etc/puppetlabs/code/environments/MY_BRANCH/modules/ and working.

I'm now wanting to use a few modules from Puppet Forge so I'm adding them to my Puppetfile, but when I run r10k puppetfile install the modules directory is completely cleared out and only the puppet forge modules are left.

What is the best solution to this?

Before:

-modules/
  -custom_facts/
  -custom_files/

After:

-modules/
  -certregen/
  -inifile/

Desired:

 -modules/
  -custom_facts/
  -custom_files/
  -certregen/
  -inifile/

Body:
There is a not very well-known option for a module install in a Puppetfile. It is the local option: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#local.

You can set it to true in your Puppetfile to avoid purging modules stored inside your control repo:

mod 'custom_facts', local: true
mod 'custom_files', local: true

After modifying the Puppetfile like above, use r10k deploy display to confirm the satisfactory results.

Note that another option is to move the local modules into another module directory. For example:

repo root dir
|── Puppetfile
|── local_modules
|   |── custom_facts
|   |── custom_files

R10k will ignore that directory during module deployments (but not during environment deployments of your control repo) and the modules will not be purged. However, you will need to setup your enviroment.conf to look for modules in that additional path: https://docs.puppet.com/puppet/5.0/config_file_environment.html#modulepath


来源: stackexchange

问:
How can i list all tables involved in SQLAlchemy statements
How can i list all tables involved in SQLAlchemy statements ?
let assume we have the following query

```<code>query = session.query(Address).filter(Address.person == person)
</code>```

how can list the tables that is used by this query
in this case : Person , Address

答:
r-m-n answer is good , but it doesn't handle all cases , sub queries ,delete statements , exist statements etc </p>

<p>here is a general way to extract all tables </p>

```<code>from sqlalchemy.sql.visitors import ClauseVisitor
from sqlalchemy import Table

def extract_tables(sql_stmt):
    tables = []
    visitor = ClauseVisitor()
    cluase_iter = visitor.iterate(elem)
    for e in cluase_iter:
        if isinstance(e, Table):
            tables.append(e)
        if isinstance(e, (ValuesBase, UpdateBase)):
            tables.append(e.table)
    return set(tables)
</code>```

ContentLicense: CC BY-SA 3.0

Body:
How can i list all tables involved in SQLAlchemy statements ?
let assume we have the following query

query = session.query(Address).filter(Address.person == person)

how can list the tables that is used by this query
in this case : Person , Address

Body:
r-m-n answer is good , but it doesn't handle all cases , sub queries ,delete statements , exist statements etc

here is a general way to extract all tables

from sqlalchemy.sql.visitors import ClauseVisitor
from sqlalchemy import Table

def extract_tables(sql_stmt):
    tables = []
    visitor = ClauseVisitor()
    cluase_iter = visitor.iterate(elem)
    for e in cluase_iter:
        if isinstance(e, Table):
            tables.append(e)
        if isinstance(e, (ValuesBase, UpdateBase)):
            tables.append(e.table)
    return set(tables)


问:
RxJS: Disable refresh button for duration after clicked
I am new to RxJS and tried to do a simple demo that lets you refresh the data every one second.

I made a button and created a click stream from it.
The problem started when i wanted to make a stream that every button click emits false and after one second emits true once again.

For example - the initial state is true as we can refresh at start.
Once i clicked the button the new value should be false right after the click as we cant refresh further.

Lastly after one second passed - the value should be true once again.

I tried creating it and succeeded, but it looks terrible.
Any ideas hot to do it better and cleaner?
Another thing is I don't really know if it is even a good idea to use RxJS here as the easy regular way is to have a Boolean set to true and after I clicked set it to false and with setTimeout change it back to true.

Here is what i did:

```<code>// The stream of the button clicks.
$clicksStream
  // Change the click stream to the timed true false change.
  .switchMap(() => Observable
                    // Emit first value immediately and every 1 second after.
                    .timer(0, 1000)
                    // Map each one - 0 becomes false and others true.
                    .map(x => !!x)
                    // Take only first two items.
                    .take(2))
  // Always the start value is true.
  .startWith(true);
</code>```

答:
You can use the timeoutWith operator to do this.

```<code>$clickStream
  .switchMapTo(
    // Start with false
    Observable.of(false)
      // If no values are emitted for 1 second emit true
      .timeoutWith(1000, Observable.of(true))
  )
  .startWith(true);
</code>```

Body:
I am new to RxJS and tried to do a simple demo that lets you refresh the data every one second.

I made a button and created a click stream from it.
The problem started when i wanted to make a stream that every button click emits false and after one second emits true once again.

For example - the initial state is true as we can refresh at start.
Once i clicked the button the new value should be false right after the click as we cant refresh further.

Lastly after one second passed - the value should be true once again.

I tried creating it and succeeded, but it looks terrible.
Any ideas hot to do it better and cleaner?
Another thing is I don't really know if it is even a good idea to use RxJS here as the easy regular way is to have a Boolean set to true and after I clicked set it to false and with setTimeout change it back to true.

Here is what i did:

// The stream of the button clicks.
$clicksStream
  // Change the click stream to the timed true false change.
  .switchMap(() => Observable
                    // Emit first value immediately and every 1 second after.
                    .timer(0, 1000)
                    // Map each one - 0 becomes false and others true.
                    .map(x => !!x)
                    // Take only first two items.
                    .take(2))
  // Always the start value is true.
  .startWith(true);

Body:
You can use the timeoutWith operator to do this.

$clickStream
  .switchMapTo(
    // Start with false
    Observable.of(false)
      // If no values are emitted for 1 second emit true
      .timeoutWith(1000, Observable.of(true))
  )
  .startWith(true);


问:
jQuery doesn't work with pages loaded with ajax
I have seen other questions like this one here but they didn't seem to help.

I have purchased an html theme that changes/transitions between pages with ajax.

When I slide into a certain page where I am trying to use jQuery, nothing happens. But if I refresh that page then the jQuery fires.

Is there a way to get the jquery to work when transitioning into the page instead of having to refresh it?

答: I'm not sure how your template is set up but move jQuery to whatever the base file is that loads other libraries. It should be where all the CSS, etc, is loaded also.</p>


问:
Spark runtime error for MLlib api using sbt run
I am trying to run the following code using sbt package and sbt run. I am getting a runtime error that doesn't make sense to me. The code works great on spark-shell. The error occurs when executing the computeSVD line. If this line is commented out, the program works fine. I have seen similar issues for other API for the MLlib library. It will be great if someone can provide insights into the problem.

Code:

```<code>package com.sracr.test

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.mllib.linalg.Matrix
import org.apache.spark.mllib.linalg.SingularValueDecomposition
import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.mllib.linalg.distributed.RowMatrix

object Test {

       def main(args: Array[ String ]) {

         val conf = new SparkConf().setAppName("MySparkApp").setMaster("spark://127.0.0.1:7077")

         var ctx : SparkContext = new SparkContext(conf)

         ctx.addJar("target/scala-2.11/spark-test_2.11-1.0.jar")

         println("Hello, This is a start!")

         val data = List(
           Vectors.sparse(5, Seq((1, 1.0), (3, 7.0))),
           Vectors.dense(2.0, 0.0, 3.0, 4.0, 5.0),
           Vectors.dense(4.0, 0.0, 0.0, 6.0, 7.0))

         val dataRDD = ctx.parallelize(data)

         val mat: RowMatrix = new RowMatrix(dataRDD)

         println(mat.numCols())

         val svd: SingularValueDecomposition[RowMatrix, Matrix] = mat.computeSVD(2, computeU = true)

         println(mat.numRows())

         println("It Works!!!!!")

         ctx.stop()

       }

}
</code>```

Error:

```$sbt run
[warn] Executing in batch mode.
[warn]   For better performance, hit [ENTER] to switch to interactive mode, or
[warn]   consider launching sbt without any commands, or explicitly passing 'shell'
[info] Loading project definition from /Users/ani.das/Projects/spark/MySpark/spark-test/project
[info] Set current project to spark test (in build file:/Users/ani.das/Projects/spark/MySpark/spark-test/)
[info] Running com.sracr.test.Test
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
17/07/06 10:51:18 INFO SparkContext: Running Spark version 2.1.0
17/07/06 10:51:18 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
17/07/06 10:51:18 WARN Utils: Your hostname, 127.0.0.1 resolves to a loopback address: 127.0.0.1; using 105.145.28.172 instead (on interface en0)
17/07/06 10:51:18 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
17/07/06 10:51:18 INFO SecurityManager: Changing view acls to: ani.das
17/07/06 10:51:18 INFO SecurityManager: Changing modify acls to: ani.das
17/07/06 10:51:18 INFO SecurityManager: Changing view acls groups to:
17/07/06 10:51:18 INFO SecurityManager: Changing modify acls groups to:
17/07/06 10:51:18 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(ani.das); groups with view permissions: Set(); users  with modify permissions: Set(ani.das); groups with modify permissions: Set()
17/07/06 10:51:19 INFO Utils: Successfully started service 'sparkDriver' on port 65196.
17/07/06 10:51:19 INFO SparkEnv: Registering MapOutputTracker
17/07/06 10:51:19 INFO SparkEnv: Registering BlockManagerMaster
17/07/06 10:51:19 INFO BlockManagerMasterEndpoint: Using org.apache.spark.storage.DefaultTopologyMapper for getting topology information
17/07/06 10:51:19 INFO BlockManagerMasterEndpoint: BlockManagerMasterEndpoint up
17/07/06 10:51:19 INFO DiskBlockManager: Created local directory at /private/var/folders/4c/s3nt_0s96z57zfxc3dlyq3swjl4fq9/T/blockmgr-5317c7b1-ff8d-463a-8405-dd7c3f12074a
17/07/06 10:51:19 INFO MemoryStore: MemoryStore started with capacity 408.9 MB
17/07/06 10:51:19 INFO SparkEnv: Registering OutputCommitCoordinator
17/07/06 10:51:19 WARN Utils: Service 'SparkUI' could not bind on port 4040. Attempting port 4041.
17/07/06 10:51:19 INFO Utils: Successfully started service 'SparkUI' on port 4041.
17/07/06 10:51:19 INFO SparkUI: Bound SparkUI to 0.0.0.0, and started at http://105.145.28.172:4041
17/07/06 10:51:19 INFO StandaloneAppClient$ClientEndpoint: Connecting to master spark://127.0.0.1:7077...
17/07/06 10:51:19 INFO TransportClientFactory: Successfully created connection to /127.0.0.1:7077 after 31 ms (0 ms spent in bootstraps)
17/07/06 10:51:19 INFO StandaloneSchedulerBackend: Connected to Spark cluster with app ID app-20170706105119-0007
17/07/06 10:51:19 INFO StandaloneAppClient$ClientEndpoint: Executor added: app-20170706105119-0007/0 on worker-20170706103441-105.145.28.172-64630 (105.145.28.172:64630) with 8 cores
17/07/06 10:51:19 INFO StandaloneSchedulerBackend: Granted executor ID app-20170706105119-0007/0 on hostPort 105.145.28.172:64630 with 8 cores, 1024.0 MB RAM
17/07/06 10:51:19 INFO StandaloneAppClient$ClientEndpoint: Executor updated: app-20170706105119-0007/0 is now RUNNING
17/07/06 10:51:19 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 65198.
17/07/06 10:51:19 INFO NettyBlockTransferService: Server created on 105.145.28.172:65198
17/07/06 10:51:19 INFO BlockManager: Using org.apache.spark.storage.RandomBlockReplicationPolicy for block replication policy
17/07/06 10:51:19 INFO BlockManagerMaster: Registering BlockManager BlockManagerId(driver, 105.145.28.172, 65198, None)
17/07/06 10:51:19 INFO BlockManagerMasterEndpoint: Registering block manager 105.145.28.172:65198 with 408.9 MB RAM, BlockManagerId(driver, 105.145.28.172, 65198, None)
17/07/06 10:51:19 INFO BlockManagerMaster: Registered BlockManager BlockManagerId(driver, 105.145.28.172, 65198, None)
17/07/06 10:51:19 INFO BlockManager: Initialized BlockManager: BlockManagerId(driver, 105.145.28.172, 65198, None)
17/07/06 10:51:19 INFO StandaloneSchedulerBackend: SchedulerBackend is ready for scheduling beginning after reached minRegisteredResourcesRatio: 0.0
17/07/06 10:51:19 INFO SparkContext: Added JAR target/scala-2.11/spark-test_2.11-1.0.jar at spark://105.145.28.172:65196/jars/spark-test_2.11-1.0.jar with timestamp 1499363479936
Hello, This is a start!
17/07/06 10:51:20 INFO SparkContext: Starting job: first at RowMatrix.scala:61
17/07/06 10:51:20 INFO DAGScheduler: Got job 0 (first at RowMatrix.scala:61) with 1 output partitions
17/07/06 10:51:20 INFO DAGScheduler: Final stage: ResultStage 0 (first at RowMatrix.scala:61)
17/07/06 10:51:20 INFO DAGScheduler: Parents of final stage: List()
17/07/06 10:51:20 INFO DAGScheduler: Missing parents: List()
17/07/06 10:51:20 INFO DAGScheduler: Submitting ResultStage 0 (ParallelCollectionRDD[0] at parallelize at test.scala:27), which has no missing parents
17/07/06 10:51:20 INFO MemoryStore: Block broadcast_0 stored as values in memory (estimated size 1408.0 B, free 408.9 MB)
17/07/06 10:51:20 INFO MemoryStore: Block broadcast_0_piece0 stored as bytes in memory (estimated size 958.0 B, free 408.9 MB)
17/07/06 10:51:20 INFO BlockManagerInfo: Added broadcast_0_piece0 in memory on 105.145.28.172:65198 (size: 958.0 B, free: 408.9 MB)
17/07/06 10:51:20 INFO SparkContext: Created broadcast 0 from broadcast at DAGScheduler.scala:996
17/07/06 10:51:20 INFO DAGScheduler: Submitting 1 missing tasks from ResultStage 0 (ParallelCollectionRDD[0] at parallelize at test.scala:27)
17/07/06 10:51:20 INFO TaskSchedulerImpl: Adding task set 0.0 with 1 tasks
17/07/06 10:51:21 INFO CoarseGrainedSchedulerBackend$DriverEndpoint: Registered executor NettyRpcEndpointRef(null) (105.145.28.172:65200) with ID 0
17/07/06 10:51:21 INFO TaskSetManager: Starting task 0.0 in stage 0.0 (TID 0, 105.145.28.172, executor 0, partition 0, PROCESS_LOCAL, 6215 bytes)
17/07/06 10:51:21 INFO BlockManagerMasterEndpoint: Registering block manager 105.145.28.172:65202 with 366.3 MB RAM, BlockManagerId(0, 105.145.28.172, 65202, None)
17/07/06 10:51:21 INFO BlockManagerInfo: Added broadcast_0_piece0 in memory on 105.145.28.172:65202 (size: 958.0 B, free: 366.3 MB)
17/07/06 10:51:22 INFO TaskSetManager: Finished task 0.0 in stage 0.0 (TID 0) in 503 ms on 105.145.28.172 (executor 0) (1/1)
17/07/06 10:51:22 INFO TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool
17/07/06 10:51:22 INFO DAGScheduler: ResultStage 0 (first at RowMatrix.scala:61) finished in 1.712 s
17/07/06 10:51:22 INFO DAGScheduler: Job 0 finished: first at RowMatrix.scala:61, took 1.885817 s
5
17/07/06 10:51:22 INFO SparkContext: Starting job: treeAggregate at RowMatrix.scala:122
17/07/06 10:51:22 INFO DAGScheduler: Got job 1 (treeAggregate at RowMatrix.scala:122) with 2 output partitions
17/07/06 10:51:22 INFO DAGScheduler: Final stage: ResultStage 1 (treeAggregate at RowMatrix.scala:122)
17/07/06 10:51:22 INFO DAGScheduler: Parents of final stage: List()
17/07/06 10:51:22 INFO DAGScheduler: Missing parents: List()
17/07/06 10:51:22 INFO DAGScheduler: Submitting ResultStage 1 (MapPartitionsRDD[1] at treeAggregate at RowMatrix.scala:122), which has no missing parents
17/07/06 10:51:22 INFO MemoryStore: Block broadcast_1 stored as values in memory (estimated size 2.6 KB, free 408.9 MB)
17/07/06 10:51:22 INFO MemoryStore: Block broadcast_1_piece0 stored as bytes in memory (estimated size 1560.0 B, free 408.9 MB)
17/07/06 10:51:22 INFO BlockManagerInfo: Added broadcast_1_piece0 in memory on 105.145.28.172:65198 (size: 1560.0 B, free: 408.9 MB)
17/07/06 10:51:22 INFO SparkContext: Created broadcast 1 from broadcast at DAGScheduler.scala:996
17/07/06 10:51:22 INFO DAGScheduler: Submitting 2 missing tasks from ResultStage 1 (MapPartitionsRDD[1] at treeAggregate at RowMatrix.scala:122)
17/07/06 10:51:22 INFO TaskSchedulerImpl: Adding task set 1.0 with 2 tasks
17/07/06 10:51:22 INFO TaskSetManager: Starting task 0.0 in stage 1.0 (TID 1, 105.145.28.172, executor 0, partition 0, PROCESS_LOCAL, 6223 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Starting task 1.0 in stage 1.0 (TID 2, 105.145.28.172, executor 0, partition 1, PROCESS_LOCAL, 6258 bytes)
17/07/06 10:51:22 INFO BlockManagerInfo: Added broadcast_1_piece0 in memory on 105.145.28.172:65202 (size: 1560.0 B, free: 366.3 MB)
17/07/06 10:51:22 WARN TaskSetManager: Lost task 0.0 in stage 1.0 (TID 1, 105.145.28.172, executor 0): java.lang.NullPointerException
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
    at org.apache.spark.scheduler.Task.run(Task.scala:99)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:322)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

17/07/06 10:51:22 INFO TaskSetManager: Lost task 1.0 in stage 1.0 (TID 2) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 1]
17/07/06 10:51:22 INFO TaskSetManager: Starting task 1.1 in stage 1.0 (TID 3, 105.145.28.172, executor 0, partition 1, PROCESS_LOCAL, 6258 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Starting task 0.1 in stage 1.0 (TID 4, 105.145.28.172, executor 0, partition 0, PROCESS_LOCAL, 6223 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Lost task 1.1 in stage 1.0 (TID 3) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 2]
17/07/06 10:51:22 INFO TaskSetManager: Starting task 1.2 in stage 1.0 (TID 5, 105.145.28.172, executor 0, partition 1, PROCESS_LOCAL, 6258 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Lost task 0.1 in stage 1.0 (TID 4) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 3]
17/07/06 10:51:22 INFO TaskSetManager: Starting task 0.2 in stage 1.0 (TID 6, 105.145.28.172, executor 0, partition 0, PROCESS_LOCAL, 6223 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Lost task 0.2 in stage 1.0 (TID 6) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 4]
17/07/06 10:51:22 INFO TaskSetManager: Starting task 0.3 in stage 1.0 (TID 7, 105.145.28.172, executor 0, partition 0, PROCESS_LOCAL, 6223 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Lost task 1.2 in stage 1.0 (TID 5) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 5]
17/07/06 10:51:22 INFO TaskSetManager: Starting task 1.3 in stage 1.0 (TID 8, 105.145.28.172, executor 0, partition 1, PROCESS_LOCAL, 6258 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Lost task 0.3 in stage 1.0 (TID 7) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 6]
17/07/06 10:51:22 ERROR TaskSetManager: Task 0 in stage 1.0 failed 4 times; aborting job
17/07/06 10:51:22 INFO TaskSetManager: Lost task 1.3 in stage 1.0 (TID 8) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 7]
17/07/06 10:51:22 INFO TaskSchedulerImpl: Removed TaskSet 1.0, whose tasks have all completed, from pool
17/07/06 10:51:22 INFO TaskSchedulerImpl: Cancelling stage 1
17/07/06 10:51:22 INFO DAGScheduler: ResultStage 1 (treeAggregate at RowMatrix.scala:122) failed in 0.391 s due to Job aborted due to stage failure: Task 0 in stage 1.0 failed 4 times, most recent failure: Lost task 0.3 in stage 1.0 (TID 7, 105.145.28.172, executor 0): java.lang.NullPointerException
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
    at org.apache.spark.scheduler.Task.run(Task.scala:99)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:322)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Driver stacktrace:
17/07/06 10:51:22 INFO DAGScheduler: Job 1 failed: treeAggregate at RowMatrix.scala:122, took 0.403468 s
[error] (run-main-0) org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 1.0 failed 4 times, most recent failure: Lost task 0.3 in stage 1.0 (TID 7, 105.145.28.172, executor 0): java.lang.NullPointerException
[error]     at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
[error]     at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
[error]     at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
[error]     at org.apache.spark.scheduler.Task.run(Task.scala:99)
[error]     at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:322)
[error]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[error]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[error]     at java.lang.Thread.run(Thread.java:745)
[error]
[error] Driver stacktrace:
org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 1.0 failed 4 times, most recent failure: Lost task 0.3 in stage 1.0 (TID 7, 105.145.28.172, executor 0): java.lang.NullPointerException
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
    at org.apache.spark.scheduler.Task.run(Task.scala:99)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:322)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Driver stacktrace:
    at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1435)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1423)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1422)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
    at org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:1422)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:802)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:802)
    at scala.Option.foreach(Option.scala:257)
    at org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:802)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.doOnReceive(DAGScheduler.scala:1650)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1605)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1594)
    at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:48)
    at org.apache.spark.scheduler.DAGScheduler.runJob(DAGScheduler.scala:628)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1918)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1981)
    at org.apache.spark.rdd.RDD$$anonfun$reduce$1.apply(RDD.scala:1025)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
    at org.apache.spark.rdd.RDD.withScope(RDD.scala:362)
    at org.apache.spark.rdd.RDD.reduce(RDD.scala:1007)
    at org.apache.spark.rdd.RDD$$anonfun$treeAggregate$1.apply(RDD.scala:1150)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
    at org.apache.spark.rdd.RDD.withScope(RDD.scala:362)
    at org.apache.spark.rdd.RDD.treeAggregate(RDD.scala:1127)
    at org.apache.spark.mllib.linalg.distributed.RowMatrix.computeGramianMatrix(RowMatrix.scala:122)
    at org.apache.spark.mllib.linalg.distributed.RowMatrix.computeSVD(RowMatrix.scala:259)
    at org.apache.spark.mllib.linalg.distributed.RowMatrix.computeSVD(RowMatrix.scala:194)
    at com.sracr.test.Test$.main(test.scala:33)
    at com.sracr.test.Test.main(test.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
Caused by: java.lang.NullPointerException
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
    at org.apache.spark.scheduler.Task.run(Task.scala:99)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:322)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[trace] Stack trace suppressed: run last compile:run for the full output.
17/07/06 10:51:22 ERROR ContextCleaner: Error in cleaning thread
java.lang.InterruptedException
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
    at org.apache.spark.ContextCleaner$$anonfun$org$apache$spark$ContextCleaner$$keepCleaning$1.apply$mcV$sp(ContextCleaner.scala:175)
    at org.apache.spark.util.Utils$.tryOrStopSparkContext(Utils.scala:1245)
    at org.apache.spark.ContextCleaner.org$apache$spark$ContextCleaner$$keepCleaning(ContextCleaner.scala:172)
    at org.apache.spark.ContextCleaner$$anon$1.run(ContextCleaner.scala:67)
17/07/06 10:51:22 ERROR Utils: uncaught error in thread SparkListenerBus, stopping SparkContext
java.lang.InterruptedException
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:998)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
    at java.util.concurrent.Semaphore.acquire(Semaphore.java:312)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(LiveListenerBus.scala:80)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply(LiveListenerBus.scala:79)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply(LiveListenerBus.scala:79)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1.apply$mcV$sp(LiveListenerBus.scala:78)
    at org.apache.spark.util.Utils$.tryOrStopSparkContext(Utils.scala:1245)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1.run(LiveListenerBus.scala:77)
17/07/06 10:51:22 ERROR Utils: throw uncaught fatal error in thread SparkListenerBus
java.lang.InterruptedException
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:998)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
    at java.util.concurrent.Semaphore.acquire(Semaphore.java:312)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(LiveListenerBus.scala:80)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply(LiveListenerBus.scala:79)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply(LiveListenerBus.scala:79)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1.apply$mcV$sp(LiveListenerBus.scala:78)
    at org.apache.spark.util.Utils$.tryOrStopSparkContext(Utils.scala:1245)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1.run(LiveListenerBus.scala:77)
17/07/06 10:51:22 INFO SparkUI: Stopped Spark web UI at http://105.145.28.172:4041
17/07/06 10:51:22 INFO StandaloneSchedulerBackend: Shutting down all executors
java.lang.RuntimeException: Nonzero exit code: 1
    at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) Nonzero exit code: 1
[error] Total time: 5 s, completed Jul 6, 2017 10:51:22 AM
17/07/06 10:51:22 INFO DiskBlockManager: Shutdown hook called
17/07/06 10:51:22 INFO ShutdownHookManager: Shutdown hook called
17/07/06 10:51:22 INFO ShutdownHookManager: Deleting directory /private/var/folders/4c/s3nt_0s96z57zfxc3dlyq3swjl4fq9/T/spark-4bc93888-b930-4621-9cc8-b44fc3b6bd9e
17/07/06 10:51:22 INFO ShutdownHookManager: Deleting directory /private/var/folders/4c/s3nt_0s96z57zfxc3dlyq3swjl4fq9/T/spark-4bc93888-b930-4621-9cc8-b44fc3b6bd9e/userFiles-c5140f8e-6edb-4c89-b113-02d406019feb
```

答: This problem was due to a version issue. It is now resolved. I was using MLlib 2.1.0 with Spark 2.1.1. </p>

Body:
I am trying to run the following code using sbt package and sbt run. I am getting a runtime error that doesn't make sense to me. The code works great on spark-shell. The error occurs when executing the computeSVD line. If this line is commented out, the program works fine. I have seen similar issues for other API for the MLlib library. It will be great if someone can provide insights into the problem.

Code:

package com.sracr.test

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.mllib.linalg.Matrix
import org.apache.spark.mllib.linalg.SingularValueDecomposition
import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.mllib.linalg.distributed.RowMatrix

object Test {

       def main(args: Array[ String ]) {

         val conf = new SparkConf().setAppName("MySparkApp").setMaster("spark://127.0.0.1:7077")

         var ctx : SparkContext = new SparkContext(conf)

         ctx.addJar("target/scala-2.11/spark-test_2.11-1.0.jar")

         println("Hello, This is a start!")

         val data = List(
           Vectors.sparse(5, Seq((1, 1.0), (3, 7.0))),
           Vectors.dense(2.0, 0.0, 3.0, 4.0, 5.0),
           Vectors.dense(4.0, 0.0, 0.0, 6.0, 7.0))

         val dataRDD = ctx.parallelize(data)

         val mat: RowMatrix = new RowMatrix(dataRDD)

         println(mat.numCols())

         val svd: SingularValueDecomposition[RowMatrix, Matrix] = mat.computeSVD(2, computeU = true)

         println(mat.numRows())

         println("It Works!!!!!")

         ctx.stop()

       }

}

Error:

$sbt run
[warn] Executing in batch mode.
[warn]   For better performance, hit [ENTER] to switch to interactive mode, or
[warn]   consider launching sbt without any commands, or explicitly passing 'shell'
[info] Loading project definition from /Users/ani.das/Projects/spark/MySpark/spark-test/project
[info] Set current project to spark test (in build file:/Users/ani.das/Projects/spark/MySpark/spark-test/)
[info] Running com.sracr.test.Test
Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties
17/07/06 10:51:18 INFO SparkContext: Running Spark version 2.1.0
17/07/06 10:51:18 WARN NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
17/07/06 10:51:18 WARN Utils: Your hostname, 127.0.0.1 resolves to a loopback address: 127.0.0.1; using 105.145.28.172 instead (on interface en0)
17/07/06 10:51:18 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
17/07/06 10:51:18 INFO SecurityManager: Changing view acls to: ani.das
17/07/06 10:51:18 INFO SecurityManager: Changing modify acls to: ani.das
17/07/06 10:51:18 INFO SecurityManager: Changing view acls groups to:
17/07/06 10:51:18 INFO SecurityManager: Changing modify acls groups to:
17/07/06 10:51:18 INFO SecurityManager: SecurityManager: authentication disabled; ui acls disabled; users  with view permissions: Set(ani.das); groups with view permissions: Set(); users  with modify permissions: Set(ani.das); groups with modify permissions: Set()
17/07/06 10:51:19 INFO Utils: Successfully started service 'sparkDriver' on port 65196.
17/07/06 10:51:19 INFO SparkEnv: Registering MapOutputTracker
17/07/06 10:51:19 INFO SparkEnv: Registering BlockManagerMaster
17/07/06 10:51:19 INFO BlockManagerMasterEndpoint: Using org.apache.spark.storage.DefaultTopologyMapper for getting topology information
17/07/06 10:51:19 INFO BlockManagerMasterEndpoint: BlockManagerMasterEndpoint up
17/07/06 10:51:19 INFO DiskBlockManager: Created local directory at /private/var/folders/4c/s3nt_0s96z57zfxc3dlyq3swjl4fq9/T/blockmgr-5317c7b1-ff8d-463a-8405-dd7c3f12074a
17/07/06 10:51:19 INFO MemoryStore: MemoryStore started with capacity 408.9 MB
17/07/06 10:51:19 INFO SparkEnv: Registering OutputCommitCoordinator
17/07/06 10:51:19 WARN Utils: Service 'SparkUI' could not bind on port 4040. Attempting port 4041.
17/07/06 10:51:19 INFO Utils: Successfully started service 'SparkUI' on port 4041.
17/07/06 10:51:19 INFO SparkUI: Bound SparkUI to 0.0.0.0, and started at http://105.145.28.172:4041
17/07/06 10:51:19 INFO StandaloneAppClient$ClientEndpoint: Connecting to master spark://127.0.0.1:7077...
17/07/06 10:51:19 INFO TransportClientFactory: Successfully created connection to /127.0.0.1:7077 after 31 ms (0 ms spent in bootstraps)
17/07/06 10:51:19 INFO StandaloneSchedulerBackend: Connected to Spark cluster with app ID app-20170706105119-0007
17/07/06 10:51:19 INFO StandaloneAppClient$ClientEndpoint: Executor added: app-20170706105119-0007/0 on worker-20170706103441-105.145.28.172-64630 (105.145.28.172:64630) with 8 cores
17/07/06 10:51:19 INFO StandaloneSchedulerBackend: Granted executor ID app-20170706105119-0007/0 on hostPort 105.145.28.172:64630 with 8 cores, 1024.0 MB RAM
17/07/06 10:51:19 INFO StandaloneAppClient$ClientEndpoint: Executor updated: app-20170706105119-0007/0 is now RUNNING
17/07/06 10:51:19 INFO Utils: Successfully started service 'org.apache.spark.network.netty.NettyBlockTransferService' on port 65198.
17/07/06 10:51:19 INFO NettyBlockTransferService: Server created on 105.145.28.172:65198
17/07/06 10:51:19 INFO BlockManager: Using org.apache.spark.storage.RandomBlockReplicationPolicy for block replication policy
17/07/06 10:51:19 INFO BlockManagerMaster: Registering BlockManager BlockManagerId(driver, 105.145.28.172, 65198, None)
17/07/06 10:51:19 INFO BlockManagerMasterEndpoint: Registering block manager 105.145.28.172:65198 with 408.9 MB RAM, BlockManagerId(driver, 105.145.28.172, 65198, None)
17/07/06 10:51:19 INFO BlockManagerMaster: Registered BlockManager BlockManagerId(driver, 105.145.28.172, 65198, None)
17/07/06 10:51:19 INFO BlockManager: Initialized BlockManager: BlockManagerId(driver, 105.145.28.172, 65198, None)
17/07/06 10:51:19 INFO StandaloneSchedulerBackend: SchedulerBackend is ready for scheduling beginning after reached minRegisteredResourcesRatio: 0.0
17/07/06 10:51:19 INFO SparkContext: Added JAR target/scala-2.11/spark-test_2.11-1.0.jar at spark://105.145.28.172:65196/jars/spark-test_2.11-1.0.jar with timestamp 1499363479936
Hello, This is a start!
17/07/06 10:51:20 INFO SparkContext: Starting job: first at RowMatrix.scala:61
17/07/06 10:51:20 INFO DAGScheduler: Got job 0 (first at RowMatrix.scala:61) with 1 output partitions
17/07/06 10:51:20 INFO DAGScheduler: Final stage: ResultStage 0 (first at RowMatrix.scala:61)
17/07/06 10:51:20 INFO DAGScheduler: Parents of final stage: List()
17/07/06 10:51:20 INFO DAGScheduler: Missing parents: List()
17/07/06 10:51:20 INFO DAGScheduler: Submitting ResultStage 0 (ParallelCollectionRDD[0] at parallelize at test.scala:27), which has no missing parents
17/07/06 10:51:20 INFO MemoryStore: Block broadcast_0 stored as values in memory (estimated size 1408.0 B, free 408.9 MB)
17/07/06 10:51:20 INFO MemoryStore: Block broadcast_0_piece0 stored as bytes in memory (estimated size 958.0 B, free 408.9 MB)
17/07/06 10:51:20 INFO BlockManagerInfo: Added broadcast_0_piece0 in memory on 105.145.28.172:65198 (size: 958.0 B, free: 408.9 MB)
17/07/06 10:51:20 INFO SparkContext: Created broadcast 0 from broadcast at DAGScheduler.scala:996
17/07/06 10:51:20 INFO DAGScheduler: Submitting 1 missing tasks from ResultStage 0 (ParallelCollectionRDD[0] at parallelize at test.scala:27)
17/07/06 10:51:20 INFO TaskSchedulerImpl: Adding task set 0.0 with 1 tasks
17/07/06 10:51:21 INFO CoarseGrainedSchedulerBackend$DriverEndpoint: Registered executor NettyRpcEndpointRef(null) (105.145.28.172:65200) with ID 0
17/07/06 10:51:21 INFO TaskSetManager: Starting task 0.0 in stage 0.0 (TID 0, 105.145.28.172, executor 0, partition 0, PROCESS_LOCAL, 6215 bytes)
17/07/06 10:51:21 INFO BlockManagerMasterEndpoint: Registering block manager 105.145.28.172:65202 with 366.3 MB RAM, BlockManagerId(0, 105.145.28.172, 65202, None)
17/07/06 10:51:21 INFO BlockManagerInfo: Added broadcast_0_piece0 in memory on 105.145.28.172:65202 (size: 958.0 B, free: 366.3 MB)
17/07/06 10:51:22 INFO TaskSetManager: Finished task 0.0 in stage 0.0 (TID 0) in 503 ms on 105.145.28.172 (executor 0) (1/1)
17/07/06 10:51:22 INFO TaskSchedulerImpl: Removed TaskSet 0.0, whose tasks have all completed, from pool
17/07/06 10:51:22 INFO DAGScheduler: ResultStage 0 (first at RowMatrix.scala:61) finished in 1.712 s
17/07/06 10:51:22 INFO DAGScheduler: Job 0 finished: first at RowMatrix.scala:61, took 1.885817 s
5
17/07/06 10:51:22 INFO SparkContext: Starting job: treeAggregate at RowMatrix.scala:122
17/07/06 10:51:22 INFO DAGScheduler: Got job 1 (treeAggregate at RowMatrix.scala:122) with 2 output partitions
17/07/06 10:51:22 INFO DAGScheduler: Final stage: ResultStage 1 (treeAggregate at RowMatrix.scala:122)
17/07/06 10:51:22 INFO DAGScheduler: Parents of final stage: List()
17/07/06 10:51:22 INFO DAGScheduler: Missing parents: List()
17/07/06 10:51:22 INFO DAGScheduler: Submitting ResultStage 1 (MapPartitionsRDD[1] at treeAggregate at RowMatrix.scala:122), which has no missing parents
17/07/06 10:51:22 INFO MemoryStore: Block broadcast_1 stored as values in memory (estimated size 2.6 KB, free 408.9 MB)
17/07/06 10:51:22 INFO MemoryStore: Block broadcast_1_piece0 stored as bytes in memory (estimated size 1560.0 B, free 408.9 MB)
17/07/06 10:51:22 INFO BlockManagerInfo: Added broadcast_1_piece0 in memory on 105.145.28.172:65198 (size: 1560.0 B, free: 408.9 MB)
17/07/06 10:51:22 INFO SparkContext: Created broadcast 1 from broadcast at DAGScheduler.scala:996
17/07/06 10:51:22 INFO DAGScheduler: Submitting 2 missing tasks from ResultStage 1 (MapPartitionsRDD[1] at treeAggregate at RowMatrix.scala:122)
17/07/06 10:51:22 INFO TaskSchedulerImpl: Adding task set 1.0 with 2 tasks
17/07/06 10:51:22 INFO TaskSetManager: Starting task 0.0 in stage 1.0 (TID 1, 105.145.28.172, executor 0, partition 0, PROCESS_LOCAL, 6223 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Starting task 1.0 in stage 1.0 (TID 2, 105.145.28.172, executor 0, partition 1, PROCESS_LOCAL, 6258 bytes)
17/07/06 10:51:22 INFO BlockManagerInfo: Added broadcast_1_piece0 in memory on 105.145.28.172:65202 (size: 1560.0 B, free: 366.3 MB)
17/07/06 10:51:22 WARN TaskSetManager: Lost task 0.0 in stage 1.0 (TID 1, 105.145.28.172, executor 0): java.lang.NullPointerException
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
    at org.apache.spark.scheduler.Task.run(Task.scala:99)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:322)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

17/07/06 10:51:22 INFO TaskSetManager: Lost task 1.0 in stage 1.0 (TID 2) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 1]
17/07/06 10:51:22 INFO TaskSetManager: Starting task 1.1 in stage 1.0 (TID 3, 105.145.28.172, executor 0, partition 1, PROCESS_LOCAL, 6258 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Starting task 0.1 in stage 1.0 (TID 4, 105.145.28.172, executor 0, partition 0, PROCESS_LOCAL, 6223 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Lost task 1.1 in stage 1.0 (TID 3) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 2]
17/07/06 10:51:22 INFO TaskSetManager: Starting task 1.2 in stage 1.0 (TID 5, 105.145.28.172, executor 0, partition 1, PROCESS_LOCAL, 6258 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Lost task 0.1 in stage 1.0 (TID 4) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 3]
17/07/06 10:51:22 INFO TaskSetManager: Starting task 0.2 in stage 1.0 (TID 6, 105.145.28.172, executor 0, partition 0, PROCESS_LOCAL, 6223 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Lost task 0.2 in stage 1.0 (TID 6) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 4]
17/07/06 10:51:22 INFO TaskSetManager: Starting task 0.3 in stage 1.0 (TID 7, 105.145.28.172, executor 0, partition 0, PROCESS_LOCAL, 6223 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Lost task 1.2 in stage 1.0 (TID 5) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 5]
17/07/06 10:51:22 INFO TaskSetManager: Starting task 1.3 in stage 1.0 (TID 8, 105.145.28.172, executor 0, partition 1, PROCESS_LOCAL, 6258 bytes)
17/07/06 10:51:22 INFO TaskSetManager: Lost task 0.3 in stage 1.0 (TID 7) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 6]
17/07/06 10:51:22 ERROR TaskSetManager: Task 0 in stage 1.0 failed 4 times; aborting job
17/07/06 10:51:22 INFO TaskSetManager: Lost task 1.3 in stage 1.0 (TID 8) on 105.145.28.172, executor 0: java.lang.NullPointerException (null) [duplicate 7]
17/07/06 10:51:22 INFO TaskSchedulerImpl: Removed TaskSet 1.0, whose tasks have all completed, from pool
17/07/06 10:51:22 INFO TaskSchedulerImpl: Cancelling stage 1
17/07/06 10:51:22 INFO DAGScheduler: ResultStage 1 (treeAggregate at RowMatrix.scala:122) failed in 0.391 s due to Job aborted due to stage failure: Task 0 in stage 1.0 failed 4 times, most recent failure: Lost task 0.3 in stage 1.0 (TID 7, 105.145.28.172, executor 0): java.lang.NullPointerException
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
    at org.apache.spark.scheduler.Task.run(Task.scala:99)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:322)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Driver stacktrace:
17/07/06 10:51:22 INFO DAGScheduler: Job 1 failed: treeAggregate at RowMatrix.scala:122, took 0.403468 s
[error] (run-main-0) org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 1.0 failed 4 times, most recent failure: Lost task 0.3 in stage 1.0 (TID 7, 105.145.28.172, executor 0): java.lang.NullPointerException
[error]     at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
[error]     at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
[error]     at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
[error]     at org.apache.spark.scheduler.Task.run(Task.scala:99)
[error]     at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:322)
[error]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
[error]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
[error]     at java.lang.Thread.run(Thread.java:745)
[error]
[error] Driver stacktrace:
org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 1.0 failed 4 times, most recent failure: Lost task 0.3 in stage 1.0 (TID 7, 105.145.28.172, executor 0): java.lang.NullPointerException
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
    at org.apache.spark.scheduler.Task.run(Task.scala:99)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:322)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

Driver stacktrace:
    at org.apache.spark.scheduler.DAGScheduler.org$apache$spark$scheduler$DAGScheduler$$failJobAndIndependentStages(DAGScheduler.scala:1435)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1423)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$abortStage$1.apply(DAGScheduler.scala:1422)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
    at org.apache.spark.scheduler.DAGScheduler.abortStage(DAGScheduler.scala:1422)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:802)
    at org.apache.spark.scheduler.DAGScheduler$$anonfun$handleTaskSetFailed$1.apply(DAGScheduler.scala:802)
    at scala.Option.foreach(Option.scala:257)
    at org.apache.spark.scheduler.DAGScheduler.handleTaskSetFailed(DAGScheduler.scala:802)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.doOnReceive(DAGScheduler.scala:1650)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1605)
    at org.apache.spark.scheduler.DAGSchedulerEventProcessLoop.onReceive(DAGScheduler.scala:1594)
    at org.apache.spark.util.EventLoop$$anon$1.run(EventLoop.scala:48)
    at org.apache.spark.scheduler.DAGScheduler.runJob(DAGScheduler.scala:628)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1918)
    at org.apache.spark.SparkContext.runJob(SparkContext.scala:1981)
    at org.apache.spark.rdd.RDD$$anonfun$reduce$1.apply(RDD.scala:1025)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
    at org.apache.spark.rdd.RDD.withScope(RDD.scala:362)
    at org.apache.spark.rdd.RDD.reduce(RDD.scala:1007)
    at org.apache.spark.rdd.RDD$$anonfun$treeAggregate$1.apply(RDD.scala:1150)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:151)
    at org.apache.spark.rdd.RDDOperationScope$.withScope(RDDOperationScope.scala:112)
    at org.apache.spark.rdd.RDD.withScope(RDD.scala:362)
    at org.apache.spark.rdd.RDD.treeAggregate(RDD.scala:1127)
    at org.apache.spark.mllib.linalg.distributed.RowMatrix.computeGramianMatrix(RowMatrix.scala:122)
    at org.apache.spark.mllib.linalg.distributed.RowMatrix.computeSVD(RowMatrix.scala:259)
    at org.apache.spark.mllib.linalg.distributed.RowMatrix.computeSVD(RowMatrix.scala:194)
    at com.sracr.test.Test$.main(test.scala:33)
    at com.sracr.test.Test.main(test.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
Caused by: java.lang.NullPointerException
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.SparkContext$$anonfun$33.apply(SparkContext.scala:2028)
    at org.apache.spark.scheduler.ResultTask.runTask(ResultTask.scala:87)
    at org.apache.spark.scheduler.Task.run(Task.scala:99)
    at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:322)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
[trace] Stack trace suppressed: run last compile:run for the full output.
17/07/06 10:51:22 ERROR ContextCleaner: Error in cleaning thread
java.lang.InterruptedException
    at java.lang.Object.wait(Native Method)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
    at org.apache.spark.ContextCleaner$$anonfun$org$apache$spark$ContextCleaner$$keepCleaning$1.apply$mcV$sp(ContextCleaner.scala:175)
    at org.apache.spark.util.Utils$.tryOrStopSparkContext(Utils.scala:1245)
    at org.apache.spark.ContextCleaner.org$apache$spark$ContextCleaner$$keepCleaning(ContextCleaner.scala:172)
    at org.apache.spark.ContextCleaner$$anon$1.run(ContextCleaner.scala:67)
17/07/06 10:51:22 ERROR Utils: uncaught error in thread SparkListenerBus, stopping SparkContext
java.lang.InterruptedException
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:998)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
    at java.util.concurrent.Semaphore.acquire(Semaphore.java:312)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(LiveListenerBus.scala:80)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply(LiveListenerBus.scala:79)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply(LiveListenerBus.scala:79)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1.apply$mcV$sp(LiveListenerBus.scala:78)
    at org.apache.spark.util.Utils$.tryOrStopSparkContext(Utils.scala:1245)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1.run(LiveListenerBus.scala:77)
17/07/06 10:51:22 ERROR Utils: throw uncaught fatal error in thread SparkListenerBus
java.lang.InterruptedException
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer.java:998)
    at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1304)
    at java.util.concurrent.Semaphore.acquire(Semaphore.java:312)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply$mcV$sp(LiveListenerBus.scala:80)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply(LiveListenerBus.scala:79)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1$$anonfun$apply$mcV$sp$1.apply(LiveListenerBus.scala:79)
    at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1$$anonfun$run$1.apply$mcV$sp(LiveListenerBus.scala:78)
    at org.apache.spark.util.Utils$.tryOrStopSparkContext(Utils.scala:1245)
    at org.apache.spark.scheduler.LiveListenerBus$$anon$1.run(LiveListenerBus.scala:77)
17/07/06 10:51:22 INFO SparkUI: Stopped Spark web UI at http://105.145.28.172:4041
17/07/06 10:51:22 INFO StandaloneSchedulerBackend: Shutting down all executors
java.lang.RuntimeException: Nonzero exit code: 1
    at scala.sys.package$.error(package.scala:27)
[trace] Stack trace suppressed: run last compile:run for the full output.
[error] (compile:run) Nonzero exit code: 1
[error] Total time: 5 s, completed Jul 6, 2017 10:51:22 AM
17/07/06 10:51:22 INFO DiskBlockManager: Shutdown hook called
17/07/06 10:51:22 INFO ShutdownHookManager: Shutdown hook called
17/07/06 10:51:22 INFO ShutdownHookManager: Deleting directory /private/var/folders/4c/s3nt_0s96z57zfxc3dlyq3swjl4fq9/T/spark-4bc93888-b930-4621-9cc8-b44fc3b6bd9e
17/07/06 10:51:22 INFO ShutdownHookManager: Deleting directory /private/var/folders/4c/s3nt_0s96z57zfxc3dlyq3swjl4fq9/T/spark-4bc93888-b930-4621-9cc8-b44fc3b6bd9e/userFiles-c5140f8e-6edb-4c89-b113-02d406019feb


问:
Google Places API Web Service getUrl returning invalid URL
Google Places API Web Service For Javascript randomly started returning bad URLs when calling

```<code>photo.getUrl({maxWidth: 400, maxHeight: 400});
</code>```

Keep in mind my app is doing everything perfect, not caching etc. and everything else in the web service works. The weird part is the fact it returns a URL that is just plain invalid. I am using this service within an Ionic app.

Example Returned URL:
    https://lh3.googleusercontent.com/w400-h400-p/AF1QipPB7DYeNrzI7wCylJXOUwodGyGOS691HnZ5maFx=k

This is pretty much breaking my entire app, and I do not know any way to solve it. It started happening yesterday around 2:00 PM. The Service has worked flawlessly for about 2 months now.

答:
It was a bug on Google side reported in the public issue tracker:

https://issuetracker.google.com/issues/63298126

As of time of writing the bug is marked as Fixed, so you should be OK now.

Body:
Google Places API Web Service For Javascript randomly started returning bad URLs when calling

photo.getUrl({maxWidth: 400, maxHeight: 400});

Keep in mind my app is doing everything perfect, not caching etc. and everything else in the web service works. The weird part is the fact it returns a URL that is just plain invalid. I am using this service within an Ionic app.

Example Returned URL:
    https://lh3.googleusercontent.com/w400-h400-p/AF1QipPB7DYeNrzI7wCylJXOUwodGyGOS691HnZ5maFx=k

This is pretty much breaking my entire app, and I do not know any way to solve it. It started happening yesterday around 2:00 PM. The Service has worked flawlessly for about 2 months now.


问:
c strcmp source code
```<code>int strcmp(const char *s1, const char *s2)

{
  int ret = 0;

  while (!(ret = *(unsigned char *) s1 - *(unsigned char *) s2) && *s2) ++s1, ++s2;

  if (ret < 0)

    ret = -1;
  else if (ret > 0)

    ret = 1 ;

  return ret;
}
</code>```

I review the code from : http://www.jbox.dk/sanos/source/lib/string.c.html

I suppose that there're some problem.
If strlen(s2)>strlen(s1),then ++s1 may beyond the range. Unfortunately, then the function return error.

答:
s1 is implicitly guarded due to zero-termination. The zero-termination will lead to there being a difference between "*(unsigned char ) s1" and "(unsigned char *) s2", terminating the loop.

So no, the code looks correct to me.

ContentLicense: CC BY-SA 2.5

Title: c strcmp source code

Body:
int strcmp(const char *s1, const char *s2)

{
  int ret = 0;

  while (!(ret = *(unsigned char *) s1 - *(unsigned char *) s2) && *s2) ++s1, ++s2;

  if (ret < 0)

    ret = -1;
  else if (ret > 0)

    ret = 1 ;

  return ret;
}

I review the code from : http://www.jbox.dk/sanos/source/lib/string.c.html

I suppose that there're some problem.
If strlen(s2)>strlen(s1),then ++s1 may beyond the range. Unfortunately, then the function return error.


问:
Computing with a large data file
I have a very large (say a few thousand) list of partitions, something like:

```<code>[[9,0,0,0,0,0,0,0,0],
[8,1,0,0,0,0,0,0,0],
...,
[1,1,1,1,1,1,1,1,1]]
</code>```

What I want to do is apply to each of them a function (which outputs a small number of partitions), then put all the outputs in a list and remove duplicates.

I am able to do this, but the problem is that my computer gets very slow if I put the above list directly into the python file (esp. when scrolling). What is making it slow? If it is memory being used to load the whole list,

Is there a way to put the partitions in another file, and have the function just read the list term by term?

EDIT: I am adding some code. My code is probably very inefficient because I'm quite an amateur. So what I really have is a list of lists of partitions, that I want to add to:

```<code>listofparts3 = [[[3],[2,1],[1,1,1]],
[[6],[5,1],...,[1,1,1,1,1,1]],...]

def addtolist3(n):
    a=int(n/3)-2
    counter = 0
    added = []
    for i in range(len(listofparts3[a])):
        first = listofparts3[a][i]
        if len(first)<n:
            for i in range(n-len(first)):
                first.append(0)
        answer = lowering1(fock(first),-2)[0]
        for j in range(len(answer)):
            newelement = True
            for k in range(len(added)):
                if (answer[j]==added[k]).all():
                    newelement = False
                    break
            if newelement==True:
                added.append(answer[j])
        print(counter)
        counter = counter+1
    for i in range(len(added)):
        added[i]=partition(added[i]).tolist()
    return(added)
</code>```

fock, lowering1, partition are all functions in earlier code, they are pretty simple functions. The above function, say addtolist(24), takes all the partition of 21 that I have and returns the desired list of partitions of 24, which I can then append to the end of listofparts3.

答:
A few thousand partitions uses only a modest amount of memory, so that likely isn't the source of your problem.

One way to speed-up function application is to use map() for Python 3 or itertools.imap() from Python 2.

The fastest way to eliminate duplicates is to feed them into a Python set() object.

Title: Computing with a large data file

Body:
I have a very large (say a few thousand) list of partitions, something like:

[[9,0,0,0,0,0,0,0,0],
[8,1,0,0,0,0,0,0,0],
...,
[1,1,1,1,1,1,1,1,1]]

What I want to do is apply to each of them a function (which outputs a small number of partitions), then put all the outputs in a list and remove duplicates.

I am able to do this, but the problem is that my computer gets very slow if I put the above list directly into the python file (esp. when scrolling). What is making it slow? If it is memory being used to load the whole list,

Is there a way to put the partitions in another file, and have the function just read the list term by term?

EDIT: I am adding some code. My code is probably very inefficient because I'm quite an amateur. So what I really have is a list of lists of partitions, that I want to add to:

listofparts3 = [[[3],[2,1],[1,1,1]],
[[6],[5,1],...,[1,1,1,1,1,1]],...]

def addtolist3(n):
    a=int(n/3)-2
    counter = 0
    added = []
    for i in range(len(listofparts3[a])):
        first = listofparts3[a][i]
        if len(first)<n:
            for i in range(n-len(first)):
                first.append(0)
        answer = lowering1(fock(first),-2)[0]
        for j in range(len(answer)):
            newelement = True
            for k in range(len(added)):
                if (answer[j]==added[k]).all():
                    newelement = False
                    break
            if newelement==True:
                added.append(answer[j])
        print(counter)
        counter = counter+1
    for i in range(len(added)):
        added[i]=partition(added[i]).tolist()
    return(added)

fock, lowering1, partition are all functions in earlier code, they are pretty simple functions. The above function, say addtolist(24), takes all the partition of 21 that I have and returns the desired list of partitions of 24, which I can then append to the end of listofparts3.


问:
Quick Books Qbxml to create an invoice with No line items (empty transaction)
At the company where I work, we have the following technologies in Dev environment
- company's own C# web application called companyABCDevapplication
- installation of Quick Books Web Connector
- installation of Quick books Quickbooks Desktop 2017 Premier Trial Version

I've been tasked with creating an interfacing Web service that will be invoked by a Quick Books Web Connector Installation to communicate with our companyABCDevapplication

Here are the technologies being used for local development:

Intuit Quickbooks Desktop 2017 Premier Trial Version

Intuit QuickBooks Web Connector Version 2.2.0.71

Microsoft Visual Studio Enterprise 2015

Version 14.0.25431.01 Update 3

Microsoft .NET FrameworkVersion 4.6.01055

```<code><?xml version="1.0" encoding="utf-16"?>
<?qbxml version="13.0"?>
<QBXML>
    <QBXMLMsgsRq onError="stopOnError">
       <InvoiceAddRq requestID="0">
            <InvoiceAdd defMacro="TxnID:8465928136">
                <CustomerRef>
                    <FullName>la lakers</FullName>
        </CustomerRef>       <TemplateRef>
                   <FullName>Intuit Product Invoice</FullName>
        </TemplateRef>
      </InvoiceAdd>
    </InvoiceAddRq>
  </QBXMLMsgsRq>
</QBXML>
</code>```

If you look at the QBXML code above, you will notice that we want to just create an Invoice in quickbooks but withOut containing  items list, but it gives us the following error when our application sends it over to Quickbooks via our Web Service and the Quickbooks Web connector:

```<code><?xml version=\"1.0\" ?>
<QBXML>
       <QBXMLMsgsRs>
                  <InvoiceAddRs requestID="0" statusCode="3180" statusSeverity="Error" statusMessage="There was an error when saving a Invoice.  QuickBooks error message: The transaction is empty." />
        </QBXMLMsgsRs>
 </QBXML>
</code>```

Is that possible to create an invoice withOut any invoice line items using the QuickBooks Web Connector Version 2.2.0.71 and Quickbooks Desktop 2017 Premier Trial Version?  If yes, what should the xml look like?  could someone please provide a sample?

答:
Just like when using QuickBooks manually, you need to enter something in the lines in order to save the invoice. However, you don't need to have an item or dollar amount on the invoice, you can simply add information to the Description column. You can't have just a space, though so you may want to have a period or underscore as the description: The XML would look like:

```<code><?xml version="1.0" encoding="utf-16"?>
<?qbxml version="13.0"?>
<QBXML>
    <QBXMLMsgsRq onError="stopOnError">
       <InvoiceAddRq requestID="0">
            <InvoiceAdd defMacro="TxnID:8465928136">
                <CustomerRef>
                    <FullName>la lakers</FullName>
                </CustomerRef>
                <TemplateRef>
                    <FullName>Intuit Product Invoice</FullName>
               </TemplateRef>
            <InvoiceLineAdd>
                   <Desc>.</Desc>
            </InvoiceLineAdd>
        </InvoiceLineAdd>
  </InvoiceAdd>
</InvoiceAddRq>
</code>```

'

Body:
At the company where I work, we have the following technologies in Dev environment
- company's own C# web application called companyABCDevapplication
- installation of Quick Books Web Connector
- installation of Quick books Quickbooks Desktop 2017 Premier Trial Version

I've been tasked with creating an interfacing Web service that will be invoked by a Quick Books Web Connector Installation to communicate with our companyABCDevapplication

Here are the technologies being used for local development:

Intuit Quickbooks Desktop 2017 Premier Trial Version

Intuit QuickBooks Web Connector Version 2.2.0.71

Microsoft Visual Studio Enterprise 2015

Version 14.0.25431.01 Update 3

Microsoft .NET FrameworkVersion 4.6.01055

<?xml version="1.0" encoding="utf-16"?>
<?qbxml version="13.0"?>
<QBXML>
    <QBXMLMsgsRq onError="stopOnError">
       <InvoiceAddRq requestID="0">
            <InvoiceAdd defMacro="TxnID:8465928136">
                <CustomerRef>
                    <FullName>la lakers</FullName>
        </CustomerRef>       <TemplateRef>
                   <FullName>Intuit Product Invoice</FullName>
        </TemplateRef>
      </InvoiceAdd>
    </InvoiceAddRq>
  </QBXMLMsgsRq>
</QBXML>

If you look at the QBXML code above, you will notice that we want to just create an Invoice in quickbooks but withOut containing  items list, but it gives us the following error when our application sends it over to Quickbooks via our Web Service and the Quickbooks Web connector:

<?xml version=\"1.0\" ?>
<QBXML>
       <QBXMLMsgsRs>
                  <InvoiceAddRs requestID="0" statusCode="3180" statusSeverity="Error" statusMessage="There was an error when saving a Invoice.  QuickBooks error message: The transaction is empty." />
        </QBXMLMsgsRs>
 </QBXML>

Is that possible to create an invoice withOut any invoice line items using the QuickBooks Web Connector Version 2.2.0.71 and Quickbooks Desktop 2017 Premier Trial Version?  If yes, what should the xml look like?  could someone please provide a sample?

Body:
Just like when using QuickBooks manually, you need to enter something in the lines in order to save the invoice. However, you don't need to have an item or dollar amount on the invoice, you can simply add information to the Description column. You can't have just a space, though so you may want to have a period or underscore as the description: The XML would look like:

<?xml version="1.0" encoding="utf-16"?>
<?qbxml version="13.0"?>
<QBXML>
    <QBXMLMsgsRq onError="stopOnError">
       <InvoiceAddRq requestID="0">
            <InvoiceAdd defMacro="TxnID:8465928136">
                <CustomerRef>
                    <FullName>la lakers</FullName>
                </CustomerRef>
                <TemplateRef>
                    <FullName>Intuit Product Invoice</FullName>
               </TemplateRef>
            <InvoiceLineAdd>
                   <Desc>.</Desc>
            </InvoiceLineAdd>
        </InvoiceLineAdd>
  </InvoiceAdd>
</InvoiceAddRq>

'


问:
How to keep lookup tables initialized for prediction (and not just training)?
I create a lookup table from tf.contrib.lookup, using the training data (as input). Then, I pass every input through that lookup table, before passing it through my model.

This works for training, but when it comes to online prediction from this same model, it raises the error:

Table not initialized

I'm using SavedModel to save the model. I run the prediction from this saved model.

How can I initialize this table so that it stays initialized? Or is there a better way to save the model so that the table is always initialized?

答:
I think you would be better off using tf.tables_initializer() as the legacy_init_op.

tf.saved_model.main_op.main_op() also adds local and global initialization ops in addition to table initialization.
when you load the saved model and it runs the legacy_init_op, it would reset your variables, which is not what you want.

ContentLicense: CC BY-SA 4.0


问:
ERR_TOO_MANY_REDIRECTS from htacces
I change the .htaccess file and I added this:

```<code>RewriteCond %{HTTPS} !on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</code>```

but when I try to access the page, it gives me this error:

```<code>ERR_TOO_MANY_REDIRECTS
</code>```

I cleared all my cache and cookies, I tried it with another browser, and it didn't work.

Please help me

答:
It appears that some versions of the apache http servers ssl module do not set the %{HTTPS} variable, quite in contrast to what the documentation claims. Have a try using this alternative:

```<code>RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,QSA]
</code>```

And a general hint: you should always prefer to place such rules inside the http servers (virtual) host configuration instead of using dynamic configuration files (.htaccess style files). Those files are notoriously error prone, hard to debug and they really slow down the server. They are only provided as a last option for situations where you do not have control over the host configuration (read: really cheap hosting service providers) or if you have an application that relies on writing its own rewrite rules (which is an obvious security nightmare).

Title: ERR_TOO_MANY_REDIRECTS from htacces

Body:
I change the .htaccess file and I added this:

RewriteCond %{HTTPS} !on
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

but when I try to access the page, it gives me this error:

ERR_TOO_MANY_REDIRECTS

I cleared all my cache and cookies, I tried it with another browser, and it didn't work.

Please help me

Body:
It appears that some versions of the apache http servers ssl module do not set the %{HTTPS} variable, quite in contrast to what the documentation claims. Have a try using this alternative:

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,QSA]

And a general hint: you should always prefer to place such rules inside the http servers (virtual) host configuration instead of using dynamic configuration files (.htaccess style files). Those files are notoriously error prone, hard to debug and they really slow down the server. They are only provided as a last option for situations where you do not have control over the host configuration (read: really cheap hosting service providers) or if you have an application that relies on writing its own rewrite rules (which is an obvious security nightmare).


问:
Where to get/How to build Windows binary of mod_wsgi with python 3.0 support?
I wanted to experiment a little with python 3.0 at home. I got python 3.0 working, I've played around with some scripts, and I thought it would be fun to try to make a small web-project with it.

As I was googling, it turned out, that mod_python, for some reasons, will not be able to support python 3.0.

The only other alternative I've found is mod_wsgi.

On the main page of the mod_wsgi project, it says, that if you want to play with python 3.0, you have to get the latest version from subversion repository. I was wondering, if there is somewhere a pre-built windows binaries available?

If there are no such binaries, then I'd be thankful for any resources about building it with VC++ 2008. Or maybe even general resources about building apache and it's modules with VC++ 2008. Thanks.

Oh and, I'm using the latest Apache 2.2 release.

EDIT: Will it be a problem, if I'll be using the official apache build with my own build of a mod_wsgi (I used depends.exe on apache, and seems that it's not built with VC++ 2008)?

答:
I would like to find either 2.6 (preferable) or 3.0 (okay) Windows binaries myself, and have looked into this a bit.

There are Windows build steps for mod_wsgi buried deep in the Google Group for it. I think they're out of date; only one person appears to have ever done it and told the world how well it worked out. There may well be problems compiling that require a patch.

I do not think you will need to build your own Apache, or if it matters that the VC++ version is different (though I don't have a ton of evidence for this belief). VC++ version is very important for Python module builds since they rely heavily on the internals of the compiler data structures. I think the Apache module interface is more structured.

You'll probably want to post to the mod_wsgi group if you try this and hit problems, or if you successfully build the modules, please post them as some of us would very much like them but are too busy to get to doing it ourselves :(

OwnerDisplayName: Paulius Maruška

LastEditorDisplayName: Paulius Maruška

OwnerDisplayName: kquinn


问:
HQl equivalent of sql query
```<code>String SQL_QUERY = "SELECT count(*) FROM (SELECT * FROM Url as U where U.pageType=" + 1 + " group  by U.pageId having count(U.pageId) = 1)";
query = session.createQuery(SQL_QUERY);
</code>```

I am getting an error

org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 23 [ SELECT count() FROM (SELECT * FROM Url as U where U.pageType = 2 group by U.pageId having count(U.pageId) = 1)]

答:
You can use group by and having and subqueries in hql as well.

Some examples:

link text

Title: HQl equivalent of sql query

Body:
String SQL_QUERY = "SELECT count(*) FROM (SELECT * FROM Url as U where U.pageType=" + 1 + " group  by U.pageId having count(U.pageId) = 1)";
query = session.createQuery(SQL_QUERY);

I am getting an error

org.hibernate.hql.ast.QuerySyntaxException: unexpected token: ( near line 1, column 23 [ SELECT count() FROM (SELECT * FROM Url as U where U.pageType = 2 group by U.pageId having count(U.pageId) = 1)]


问:
Fastest way to bcrypt 3 million records
We've inherited a system which has 3 million user logins, in a CSV broken into chunks of 500k, with unhashed passwords.

The client against advice, has decided he wants to keep the same passwords but just hash them for the new system, rather then forcing users to set new passwords, so please no replies saying "just dont do it".

We're currently using PHP to process the file to normalise the data and bcrypt the existing strings.

However running a test on 200 records, the moment we add bcrypt into the loop the process takes around 7 seconds longer.

Over time this will obviously stack up considerably.

Does anybody have other suggestions how we can convert the strings to bcrypt with more speed? I was thinking maybe there was a command line tool which we could pass the CSV into and it "knew column 4" was the password, and hash it, then save back to the file or something.

Any suggestions at this point are welcome.

It would be worth saying we need to repeat this process on the launch day so it needs to be appropriate to do with minimal downtime?

Many thanks

Update

For those who are interested, on a 2012 MBP with 2.6Ghz i7 and 8GB ram it took 9 hours to complete the initial round running 6 instances of the script each instance processing 500k users.

答: Give the CSV a new field PasswordHash. At the launch day it is empty for all clients. For a transition period the authentication code checks the user credentials against the plain passwords and against the hashed ones. During the following hours/days/weeks a background process hashes all passwords and delete the plain ones.

Title: Fastest way to bcrypt 3 million records


问:
Images dissappear when height/weidth switched from pixels to percentage?
So I have 3 circular images on my page. For some reason, when I change their height/width from px to %, the images just dissappear. They work perfectly at 200px height/width, and at 50px.. but I want them at 20%.

Code:

<!DOCTYPE html>

  <link rel="stylesheet" href="styles.css">
   <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">

Welcome to RyanTeaches

Activities

Activities

```

Site to see:
http://ryanteaches.com/newindex.html

Any ideas why they dissappear?

Cheers.

答:
The reason the images go away, you DIV's CLASS="wrap" have no content IE( no Width and/or height) for the image to be displayed in .

In short: 25% of an empty DIV is nothing

Just so you can see... for example

```<code>.wrap {
width: 100px;
height: 100px;
}
</code>```

Body:
So I have 3 circular images on my page. For some reason, when I change their height/width from px to %, the images just dissappear. They work perfectly at 200px height/width, and at 50px.. but I want them at 20%.

Code:

<!DOCTYPE html>

  <link rel="stylesheet" href="styles.css">
   <link href="https://fonts.googleapis.com/css?family=Montserrat" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">

Welcome to RyanTeaches

Activities

Activities

Site to see:
http://ryanteaches.com/newindex.html

Any ideas why they dissappear?

Cheers.

Body:
The reason the images go away, you DIV's CLASS="wrap" have no content IE( no Width and/or height) for the image to be displayed in .

In short: 25% of an empty DIV is nothing

Just so you can see... for example

.wrap {
width: 100px;
height: 100px;
}


问:
How to search a list of Objects that are displayed in a RecyclerView?
I am currently trying to implement a SearchView, but the displayed search results change only for the first Search, everything else I enter into SearchView is ignored.

Here is my Code for Searching in my MainActivity.java:

```<code>testList = Arrays.asList(new TestItem("aw"), new TestItem("aa"), new TestItem("w"));

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.test_menu, menu);

    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(this);
    return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onQueryTextChange(String newText) {
    List<TestItem> result = new ArrayList<>();
    for(TestItem t: testList) {
        if(t.getName().contains(newText) {
            result.add(t);
        }
    }
    adapter.changeList(result);
    return true;
}
</code>```

adapter.changeList:

```<code>public void changeList(List<TestItem> newList) {
    this.list = new ArrayList<>(newList);
}
</code>```

onQueryTextChange gets called after each text change, but the search result is shown only once. When entering a and Enter the RecyclerView shows aw and aa (is it normal to have to press Enter for onQueryTextChange to start?), but when I then enter aa the displayed items stay the same.

答:
I think your implementation is not correct. You don't need to press the enter for search result. For implementation you can keep a intact copy of your array list.Then make another temporary list form that list when query text is changed. So when you are filtering, you are searching the actual list not the filtered list.

1.pass search keyword to the list adapter

```<code>public boolean onQueryTextChange(String newText) {

    adapter.getFilter().filter(newText);
    return true;
}
</code>```

2. In adapter implement Filterable and override method

```<code>@Override
public Filter getFilter() {
    if (frameFilter == null) {
        frameFilter = new FrameFilter();
    }

    return frameFilter;
}
</code>```

3. Filtering class can be something like this: 'categoryMain' is my intact list and 'categoryTemp' is my temporary list

```<code>private class FrameFilter extends Filter {

    @Override
    protected FilterResults performFiltering(CharSequence constraint) {

        FilterResults filterResults = new FilterResults();
        if (constraint != null && constraint.length() > 0) {
            ArrayList<Category> tempList = new ArrayList<>();

            // search content in friend list
            Log.i("key",constraint.toString());
            for (Category category : categoriesMain) {
                if (category.getCategory_name().toLowerCase().contains(constraint.toString().toLowerCase())) {
                    tempList.add(category);
                }
            }
            filterResults.count = tempList.size();
            filterResults.values = tempList;
        } else {

            filterResults.count = categoriesMain.size();
            filterResults.values = categoriesMain.clone();
        }
        return filterResults;
    }

    /**
     * Notify about filtered list to ui
     *
     * @param constraint text
     * @param results    filtered result
     */
    @SuppressWarnings("unchecked")
    @Override
    protected void publishResults(CharSequence constraint, FilterResults results) {

        categoriesTemp = (ArrayList<Category>) results.values;
        notifyDataSetChanged();
    }
}
</code>```

Body:
I am currently trying to implement a SearchView, but the displayed search results change only for the first Search, everything else I enter into SearchView is ignored.

Here is my Code for Searching in my MainActivity.java:

testList = Arrays.asList(new TestItem("aw"), new TestItem("aa"), new TestItem("w"));

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.test_menu, menu);

    SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
    searchView.setOnQueryTextListener(this);
    return super.onCreateOptionsMenu(menu);
}

@Override
public boolean onQueryTextChange(String newText) {
    List<TestItem> result = new ArrayList<>();
    for(TestItem t: testList) {
        if(t.getName().contains(newText) {
            result.add(t);
        }
    }
    adapter.changeList(result);
    return true;
}

adapter.changeList:

public void changeList(List<TestItem> newList) {
    this.list = new ArrayList<>(newList);
}

onQueryTextChange gets called after each text change, but the search result is shown only once. When entering a and Enter the RecyclerView shows aw and aa (is it normal to have to press Enter for onQueryTextChange to start?), but when I then enter aa the displayed items stay the same.

Body:
I think your implementation is not correct. You don't need to press the enter for search result. For implementation you can keep a intact copy of your array list.Then make another temporary list form that list when query text is changed. So when you are filtering, you are searching the actual list not the filtered list.

1.pass search keyword to the list adapter

public boolean onQueryTextChange(String newText) {

    adapter.getFilter().filter(newText);
    return true;
}

2. In adapter implement Filterable and override method

@Override
public Filter getFilter() {
    if (frameFilter == null) {
        frameFilter = new FrameFilter();
    }

    return frameFilter;
}

3. Filtering class can be something like this: 'categoryMain' is my intact list and 'categoryTemp' is my temporary list

private class FrameFilter extends Filter {

    @Override
    protected FilterResults performFiltering(CharSequence constraint) {

        FilterResults filterResults = new FilterResults();
        if (constraint != null && constraint.length() > 0) {
            ArrayList<Category> tempList = new ArrayList<>();

            // search content in friend list
            Log.i("key",constraint.toString());
            for (Category category : categoriesMain) {
                if (category.getCategory_name().toLowerCase().contains(constraint.toString().toLowerCase())) {
                    tempList.add(category);
                }
            }
            filterResults.count = tempList.size();
            filterResults.values = tempList;
        } else {

            filterResults.count = categoriesMain.size();
            filterResults.values = categoriesMain.clone();
        }
        return filterResults;
    }

    /**
     * Notify about filtered list to ui
     *
     * @param constraint text
     * @param results    filtered result
     */
    @SuppressWarnings("unchecked")
    @Override
    protected void publishResults(CharSequence constraint, FilterResults results) {

        categoriesTemp = (ArrayList<Category>) results.values;
        notifyDataSetChanged();
    }
}


问:
PHP - DEFINE array with string on end
I'm creating an array for user levels and want to make them secure by adding a secret 10 digit string to the end of each of the user levels in the array UserLevels. I'm using the code below but I can't seem to add a string to an array when using the PHP term define.

My code is below:

```<code>//Change the 10 digits of the $secret definition to a randomised string
$secret = '0000000000';

define('UserLevels', array(
    'Owner'.$secret,
    'Admin'.$secret,
    'Staff'.$secret
));
</code>```

I was going to make it hash / check the user levels to make them more secure then use something to check the hash later in each page.

答:
Check your PHP version.

The syntax you're using for defining an array constant should only work in PHP 7.

```<code>// Works as of PHP 5.6.0
const ANIMALS = array('dog', 'cat', 'bird');
echo ANIMALS[1]; // outputs "cat"
</code>```

http://php.net/manual/en/language.constants.syntax.php

You can serialize the array to store the constant as a string then use unserialize to return it to an array when you need to access the values.

```<code><?php

//Change the 10 digits of the $secret definition to a randomised string
$secret = '0000000000';

$user_levels = array(
    'Owner'.$secret,
    'Admin'.$secret,
    'Staff'.$secret
);

define('UserLevels', serialize($user_levels));
var_dump(UserLevels);
var_dump(unserialize(UserLevels));
</code>```

https://eval.in/829457

Title: PHP - DEFINE array with string on end

Body:
I'm creating an array for user levels and want to make them secure by adding a secret 10 digit string to the end of each of the user levels in the array UserLevels. I'm using the code below but I can't seem to add a string to an array when using the PHP term define.

My code is below:

//Change the 10 digits of the $secret definition to a randomised string
$secret = '0000000000';

define('UserLevels', array(
    'Owner'.$secret,
    'Admin'.$secret,
    'Staff'.$secret
));

I was going to make it hash / check the user levels to make them more secure then use something to check the hash later in each page.

Body:
Check your PHP version.

The syntax you're using for defining an array constant should only work in PHP 7.

// Works as of PHP 5.6.0
const ANIMALS = array('dog', 'cat', 'bird');
echo ANIMALS[1]; // outputs "cat"

http://php.net/manual/en/language.constants.syntax.php

You can serialize the array to store the constant as a string then use unserialize to return it to an array when you need to access the values.

<?php

//Change the 10 digits of the $secret definition to a randomised string
$secret = '0000000000';

$user_levels = array(
    'Owner'.$secret,
    'Admin'.$secret,
    'Staff'.$secret
);

define('UserLevels', serialize($user_levels));
var_dump(UserLevels);
var_dump(unserialize(UserLevels));

https://eval.in/829457


问:
How to place a button next to a text?
Hey guys I need to place these two buttons next to a name. How can I do that? They always appear below the word.

<ion-list>
    <ion-item *ngFor="let service of services">

{{service.name}}

        <button ion-fab mini color="danger"><ion-icon name="trash"></ion-icon></button>
        <button ion-fab mini color="secondary"><ion-icon name="create"></ion-icon></button>
    </ion-item>
</ion-list>```

答:
The solution I found was this one:

```<code><ion-list>
  <ion-item *ngFor="let service of services | orderBy: 'name'">
    <ion-label>{{service.name}}</ion-label>
    <button (click)="onActive(service.detalhe.id)" *ngIf="service.isActive" ion-button outline item-right>Desativar</button>
    <button (click)="onActive(service.detalhe.id)" *ngIf="!service.isActive" ion-button outline item-right>Ativar</button>
    <button (click)="openUpdatePage(service)" ion-fab mini color="secondary" item-right><ion-icon name="create"></ion-icon></button>
    <button (click)="deleteService(service)" ion-fab mini color="danger" item-right><ion-icon name="trash"></ion-icon></button>
  </ion-item>
</code>```

Thank you all for the answers!

Title: How to place a button next to a text?

Body:
The solution I found was this one:

<ion-list>
  <ion-item *ngFor="let service of services | orderBy: 'name'">
    <ion-label>{{service.name}}</ion-label>
    <button (click)="onActive(service.detalhe.id)" *ngIf="service.isActive" ion-button outline item-right>Desativar</button>
    <button (click)="onActive(service.detalhe.id)" *ngIf="!service.isActive" ion-button outline item-right>Ativar</button>
    <button (click)="openUpdatePage(service)" ion-fab mini color="secondary" item-right><ion-icon name="create"></ion-icon></button>
    <button (click)="deleteService(service)" ion-fab mini color="danger" item-right><ion-icon name="trash"></ion-icon></button>
  </ion-item>

Thank you all for the answers!


问:
How to access the magic _destroy attribute used in accepts_nested_attributes_for?
On a form submit that fails because of a validation error, I need to hide form elements that have been marked for destroy.

I'm using accepts_nested_attributes_for, which adds a _destroy field to the form. How do I access the value of this field after a form submit?

```<code>>>  f2.hidden_field :_destroy
=> "<input type=\"hidden\" value=\"true\" ...
>>  f2.object[:_destroy]
=> nil
</code>```

Id and other attributes work as expected.

```<code>>>  f2.object[:id]
=> 10
</code>```

答:
you can check with Object.marked_for_destruction? if it's true then the record marked,

for your code

```<code>if f2.marked_for_destruction?
  # your code here
end
</code>```

Body:
On a form submit that fails because of a validation error, I need to hide form elements that have been marked for destroy.

I'm using accepts_nested_attributes_for, which adds a _destroy field to the form. How do I access the value of this field after a form submit?

>>  f2.hidden_field :_destroy
=> "<input type=\"hidden\" value=\"true\" ...
>>  f2.object[:_destroy]
=> nil

Id and other attributes work as expected.

>>  f2.object[:id]
=> 10

Body:
you can check with Object.marked_for_destruction? if it's true then the record marked,

for your code

if f2.marked_for_destruction?
  # your code here
end


问:
Why do we do a POST to confirm deletion in asp.net MVC?
The following is a note from Professional ASP.NET MVC 2 by Scott Hanselman ++

You might ask — why did we go through
  the effort of creating a <form> within
  our Delete Confi rmation screen? Why
  not just use a standard hyperlink to
  link to an action method that does the
  actual delete operation? The reason is
  because we want to be careful to guard
  against Web-crawlers and search
  engines discovering our URLs and
  inadvertently causing data to be
  deleted when they follow the links.
  HTTP-GET-based URLs are considered
  safe for them to access/crawl, and
  they are supposed to not follow
  HTTP-POST ones. A good rule is to make
  sure that you always put destructive
  or data-modifying operations behind
  HTTP-POST requests.

If web-crawlers and search engine have no access to the page containing deletion button, is it safe to use a standard hyperlink to link to an action method doing the actual delete operation?

答: I would add what even if admin page is protected by password, delete links could be "clicked" by some locally installed web accelerator software. So using POST method is safer.</p>


问:
MS ACCESS: Print a report based on a recordset instead of record_ID
Desperate and weekend in sight, I cannot stop until I fix this. Please bear with me...

I am on a subform that fetches some data from excel files. (Functions like a search form)

With the submit button, I put the search results into the table with a recordset. (code below)

ALL THIS WORKS FINE! Now, I want to print a report from the same record I just added with the code below.
How can I do this? As I'm currently on a form that has no record_ID (because it's for searching only)

How do I print out the report, with the current "item_ID" (the one I just added)???

Private Sub Submit_Click()
Dim db As Database
Dim rec As Recordset
Set db = CurrentDb
Set rec = db.OpenRecordset("Select * from inboundreturns_items")
rec.AddNew
rec("returnID") = Forms!inboundreturns.returnID.Value
rec("ireq") = Me.ireq
rec("item") = Me.Item
rec("tasknumber") = Me.tasknumber
rec("country") = Me.Country
rec("engineername") = Me.engineer
rec("connote") = Me.connote
rec("status") = Me.Status
rec.Update
Set rec = Nothing
Set db = Nothing
End Sub

(FYI: The report is based on the table inboundreturns_items)

答:
Just did an experiment and this seems to work. After the rec.Update, try:

rec.MoveLast
DoCmd.OpenReport "reportname", , , "ItemID=" & rec!ItemID