问:
How to change site title on scroll
I want to change the site title's h1(.site-h1) to another text when down scrolling with jquery. For example, "my site" changes "welcome" when scrolling.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

my title

   MENU

          <button type="button" name="button">CONTACTME</button>

```

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.navbar {
  background-color: #F4F7F6;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
}

.navbar .site-h1 h1 {
  text-align: center;
  font-family: 'Oleo Script', cursive;
  color: #202221;
  font-size: 2rem;
  margin-top: 1rem;
}

.navbar .menu-title {
  cursor: pointer;
}

.navbar .menu-title h2 {
  margin-top: -65px ;
  padding: .7rem 1.2rem;
  font-family: 'Roboto Slab', serif;
  font-size: .8rem;
  font-weight: lighter;
  transition: 1s;
}

.navbar .menu-title h2:hover {
  color: #A6ABAB;
}

.navbar .contactme {
  text-align: right;
  margin-top: -50px;
  padding-right: 1rem;
  font-family: 'Roboto Slab', serif;
  padding-bottom: 1rem;
}

.navbar .contactme button {
  background-color: #DF3E7B;
  color: #F4F7F6;
  border: none;
  border-radius: 1rem;
  padding: .7rem;
  font-weight: bold;
  font-size: .8rem;
  cursor: pointer;
}

.navbar .contactme button:hover {
  background-color: #dd85a5;
}</code>```

答:
By when scrolling, I assume that you mean on all the document. For this we use jQuery scroll method.
But you can notice that in order to optimize it, I'm using jQuery One here to  prevent the script from firing the event many times at every tiny scroll change.

$(window).one('scroll', function() {
    $('.site-h1 h1').text('Welcome! Happy Scrolling :)');
    console.log('scroll detected!');
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.navbar {
  background-color: #F4F7F6;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
}

.navbar .site-h1 h1 {
  text-align: center;
  font-family: 'Oleo Script', cursive;
  color: #202221;
  font-size: 2rem;
  margin-top: 1rem;
}

.navbar .menu-title {
  cursor: pointer;
}

.navbar .menu-title h2 {
  margin-top: -65px ;
  padding: .7rem 1.2rem;
  font-family: 'Roboto Slab', serif;
  font-size: .8rem;
  font-weight: lighter;
  transition: 1s;
}

.navbar .menu-title h2:hover {
  color: #A6ABAB;
}

.navbar .contactme {
  text-align: right;
  margin-top: -50px;
  padding-right: 1rem;
  font-family: 'Roboto Slab', serif;
  padding-bottom: 1rem;
}

.navbar .contactme button {
  background-color: #DF3E7B;
  color: #F4F7F6;
  border: none;
  border-radius: 1rem;
  padding: .7rem;
  font-weight: bold;
  font-size: .8rem;
  cursor: pointer;
}

.navbar .contactme button:hover {
  background-color: #dd85a5;
}</code>```

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha256-L/W5Wfqfa0sdBNIKN9cG6QA5F2qx4qICmU2VgLruv9Y=" crossorigin="anonymous" />

my title

   MENU

          <button type="button" name="button">CONTACTME</button>

Lorem

Ipsum

Lorem

Ipsum

Lorem

Ipsum

Lorem

Ipsum

     Some Text

```

Title: How to change site title on scroll

Body:
I want to change the site title's h1(.site-h1) to another text when down scrolling with jquery. For example, "my site" changes "welcome" when scrolling.

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

my title

   MENU

          <button type="button" name="button">CONTACTME</button>

.navbar {
  background-color: #F4F7F6;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
}

.navbar .site-h1 h1 {
  text-align: center;
  font-family: 'Oleo Script', cursive;
  color: #202221;
  font-size: 2rem;
  margin-top: 1rem;
}

.navbar .menu-title {
  cursor: pointer;
}

.navbar .menu-title h2 {
  margin-top: -65px ;
  padding: .7rem 1.2rem;
  font-family: 'Roboto Slab', serif;
  font-size: .8rem;
  font-weight: lighter;
  transition: 1s;
}

.navbar .menu-title h2:hover {
  color: #A6ABAB;
}

.navbar .contactme {
  text-align: right;
  margin-top: -50px;
  padding-right: 1rem;
  font-family: 'Roboto Slab', serif;
  padding-bottom: 1rem;
}

.navbar .contactme button {
  background-color: #DF3E7B;
  color: #F4F7F6;
  border: none;
  border-radius: 1rem;
  padding: .7rem;
  font-weight: bold;
  font-size: .8rem;
  cursor: pointer;
}

.navbar .contactme button:hover {
  background-color: #dd85a5;
}

Body:
By when scrolling, I assume that you mean on all the document. For this we use jQuery scroll method.
But you can notice that in order to optimize it, I'm using jQuery One here to  prevent the script from firing the event many times at every tiny scroll change.

$(window).one('scroll', function() {
    $('.site-h1 h1').text('Welcome! Happy Scrolling :)');
    console.log('scroll detected!');
});

.navbar {
  background-color: #F4F7F6;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
}

.navbar .site-h1 h1 {
  text-align: center;
  font-family: 'Oleo Script', cursive;
  color: #202221;
  font-size: 2rem;
  margin-top: 1rem;
}

.navbar .menu-title {
  cursor: pointer;
}

.navbar .menu-title h2 {
  margin-top: -65px ;
  padding: .7rem 1.2rem;
  font-family: 'Roboto Slab', serif;
  font-size: .8rem;
  font-weight: lighter;
  transition: 1s;
}

.navbar .menu-title h2:hover {
  color: #A6ABAB;
}

.navbar .contactme {
  text-align: right;
  margin-top: -50px;
  padding-right: 1rem;
  font-family: 'Roboto Slab', serif;
  padding-bottom: 1rem;
}

.navbar .contactme button {
  background-color: #DF3E7B;
  color: #F4F7F6;
  border: none;
  border-radius: 1rem;
  padding: .7rem;
  font-weight: bold;
  font-size: .8rem;
  cursor: pointer;
}

.navbar .contactme button:hover {
  background-color: #dd85a5;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha256-L/W5Wfqfa0sdBNIKN9cG6QA5F2qx4qICmU2VgLruv9Y=" crossorigin="anonymous" />
<nav class="navbar">
      <div class="navbar-container">
        <div class="site-h1">
          <h1>my title</h1>
        </div>
        <div class="menu-bar">
          <div class="menu-title">
            <h2><i class="fas fa-bars"></i>&nbsp;&nbsp;&nbsp;MENU</h2>
          </div>
        </div>
        <div class="contactme">
          <button type="button" name="button">CONTACTME</button>
        </div>
      </div>
    </nav>
    <div class="somespace">
    <p>Lorem</p>
    <p>Ipsum</p>
    <p>Lorem</p>
    <p>Ipsum</p>
    <p>Lorem</p>
    <p>Ipsum</p>
        <p>Lorem</p>
    <p>Ipsum</p>
    </div>
    <div class="bottom">
     Some Text
    </div>


来源: stackexchange

问:
Calculate elapsed time in milliseconds using Go
I'm using the following code (Go version 1.12) to log elapsed time:

```<code>package time

func Elapsed() func() {
    start := time.Now()
    return func() {
        log.Debugf("Call took %v", time.Since(start))
    }
}
</code>```

This normally works fine for ms:

"elapsed":"945.714448ms"

However, it changes from ms to s if it's above 1 second:

"elapsed":"3.577901569s"

How do I force it to always log in milliseconds?

答:
You can use Milliseconds() on the Duration that is returned from Since():

```<code>log.Debugf("Call took %vms", time.Since(start).Milliseconds())
</code>```

Note that this does not add the unit (in case you need it).

ContentLicense: CC BY-SA 4.0

Body:
I'm using the following code (Go version 1.12) to log elapsed time:

package time

func Elapsed() func() {
    start := time.Now()
    return func() {
        log.Debugf("Call took %v", time.Since(start))
    }
}

This normally works fine for ms:

"elapsed":"945.714448ms"

However, it changes from ms to s if it's above 1 second:

"elapsed":"3.577901569s"

How do I force it to always log in milliseconds?

Body:
You can use Milliseconds() on the Duration that is returned from Since():

log.Debugf("Call took %vms", time.Since(start).Milliseconds())

Note that this does not add the unit (in case you need it).


问:
Tensorflow Training accuracy much higher than test accuracy
I am consistently getting around 60% accuracy for the training data but when I try and predict the outcome with my test data the model is about 50% accurate (which is to be expected if it were random).

```<code>def train_model(training_data, training_differential, test_data,
test_differential):
    num_nodes = 180

    model = keras.Sequential([
        keras.layers.Flatten(input_shape=(12, 22)),
        keras.layers.Dense(num_nodes, activation="relu"),
        keras.layers.Dense(2, activation="softmax")
    ])

model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"])

model.fit(training_data, training_differential, epochs=20)

predictions = model.predict(test_data)

return predictions
</code>```

Not sure if I'm overfitting the data or if I'm using an incorrect model. Any help would be much appreciated!

答:
This could be a lot things, what kind of data is going in and what are your target types? Are they classes like [0,1] or integers [6,2]. If they are classes then you probably don't need sparse categorical crossentropy just categorical crossentropy. If this is a binary classification problem e.g. cat or dog but never both then your final layer should be of size 1 where the target is a single vector where each value is either 1 or 0.

Also how big is your training set? If it's too small overfitting could well be a problem.

One place to start here regardless might be to reduce the number of nodes and thus the capacity of the network itself. You could also introduce some form regularization to prevent the network from overfitting on the training set.

Body:
I am consistently getting around 60% accuracy for the training data but when I try and predict the outcome with my test data the model is about 50% accurate (which is to be expected if it were random).

def train_model(training_data, training_differential, test_data,
test_differential):
    num_nodes = 180

    model = keras.Sequential([
        keras.layers.Flatten(input_shape=(12, 22)),
        keras.layers.Dense(num_nodes, activation="relu"),
        keras.layers.Dense(2, activation="softmax")
    ])

model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics=["accuracy"])

model.fit(training_data, training_differential, epochs=20)

predictions = model.predict(test_data)

return predictions

Not sure if I'm overfitting the data or if I'm using an incorrect model. Any help would be much appreciated!


问:
API Call for Cloud Security Command Center
I am using list_findings() API for listing the security issues identified in Cloud Security command center. I want to list the findings every 5 minutes.

```<code> c = (datetime.utcnow() - timedelta(minutes =5)).replace(tzinfo=pytz.UTC, microsecond =0)
 project_filter = (
     "state = \"ACTIVE\" AND create_time > \"2020-02-19T15:20:10-00:00\""
 )
 finding_result_iterator = client.list_findings(source_name, filter_ = project_filter)
</code>```

How can I pass the value of c in the project_filter? I don't want to hard code the value of create_time. It should automatically take the time from the variable c in every run of the script. I tried different ways to pass the value to create_time but its not working. Could someone please help. Here is the link for the doc provided by google
    https://cloud.google.com/security-command-center/docs/how-to-api-list-findings

I am trying to use something like this but its giving error

```<code>project_filter = (
    "state = \"ACTIVE\" AND create_time >\'c\'"
)
</code>```

Error -

```<code>google.api_core.exceptions.InvalidArgument: 400 Invalid Filter. Filter must be non-null and filter upon a field in the request. Example: "event_time = 123 OR event_time >= 123 OR event_time <= 123"
</code>```

答:
Actually project_filter is a string, so string concatenation worked.</p>

```<code>project_filter = (
    "state = \"ACTIVE\" AND create_time > \"" + c + "\""
)
</code>```

Body:
I am using list_findings() API for listing the security issues identified in Cloud Security command center. I want to list the findings every 5 minutes.

 c = (datetime.utcnow() - timedelta(minutes =5)).replace(tzinfo=pytz.UTC, microsecond =0)
 project_filter = (
     "state = \"ACTIVE\" AND create_time > \"2020-02-19T15:20:10-00:00\""
 )
 finding_result_iterator = client.list_findings(source_name, filter_ = project_filter)

How can I pass the value of c in the project_filter? I don't want to hard code the value of create_time. It should automatically take the time from the variable c in every run of the script. I tried different ways to pass the value to create_time but its not working. Could someone please help. Here is the link for the doc provided by google
    https://cloud.google.com/security-command-center/docs/how-to-api-list-findings

I am trying to use something like this but its giving error

project_filter = (
    "state = \"ACTIVE\" AND create_time >\'c\'"
)

Error -

google.api_core.exceptions.InvalidArgument: 400 Invalid Filter. Filter must be non-null and filter upon a field in the request. Example: "event_time = 123 OR event_time >= 123 OR event_time <= 123"

Body:
Actually project_filter is a string, so string concatenation worked.

project_filter = (
    "state = \"ACTIVE\" AND create_time > \"" + c + "\""
)


问:
What unix command can we use to append some text to a specific line in a file?
Does anyone know of a series of unix commands that allows someone to append some text to the end of a specific line in a file?

eg

Line 1

Line 2

Line 3

Line 4

I wish to append the text ", extra information" to Line 3 so that the File will now look like this:

Line 1

Line 2

Line 3, extra information

Line 4

答:
If you want the extra information to be appended to just one line, any of the sed/awk one-liners will do.

If you want to append something to (almost) every line in the file, you should create a second file with the extra information for each line and use paste:

```<code>$ cat myfile
line 1
line 2
line 3
line 4
$ cat extra
something

something else
$ paste myfile extra
line 1  something
line 2
line 3  something else
line 4
</code>```

OwnerDisplayName: Alex Wong

ContentLicense: CC BY-SA 2.5

Body:
If you want the extra information to be appended to just one line, any of the sed/awk one-liners will do.

If you want to append something to (almost) every line in the file, you should create a second file with the extra information for each line and use paste:

$ cat myfile
line 1
line 2
line 3
line 4
$ cat extra
something

something else
$ paste myfile extra
line 1  something
line 2
line 3  something else
line 4

OwnerDisplayName: Roberto Bonvallet


问:
Calling a function within ReReplace function
Is there a way to write in coldfusion something like:

```<code>< cfset ReReplace(value,"&#\d+;","#decodeHtmlEntity(\1)#", "all") >
</code>```

Thanks a lot

答:
I don't think this will work if you want to replace regular expression value as argument of decodeHTMLEntity.

Updated:

```<code>   <cfset myVar = ReReplace("ABC123DEF","(\d+)",addOne('\1'), "all") >
   <cffunction name="addOne" access="public" output="false" returntype="string">
    <cfargument name="arg1" required="true" type="string" />
    <cfreturn arg1 + 1>
</cffunction>
<cfdump var="#myvar#">
</code>```

Above code written to find 123 from text and add one into it but this will not work as arg1 will have \1 which is not numeric value.

ContentLicense: CC BY-SA 3.0

Body:
Is there a way to write in coldfusion something like:

< cfset ReReplace(value,"&#\d+;","#decodeHtmlEntity(\1)#", "all") >

Thanks a lot

Body:
I don't think this will work if you want to replace regular expression value as argument of decodeHTMLEntity.

Updated:

   <cfset myVar = ReReplace("ABC123DEF","(\d+)",addOne('\1'), "all") >
   <cffunction name="addOne" access="public" output="false" returntype="string">
    <cfargument name="arg1" required="true" type="string" />
    <cfreturn arg1 + 1>
</cffunction>
<cfdump var="#myvar#">

Above code written to find 123 from text and add one into it but this will not work as arg1 will have \1 which is not numeric value.


问:
How to replace NaNs in a 1D array with the mean of nearest neighbors?
I have a large 1D-array with some 'NaN' values dispersed in it. I would like to replace the 'NaN' values with the mean of the values on each side of the 'NaN'.

There is a lot of documentation on this site about replacing 'NaN' with the mean of a column or row, but I want to replace it with just the average of its neighbors.

I have written the following code, but it is not replacing the 'NaN' values at all. Can someone please tell me what I am doing wrong? Thanks in advance.

```<code>import numpy as np

lfc=['NaN', 4, 'NaN', 6, 3, 'NaN', 1]

for i in range(0, len(lfc)):
   if lfc[0] == 'nan':
       lfc[0] = lfc[1]
   elif lfc[i] == 'nan':
       lfc[i] = (lfc[i-1] + lfc[i+1]) / 2
   elif lfc[len(lfc)-1] == 'nan':
       lfc[len(lfc)-1] = lfc[len(lfc)-2]

</code>```

Edit

Sample input:

```<code>lfc=['NaN', 4, 'NaN', 6, 3, 'NaN', 1]
</code>```

Expected output:

```<code>lfc=[4, 4, 5, 3, 2, 1]
</code>```

答:
```<code># to convert, you can use
lfc=['nan', 4, 'nan', 6, 3, 'nan', 1]
lfc= [np.nan if x == 'nan' else x for x in lfc ]

for i in range(0,len(lfc)):
    if lfc[0] is np.nan:
        lfc[0]=lfc[1]
    elif lfc[i] is np.nan:
        lfc[i]=(lfc[i-1]+lfc[i+1])/2
    elif lfc[len(lfc)-1] is np.nan:
        lfc[len(lfc)-1]=lfc[len(lfc)-2]

 [4, 4, 5.0, 6, 3, 2.0, 1]
</code>```

NOTE: This does not take care if the neighbor itself is NaN.

Body:
I have a large 1D-array with some 'NaN' values dispersed in it. I would like to replace the 'NaN' values with the mean of the values on each side of the 'NaN'.

There is a lot of documentation on this site about replacing 'NaN' with the mean of a column or row, but I want to replace it with just the average of its neighbors.

I have written the following code, but it is not replacing the 'NaN' values at all. Can someone please tell me what I am doing wrong? Thanks in advance.

import numpy as np

lfc=['NaN', 4, 'NaN', 6, 3, 'NaN', 1]

for i in range(0, len(lfc)):
   if lfc[0] == 'nan':
       lfc[0] = lfc[1]
   elif lfc[i] == 'nan':
       lfc[i] = (lfc[i-1] + lfc[i+1]) / 2
   elif lfc[len(lfc)-1] == 'nan':
       lfc[len(lfc)-1] = lfc[len(lfc)-2]

Edit

Sample input:

lfc=['NaN', 4, 'NaN', 6, 3, 'NaN', 1]

Expected output:

lfc=[4, 4, 5, 3, 2, 1]

Body:
# to convert, you can use
lfc=['nan', 4, 'nan', 6, 3, 'nan', 1]
lfc= [np.nan if x == 'nan' else x for x in lfc ]

for i in range(0,len(lfc)):
    if lfc[0] is np.nan:
        lfc[0]=lfc[1]
    elif lfc[i] is np.nan:
        lfc[i]=(lfc[i-1]+lfc[i+1])/2
    elif lfc[len(lfc)-1] is np.nan:
        lfc[len(lfc)-1]=lfc[len(lfc)-2]

 [4, 4, 5.0, 6, 3, 2.0, 1]

NOTE: This does not take care if the neighbor itself is NaN.


问:
running metabat2 and checkM with snakemake
Hi I have been trying to put metabat2 and checkm in my pipeline to see which bacteria in my sample but I keep running in to an error with snakema. My snakemake code is

```<code>rule all:
    input:
        [f"nanoplot_out/" for sample in samples],
    [f"zipped/zipped.gz" for sample in samples],
    [f"filtered/nanofilt_out.gz" for sample in samples],
    [f"unzipped/read.fastq" for sample in samples],
    [f"assembled/" for sample in samples],
    [f"nanopolish/assembly.fasta" for sample in samples],
[f"medaka_consensus/" for sample in samples],
    [f"input/consensus.fasta" for sample in samples],
    [f"output_antismash/" for sample in samples],
    [f"metabat2/bin" for sample in samples],
    [f"metabat2/CheckM.txt" for sample in samples]
rule metabat2:
    input:
        "medaka_consensus/consensus.fasta"
    output:
        directory("metabat2/")
    conda:
        "envs/metabat2.yaml"
    shell:
        "metabat2 -i {input} -o {output} -v"

rule checkM:
    input:
        "metabat2/"
    output:
        "metabat2/CheckM.txt"
    conda:
        "envs/metabat2.yaml"
    shell:
        "checkm lineage_wf -f {output} -t 30 -x fa {input}"
</code>```

and my error message is MissingInputException in line 4 of /home/ec2-user/snakemake_JHB-2-14-20_uncor_polish_anti5_meta/Snakefile:
Missing input files for rule all:
metabat2/bin

Is there anyone that could help me to make it work?

答:
The error message is stating that snakemake could not find any rule that can create the file (or directory?) metabat2/bin. Assuming it gets created by the rule metabat2, you will need to add it as part of output.

```<code>rule metabat2:
    input:
        "medaka_consensus/consensus.fasta"
    output:
        a = metabat2/bin
        b = directory("metabat2/")
    conda:
        "envs/metabat2.yaml"
    shell:
        "metabat2 -i {input} -o {output.b} -v"
</code>```

Body:
Hi I have been trying to put metabat2 and checkm in my pipeline to see which bacteria in my sample but I keep running in to an error with snakema. My snakemake code is

rule all:
    input:
        [f"nanoplot_out/" for sample in samples],
    [f"zipped/zipped.gz" for sample in samples],
    [f"filtered/nanofilt_out.gz" for sample in samples],
    [f"unzipped/read.fastq" for sample in samples],
    [f"assembled/" for sample in samples],
    [f"nanopolish/assembly.fasta" for sample in samples],
[f"medaka_consensus/" for sample in samples],
    [f"input/consensus.fasta" for sample in samples],
    [f"output_antismash/" for sample in samples],
    [f"metabat2/bin" for sample in samples],
    [f"metabat2/CheckM.txt" for sample in samples]
rule metabat2:
    input:
        "medaka_consensus/consensus.fasta"
    output:
        directory("metabat2/")
    conda:
        "envs/metabat2.yaml"
    shell:
        "metabat2 -i {input} -o {output} -v"

rule checkM:
    input:
        "metabat2/"
    output:
        "metabat2/CheckM.txt"
    conda:
        "envs/metabat2.yaml"
    shell:
        "checkm lineage_wf -f {output} -t 30 -x fa {input}"

and my error message is MissingInputException in line 4 of /home/ec2-user/snakemake_JHB-2-14-20_uncor_polish_anti5_meta/Snakefile:
Missing input files for rule all:
metabat2/bin

Is there anyone that could help me to make it work?

Body:
The error message is stating that snakemake could not find any rule that can create the file (or directory?) metabat2/bin. Assuming it gets created by the rule metabat2, you will need to add it as part of output.

rule metabat2:
    input:
        "medaka_consensus/consensus.fasta"
    output:
        a = metabat2/bin
        b = directory("metabat2/")
    conda:
        "envs/metabat2.yaml"
    shell:
        "metabat2 -i {input} -o {output.b} -v"


问:
Relationship Constraints on weighted shortest path in neo4j cypher
I am experimenting with neo4j.
I have a graph like this.

The query to create the above graph:

```<code>merge (:node{name : '1'});
merge (:node{name : '2'});
merge (:node{name : '3'});
merge (:node{name : '4'});
merge (:node{name : '5'});
merge (:node{name : '6'});
merge (:node{name : '7'});
merge (:node{name : '8'});

match (n1:node{name : '1'}), (n2:node{name : '2'}) merge (n1) -[:edge{cost : 100, Property1:'P1', Property2: 'P2'}]-> (n2)
match (n1:node{name : '2'}), (n2:node{name : '3'}) merge (n1) -[:edge{cost : 100, Property1:'P1', Property2: 'P2'}]-> (n2)
match (n1:node{name : '3'}), (n2:node{name : '4'}) merge (n1) -[:edge{cost : 200, Property1:'P1', Property2: 'P2'}]-> (n2)
match (n1:node{name : '1'}), (n2:node{name : '5'}) merge (n1) -[:edge{cost : 40, Property1:'P1'}]-> (n2)
match (n1:node{name : '5'}), (n2:node{name : '6'}) merge (n1) -[:edge{cost : 50, Property1:'P1'}]-> (n2)
match (n1:node{name : '6'}), (n2:node{name : '4'}) merge (n1) -[:edge{cost : 60, Property1:'P1'}]-> (n2)
match (n1:node{name : '1'}), (n2:node{name : '7'}) merge (n1) -[:edge{cost : 60, Property2: 'P2'}]-> (n2)
match (n1:node{name : '7'}), (n2:node{name : '8'}) merge (n1) -[:edge{cost : 60, Property2: 'P2'}]-> (n2)
match (n1:node{name : '6'}), (n2:node{name : '8'}) merge (n1) -[:edge{cost : 20, Property1:'P1'}]-> (n2)
match (n1:node{name : '8'}), (n2:node{name : '4'}) merge (n1) -[:edge{cost : 20, Property2: 'P2'}]-> (n2)
</code>```

I want the answer to the following queries.

Shortest path between 1 to 4 where relationship property : Property1 = 'P1' and relationship property : Property2 = 'P2' ( Cost : 400, 1 -> 2 -> 3 -> 4)

Shortest path between 1 to 4 where relationship property : Property1 = 'P1' (Cost : 150, 1 -> 5 -> 6 -> 4). Here the path (1 -> 2 -> 3 -> 4) is also valid, but since its cost is large, it is not the answer.

Shortest path between 1 to 4 where relationship property : Property2 = 'P2' (Cost : 140, 1 -> 7 -> 8 -> 4). Again here the path (1 -> 2 -> 3 -> 4) is also valid, but since its cost is large, it is not the answer.

Shortest path between 1 to 4 where relationship property : Property1 = 'P1' or relationship property : Property2 = 'P2' ( Cost : 130, 1 -> 5 -> 6 -> 8 -> 4). Here any path is valid, but the above path is the optimal.

Shortest path between 1 to 4 where relationship property : Property1 != 'P1'. (Cost : 140, 1 -> 7 -> 8 -> 4).

Here, Property1 can be anything and Property2 also can be anything (not necessarily 'P1' and 'P2' respectively.). In all cases, if there is an edge whose relationship property Property1 = 'P3', then that edge should be considered for optimal path.

Suppose if I want to filter based on the node condition too (like node having Property = 'P5') along with relationship condition, can this be done ?

Am using cypher query language.

A good search on the internet gives only giving constraints on non weighted graph (Cypher: Shortest Path with Constraint)

答:
Try the graph algorithms library. https://neo4j.com/docs/graph-algorithms/current/labs-algorithms/shortest-path/</p>

```<code>//1.
MATCH (start:node {name: '1'}), (end:node {name: '4'})
CALL algo.shortestPath.stream(start, end, 'cost', {
  nodeQuery:'MATCH (n:node) RETURN id(n) as id',
  relationshipQuery:'MATCH (n:node)-[r:edge]->(m:node) WHERE r.Property1="P1" and r.Property2="P2" RETURN id(n) AS source, id(m) AS target, r.cost AS weight',
    graph: 'cypher', duplicateRelationships: 'min'})
YIELD nodeId, cost
RETURN algo.asNode(nodeId).name AS name, cost;

//2.
MATCH (start:node {name: '1'}), (end:node {name: '4'})
CALL algo.shortestPath.stream(start, end, 'cost', {
  nodeQuery:'MATCH (n:node) RETURN id(n) as id',
  relationshipQuery:'MATCH (n:node)-[r:edge]->(m:node) WHERE r.Property1="P1" RETURN id(n) AS source, id(m) AS target, r.cost AS weight',
    graph: 'cypher', duplicateRelationships: 'min'})
YIELD nodeId, cost
RETURN algo.asNode(nodeId).name AS name, cost;

//3.
MATCH (start:node {name: '1'}), (end:node {name: '4'})
CALL algo.shortestPath.stream(start, end, 'cost', {
  nodeQuery:'MATCH (n:node) RETURN id(n) as id',
  relationshipQuery:'MATCH (n:node)-[r:edge]->(m:node) WHERE r.Property2="P2" RETURN id(n) AS source, id(m) AS target, r.cost AS weight',
    graph: 'cypher', duplicateRelationships: 'min'})
YIELD nodeId, cost
RETURN algo.asNode(nodeId).name AS name, cost;

//4.
MATCH (start:node {name: '1'}), (end:node {name: '4'})
CALL algo.shortestPath.stream(start, end, 'cost', {
  nodeQuery:'MATCH (n:node) RETURN id(n) as id',
  relationshipQuery:'MATCH (n:node)-[r:edge]->(m:node) WHERE r.Property1="P1" or r.Property2 = "P2" RETURN id(n) AS source, id(m) AS target, r.cost AS weight',
    graph: 'cypher', duplicateRelationships: 'min'})
YIELD nodeId, cost
RETURN algo.asNode(nodeId).name AS name, cost;

//5.
MATCH (start:node {name: '1'}), (end:node {name: '4'})
CALL algo.shortestPath.stream(start, end, 'cost', {
  nodeQuery:'MATCH (n:node) RETURN id(n) as id',
  relationshipQuery:'MATCH (n:node)-[r:edge]->(m:node) WHERE  coalesce(r.Property1, "P2")<>"P1" RETURN id(n) AS source, id(m) AS target, r.cost AS weight',
    graph: 'cypher', duplicateRelationships: 'min'})
YIELD nodeId, cost
RETURN algo.asNode(nodeId).name AS name, cost;

</code>```

Body:
I am experimenting with neo4j.
I have a graph like this.

The query to create the above graph:

merge (:node{name : '1'});
merge (:node{name : '2'});
merge (:node{name : '3'});
merge (:node{name : '4'});
merge (:node{name : '5'});
merge (:node{name : '6'});
merge (:node{name : '7'});
merge (:node{name : '8'});

match (n1:node{name : '1'}), (n2:node{name : '2'}) merge (n1) -[:edge{cost : 100, Property1:'P1', Property2: 'P2'}]-> (n2)
match (n1:node{name : '2'}), (n2:node{name : '3'}) merge (n1) -[:edge{cost : 100, Property1:'P1', Property2: 'P2'}]-> (n2)
match (n1:node{name : '3'}), (n2:node{name : '4'}) merge (n1) -[:edge{cost : 200, Property1:'P1', Property2: 'P2'}]-> (n2)
match (n1:node{name : '1'}), (n2:node{name : '5'}) merge (n1) -[:edge{cost : 40, Property1:'P1'}]-> (n2)
match (n1:node{name : '5'}), (n2:node{name : '6'}) merge (n1) -[:edge{cost : 50, Property1:'P1'}]-> (n2)
match (n1:node{name : '6'}), (n2:node{name : '4'}) merge (n1) -[:edge{cost : 60, Property1:'P1'}]-> (n2)
match (n1:node{name : '1'}), (n2:node{name : '7'}) merge (n1) -[:edge{cost : 60, Property2: 'P2'}]-> (n2)
match (n1:node{name : '7'}), (n2:node{name : '8'}) merge (n1) -[:edge{cost : 60, Property2: 'P2'}]-> (n2)
match (n1:node{name : '6'}), (n2:node{name : '8'}) merge (n1) -[:edge{cost : 20, Property1:'P1'}]-> (n2)
match (n1:node{name : '8'}), (n2:node{name : '4'}) merge (n1) -[:edge{cost : 20, Property2: 'P2'}]-> (n2)

I want the answer to the following queries.

Shortest path between 1 to 4 where relationship property : Property1 = 'P1' and relationship property : Property2 = 'P2' ( Cost : 400, 1 -> 2 -> 3 -> 4)

Shortest path between 1 to 4 where relationship property : Property1 = 'P1' (Cost : 150, 1 -> 5 -> 6 -> 4). Here the path (1 -> 2 -> 3 -> 4) is also valid, but since its cost is large, it is not the answer.

Shortest path between 1 to 4 where relationship property : Property2 = 'P2' (Cost : 140, 1 -> 7 -> 8 -> 4). Again here the path (1 -> 2 -> 3 -> 4) is also valid, but since its cost is large, it is not the answer.

Shortest path between 1 to 4 where relationship property : Property1 = 'P1' or relationship property : Property2 = 'P2' ( Cost : 130, 1 -> 5 -> 6 -> 8 -> 4). Here any path is valid, but the above path is the optimal.

Shortest path between 1 to 4 where relationship property : Property1 != 'P1'. (Cost : 140, 1 -> 7 -> 8 -> 4).

Here, Property1 can be anything and Property2 also can be anything (not necessarily 'P1' and 'P2' respectively.). In all cases, if there is an edge whose relationship property Property1 = 'P3', then that edge should be considered for optimal path.

Suppose if I want to filter based on the node condition too (like node having Property = 'P5') along with relationship condition, can this be done ?

Am using cypher query language.

A good search on the internet gives only giving constraints on non weighted graph (Cypher: Shortest Path with Constraint)

Body:
Try the graph algorithms library. https://neo4j.com/docs/graph-algorithms/current/labs-algorithms/shortest-path/

//1.
MATCH (start:node {name: '1'}), (end:node {name: '4'})
CALL algo.shortestPath.stream(start, end, 'cost', {
  nodeQuery:'MATCH (n:node) RETURN id(n) as id',
  relationshipQuery:'MATCH (n:node)-[r:edge]->(m:node) WHERE r.Property1="P1" and r.Property2="P2" RETURN id(n) AS source, id(m) AS target, r.cost AS weight',
    graph: 'cypher', duplicateRelationships: 'min'})
YIELD nodeId, cost
RETURN algo.asNode(nodeId).name AS name, cost;

//2.
MATCH (start:node {name: '1'}), (end:node {name: '4'})
CALL algo.shortestPath.stream(start, end, 'cost', {
  nodeQuery:'MATCH (n:node) RETURN id(n) as id',
  relationshipQuery:'MATCH (n:node)-[r:edge]->(m:node) WHERE r.Property1="P1" RETURN id(n) AS source, id(m) AS target, r.cost AS weight',
    graph: 'cypher', duplicateRelationships: 'min'})
YIELD nodeId, cost
RETURN algo.asNode(nodeId).name AS name, cost;

//3.
MATCH (start:node {name: '1'}), (end:node {name: '4'})
CALL algo.shortestPath.stream(start, end, 'cost', {
  nodeQuery:'MATCH (n:node) RETURN id(n) as id',
  relationshipQuery:'MATCH (n:node)-[r:edge]->(m:node) WHERE r.Property2="P2" RETURN id(n) AS source, id(m) AS target, r.cost AS weight',
    graph: 'cypher', duplicateRelationships: 'min'})
YIELD nodeId, cost
RETURN algo.asNode(nodeId).name AS name, cost;

//4.
MATCH (start:node {name: '1'}), (end:node {name: '4'})
CALL algo.shortestPath.stream(start, end, 'cost', {
  nodeQuery:'MATCH (n:node) RETURN id(n) as id',
  relationshipQuery:'MATCH (n:node)-[r:edge]->(m:node) WHERE r.Property1="P1" or r.Property2 = "P2" RETURN id(n) AS source, id(m) AS target, r.cost AS weight',
    graph: 'cypher', duplicateRelationships: 'min'})
YIELD nodeId, cost
RETURN algo.asNode(nodeId).name AS name, cost;

//5.
MATCH (start:node {name: '1'}), (end:node {name: '4'})
CALL algo.shortestPath.stream(start, end, 'cost', {
  nodeQuery:'MATCH (n:node) RETURN id(n) as id',
  relationshipQuery:'MATCH (n:node)-[r:edge]->(m:node) WHERE  coalesce(r.Property1, "P2")<>"P1" RETURN id(n) AS source, id(m) AS target, r.cost AS weight',
    graph: 'cypher', duplicateRelationships: 'min'})
YIELD nodeId, cost
RETURN algo.asNode(nodeId).name AS name, cost;


问:
UIWebView webViewDidFinishLoad not getting called iOS
I am loading some file from document directory using UIWebView. I have set the delegate of UIWebView and I am responding to 2 methods of delegate that is
webViewDidStartLoad and webViewDidFinishLoad I am receiving the webViewDidStartLoad But I am not receiving webViewDidFinishLoad method.

Below is the code:

```<code>@interface MyView: UIViewController <UIWebViewDelegate> {
           UIWebView *webView;
}

@property (nonatomic, retain) UIWebView *webView;

========================= Class ===========================

-(void)viewDidLoad {
    CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
    mWebView = [[UIWebView alloc] initWithFrame:webFrame];
    mWebView.delegate = self;
    mWebView.scalesPageToFit = YES;
    [self.view addSubview:mWebView];
        NSString *path = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", pathString]];

    [mWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]] ];
}

// Delegate methods

-(void)webViewDidStartLoad:(UIWebView *)webView {
    NSLog(@"start");
}

-(void)webViewDidFinishLoad:(UIWebView *)webView {
    NSLog(@"finish");
}

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    NSLog(@"Error for WEBVIEW: %@", [error description]);
}
</code>```

Please let me know what is going wrong. I am not getting any error in didFailLoadWithError delegate method.

Note:- the file that I am loading are huge say 3 MB.

Thanks

=============EDITED==================

As I was loading very huge File the delegate was coming after very long duration that I was not able to notice but for small files everything is working fine

答: Probably it is experiencing an error. Implement –webView:didFailLoadWithError: and check.

Body:
I am loading some file from document directory using UIWebView. I have set the delegate of UIWebView and I am responding to 2 methods of delegate that is
webViewDidStartLoad and webViewDidFinishLoad I am receiving the webViewDidStartLoad But I am not receiving webViewDidFinishLoad method.

Below is the code:

@interface MyView: UIViewController <UIWebViewDelegate> {
           UIWebView *webView;
}

@property (nonatomic, retain) UIWebView *webView;

========================= Class ===========================

-(void)viewDidLoad {
    CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
    mWebView = [[UIWebView alloc] initWithFrame:webFrame];
    mWebView.delegate = self;
    mWebView.scalesPageToFit = YES;
    [self.view addSubview:mWebView];
        NSString *path = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", pathString]];

    [mWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]] ];
}

// Delegate methods

-(void)webViewDidStartLoad:(UIWebView *)webView {
    NSLog(@"start");
}

-(void)webViewDidFinishLoad:(UIWebView *)webView {
    NSLog(@"finish");
}

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    NSLog(@"Error for WEBVIEW: %@", [error description]);
}

Please let me know what is going wrong. I am not getting any error in didFailLoadWithError delegate method.

Note:- the file that I am loading are huge say 3 MB.

Thanks

=============EDITED==================

As I was loading very huge File the delegate was coming after very long duration that I was not able to notice but for small files everything is working fine


问:
Installed R packages in Dockerfile won't be found when running container
I'm trying to install several R packages in a Python Docker image. I've this small Dockerfile:

```<code># Python 3.7.5
FROM python:3.7.5
ENV PYTHONUNBUFFERED 1

# Install R 3.6
RUN echo 'deb http://cran.rstudio.com/bin/linux/debian buster-cran35/' >> /etc/apt/sources.list
RUN apt install dirmngr
RUN apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'
RUN apt update
RUN apt install -y r-base

# Install R dependencies
RUN R -e "install.packages('BiocManager', dependencies=TRUE, repos='http://cran.rstudio.com/')"
</code>```

It doesn't throw any error. But when I run docker container exec -it <my container> bash and do:

Rscript -e 'installed.packages()' | grep BiocManager

There aren't any results. I don't know if this applies, but during building it throws:

The downloaded source packages are in

'/tmp/Rtmp7jBLWQ/downloaded_packages'

Maybe that it's installing the packages on a temp folder is the problem. Is there any way to install R packages without making an image base on R-base image and use install2.r?

答:
What a shame... I had a docker-compose with a build: . clause and I forget to run docker-compose build. That's why the changes didn't apply.

However I used the r-base image to install the dependies in an easier way. My final Dockerfile is:

```<code>FROM r-base:3.6.2

# Install R dependencies
RUN install2.r --error BiocManager

# Install Python 3.7
RUN apt install -y python3.7 python3-pip
</code>```

Body:
I'm trying to install several R packages in a Python Docker image. I've this small Dockerfile:

# Python 3.7.5
FROM python:3.7.5
ENV PYTHONUNBUFFERED 1

# Install R 3.6
RUN echo 'deb http://cran.rstudio.com/bin/linux/debian buster-cran35/' >> /etc/apt/sources.list
RUN apt install dirmngr
RUN apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF'
RUN apt update
RUN apt install -y r-base

# Install R dependencies
RUN R -e "install.packages('BiocManager', dependencies=TRUE, repos='http://cran.rstudio.com/')"

It doesn't throw any error. But when I run docker container exec -it <my container> bash and do:

Rscript -e 'installed.packages()' | grep BiocManager

There aren't any results. I don't know if this applies, but during building it throws:

The downloaded source packages are in

'/tmp/Rtmp7jBLWQ/downloaded_packages'

Maybe that it's installing the packages on a temp folder is the problem. Is there any way to install R packages without making an image base on R-base image and use install2.r?

Body:
What a shame... I had a docker-compose with a build: . clause and I forget to run docker-compose build. That's why the changes didn't apply.

However I used the r-base image to install the dependies in an easier way. My final Dockerfile is:

FROM r-base:3.6.2

# Install R dependencies
RUN install2.r --error BiocManager

# Install Python 3.7
RUN apt install -y python3.7 python3-pip


问:
PayPal IPN Listener keeps 'Retrying' HTTP Response 500
My IPN Listener has been working fine for the last 6 months. This last week though, all transactions are 'Retrying' and causing a HTTP 500 Response. I haven't changed any code in the IPN Listener and I haven't changed any settings in PayPal. I have rang PayPal and they say it's not a problem their end. My hosting company 1&1 Ionos have pretty much no idea what I'm talking about. My IPN Listener code is below. My site uses Asp.Net/VB.Net..</p>

```<code>Imports System.Net
Imports System.IO
Imports System.Web.Util
Imports System.Data.Common

Partial Class IPNListener
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        'Post back to either sandbox or live
        'Dim strURL As String = "https://www.sandbox.paypal.com/cgi-bin/webscr"
        Dim strURL As String = "https://www.paypal.com/cgi-bin/webscr"
        Dim req As HttpWebRequest = CType(WebRequest.Create(strURL), HttpWebRequest)

        'Set values for the request back
        req.Method = "POST"
        req.ContentType = "application/x-www-form-urlencoded"
        req.Proxy = New WebProxy("ntproxyus.lxa.perfora.net", 3128)

        Dim Param() As Byte = Request.BinaryRead(HttpContext.Current.Request.ContentLength)
        Dim strRequest As String = Encoding.ASCII.GetString(Param)
        strRequest = strRequest + "&cmd=_notify-validate"
        req.ContentLength = strRequest.Length

        'Send the request to PayPal and get the response
        Dim streamOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
        streamOut.Write(strRequest)
        streamOut.Close()
        Dim streamIn As StreamReader = New StreamReader(req.GetResponse().GetResponseStream())
        Dim strResponse As String = streamIn.ReadToEnd()
        streamIn.Close()

        Dim qscoll As NameValueCollection = HttpUtility.ParseQueryString(strRequest)

        'Insert the paypal response
        Dim order As New orders
        order.InsertPaypalResponse(qscoll("txn_id"), qscoll("custom"), strRequest)

        If strResponse = "VERIFIED" Then
              order.UpdateOrderFromPaypal(qscoll("custom"), qscoll("txn_id"), qscoll("payment_status"))
        ElseIf strResponse = "INVALID" Then
            'log for manual investigation
            order.UpdateOrderFromPaypal(qscoll("custom"), qscoll("txn_id"), qscoll("payment_status"))
        Else
            'Response wasn't VERIFIED or INVALID, log for manual investigation
            order.UpdateOrderFromPaypal(qscoll("custom"), qscoll("txn_id"), qscoll("payment_status"))
        End If
    End Sub
End Class
</code>```

答:
Your IPN listener likely is having problems connecting to https://www.paypal.com/cgi-bin/webscr in order to validate the IPNs it receives, and so is refusing to process the IPN and returning an HTTP 500, causing PayPal to retry its delivery repeatedly.

For your listener to be able to connect to PayPal and validate IPNs, you need to ensure you have an updated Certificate Authority bundle / list that is able to verify the issuer of the PayPal servers' current, cryptographically secure SSL certificates.

While you are at it, update your IPN listener to use ipnpb.paypal.com rather than www.paypal.com See the current documentation: https://developer.paypal.com/docs/ipn/integration-guide/IPNImplementation/

Body:
My IPN Listener has been working fine for the last 6 months. This last week though, all transactions are 'Retrying' and causing a HTTP 500 Response. I haven't changed any code in the IPN Listener and I haven't changed any settings in PayPal. I have rang PayPal and they say it's not a problem their end. My hosting company 1&1 Ionos have pretty much no idea what I'm talking about. My IPN Listener code is below. My site uses Asp.Net/VB.Net..

Imports System.Net
Imports System.IO
Imports System.Web.Util
Imports System.Data.Common

Partial Class IPNListener
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        'Post back to either sandbox or live
        'Dim strURL As String = "https://www.sandbox.paypal.com/cgi-bin/webscr"
        Dim strURL As String = "https://www.paypal.com/cgi-bin/webscr"
        Dim req As HttpWebRequest = CType(WebRequest.Create(strURL), HttpWebRequest)

        'Set values for the request back
        req.Method = "POST"
        req.ContentType = "application/x-www-form-urlencoded"
        req.Proxy = New WebProxy("ntproxyus.lxa.perfora.net", 3128)

        Dim Param() As Byte = Request.BinaryRead(HttpContext.Current.Request.ContentLength)
        Dim strRequest As String = Encoding.ASCII.GetString(Param)
        strRequest = strRequest + "&cmd=_notify-validate"
        req.ContentLength = strRequest.Length

        'Send the request to PayPal and get the response
        Dim streamOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
        streamOut.Write(strRequest)
        streamOut.Close()
        Dim streamIn As StreamReader = New StreamReader(req.GetResponse().GetResponseStream())
        Dim strResponse As String = streamIn.ReadToEnd()
        streamIn.Close()

        Dim qscoll As NameValueCollection = HttpUtility.ParseQueryString(strRequest)

        'Insert the paypal response
        Dim order As New orders
        order.InsertPaypalResponse(qscoll("txn_id"), qscoll("custom"), strRequest)

        If strResponse = "VERIFIED" Then
              order.UpdateOrderFromPaypal(qscoll("custom"), qscoll("txn_id"), qscoll("payment_status"))
        ElseIf strResponse = "INVALID" Then
            'log for manual investigation
            order.UpdateOrderFromPaypal(qscoll("custom"), qscoll("txn_id"), qscoll("payment_status"))
        Else
            'Response wasn't VERIFIED or INVALID, log for manual investigation
            order.UpdateOrderFromPaypal(qscoll("custom"), qscoll("txn_id"), qscoll("payment_status"))
        End If
    End Sub
End Class


问:
How to access Activity UI from my class?
I have an activity which creates an object instance of my class:

```<code>file MyActivity.java:
public class MyActivity extends Activity {
    TextView myView = (TextView)findViewById(R.id.myView);
    ...
    Points myPoints new Points();
    ...
}
--------------------------------------------------------------

file Points.java:
private class Points {
    ...
    HOW TO USE myView HERE ???
    ...
}
--------------------------------------------------------------
</code>```

How do I use the UI objects in my class (which does not extend an
Activity)? Should I pass some context to my Points class? How do I do, exactly?

答:
Your Points can't be a private class without being an inner class. So your code doesn't even compile...

Pass the view as parameter to the constructor of your Points class:

```<code>public class MyActivity extends Activity {
    TextView myView = (TextView)findViewById(R.id.myView);
    Points myPoints new Points(myView);

    private class Points {
        public Points(TextView view) {
            // todo
        }
    }
}
</code>```

Body:
I have an activity which creates an object instance of my class:

file MyActivity.java:
public class MyActivity extends Activity {
    TextView myView = (TextView)findViewById(R.id.myView);
    ...
    Points myPoints new Points();
    ...
}
--------------------------------------------------------------

file Points.java:
private class Points {
    ...
    HOW TO USE myView HERE ???
    ...
}
--------------------------------------------------------------

How do I use the UI objects in my class (which does not extend an
Activity)? Should I pass some context to my Points class? How do I do, exactly?

Body:
Your Points can't be a private class without being an inner class. So your code doesn't even compile...

Pass the view as parameter to the constructor of your Points class:

public class MyActivity extends Activity {
    TextView myView = (TextView)findViewById(R.id.myView);
    Points myPoints new Points(myView);

    private class Points {
        public Points(TextView view) {
            // todo
        }
    }
}


问:
Building React Native for iOS fails: code signature not vaild for AppAuth
I am trying to integrate react-native-app-auth into my React Native app. It works on Android, but when trying to build the project on iOS I get the following:

```<code>dyld: Library not loaded: @rpath/AppAuth.framework/AppAuth
  Referenced from: /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/MapMobileWorkbench
  Reason: no suitable image found.  Did find:
    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: code signature invalid for '/private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth'

    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: stat() failed with errno=25
    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: code signature invalid for '/private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth'

    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: stat() failed with errno=1
    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: code signature invalid for '/private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth'

    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: stat() failed with errno=1
(lldb)
</code>```

After that pops up, continuing the run the app causes it to crash.

React Native Info:

```<code>  React Native Environment Info:
    System:
      OS: macOS 10.14.6
      CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
      Memory: 1.29 GB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.16.1 - /var/folders/2p/5xwrclh55wjc5glqmnwdcbqm0000gp/T/yarn--1582121305976-0.1309360786018443/node
      Yarn: 1.22.0 - /var/folders/2p/5xwrclh55wjc5glqmnwdcbqm0000gp/T/yarn--1582121305976-0.1309360786018443/yarn
      npm: 6.9.0 - ~/.nvm/versions/node/v10.16.1/bin/npm
    SDKs:
      iOS SDK:
        Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    IDEs:
      Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.5 => 0.59.5
</code>```

Both the .a library and the .framework for AppAuth are in the link list for the target I am building, but the color of the icon for the .framework file is more of a pale yellow versus the regular yellow of the rest of the .framework files linked. That is the only thing I have noticed that might mean something. I have tried deleting and reinstalling my pods a number of times without any luck there, either. And I have tried both the new and the legacy build systems. I am not sure what else to try.

答: mark the frameworks as (Do Not Embed) in the Frameworks, Libraries and embedded content section and in Build Phases/Link Binary With Libraries, Mark the frameworks as (optional). This should avoid the error.

Body:
I am trying to integrate react-native-app-auth into my React Native app. It works on Android, but when trying to build the project on iOS I get the following:

dyld: Library not loaded: @rpath/AppAuth.framework/AppAuth
  Referenced from: /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/MapMobileWorkbench
  Reason: no suitable image found.  Did find:
    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: code signature invalid for '/private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth'

    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: stat() failed with errno=25
    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: code signature invalid for '/private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth'

    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: stat() failed with errno=1
    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: code signature invalid for '/private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth'

    /private/var/containers/Bundle/Application/38019FA7-8A4E-43F9-93BE-51A59E42308B/MapMobileWorkbench.app/Frameworks/AppAuth.framework/AppAuth: stat() failed with errno=1
(lldb)

After that pops up, continuing the run the app causes it to crash.

React Native Info:

  React Native Environment Info:
    System:
      OS: macOS 10.14.6
      CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
      Memory: 1.29 GB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 10.16.1 - /var/folders/2p/5xwrclh55wjc5glqmnwdcbqm0000gp/T/yarn--1582121305976-0.1309360786018443/node
      Yarn: 1.22.0 - /var/folders/2p/5xwrclh55wjc5glqmnwdcbqm0000gp/T/yarn--1582121305976-0.1309360786018443/yarn
      npm: 6.9.0 - ~/.nvm/versions/node/v10.16.1/bin/npm
    SDKs:
      iOS SDK:
        Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1
    IDEs:
      Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.5 => 0.59.5

Both the .a library and the .framework for AppAuth are in the link list for the target I am building, but the color of the icon for the .framework file is more of a pale yellow versus the regular yellow of the rest of the .framework files linked. That is the only thing I have noticed that might mean something. I have tried deleting and reinstalling my pods a number of times without any luck there, either. And I have tried both the new and the legacy build systems. I am not sure what else to try.


问:
Launching node.js NPX from Eclipse Project
I'm working on some web projects with Eclipse, node.js, React, JSX, and Babel. However whenever working on a project, it feels rather cumbersome to have to navigate to the project folder, open a command prompt, and then type in the command to launch Babel for compiling the JSX. For example, what I typically run at the project root:

```<code>npx babel --watch src --out-dir . --presets react-app/prod
</code>```

So, I was wondering of there was a more simple method by which to launch a command window for the command from within Eclipse. Whether or not it opens a separate command prompt window or does so from within Eclipse (local terminal) I guess isn't too important. Either way, I'm not having much luck in determining if it's even possible.

答: Yes, define an External Builder program: https://help.eclipse.org/2019-12/topic/org.eclipse.platform.doc.user/gettingStarted/qs-96_non_ant_pjs.htm?cp=0_1_2_2_0</p>

Body:
I'm working on some web projects with Eclipse, node.js, React, JSX, and Babel. However whenever working on a project, it feels rather cumbersome to have to navigate to the project folder, open a command prompt, and then type in the command to launch Babel for compiling the JSX. For example, what I typically run at the project root:

npx babel --watch src --out-dir . --presets react-app/prod

So, I was wondering of there was a more simple method by which to launch a command window for the command from within Eclipse. Whether or not it opens a separate command prompt window or does so from within Eclipse (local terminal) I guess isn't too important. Either way, I'm not having much luck in determining if it's even possible.


问:
Convert Excel sheet to paradox DB
given a data in an excel sheet, For the purpose of converting it to Paradox DB, to get used in paradox program. there are any application that convert excel sheet to paradox DB? </p>

答: The paradox application itself can definitely import csv files and store them in a paradox table. I can’t remember if it can import Xls direct so you may have to save as in excel to convert your data to csv first.</p>

Title: Convert Excel sheet to paradox DB


问:
Making a series of plots that proceed by a click
In the example below I would like to be able to control when I go to the next plot by a using mouse click (or keyboard entry)

```<code>for (i in 1:5){
    plot(1:i)
    Sys.sleep(1)
    #add something here that requests mouse click to proceed
}
</code>```

Is this possible? There is a setting in the X11() help file caled 'clickToConfirm' but I can't work out what that does.

It would also be helpful to me to be to be able to scroll back and forth through plots using the arrow keys. Is this possible?

Currently if I need to look at lots of plots I output them into a big .pdf file and scroll though them all there, but that is a bit cumbersome.

Thanks

Tom

答:
In R, that would be done by setting par(ask=TRUE). Try the following code, which shows how to reset the par when exiting the function :

```<code>op <- par(ask=TRUE)
for (i in 1:5){
    plot(1:i)
}
par(op)
</code>```

If you want to keep a history to browse through, you can either open a window and click on recording in the History  menu, or you can open the window yourself with the history on. Demonstrated in a function :

```<code>plot.fun <- function(){
    windows(record=TRUE) # opens a window and starts recording
    op <- par(ask=TRUE)
    on.exit(par(op))

    for (i in 1:5){
        plot(1:i)
    }
    windows.options(record=FALSE) #stops recording.
}
plot.fun()
</code>```

This will however keep all previous plots in the history for browsing as well, so if you run this code 3 times you'll have 15 plots in the plot history. Also note that the open plot window will keep on recording until you turn off the recording in the menu.

You can play with the plot history, as you'll have a variable .SavedPlots which contains the saved plot history. It can be cleared using the menu History > clear history in the plot window. If you want to clear the history from the console, you could hack that by

```<code>.SavedPlots <- NULL
</code>```

But I advise you not to do this, as changing the .SavedPlots variable can cause R to crash.

See also ?windows and ?recordPlot for a bit more information. But as you're getting close to the internal code of R, be warned that you can get pretty awkward behaviour if you start playing around with these things.

Body:
In the example below I would like to be able to control when I go to the next plot by a using mouse click (or keyboard entry)

for (i in 1:5){
    plot(1:i)
    Sys.sleep(1)
    #add something here that requests mouse click to proceed
}

Is this possible? There is a setting in the X11() help file caled 'clickToConfirm' but I can't work out what that does.

It would also be helpful to me to be to be able to scroll back and forth through plots using the arrow keys. Is this possible?

Currently if I need to look at lots of plots I output them into a big .pdf file and scroll though them all there, but that is a bit cumbersome.

Thanks

Tom

Body:
In R, that would be done by setting par(ask=TRUE). Try the following code, which shows how to reset the par when exiting the function :

op <- par(ask=TRUE)
for (i in 1:5){
    plot(1:i)
}
par(op)

If you want to keep a history to browse through, you can either open a window and click on recording in the History  menu, or you can open the window yourself with the history on. Demonstrated in a function :

plot.fun <- function(){
    windows(record=TRUE) # opens a window and starts recording
    op <- par(ask=TRUE)
    on.exit(par(op))

    for (i in 1:5){
        plot(1:i)
    }
    windows.options(record=FALSE) #stops recording.
}
plot.fun()

This will however keep all previous plots in the history for browsing as well, so if you run this code 3 times you'll have 15 plots in the plot history. Also note that the open plot window will keep on recording until you turn off the recording in the menu.

You can play with the plot history, as you'll have a variable .SavedPlots which contains the saved plot history. It can be cleared using the menu History > clear history in the plot window. If you want to clear the history from the console, you could hack that by

.SavedPlots <- NULL

But I advise you not to do this, as changing the .SavedPlots variable can cause R to crash.

See also ?windows and ?recordPlot for a bit more information. But as you're getting close to the internal code of R, be warned that you can get pretty awkward behaviour if you start playing around with these things.


问:
Slicing of list impossible after modifying __getitem__
For a specific use case I want to define a list class that returns 0 if an index is either negative or out of range.

My current approach is already serving the specific purpose:

```<code>class mlist(list):
    def __getitem__(self, n):
        if (len(self)<=n) or (n<0):
            return 0
        return super(mlist, self).__getitem__(n)

l = mlist([1,2,3,4])
l[-2]
>>> 0
l[10]
>>> 0
</code>```

But unfortunately, it causes some bad behavior when slicing the list:

```<code>l[0:2]
>>> TypeError: '<=' not supported between instances of 'int' and 'slice'
</code>```

Is there a way to fix this problem?

答:
The issue is that the argument n is anything you pass between square brackets, whether is is an index (so type int), or a slice (of type slice).

Your current code only works in the case n is of type int, it does not take care of slices properly.

If you want to keep slicing functionality the same as default, why not call super().__getitem__(n) ?

```<code>class mlist(list):
    def __getitem__(self, n):
        # If n is a slice
        if isinstance(n, slice):
            return super().__getitem__(n)

        # Otherwise
        if len(self)<=n or n<0:
            return 0
        return super(mlist, self).__getitem__(n)
</code>```

However, if you want to implement your own logic for slices, you can do so inside the if isinstance(n, slice): block.

Body:
For a specific use case I want to define a list class that returns 0 if an index is either negative or out of range.

My current approach is already serving the specific purpose:

class mlist(list):
    def __getitem__(self, n):
        if (len(self)<=n) or (n<0):
            return 0
        return super(mlist, self).__getitem__(n)

l = mlist([1,2,3,4])
l[-2]
>>> 0
l[10]
>>> 0

But unfortunately, it causes some bad behavior when slicing the list:

l[0:2]
>>> TypeError: '<=' not supported between instances of 'int' and 'slice'

Is there a way to fix this problem?

Body:
The issue is that the argument n is anything you pass between square brackets, whether is is an index (so type int), or a slice (of type slice).

Your current code only works in the case n is of type int, it does not take care of slices properly.

If you want to keep slicing functionality the same as default, why not call super().__getitem__(n) ?

class mlist(list):
    def __getitem__(self, n):
        # If n is a slice
        if isinstance(n, slice):
            return super().__getitem__(n)

        # Otherwise
        if len(self)<=n or n<0:
            return 0
        return super(mlist, self).__getitem__(n)

However, if you want to implement your own logic for slices, you can do so inside the if isinstance(n, slice): block.


问:
Is it possible to compile and run the dlib library on embedded devices with ARM Cortex-M7 processors?
I have just started using the amazing dlib library in Visual Studio and I have been able to compile and run the face detection examples. I was wondering if it would be possible to compile and run the library on an Mbed device, such as this one, with an M7 (or other M-series) processor. In other words, what specifications should I look out for to determine whether a microcontroller can, if at all, run dlib. Note that Mbed devices run C++ code, so it would be possible to copy and paste the source code of dlib and compile it, but I want to know if this is possible before I purchase a board. Also, if the RAM and ROM of the board are not enough, I can always attach external RAM/ROM.

Alternatively, if anyone knows of a library that can perform face detection or recognition on an embedded device, I would be happy to hear it.

Thanks.

答: Take a look at Tensorflow Lite for Microcontrollers.  You can put these on embedded devices.  Wake words and object detection runs easily on various boards (Arduino Nano 33, SparkFun Edge).  There's a compiler included for Mbed.</p>


问:
How to return number-loops in String? [Java]
I am practicing some exercises of java and I got some problems in returning this in String as asked in the question.

"Write nested for-loops to produce the following output from the given
  input n."

Can someone help me to return this same logic in String? [Java]

```<code>public String numberLoops(int n) {
    int n = 8;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < n; j++) {
            if (j < n - i) {
                System.out.print(".");
            } else if (j == j) {
                System.out.print(i);
            }

        }
        if (i < n) {
            System.out.print("");
        }
        System.out.println();
    }
    return null;
}
</code>```

答: you can use object stringbuider to append the output</p>

Body:
I am practicing some exercises of java and I got some problems in returning this in String as asked in the question.

"Write nested for-loops to produce the following output from the given
  input n."

Can someone help me to return this same logic in String? [Java]

public String numberLoops(int n) {
    int n = 8;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < n; j++) {
            if (j < n - i) {
                System.out.print(".");
            } else if (j == j) {
                System.out.print(i);
            }

        }
        if (i < n) {
            System.out.print("");
        }
        System.out.println();
    }
    return null;
}


问:
How to catch an ActiveRecord::RecordInvalid error in rails/rspec
I want to catch an ActiveRecord error on Rspec: (I'm also using a factory)

Rspec

```<code>it "should throw an error" do
    animal = create(:animal)
    food_store = -1;
    expect(animal.update!(food_store: food_store)).to raise_error(ActiveRecord::RecordInvalid)
</code>```

Validator:

```<code>class AnimalValidator < ActiveModel::Validator
  def validate(record)
    if record.food_store < 1
      record.errors[:food_store] << "store can't be negative"
    end
  end
end
</code>```

I keep getting this error message:

```<code> Failure/Error: expect(animal.update!(food_store: new_share)).raise_error(ActiveRecord::RecordInvalid)

 ActiveRecord::RecordInvalid:
   Validation failed: store can't be negative
</code>```

How am I suppose to catch this activeRecord error?

答:
With raise_error, you need to expect a block. Without a block, it'll execute the animal.update! code and try to pass the return value of that method call to the expect method as a parameter, but it can't because it's already errors out. With a block, it defers execution of the block until the expect tells it to run (i.e., with yield or similar) and it gives RSpec a chance to intercept the exception.

So, use:

```<code>expect { animal.update!(food_store: food_store) }.to raise_error(ActiveRecord::RecordInvalid)
</code>```

instead

Body:
I want to catch an ActiveRecord error on Rspec: (I'm also using a factory)

Rspec

it "should throw an error" do
    animal = create(:animal)
    food_store = -1;
    expect(animal.update!(food_store: food_store)).to raise_error(ActiveRecord::RecordInvalid)

Validator:

class AnimalValidator < ActiveModel::Validator
  def validate(record)
    if record.food_store < 1
      record.errors[:food_store] << "store can't be negative"
    end
  end
end

I keep getting this error message:

 Failure/Error: expect(animal.update!(food_store: new_share)).raise_error(ActiveRecord::RecordInvalid)

 ActiveRecord::RecordInvalid:
   Validation failed: store can't be negative

How am I suppose to catch this activeRecord error?

Body:
With raise_error, you need to expect a block. Without a block, it'll execute the animal.update! code and try to pass the return value of that method call to the expect method as a parameter, but it can't because it's already errors out. With a block, it defers execution of the block until the expect tells it to run (i.e., with yield or similar) and it gives RSpec a chance to intercept the exception.

So, use:

expect { animal.update!(food_store: food_store) }.to raise_error(ActiveRecord::RecordInvalid)

instead


问:
Plone 4.0.5 unified installer failing on Ubuntu 11.04 (natty) with zip/zlib error
I am a Plone newbie and am trying to install Plone 4.0.5 on Ubuntu 11.04 Natty using the Unified Installer.

I unpack the installer and run the ./install.sh zeo as root and I get the following error:

```
ZEO Cluster Install selected

Detailed installation log being written to /tmp/Plone-4.0.5-UnifiedInstaller/install.log

Root install method chosen. Will install for use by system user plone

Installing Plone 4.0.5 at /usr/local/Plone

User 'plone' already exists. No need to create it.
Skipping libjpeg build
Skipping zlib build
Skipping readline build
Installing Python 2.6.6. This takes a while...
Traceback (most recent call last):
  File "", line 1, in
LookupError: unknown encoding: zip
Python zlib support is missing; something went wrong in the zlib or python build.

Installation has failed.
See the detailed installation log at /tmp/Plone-4.0.5-UnifiedInstaller/install.log
to determine the cause.
```

I have installed these ubuntu packages too:

```
apt-get install zlib1g zlib1g-dev zlibc libghc6-zlib-dev zlibc
```

The install.log is quite big - I'm just including mentions of zlib here:

```
Starting at Tue May 17 14:12:46 SAST 2011
configure: WARNING: unrecognized options: --with-readline, --with-zlib, --disable-tk, --with-cxx
...
Failed to find the necessary bits to build these modules:
_bsddb             _sqlite3           _tkinter
bsddb185           dbm                gdbm
sunaudiodev        zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Failed to build these modules:
crypt              nis
...
```

I can't find a setup.py in the installation files.

Any ideas what I should do or what I should be looking for?

Thank you.

答:
Its an issue with the Python disutils and the new multilib setup of natty.  I ran into the same issue trying to get sqlite support in Python built from source.

You can hack around it in the detect modules section of the setup.py

http://bugs.python.org/issue9762

Edit:

To work around it, change lib_dirs in the python setup.py (around line 408) to this (for an x86_64 machine):

```<code>lib_dirs = self.compiler.library_dirs + [
    '/lib64', '/usr/lib64',
    '/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu',
    ]
</code>```

(the /usr/lib/x86_64-linux-gnu is missing)

Body:
I am a Plone newbie and am trying to install Plone 4.0.5 on Ubuntu 11.04 Natty using the Unified Installer.

I unpack the installer and run the ./install.sh zeo as root and I get the following error:

ZEO Cluster Install selected

Detailed installation log being written to /tmp/Plone-4.0.5-UnifiedInstaller/install.log

Root install method chosen. Will install for use by system user plone

Installing Plone 4.0.5 at /usr/local/Plone

User 'plone' already exists. No need to create it.
Skipping libjpeg build
Skipping zlib build
Skipping readline build
Installing Python 2.6.6. This takes a while...
Traceback (most recent call last):
  File "", line 1, in
LookupError: unknown encoding: zip
Python zlib support is missing; something went wrong in the zlib or python build.

Installation has failed.
See the detailed installation log at /tmp/Plone-4.0.5-UnifiedInstaller/install.log
to determine the cause.

I have installed these ubuntu packages too:

apt-get install zlib1g zlib1g-dev zlibc libghc6-zlib-dev zlibc

The install.log is quite big - I'm just including mentions of zlib here:

Starting at Tue May 17 14:12:46 SAST 2011
configure: WARNING: unrecognized options: --with-readline, --with-zlib, --disable-tk, --with-cxx
...
Failed to find the necessary bits to build these modules:
_bsddb             _sqlite3           _tkinter
bsddb185           dbm                gdbm
sunaudiodev        zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

Failed to build these modules:
crypt              nis
...

I can't find a setup.py in the installation files.

Any ideas what I should do or what I should be looking for?

Thank you.

Body:
Its an issue with the Python disutils and the new multilib setup of natty.  I ran into the same issue trying to get sqlite support in Python built from source.

You can hack around it in the detect modules section of the setup.py

http://bugs.python.org/issue9762

Edit:

To work around it, change lib_dirs in the python setup.py (around line 408) to this (for an x86_64 machine):

lib_dirs = self.compiler.library_dirs + [
    '/lib64', '/usr/lib64',
    '/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu',
    ]

(the /usr/lib/x86_64-linux-gnu is missing)


问:
Execution failed for task ':app:mergeDexDebug'. Firestore | Flutter
Trying to use Firestore in my project. My project is a brand new one, but having problems running the app on my device without getting an error:
Execution failed for task ':app:mergeDexDebug'.

My app is using AndroidX. I've added my google-services.json file, followed the steps etc.

Yaml file:

```<code>dependencies:
  cloud_firestore: ^0.13.3
</code>```

android/build.gradle:

```<code>com.google.gms:google-services:4.3.3
</code>```

Full error:

FAILURE: Build failed with an exception.

What went wrong:
      Execution failed for task ':app:mergeDexDebug'.
  A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
  com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
       The number of method references in a .dex file cannot exceed 64K.
       Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

答:
Fixed the issue, but don't understand why. Why do I need to enable multiDex when I believe Firestore is using AndroidX?

Anyway, the fix. Add multiDexEnabled true to your app/build.gradle

```<code>defaultConfig {
    // TODO: Specify your own unique Application ID
    (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.poll"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    //This line here...
    multiDexEnabled true
}
</code>```

Body:
Trying to use Firestore in my project. My project is a brand new one, but having problems running the app on my device without getting an error:
Execution failed for task ':app:mergeDexDebug'.

My app is using AndroidX. I've added my google-services.json file, followed the steps etc.

Yaml file:

dependencies:
  cloud_firestore: ^0.13.3

android/build.gradle:

com.google.gms:google-services:4.3.3

Full error:

FAILURE: Build failed with an exception.

What went wrong:
      Execution failed for task ':app:mergeDexDebug'.
  A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
  com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
       The number of method references in a .dex file cannot exceed 64K.
       Learn how to resolve this issue at https://developer.android.com/tools/building/multidex.html

Body:
Fixed the issue, but don't understand why. Why do I need to enable multiDex when I believe Firestore is using AndroidX?

Anyway, the fix. Add multiDexEnabled true to your app/build.gradle

defaultConfig {
    // TODO: Specify your own unique Application ID
    (https://developer.android.com/studio/build/application-id.html).
    applicationId "com.example.poll"
    minSdkVersion 16
    targetSdkVersion 28
    versionCode flutterVersionCode.toInteger()
    versionName flutterVersionName
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    //This line here...
    multiDexEnabled true
}


问:
Foreign key mismatch when insert (SQLite)
So here's my sqlite code..

```<code>CREATE TABLE "performance" (
    "title" TEXT,
    "date"  date,
    "theaterID" INTEGER,

PRIMARY KEY("title","date","theaterID"),

    FOREIGN KEY("title") REFERENCES "movies"("title"),
    FOREIGN KEY("theaterID") REFERENCES "theater"("theaterID")
);

CREATE TABLE "reservation" (
    "userName"  TEXT,
    "reservationID" INTEGER auto_increment,
    "date"  date,
    "theaterID" INTEGER,
    PRIMARY KEY("userName","reservationID","date","theaterID"),
    FOREIGN KEY("date") REFERENCES "performance"("date"),
    FOREIGN KEY("userName") REFERENCES "user"("userName"),
    FOREIGN KEY("theaterID") REFERENCES "theater"("theaterID")
);
</code>```

And I make following inserts in specific order:

```<code>INSERT INTO performance(title,date,theaterID)
VALUES("The Godfather", 20200230, 9);

INSERT INTO reservation(userName,reservationID,date,theaterID)
VALUES("user1", 1 , 20200230, 9);
</code>```

Everything works until I try to insert a reservation. I get the following error:

"foreign key mismatch error - 'reservation' referencing 'performance'"

I can't seem to find the reason for it? What changes do I have to do?

答:
check this post
What is causing Foreign Key Mismatch error?

Problem could be:

The parent key columns named in the foreign key constraint are not
the primary key of the parent table and are not subject to a unique
constraint using collating sequence specified in the CREATE TABLE

Body:
So here's my sqlite code..

CREATE TABLE "performance" (
    "title" TEXT,
    "date"  date,
    "theaterID" INTEGER,

PRIMARY KEY("title","date","theaterID"),

    FOREIGN KEY("title") REFERENCES "movies"("title"),
    FOREIGN KEY("theaterID") REFERENCES "theater"("theaterID")
);

CREATE TABLE "reservation" (
    "userName"  TEXT,
    "reservationID" INTEGER auto_increment,
    "date"  date,
    "theaterID" INTEGER,
    PRIMARY KEY("userName","reservationID","date","theaterID"),
    FOREIGN KEY("date") REFERENCES "performance"("date"),
    FOREIGN KEY("userName") REFERENCES "user"("userName"),
    FOREIGN KEY("theaterID") REFERENCES "theater"("theaterID")
);

And I make following inserts in specific order:

INSERT INTO performance(title,date,theaterID)
VALUES("The Godfather", 20200230, 9);

INSERT INTO reservation(userName,reservationID,date,theaterID)
VALUES("user1", 1 , 20200230, 9);

Everything works until I try to insert a reservation. I get the following error:

"foreign key mismatch error - 'reservation' referencing 'performance'"

I can't seem to find the reason for it? What changes do I have to do?


问:
HTML5 php contact form script confirmation
I'm having some trouble with a script confirmation. By standard it's set to hide the contact form and display a confirmation message but it's not working for all browsers. After some tests I realized it doesn't work for most IE versions, which are around 40% of my visitors.

How do I replace the hide-and-show-msg to a "thankyou.html"? I'm guessing this works as most IEs fail to show the confirmation message although they manage to hide the form. The code in 'header' is currently:

```<code><script src="php/js/jquery.validate.js"></script>
<script src="php/js/jquery.placeholder.js"></script>
<script src="php/js/jquery.form.js"></script>
<script>
$(function(){
$('#contact').validate({
submitHandler: function(form) {
    $(form).ajaxSubmit({
    url: 'thankyou.php',
    success: function() {
    $('#contact').hide();
    $('#contact-form').append("<p class='thanks'>Thank you! The message was sent.</center></p>")
    }
    });
    }
});
});
</script>
</code>```

答:
Set thankyou.php as the form action, and use jQuery validate() only to ensure that the form fields were completed:

```<code><script>
    $(function(){
       $('#contact').validate({
            // Validate your form fields here
       });
    });
</script>
...
<form id="contact" action="thankyou.php" method="post">
</code>```

Use thankyou.php to process the form submission and redirect the user to the thankyou.html:

```<code><?php
header("Location: thankyou.html");
?>
</code>```

This approach will eliminate the need for the AJAX call and form hiding.

Body:
Set thankyou.php as the form action, and use jQuery validate() only to ensure that the form fields were completed:

<script>
    $(function(){
       $('#contact').validate({
            // Validate your form fields here
       });
    });
</script>
...
<form id="contact" action="thankyou.php" method="post">

Use thankyou.php to process the form submission and redirect the user to the thankyou.html:

<?php
header("Location: thankyou.html");
?>

This approach will eliminate the need for the AJAX call and form hiding.