问:
How to return a vector of pairs
I am trying to solve this challenge from testdome. I think my approach to the solution is not optimal (or even correct). But before changing my approach I was wondering is it possible to return a vector of pairs? if yes, how?.
Below you will see the challenge, and afterwards my code.
Thank you.

#include <stdexcept>
#include <iostream>
#include <vector>
#include <utility>

std::pair<int, int> findTwoSum(const std::vector<int>& list, int sum)
{
    int tracker = list.size();
    std::pair <int, int> result;
    std::vector <std::pair <int,int>> list1(100);
    for (int i = 0; i < (int)list.size(); i++){
        for (int j = ((int)list.size()-tracker); j < (int)list.size(); j++){

            if (list[i]+list[j] == sum)
                list1.push_back(std::make_pair(list[i], list[j]) );
        }
        tracker--;
    }

    return list1; // I am stuck here

    //throw std::logic_error("Waiting to be implemented");
}

#ifndef RunTests
int main()
{
    std::vector<int> list = {3, 1, 5, 7, 5, 9};
    std::pair<int, int> indices = findTwoSum(list, 10);
    std::cout << indices.first << '\n' << indices.second;
}
#endif
```

<p><strong>EDIT</strong></p>

<p>Initially, this was my solution. But once I posted it on testdome, I am getting zero correct answers out of 4 categories. It is test number 5. That is why I thought, returning only one answer was wrong.</p>

<pre class="lang-c++ prettyprint-override"><code>
#include <stdexcept>
#include <iostream>
#include <vector>
#include <utility>

std::pair<int, int> findTwoSum(const std::vector<int>& list, int sum)
{
    int tracker = list.size();
    std::pair <int, int> result;
    std::vector <std::pair <int,int>> list1(100);
    for (int i = 0; i < (int)list.size(); i++){
        for (int j = ((int)list.size()-tracker); j < (int)list.size(); j++){
            if (list[i]+list[j] == sum)

                return result=std::make_pair(list[i], list[j]);
        }
        tracker--;
    }

    return std::make_pair(-1,-1);

    //throw std::logic_error("Waiting to be implemented");
}

#ifndef RunTests
int main()
{
    std::vector<int> list = {3, 1, 5, 7, 5, 9};
    std::pair<int, int> indices = findTwoSum(list, 10);
    std::cout << indices.first << '\n' << indices.second;
}
#endif
</code>```

答:
Use can do this:</p>

```<code> std::vector<std::pair<int, int> >findTwoSum(const
      std::vector<int>& list, int sum)
{
    int tracker = list.size();
    std::pair <int, int> result;
    std::vector <std::pair <int,int>> list1(100);
    /* ...*/
     return list1;
  }
  int main()
 {
      std::vector<int> list = {3, 1, 5, 7, 5, 9};
      auto indices = findTwoSum(list, 10);
      std::cout << indices[0].first << '\n' << indices[0].second;
 }
</code>```

Title: How to return a vector of pairs

Body:
I am trying to solve this challenge from testdome. I think my approach to the solution is not optimal (or even correct). But before changing my approach I was wondering is it possible to return a vector of pairs? if yes, how?.
Below you will see the challenge, and afterwards my code.
Thank you.

#include <stdexcept>
#include <iostream>
#include <vector>
#include <utility>

std::pair<int, int> findTwoSum(const std::vector<int>& list, int sum)
{
    int tracker = list.size();
    std::pair <int, int> result;
    std::vector <std::pair <int,int>> list1(100);
    for (int i = 0; i < (int)list.size(); i++){
        for (int j = ((int)list.size()-tracker); j < (int)list.size(); j++){

            if (list[i]+list[j] == sum)
                list1.push_back(std::make_pair(list[i], list[j]) );
        }
        tracker--;
    }

    return list1; // I am stuck here

    //throw std::logic_error("Waiting to be implemented");
}

#ifndef RunTests
int main()
{
    std::vector<int> list = {3, 1, 5, 7, 5, 9};
    std::pair<int, int> indices = findTwoSum(list, 10);
    std::cout << indices.first << '\n' << indices.second;
}
#endif

EDIT

Initially, this was my solution. But once I posted it on testdome, I am getting zero correct answers out of 4 categories. It is test number 5. That is why I thought, returning only one answer was wrong.

#include <stdexcept>
#include <iostream>
#include <vector>
#include <utility>

std::pair<int, int> findTwoSum(const std::vector<int>& list, int sum)
{
    int tracker = list.size();
    std::pair <int, int> result;
    std::vector <std::pair <int,int>> list1(100);
    for (int i = 0; i < (int)list.size(); i++){
        for (int j = ((int)list.size()-tracker); j < (int)list.size(); j++){
            if (list[i]+list[j] == sum)

                return result=std::make_pair(list[i], list[j]);
        }
        tracker--;
    }

    return std::make_pair(-1,-1);

    //throw std::logic_error("Waiting to be implemented");
}

#ifndef RunTests
int main()
{
    std::vector<int> list = {3, 1, 5, 7, 5, 9};
    std::pair<int, int> indices = findTwoSum(list, 10);
    std::cout << indices.first << '\n' << indices.second;
}
#endif

Body:
Use can do this:

 std::vector<std::pair<int, int> >findTwoSum(const
      std::vector<int>& list, int sum)
{
    int tracker = list.size();
    std::pair <int, int> result;
    std::vector <std::pair <int,int>> list1(100);
    /* ...*/
     return list1;
  }
  int main()
 {
      std::vector<int> list = {3, 1, 5, 7, 5, 9};
      auto indices = findTwoSum(list, 10);
      std::cout << indices[0].first << '\n' << indices[0].second;
 }


来源: stackexchange

问:
Get username using select prepared statement
I wrote this code, but it is just outputting "1". It should output the username of the selected user.  </p>

```<code>$uid = $_GET['id'];
if (empty($uid)) {
    echo "Error: Wrong input of values.";
} else {
    $stmt = $conn->prepare("SELECT username FROM usersinfo WHERE id = ?");
    $stmt->bind_param("s", $uid);
    $stmt->execute();
    $result = $stmt->fetch();
    echo $result;
    $stmt->close();
    $conn->close();
}
</code>```

答:
fetch() doesn't return the results. There is no useful information returned by that function. What you need to do is get the mysqli result. There are 2 ways to do it.

The simpler way:

```<code>$stmt = $conn->prepare("SELECT username FROM usersinfo WHERE id = ?");
$stmt->bind_param("s", $uid);
$stmt->execute();
$result = $stmt->get_result(); // Get the result of the above statement.
$firstRow = $result->fetch_array(); // Get the first result into an array
if ($firstRow) {
    echo $firstRow[0];
    //or
    echo $firstRow['username'];
}
</code>```

Here we get the mysqli result object and then we ask for a single row.

Another way using bind_result():

```<code>$stmt = $conn->prepare("SELECT username FROM usersinfo WHERE id = ?");
$stmt->bind_param("s", $uid);
$stmt->execute();
$stmt->bind_result($username); // Bind a single column from SELECT to a single variable
$stmt->fetch(); // Fetch the first row. It will populate the variable
echo $username;
</code>```

This is more difficult to read in my opinion. Also if you wanted to get more columns it would quickly get very complicated.

To be honest mysqli is not very friendly and is very cumbersome to use. I strongly recommend to switch to PDO, but if you can't try to encapsulate the mysqli functions in some class or function. YCS has an example of such helper function. I have recently written an example of how to extend a mysqli class with a wrapper class.

I have added a simple method to the mysqli class and take a look how simpler the statements have become.

```<code>class DBClass extends mysqli {
    public function __construct(
        $host = null,
        $username = null,
        $passwd = null,
        $dbname = null,
        $port = null,
        $socket = null
    ) {
        mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
        parent::__construct($host, $username, $passwd, $dbname, $port, $socket);
        $this->set_charset('utf8mb4');
    }

    public function safeQuery(string $sql, array $params = []): ?array {
        $stmt = $this->prepare($sql);
        if ($params) {
            $stmt->bind_param(str_repeat("s", count($params)), ...$params);
        }
        $stmt->execute();
        if ($result = $stmt->get_result()) {
            return $result->fetch_all(MYSQLI_BOTH);
        }
        return null;
    }
}
</code>```

Example usage:

```<code>$results = $conn->safeQuery("SELECT username FROM users WHERE id = ?", [$uid]);
if($results){
    echo $results[0][0]; // first row, first column
    // or
    echo $results[0]['username']; // first row, get column by name
}
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I wrote this code, but it is just outputting "1". It should output the username of the selected user.

$uid = $_GET['id'];
if (empty($uid)) {
    echo "Error: Wrong input of values.";
} else {
    $stmt = $conn->prepare("SELECT username FROM usersinfo WHERE id = ?");
    $stmt->bind_param("s", $uid);
    $stmt->execute();
    $result = $stmt->fetch();
    echo $result;
    $stmt->close();
    $conn->close();
}

Body:
fetch() doesn't return the results. There is no useful information returned by that function. What you need to do is get the mysqli result. There are 2 ways to do it.

The simpler way:

$stmt = $conn->prepare("SELECT username FROM usersinfo WHERE id = ?");
$stmt->bind_param("s", $uid);
$stmt->execute();
$result = $stmt->get_result(); // Get the result of the above statement.
$firstRow = $result->fetch_array(); // Get the first result into an array
if ($firstRow) {
    echo $firstRow[0];
    //or
    echo $firstRow['username'];
}

Here we get the mysqli result object and then we ask for a single row.

Another way using bind_result():

$stmt = $conn->prepare("SELECT username FROM usersinfo WHERE id = ?");
$stmt->bind_param("s", $uid);
$stmt->execute();
$stmt->bind_result($username); // Bind a single column from SELECT to a single variable
$stmt->fetch(); // Fetch the first row. It will populate the variable
echo $username;

This is more difficult to read in my opinion. Also if you wanted to get more columns it would quickly get very complicated.

To be honest mysqli is not very friendly and is very cumbersome to use. I strongly recommend to switch to PDO, but if you can't try to encapsulate the mysqli functions in some class or function. YCS has an example of such helper function. I have recently written an example of how to extend a mysqli class with a wrapper class.

I have added a simple method to the mysqli class and take a look how simpler the statements have become.

class DBClass extends mysqli {
    public function __construct(
        $host = null,
        $username = null,
        $passwd = null,
        $dbname = null,
        $port = null,
        $socket = null
    ) {
        mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
        parent::__construct($host, $username, $passwd, $dbname, $port, $socket);
        $this->set_charset('utf8mb4');
    }

    public function safeQuery(string $sql, array $params = []): ?array {
        $stmt = $this->prepare($sql);
        if ($params) {
            $stmt->bind_param(str_repeat("s", count($params)), ...$params);
        }
        $stmt->execute();
        if ($result = $stmt->get_result()) {
            return $result->fetch_all(MYSQLI_BOTH);
        }
        return null;
    }
}

Example usage:

$results = $conn->safeQuery("SELECT username FROM users WHERE id = ?", [$uid]);
if($results){
    echo $results[0][0]; // first row, first column
    // or
    echo $results[0]['username']; // first row, get column by name
}


问:
How do I round a percentage calculation in SQL?
I want the below percentage calculation to be to 2 decimal places.

```<code> SELECT
        (SUM(recovered)/SUM(confirmed_cases)*100) AS recovery_rate
    FROM corona
</code>```

However, the following does not work:

```<code>SELECT
    ROUND((SUM(recovered)/SUM(confirmed_cases)*100), 2) AS recovery_rate
FROM corona
</code>```

I suspect this is a data type issue since the ROUND() takes a number as its first argument and I'm guessing my SUM(...) percentage calculation isn't a number.

What's the fix? Also, is there a general percentage function in SQL?

答:
The problem is probably integer division -- but that depends on the database.  You don't mention the database or the types of your columns, but 1/2 = 0, not 0.5 in a database such as SQL Server which does integer division

This is easily fixed.  Just change 100 to 100.0:

```<code>SELECT ROUND(SUM(recovered) * 100.0 / SUM(confirmed_cases), 2) AS recovery_rate
FROM corona
</code>```

Body:
I want the below percentage calculation to be to 2 decimal places.

 SELECT
        (SUM(recovered)/SUM(confirmed_cases)*100) AS recovery_rate
    FROM corona

However, the following does not work:

SELECT
    ROUND((SUM(recovered)/SUM(confirmed_cases)*100), 2) AS recovery_rate
FROM corona

I suspect this is a data type issue since the ROUND() takes a number as its first argument and I'm guessing my SUM(...) percentage calculation isn't a number.

What's the fix? Also, is there a general percentage function in SQL?

Body:
The problem is probably integer division -- but that depends on the database.  You don't mention the database or the types of your columns, but 1/2 = 0, not 0.5 in a database such as SQL Server which does integer division

This is easily fixed.  Just change 100 to 100.0:

SELECT ROUND(SUM(recovered) * 100.0 / SUM(confirmed_cases), 2) AS recovery_rate
FROM corona


问:
In python how to delete a series of columns every nth element in a numpy 3d array?
Similar to this question, say I have a 3D Numpy array, above which I've added a comment label for clarity:

```<code>          #C  C  C  R  R  C  C  C  R  R  C  C  C
    a = [[[10,11,12,13,14,15,16,17,18,19,20,21,22],
          [23,24,25,26,27,28,29,30,31,32,33,34,35]],

         [[36,37,38,39,40,41,42,43,44,45,46,47,48],
          [48,49,50,51,52,53,54,55,56,57,58,59,60]],

         [[61,62,63,64,65,66,67,68,69,70,71,72,73],
          [74,75,76,77,78,79,80,81,82,83,84,85,86]]]
</code>```

can I delete the columns labelled R in one line of code? So delete two columns every fifth element starting at index 3. In this case, the resulting array would look like this:

```<code>          #C  C  C  C  C  C  C  C  C
    a = [[[10,11,12,15,16,17,20,21,22],
          [23,24,25,28,29,30,33,34,35]],

          [[36,37,38,41,42,43,46,47,48],
           [48,49,50,53,54,55,58,59,60]],

          [[61,62,63,66,67,68,71,72,73],
           [74,75,76,79,80,81,84,85,86]]]
</code>```

I'd like to make the code more generic so it can handle deleting pairs of columns in 3D arrays of varying sizes and locations. For this example, I can delete one column at a time using this:

```<code>    start = 3
    step = 5
    a = numpy.delete(big, numpy.s_[start:numpy.size(big, 2):step], 2)
    a = numpy.delete(a, numpy.s_[start:numpy.size(a, 2):step - 1], 2)
</code>```

But is there a way to specify a range of columns for deletion and so complete the task in one line of code?

Body:
Similar to this question, say I have a 3D Numpy array, above which I've added a comment label for clarity:

          #C  C  C  R  R  C  C  C  R  R  C  C  C
    a = [[[10,11,12,13,14,15,16,17,18,19,20,21,22],
          [23,24,25,26,27,28,29,30,31,32,33,34,35]],

         [[36,37,38,39,40,41,42,43,44,45,46,47,48],
          [48,49,50,51,52,53,54,55,56,57,58,59,60]],

         [[61,62,63,64,65,66,67,68,69,70,71,72,73],
          [74,75,76,77,78,79,80,81,82,83,84,85,86]]]

can I delete the columns labelled R in one line of code? So delete two columns every fifth element starting at index 3. In this case, the resulting array would look like this:

          #C  C  C  C  C  C  C  C  C
    a = [[[10,11,12,15,16,17,20,21,22],
          [23,24,25,28,29,30,33,34,35]],

          [[36,37,38,41,42,43,46,47,48],
           [48,49,50,53,54,55,58,59,60]],

          [[61,62,63,66,67,68,71,72,73],
           [74,75,76,79,80,81,84,85,86]]]

I'd like to make the code more generic so it can handle deleting pairs of columns in 3D arrays of varying sizes and locations. For this example, I can delete one column at a time using this:

    start = 3
    step = 5
    a = numpy.delete(big, numpy.s_[start:numpy.size(big, 2):step], 2)
    a = numpy.delete(a, numpy.s_[start:numpy.size(a, 2):step - 1], 2)

But is there a way to specify a range of columns for deletion and so complete the task in one line of code?

Body:
Just select the indices you want:

a=a[:,:,[0,1,2,5,6,7,10,11,12]]

Or, in a more general way:

a=a[:,:,[i for i in range(13) if i%5 in [0,1,2]]]

output:

array([[[10, 11, 12, 15, 16, 17, 20, 21, 22],
        [23, 24, 25, 28, 29, 30, 33, 34, 35]],
       [[36, 37, 38, 41, 42, 43, 46, 47, 48],
        [48, 49, 50, 53, 54, 55, 58, 59, 60]],
       [[61, 62, 63, 66, 67, 68, 71, 72, 73],
        [74, 75, 76, 79, 80, 81, 84, 85, 86]]])


问:
How can I convert array of bytes to a string in PHP?
I have an array of bytes that I'd like to map to their ASCII equivalents.

How can I do this?

答:
Yet another way:

```<code>$str = vsprintf(str_repeat('%c', count($bytes)), $bytes);
</code>```

Hurray!

ContentLicense: CC BY-SA 3.0

Body:
Yet another way:

$str = vsprintf(str_repeat('%c', count($bytes)), $bytes);

Hurray!


问:
Why isn't my PHP SHA256 hash equivalent to C# SHA256Managed hash
Why aren't these the same?

php:

```<code>    $hash = hash('sha256', $userData['salt'] . hash('sha256', $password) );
</code>```

c#

```<code>    public static string ComputeHash(string plainText, string salt)
    {
        // Convert plain text into a byte array.
        byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
        byte[] saltBytes = Encoding.UTF8.GetBytes(salt);

        SHA256Managed hash = new SHA256Managed();

        // Compute hash value of salt.
        byte[] plainHash = hash.ComputeHash(plainTextBytes);

        byte[] concat = new byte[plainHash.Length + saltBytes.Length];

        System.Buffer.BlockCopy(saltBytes, 0, concat, 0, saltBytes.Length);
        System.Buffer.BlockCopy(plainHash, 0, concat, saltBytes.Length, plainHash.Length);

        byte[] tHashBytes = hash.ComputeHash(concat);

        // Convert result into a base64-encoded string.
        string hashValue = Convert.ToBase64String(tHashBytes);

        // Return the result.
        return hashValue;
    }
</code>```

答:
C#

```<code>string toHash = "abcdefg";
SHA256Managed hash = new SHA256Managed();
byte[] signatureData = hash.ComputeHash(new UnicodeEncoding().GetBytes(toHash));
string hashResult = System.Convert.ToBase64String(signatureData);
</code>```

PHP

```<code>print base64_encode(hash("sha256",mb_convert_encoding("abcdefg","UTF-16LE"),true));
</code>```

Works for me.

Body:
Why aren't these the same?

php:

    $hash = hash('sha256', $userData['salt'] . hash('sha256', $password) );

c#

    public static string ComputeHash(string plainText, string salt)
    {
        // Convert plain text into a byte array.
        byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
        byte[] saltBytes = Encoding.UTF8.GetBytes(salt);

        SHA256Managed hash = new SHA256Managed();

        // Compute hash value of salt.
        byte[] plainHash = hash.ComputeHash(plainTextBytes);

        byte[] concat = new byte[plainHash.Length + saltBytes.Length];

        System.Buffer.BlockCopy(saltBytes, 0, concat, 0, saltBytes.Length);
        System.Buffer.BlockCopy(plainHash, 0, concat, saltBytes.Length, plainHash.Length);

        byte[] tHashBytes = hash.ComputeHash(concat);

        // Convert result into a base64-encoded string.
        string hashValue = Convert.ToBase64String(tHashBytes);

        // Return the result.
        return hashValue;
    }

Body:
C#

string toHash = "abcdefg";
SHA256Managed hash = new SHA256Managed();
byte[] signatureData = hash.ComputeHash(new UnicodeEncoding().GetBytes(toHash));
string hashResult = System.Convert.ToBase64String(signatureData);

PHP

print base64_encode(hash("sha256",mb_convert_encoding("abcdefg","UTF-16LE"),true));

Works for me.


问:
Get all combinations for arbitrary number of elements
How can I make a method in Java which obtains input integer n, and an array of double x, and returns all combinations of n elements out of values in x.

Where x={1,2,3} and n=2,

the expected returns/combinations are
{1,1},{1,2},{1,3},{2,2},{2,1},{2,3},{3,1},{3,2},{3,3}
(the order is not ignored.) The number should be (int) Math.pow(x.length, n)

e.g.

```<code>static List<Double[]> getAll(int n, double[] x){
 List<Double[]> combinations = new ArrayList<>();
 //number of combinations should be x.length ^ n

 // when n = 1;
 for (int i=0;i<x.length;i++)
   combinations.add({x[i]});

 return combinations;
}

// return patterns[i] is the i th pattern
//which contains num-elements from the input depths,
//  patterns[i][j] is the j th double in patterns[i]
private double[][] void makePatterns(int num, double[] depths) {
    int patternN = (int) Math.pow(depths.length, num);
    double[][] patterns = new double[patternN][num];
    System.out.println(patterns.length);
    int i = 0;
    int k = 0;
    while (i < patternN) {
        for (int j = 0; j < num; j++) {
          //  System.out.println(i+" "+j+" "+(i / (int)Math.pow(depths.length, j))%depths.length);
            patterns[i][j] = x[(i / (int)Math.pow(depths.length, j))%depths.length];
        }
        i++;

    }
  return patterns;
}
</code>```

This makePatterns is where I started...

答:
I have an idea how to solve this with an iterative algorithm, without recursion:

```<code>import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main
{

    static List<int[]> getAll(int n, int[] x)
    {
        List<int[]> combinations = new ArrayList<>();

        // First step (0)
        // Create initial combinations, filled with the first number.
        for (int number = 0; number < x.length; number++)
        {
            int[] array = new int[n]; // the final size of each array is already known
            array[0] = x[number]; // fill the first number
            combinations.add(array);
        }

        // In each following step, we add one number to each combination
        for (int step = 1; step < n; step++)
        {
            // Backup the size because we do not want to process
            // the new items that are added by the following loop itself.
            int size = combinations.size();

            // Add one number to the existing combinations
            for (int combination = 0; combination < size; combination++)
            {
                // Add one number to the existing array
                int[] array = combinations.get(combination);
                array[step] = x[0];

                // For all additional numbers, create a copy of the array
                for (int number = 1; number < x.length; number++)
                {
                    int[] copy = Arrays.copyOf(array, array.length);
                    copy[step] = x[number];
                    combinations.add(copy);
                }
            }
        }

        return combinations;
    }

    public static void main(String[] args)
    {
        int[] x = {3, 5, 7};
        int n = 3;

        // Calculate all possible combinations
        List<int[]> combinations = getAll(n, x);

        // Print the result
        for (int[] combination : combinations)
        {
            System.out.println(Arrays.toString(combination));
        }
    }
}
</code>```

My thoughts were:

Each array has a well known size (n) so I can create them immediately with the final size.

For the first step (0), I fill the arrays with the numbers from x, leaving their remaining elements uninitialized:

```<code>[3, ?, ?]
[5, ?, ?]
[7, ?, ?]
</code>```

Then I fill the remaining elements of each array step by step. But during that, the number of possible combinations increases, so I makes copies of the existing arrays and add all possible combinations to the result list.

The next step (1) fills the second column:

```<code>[3, ?, ?]   update to  [3, 3, ?]
            copy to    [3, 5, ?]
            copy to    [3, 7, ?]
[5, ?, ?]   update to  [5, 3, ?]
            copy to    [5, 5, ?]
            copy to    [5, 7, ?]
[7, ?, ?]   update to  [7, 3, ?]
            copy to    [7, 5, ?]
            copy to    [7, 7, ?]
</code>```

The next step fills the third column:

```<code>[3, 3, ?]   update to  [3, 3, 3]
            copy to    [3, 3, 5]
            copy to    [3, 3, 7]
[3, 5, ?]   update to  [3, 5, 3]
            copy to    [3, 5, 5]
            copy to    [3, 5, 7]
[3, 7, ?]   update to  [3, 7, 3] ... and so on
[5, 3, ?]
[5, 5, ?]
[5, 7, ?]
[7, 3, ?]
[7, 5, ?]
[7, 7, ?]
</code>```

My code uses arrays of int, but that works as well with double. I think that algorithm will work with any number of iterations.

Body:
How can I make a method in Java which obtains input integer n, and an array of double x, and returns all combinations of n elements out of values in x.

Where x={1,2,3} and n=2,

the expected returns/combinations are
{1,1},{1,2},{1,3},{2,2},{2,1},{2,3},{3,1},{3,2},{3,3}
(the order is not ignored.) The number should be (int) Math.pow(x.length, n)

e.g.

static List<Double[]> getAll(int n, double[] x){
 List<Double[]> combinations = new ArrayList<>();
 //number of combinations should be x.length ^ n

 // when n = 1;
 for (int i=0;i<x.length;i++)
   combinations.add({x[i]});

 return combinations;
}

// return patterns[i] is the i th pattern
//which contains num-elements from the input depths,
//  patterns[i][j] is the j th double in patterns[i]
private double[][] void makePatterns(int num, double[] depths) {
    int patternN = (int) Math.pow(depths.length, num);
    double[][] patterns = new double[patternN][num];
    System.out.println(patterns.length);
    int i = 0;
    int k = 0;
    while (i < patternN) {
        for (int j = 0; j < num; j++) {
          //  System.out.println(i+" "+j+" "+(i / (int)Math.pow(depths.length, j))%depths.length);
            patterns[i][j] = x[(i / (int)Math.pow(depths.length, j))%depths.length];
        }
        i++;

    }
  return patterns;
}

This makePatterns is where I started...

Body:
I have an idea how to solve this with an iterative algorithm, without recursion:

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main
{

    static List<int[]> getAll(int n, int[] x)
    {
        List<int[]> combinations = new ArrayList<>();

        // First step (0)
        // Create initial combinations, filled with the first number.
        for (int number = 0; number < x.length; number++)
        {
            int[] array = new int[n]; // the final size of each array is already known
            array[0] = x[number]; // fill the first number
            combinations.add(array);
        }

        // In each following step, we add one number to each combination
        for (int step = 1; step < n; step++)
        {
            // Backup the size because we do not want to process
            // the new items that are added by the following loop itself.
            int size = combinations.size();

            // Add one number to the existing combinations
            for (int combination = 0; combination < size; combination++)
            {
                // Add one number to the existing array
                int[] array = combinations.get(combination);
                array[step] = x[0];

                // For all additional numbers, create a copy of the array
                for (int number = 1; number < x.length; number++)
                {
                    int[] copy = Arrays.copyOf(array, array.length);
                    copy[step] = x[number];
                    combinations.add(copy);
                }
            }
        }

        return combinations;
    }

    public static void main(String[] args)
    {
        int[] x = {3, 5, 7};
        int n = 3;

        // Calculate all possible combinations
        List<int[]> combinations = getAll(n, x);

        // Print the result
        for (int[] combination : combinations)
        {
            System.out.println(Arrays.toString(combination));
        }
    }
}

My thoughts were:

Each array has a well known size (n) so I can create them immediately with the final size.

For the first step (0), I fill the arrays with the numbers from x, leaving their remaining elements uninitialized:

[3, ?, ?]
[5, ?, ?]
[7, ?, ?]

Then I fill the remaining elements of each array step by step. But during that, the number of possible combinations increases, so I makes copies of the existing arrays and add all possible combinations to the result list.

The next step (1) fills the second column:

[3, ?, ?]   update to  [3, 3, ?]
            copy to    [3, 5, ?]
            copy to    [3, 7, ?]
[5, ?, ?]   update to  [5, 3, ?]
            copy to    [5, 5, ?]
            copy to    [5, 7, ?]
[7, ?, ?]   update to  [7, 3, ?]
            copy to    [7, 5, ?]
            copy to    [7, 7, ?]

The next step fills the third column:

[3, 3, ?]   update to  [3, 3, 3]
            copy to    [3, 3, 5]
            copy to    [3, 3, 7]
[3, 5, ?]   update to  [3, 5, 3]
            copy to    [3, 5, 5]
            copy to    [3, 5, 7]
[3, 7, ?]   update to  [3, 7, 3] ... and so on
[5, 3, ?]
[5, 5, ?]
[5, 7, ?]
[7, 3, ?]
[7, 5, ?]
[7, 7, ?]

My code uses arrays of int, but that works as well with double. I think that algorithm will work with any number of iterations.


问:
useState doesn't update the value, and the value keep remains null
I'm building my website with React, and I'm using useState to get the id of hovered item.

But when I use setState to get the value, it doesn't update and remain 'null'

So on console, I can see the event.target.id is recognized, but even after the setState event, the state value return null.

Can anybody give some clues on what is happening here?

Here's the code

```<code>import React from 'react'
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
import styled from 'styled-components'

const WorksTitle = props => {
  const { type, title, imgSrc, link, year } = props
  const [currentMenu, setCurrentMenu] = React.useState(null)

  const handleHover = event => {
    console.log(
      'event target: ',
      event.target,
      ' / ',
      'event target id: ',
      event.target.id
    )
    **console.log(event.target.id)
    setCurrentMenu(event.target.id)
    console.log(currentMenu)**
  }

  const handleMouseOut = event => {
    console.log('mouse out from:', event.target.id)
    setCurrentMenu(null)
  }

  return (
    <StyledWorksTitle>
      <TitleItem id={title} onMouseOverCapture={handleHover} onMouseOut={handleMouseOut}>
        <div className={`itemWrapper ${(currentMenu === { title } ||
            currentMenu === null) && 'activated'}`}
          id={title}>
          <Link to={link}></Link>
        </div>
      </TitleItem>
    </StyledWorksTitle>
  )
}

/* styled-components */

export default WorksTitle

</code>```

答:
useState is asynchronous so currentMenu isn't updated until the next render.

Here is a sandbox example to demonstrate.

Body:
I'm building my website with React, and I'm using useState to get the id of hovered item.

But when I use setState to get the value, it doesn't update and remain 'null'

So on console, I can see the event.target.id is recognized, but even after the setState event, the state value return null.

Can anybody give some clues on what is happening here?

Here's the code

import React from 'react'
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
import styled from 'styled-components'

const WorksTitle = props => {
  const { type, title, imgSrc, link, year } = props
  const [currentMenu, setCurrentMenu] = React.useState(null)

  const handleHover = event => {
    console.log(
      'event target: ',
      event.target,
      ' / ',
      'event target id: ',
      event.target.id
    )
    **console.log(event.target.id)
    setCurrentMenu(event.target.id)
    console.log(currentMenu)**
  }

  const handleMouseOut = event => {
    console.log('mouse out from:', event.target.id)
    setCurrentMenu(null)
  }

  return (

  )
}

/* styled-components */

export default WorksTitle


问:
Javascript Syntax Differences
What is the difference between these two?

```<code>collapse: function(fold)
{
...
...
}
</code>```

and

```<code>function collapse(fold)
{
...
...
}
</code>```

答: The first one is not valid JavaScript, I'll assume that you meant =, not :.  This is the same in global scope, first one uses an anonymous function and the second is just some syntactic sugar to name a function.  The difference would be that in non global scope first one would produce a function in global scope, the second would be created in most recent scope (for the same effect use var x = function() {} in the first example).

Title: Javascript Syntax Differences

Body:
What is the difference between these two?

collapse: function(fold)
{
...
...
}

and

function collapse(fold)
{
...
...
}


问:
Updating only part of an HTML page using Django
I have an HTML (annotator.html) page where the top half contains a table. I have JavaScript code that pulls data out of the data model when the user selects a row in the table and displays that data in a div below the table.

My Javascript looks like this:

```<code>$('#radiological tbody').on( 'click', 'tr', function () {
    if ( $(this).hasClass('selected') ) {
        $(this).removeClass('selected');
    }
    else {
        //first unselect any other selected row
        dt_table.$('tr.selected').removeClass('selected');

        //then select row of interest
        $(this).addClass('selected');

        var rowIndex = dt_table.row('.selected')[0];
        var row = dt_table.rows(rowIndex);
        var id = row.data()[0]['id'];
        var url = '/report/' + id + '/';
        //window.location = url;

        $.ajax({
            url: url,
            type: 'get', // This is the default though, you don't actually need to always mention it
            success: function(data) {
            },
            failure: function(data) {
                alert('Got an error dude');
            }
        });
</code>```

And correctly populates the bottom half of my page but also updates the top half.  I Just want the bottom half refreshed.

My report view looks like this:

```<code>def report_page(request, id):
    template_name = "annotator.html"
    data = Radiology2.objects.get(id=id)
    context = {"data": data}
    context["title"] = title
    context["version"] = version
    context["id"] = id

    if (request.is_ajax()):
        # return render(request, template_name, context)
        return JsonResponse(context)
    else:
        return render(request, template_name, context)
</code>```

I added support for AJAX.  I'm  just not sure how to return from view properly when AJAX is used.  Obviously, I'm not understanding something.

答: You can easily use Ajax - jQuery or native JS would be better for that </p>

Body:
I have an HTML (annotator.html) page where the top half contains a table. I have JavaScript code that pulls data out of the data model when the user selects a row in the table and displays that data in a div below the table.

My Javascript looks like this:

$('#radiological tbody').on( 'click', 'tr', function () {
    if ( $(this).hasClass('selected') ) {
        $(this).removeClass('selected');
    }
    else {
        //first unselect any other selected row
        dt_table.$('tr.selected').removeClass('selected');

        //then select row of interest
        $(this).addClass('selected');

        var rowIndex = dt_table.row('.selected')[0];
        var row = dt_table.rows(rowIndex);
        var id = row.data()[0]['id'];
        var url = '/report/' + id + '/';
        //window.location = url;

        $.ajax({
            url: url,
            type: 'get', // This is the default though, you don't actually need to always mention it
            success: function(data) {
            },
            failure: function(data) {
                alert('Got an error dude');
            }
        });

And correctly populates the bottom half of my page but also updates the top half.  I Just want the bottom half refreshed.

My report view looks like this:

def report_page(request, id):
    template_name = "annotator.html"
    data = Radiology2.objects.get(id=id)
    context = {"data": data}
    context["title"] = title
    context["version"] = version
    context["id"] = id

    if (request.is_ajax()):
        # return render(request, template_name, context)
        return JsonResponse(context)
    else:
        return render(request, template_name, context)

I added support for AJAX.  I'm  just not sure how to return from view properly when AJAX is used.  Obviously, I'm not understanding something.


问:
How to Install PyMuPDF on Heroku Django
I am trying to make a script that extracts Images from PDF and I have made a script in a Django Project and added pymupdf to the requirements.txt.I Have an Aptfile with Mupdf in it and https://github.com/heroku/heroku-buildpack-apt as a buildpack along with heroku/python.While trying to push master to Heroku,The Push fails and here is the Error.</p>

```<code>    Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 322 bytes | 322.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Apt app detected
remote: -----> Detected Aptfile or Stack changes, flushing cache
remote: -----> Adding custom repositories
remote: -----> Updating apt caches
remote:        Get:1 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
remote:        Get:2 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease [46.3 kB]
remote:        Get:3 http://archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
remote:        Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
remote:        Get:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB]
remote:        Get:6 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/11 amd64 Packages [2,483 B]
remote:        Get:7 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 Packages [294 kB]
remote:        Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1,344 kB]
remote:        Get:9 http://archive.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [817 kB]
remote:        Get:10 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages [812 kB]
remote:        Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [1,101 kB]
remote:        Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,343 kB]
remote:        Fetched 17.5 MB in 3s (5,813 kB/s)
remote:        Reading package lists...
remote: -----> Fetching .debs for mupdf
remote:        Reading package lists...
remote:        Building dependency tree...
remote:        The following additional packages will be installed:
remote:          libopenjp2-7
remote:        Suggested packages:
remote:          mupdf-tools
remote:        The following NEW packages will be installed:
remote:          libopenjp2-7 mupdf
remote:        0 upgraded, 2 newly installed, 0 to remove and 46 not upgraded.
remote:        Need to get 19.2 MB of archives.
remote:        After this operation, 35.3 MB of additional disk space will be used.
remote:        Get:1 http://archive.ubuntu.com/ubuntu bionic-security/universe amd64 libopenjp2-7 amd64 2.3.0-2build0.18.04.1 [145 kB]
remote:        Get:2 http://archive.ubuntu.com/ubuntu bionic/universe amd64 mupdf amd64 1.12.0+ds1-1 [19.0 MB]
remote:        Fetched 19.2 MB in 1s (13.5 MB/s)
remote:        Download complete and in download only mode
remote: -----> Installing libopenjp2-7_2.3.0-2build0.18.04.1_amd64.deb
remote: -----> Installing mupdf_1.12.0+ds1-1_amd64.deb
remote: -----> Writing profile script
remote: -----> Rewrite package-config files
remote: -----> Python app detected
remote: -----> Need to update SQLite3, clearing cache
remote: -----> Installing python-3.6.10
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: Sqlite3 successfully installed.
remote: -----> Installing requirements with pip
remote:        Collecting bs4==0.0.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gz
remote:        Collecting Django==2.1.11 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 2))
remote:          Downloading https://files.pythonhosted.org/packages/8c/49/d5038239995594281478bf209f8d93524ad342d500009a697b27f884668a/Django-2.1.11-py3-none-any.whl (7.3MB)
remote:        Collecting django-heroku==0.3.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/59/af/5475a876c5addd5a3494db47d9f7be93cc14d3a7603542b194572791b6c6/django_heroku-0.3.1-py2.py3-none-any.whl
remote:        Collecting django-widget-tweaks==1.4.5 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 4))
remote:          Downloading https://files.pythonhosted.org/packages/1c/11/a8d3a4d73a09973d62ce381fb73a926707cb1485aa29599f2afc04dee7b4/django_widget_tweaks-1.4.5-py2.py3-none-any.whl
remote:        Collecting forex-python==1.5 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/1a/ff/f3f6da21e8fdc6ece355643871749c79a3191fed1cba088cbd0dc597dfee/forex-python-1.5.tar.gz
remote:        Collecting gunicorn==19.9.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 6))
remote:          Downloading https://files.pythonhosted.org/packages/8c/da/b8dd8deb741bff556db53902d4706774c8e1e67265f69528c14c003644e6/gunicorn-19.9.0-py2.py3-none-any.whl (112kB)
remote:        Collecting imageio==2.6.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 7))
remote:          Downloading https://files.pythonhosted.org/packages/1a/de/f7f985018f462ceeffada7f6e609919fbcc934acd9301929cba14bc2c24a/imageio-2.6.1-py3-none-any.whl (3.3MB)
remote:        Collecting img2pdf==0.3.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 8))
remote:          Downloading https://files.pythonhosted.org/packages/e0/c6/7cd14232a1b10bf884c12daf3626afb76c4f60b52ae0eb23ce1519542ae4/img2pdf-0.3.3.tar.gz (80kB)
remote:        Collecting imutils==0.5.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 9))
remote:          Downloading https://files.pythonhosted.org/packages/b5/94/46dcae8c061e28be31bcaa55c560cb30ee9403c9a4bb2659768ec1b9eb7d/imutils-0.5.3.tar.gz
remote:        Collecting opencv-python-headless==4.1.2.30 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 10))
remote:          Downloading https://files.pythonhosted.org/packages/5d/96/b2824df85d8c5f148125e4fee073a62fde17639502fe67042b212ebfe488/opencv_python_headless-4.1.2.30-cp36-cp36m-manylinux1_x86_64.whl (21.8MB)
remote:        Collecting pandas==0.25.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/52/3f/f6a428599e0d4497e1595030965b5ba455fd8ade6e977e3c819973c4b41d/pandas-0.25.3-cp36-cp36m-manylinux1_x86_64.whl (10.4MB)
remote:        Collecting Pillow==6.1.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 12))
remote:          Downloading https://files.pythonhosted.org/packages/14/41/db6dec65ddbc176a59b89485e8cc136a433ed9c6397b6bfe2cd38412051e/Pillow-6.1.0-cp36-cp36m-manylinux1_x86_64.whl (2.1MB)
remote:        Collecting Pygments==2.4.2 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 13))
remote:          Downloading https://files.pythonhosted.org/packages/5c/73/1dfa428150e3ccb0fa3e68db406e5be48698f2a979ccbcec795f28f44048/Pygments-2.4.2-py2.py3-none-any.whl (883kB)
remote:        Collecting pypandoc==1.4 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 14))
remote:          Downloading https://files.pythonhosted.org/packages/71/81/00184643e5a10a456b4118fc12c96780823adb8ed974eb2289f29703b29b/pypandoc-1.4.tar.gz
remote:        Collecting PyPDF2==1.26.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 15))
remote:          Downloading https://files.pythonhosted.org/packages/b4/01/68fcc0d43daf4c6bdbc6b33cc3f77bda531c86b174cac56ef0ffdb96faab/PyPDF2-1.26.0.tar.gz (77kB)
remote:        Collecting scikit-image==0.16.2 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/c8/bb/771800366f41d66eef51e4b80515f8ef7edab234a3f244fdce3bafe89b39/scikit_image-0.16.2-cp36-cp36m-manylinux1_x86_64.whl (26.5MB)
remote:        Collecting whitenoise==5.0.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 17))
remote:          Downloading https://files.pythonhosted.org/packages/ae/25/0c8f08c9d3c93192cd286594f1e87b17bab496fb9082c2a69e17051b91fd/whitenoise-5.0.1-py2.py3-none-any.whl
remote:        Collecting xlrd==1.2.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 18))
remote:          Downloading https://files.pythonhosted.org/packages/b0/16/63576a1a001752e34bf8ea62e367997530dc553b689356b9879339cf45a4/xlrd-1.2.0-py2.py3-none-any.whl (103kB)
remote:        Collecting zipp==0.6.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 19))
remote:          Downloading https://files.pythonhosted.org/packages/74/3d/1ee25a26411ba0401b43c6376d2316a71addcc72ef8690b101b4ea56d76a/zipp-0.6.0-py2.py3-none-any.whl
remote:        Collecting python-docx (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 20))
remote:          Downloading https://files.pythonhosted.org/packages/e4/83/c66a1934ed5ed8ab1dbb9931f1779079f8bca0f6bbc5793c06c4b5e7d671/python-docx-0.8.10.tar.gz (5.5MB)
remote:        Collecting pymupdf (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 21))
remote:          Downloading https://files.pythonhosted.org/packages/3d/6a/5b4d4f1964a0802f8f2514fcd1f8d53c7f1e74a55765f99df1cf482bbbe8/PyMuPDF-1.16.10.tar.gz (175kB)
remote:        Collecting beautifulsoup4 (from bs4==0.0.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/cb/a1/c698cf319e9cfed6b17376281bd0efc6bfc8465698f54170ef60a485ab5d/beautifulsoup4-4.8.2-py3-none-any.whl (106kB)
remote:        Collecting pytz (from Django==2.1.11->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 2))
remote:          Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
remote:        Collecting dj-database-url>=0.5.0 (from django-heroku==0.3.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/d4/a6/4b8578c1848690d0c307c7c0596af2077536c9ef2a04d42b00fabaa7e49d/dj_database_url-0.5.0-py2.py3-none-any.whl
remote:        Collecting psycopg2 (from django-heroku==0.3.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz (377kB)
remote:        Collecting requests (from forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
remote:        Collecting simplejson (from forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/98/87/a7b98aa9256c8843f92878966dc3d8d914c14aad97e2c5ce4798d5743e07/simplejson-3.17.0.tar.gz (83kB)
remote:        Collecting numpy (from imageio==2.6.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 7))
remote:          Downloading https://files.pythonhosted.org/packages/62/20/4d43e141b5bc426ba38274933ef8e76e85c7adea2c321ecf9ebf7421cedf/numpy-1.18.1-cp36-cp36m-manylinux1_x86_64.whl (20.1MB)
remote:        Collecting python-dateutil>=2.6.1 (from pandas==0.25.3->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227kB)
remote:        Collecting matplotlib!=3.0.0,>=2.0.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/7e/07/4b361d6d0f4e08942575f83a11d33f36897e1aae4279046606dd1808778a/matplotlib-3.1.3-cp36-cp36m-manylinux1_x86_64.whl (13.1MB)
remote:        Collecting networkx>=2.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/41/8f/dd6a8e85946def36e4f2c69c84219af0fa5e832b018c970e92f2ad337e45/networkx-2.4-py3-none-any.whl (1.6MB)
remote:        Collecting PyWavelets>=0.4.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/59/bb/d2b85265ec9fa3c1922210c9393d4cdf7075cc87cce6fe671d7455f80fbc/PyWavelets-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (4.4MB)
remote:        Collecting scipy>=0.19.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/dc/29/162476fd44203116e7980cfbd9352eef9db37c49445d1fec35509022f6aa/scipy-1.4.1-cp36-cp36m-manylinux1_x86_64.whl (26.1MB)
remote:        Collecting more-itertools (from zipp==0.6.0->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 19))
remote:          Downloading https://files.pythonhosted.org/packages/72/96/4297306cc270eef1e3461da034a3bebe7c84eff052326b130824e98fc3fb/more_itertools-8.2.0-py3-none-any.whl (43kB)
remote:        Collecting lxml>=2.3.2 (from python-docx->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 20))
remote:          Downloading https://files.pythonhosted.org/packages/dd/ba/a0e6866057fc0bbd17192925c1d63a3b85cf522965de9bc02364d08e5b84/lxml-4.5.0-cp36-cp36m-manylinux1_x86_64.whl (5.8MB)
remote:        Collecting soupsieve>=1.2 (from beautifulsoup4->bs4==0.0.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/81/94/03c0f04471fc245d08d0a99f7946ac228ca98da4fa75796c507f61e688c2/soupsieve-1.9.5-py2.py3-none-any.whl
remote:        Collecting certifi>=2017.4.17 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99/certifi-2019.11.28-py2.py3-none-any.whl (156kB)
remote:        Collecting chardet<3.1.0,>=3.0.2 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
remote:        Collecting idna<2.9,>=2.5 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
remote:        Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/e8/74/6e4f91745020f967d09332bb2b8b9b10090957334692eb88ea4afe91b77f/urllib3-1.25.8-py2.py3-none-any.whl (125kB)
remote:        Collecting six>=1.5 (from python-dateutil>=2.6.1->pandas==0.25.3->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl
remote:        Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/5d/bc/1e58593167fade7b544bfe9502a26dc860940a79ab306e651e7f13be68c2/pyparsing-2.4.6-py2.py3-none-any.whl (67kB)
remote:        Collecting cycler>=0.10 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
remote:        Collecting kiwisolver>=1.0.1 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/f8/a1/5742b56282449b1c0968197f63eae486eca2c35dcd334bab75ad524e0de1/kiwisolver-1.1.0-cp36-cp36m-manylinux1_x86_64.whl (90kB)
remote:        Collecting decorator>=4.3.0 (from networkx>=2.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/8f/b7/f329cfdc75f3d28d12c65980e4469e2fa373f1953f5df6e370e84ea2e875/decorator-4.4.1-py2.py3-none-any.whl
remote:        Installing collected packages: soupsieve, beautifulsoup4, bs4, pytz, Django, dj-database-url, whitenoise, psycopg2, django-heroku, django-widget-tweaks, certifi, chardet, idna, urllib3, requests, simplejson, forex-python, gunicorn, numpy, Pillow, imageio, img2pdf, imutils, opencv-python-headless, six, python-dateutil, pandas, Pygments, pypandoc, PyPDF2, pyparsing, cycler, kiwisolver, matplotlib, decorator, networkx, PyWavelets, scipy, scikit-image, xlrd, more-itertools, zipp, lxml, python-docx, pymupdf
remote:          Running setup.py install for bs4: started
remote:            Running setup.py install for bs4: finished with status 'done'
remote:          Running setup.py install for psycopg2: started
remote:            Running setup.py install for psycopg2: finished with status 'done'
remote:          Running setup.py install for simplejson: started
remote:            Running setup.py install for simplejson: finished with status 'done'
remote:          Running setup.py install for forex-python: started
remote:            Running setup.py install for forex-python: finished with status 'done'
remote:          Running setup.py install for img2pdf: started
remote:            Running setup.py install for img2pdf: finished with status 'done'
remote:          Running setup.py install for imutils: started
remote:            Running setup.py install for imutils: finished with status 'done'
remote:          Running setup.py install for pypandoc: started
remote:            Running setup.py install for pypandoc: finished with status 'done'
remote:          Running setup.py install for PyPDF2: started
remote:            Running setup.py install for PyPDF2: finished with status 'done'
remote:          Running setup.py install for python-docx: started
remote:            Running setup.py install for python-docx: finished with status 'done'
remote:          Running setup.py install for pymupdf: started
remote:            Running setup.py install for pymupdf: finished with status 'error'
remote:            Complete output from command /app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-205xyxft/pymupdf/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-a457z02t-record/install-record.txt --single-version-externally-managed --compile:
remote:            running install
remote:            running build
remote:            running build_py
remote:            creating build
remote:            creating build/lib.linux-x86_64-3.6
remote:            creating build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/__init__.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/fitz.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/utils.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/__main__.py -> build/lib.linux-x86_64-3.6/fitz
remote:            running build_ext
remote:            building 'fitz._fitz' extension
remote:            creating build/temp.linux-x86_64-3.6
remote:            creating build/temp.linux-x86_64-3.6/fitz
remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include/mupdf -I/usr/local/include/mupdf -I/app/.heroku/python/include/python3.6m -c fitz/fitz_wrap.c -o build/temp.linux-x86_64-3.6/fitz/fitz_wrap.o
remote:            fitz/fitz_wrap.c:2732:10: fatal error: fitz.h: No such file or directory
remote:             #include <fitz.h>
remote:                      ^~~~~~~~
remote:            compilation terminated.
remote:            error: command 'gcc' failed with exit status 1
remote:
remote:            ----------------------------------------
remote:        Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-205xyxft/pymupdf/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-a457z02t-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-205xyxft/pymupdf/
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to compare-tool.
remote:
To https://git.heroku.com/compare-tool.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/compare-tool.git'
</code>```

<p>`</p>

答:
After Some debugging , I have solved the Issue .

The issue was with the new version of PyMuPDF and therefore , instead of using the latest version of PyMuPdf , I used the old version.

In the Aptfile , Instead of adding Mupdf-tools , add

```<code>http://ftp.br.debian.org/debian/pool/main/m/mupdf/mupdf_1.14.0+ds1-4_amd64.deb
</code>```

In requirements.txt , instead of adding PyMuPDF , add

```<code>PyMuPDF==1.14.20
</code>```

This Should Solve it.

Title: How to Install PyMuPDF on Heroku Django

Body:
I am trying to make a script that extracts Images from PDF and I have made a script in a Django Project and added pymupdf to the requirements.txt.I Have an Aptfile with Mupdf in it and https://github.com/heroku/heroku-buildpack-apt as a buildpack along with heroku/python.While trying to push master to Heroku,The Push fails and here is the Error.

    Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 322 bytes | 322.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Apt app detected
remote: -----> Detected Aptfile or Stack changes, flushing cache
remote: -----> Adding custom repositories
remote: -----> Updating apt caches
remote:        Get:1 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
remote:        Get:2 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease [46.3 kB]
remote:        Get:3 http://archive.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
remote:        Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
remote:        Get:5 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB]
remote:        Get:6 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/11 amd64 Packages [2,483 B]
remote:        Get:7 http://apt.postgresql.org/pub/repos/apt bionic-pgdg/main amd64 Packages [294 kB]
remote:        Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1,344 kB]
remote:        Get:9 http://archive.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [817 kB]
remote:        Get:10 http://archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages [812 kB]
remote:        Get:11 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [1,101 kB]
remote:        Get:12 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1,343 kB]
remote:        Fetched 17.5 MB in 3s (5,813 kB/s)
remote:        Reading package lists...
remote: -----> Fetching .debs for mupdf
remote:        Reading package lists...
remote:        Building dependency tree...
remote:        The following additional packages will be installed:
remote:          libopenjp2-7
remote:        Suggested packages:
remote:          mupdf-tools
remote:        The following NEW packages will be installed:
remote:          libopenjp2-7 mupdf
remote:        0 upgraded, 2 newly installed, 0 to remove and 46 not upgraded.
remote:        Need to get 19.2 MB of archives.
remote:        After this operation, 35.3 MB of additional disk space will be used.
remote:        Get:1 http://archive.ubuntu.com/ubuntu bionic-security/universe amd64 libopenjp2-7 amd64 2.3.0-2build0.18.04.1 [145 kB]
remote:        Get:2 http://archive.ubuntu.com/ubuntu bionic/universe amd64 mupdf amd64 1.12.0+ds1-1 [19.0 MB]
remote:        Fetched 19.2 MB in 1s (13.5 MB/s)
remote:        Download complete and in download only mode
remote: -----> Installing libopenjp2-7_2.3.0-2build0.18.04.1_amd64.deb
remote: -----> Installing mupdf_1.12.0+ds1-1_amd64.deb
remote: -----> Writing profile script
remote: -----> Rewrite package-config files
remote: -----> Python app detected
remote: -----> Need to update SQLite3, clearing cache
remote: -----> Installing python-3.6.10
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: Sqlite3 successfully installed.
remote: -----> Installing requirements with pip
remote:        Collecting bs4==0.0.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/10/ed/7e8b97591f6f456174139ec089c769f89a94a1a4025fe967691de971f314/bs4-0.0.1.tar.gz
remote:        Collecting Django==2.1.11 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 2))
remote:          Downloading https://files.pythonhosted.org/packages/8c/49/d5038239995594281478bf209f8d93524ad342d500009a697b27f884668a/Django-2.1.11-py3-none-any.whl (7.3MB)
remote:        Collecting django-heroku==0.3.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/59/af/5475a876c5addd5a3494db47d9f7be93cc14d3a7603542b194572791b6c6/django_heroku-0.3.1-py2.py3-none-any.whl
remote:        Collecting django-widget-tweaks==1.4.5 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 4))
remote:          Downloading https://files.pythonhosted.org/packages/1c/11/a8d3a4d73a09973d62ce381fb73a926707cb1485aa29599f2afc04dee7b4/django_widget_tweaks-1.4.5-py2.py3-none-any.whl
remote:        Collecting forex-python==1.5 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/1a/ff/f3f6da21e8fdc6ece355643871749c79a3191fed1cba088cbd0dc597dfee/forex-python-1.5.tar.gz
remote:        Collecting gunicorn==19.9.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 6))
remote:          Downloading https://files.pythonhosted.org/packages/8c/da/b8dd8deb741bff556db53902d4706774c8e1e67265f69528c14c003644e6/gunicorn-19.9.0-py2.py3-none-any.whl (112kB)
remote:        Collecting imageio==2.6.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 7))
remote:          Downloading https://files.pythonhosted.org/packages/1a/de/f7f985018f462ceeffada7f6e609919fbcc934acd9301929cba14bc2c24a/imageio-2.6.1-py3-none-any.whl (3.3MB)
remote:        Collecting img2pdf==0.3.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 8))
remote:          Downloading https://files.pythonhosted.org/packages/e0/c6/7cd14232a1b10bf884c12daf3626afb76c4f60b52ae0eb23ce1519542ae4/img2pdf-0.3.3.tar.gz (80kB)
remote:        Collecting imutils==0.5.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 9))
remote:          Downloading https://files.pythonhosted.org/packages/b5/94/46dcae8c061e28be31bcaa55c560cb30ee9403c9a4bb2659768ec1b9eb7d/imutils-0.5.3.tar.gz
remote:        Collecting opencv-python-headless==4.1.2.30 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 10))
remote:          Downloading https://files.pythonhosted.org/packages/5d/96/b2824df85d8c5f148125e4fee073a62fde17639502fe67042b212ebfe488/opencv_python_headless-4.1.2.30-cp36-cp36m-manylinux1_x86_64.whl (21.8MB)
remote:        Collecting pandas==0.25.3 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/52/3f/f6a428599e0d4497e1595030965b5ba455fd8ade6e977e3c819973c4b41d/pandas-0.25.3-cp36-cp36m-manylinux1_x86_64.whl (10.4MB)
remote:        Collecting Pillow==6.1.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 12))
remote:          Downloading https://files.pythonhosted.org/packages/14/41/db6dec65ddbc176a59b89485e8cc136a433ed9c6397b6bfe2cd38412051e/Pillow-6.1.0-cp36-cp36m-manylinux1_x86_64.whl (2.1MB)
remote:        Collecting Pygments==2.4.2 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 13))
remote:          Downloading https://files.pythonhosted.org/packages/5c/73/1dfa428150e3ccb0fa3e68db406e5be48698f2a979ccbcec795f28f44048/Pygments-2.4.2-py2.py3-none-any.whl (883kB)
remote:        Collecting pypandoc==1.4 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 14))
remote:          Downloading https://files.pythonhosted.org/packages/71/81/00184643e5a10a456b4118fc12c96780823adb8ed974eb2289f29703b29b/pypandoc-1.4.tar.gz
remote:        Collecting PyPDF2==1.26.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 15))
remote:          Downloading https://files.pythonhosted.org/packages/b4/01/68fcc0d43daf4c6bdbc6b33cc3f77bda531c86b174cac56ef0ffdb96faab/PyPDF2-1.26.0.tar.gz (77kB)
remote:        Collecting scikit-image==0.16.2 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/c8/bb/771800366f41d66eef51e4b80515f8ef7edab234a3f244fdce3bafe89b39/scikit_image-0.16.2-cp36-cp36m-manylinux1_x86_64.whl (26.5MB)
remote:        Collecting whitenoise==5.0.1 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 17))
remote:          Downloading https://files.pythonhosted.org/packages/ae/25/0c8f08c9d3c93192cd286594f1e87b17bab496fb9082c2a69e17051b91fd/whitenoise-5.0.1-py2.py3-none-any.whl
remote:        Collecting xlrd==1.2.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 18))
remote:          Downloading https://files.pythonhosted.org/packages/b0/16/63576a1a001752e34bf8ea62e367997530dc553b689356b9879339cf45a4/xlrd-1.2.0-py2.py3-none-any.whl (103kB)
remote:        Collecting zipp==0.6.0 (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 19))
remote:          Downloading https://files.pythonhosted.org/packages/74/3d/1ee25a26411ba0401b43c6376d2316a71addcc72ef8690b101b4ea56d76a/zipp-0.6.0-py2.py3-none-any.whl
remote:        Collecting python-docx (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 20))
remote:          Downloading https://files.pythonhosted.org/packages/e4/83/c66a1934ed5ed8ab1dbb9931f1779079f8bca0f6bbc5793c06c4b5e7d671/python-docx-0.8.10.tar.gz (5.5MB)
remote:        Collecting pymupdf (from -r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 21))
remote:          Downloading https://files.pythonhosted.org/packages/3d/6a/5b4d4f1964a0802f8f2514fcd1f8d53c7f1e74a55765f99df1cf482bbbe8/PyMuPDF-1.16.10.tar.gz (175kB)
remote:        Collecting beautifulsoup4 (from bs4==0.0.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/cb/a1/c698cf319e9cfed6b17376281bd0efc6bfc8465698f54170ef60a485ab5d/beautifulsoup4-4.8.2-py3-none-any.whl (106kB)
remote:        Collecting pytz (from Django==2.1.11->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 2))
remote:          Downloading https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl (509kB)
remote:        Collecting dj-database-url>=0.5.0 (from django-heroku==0.3.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/d4/a6/4b8578c1848690d0c307c7c0596af2077536c9ef2a04d42b00fabaa7e49d/dj_database_url-0.5.0-py2.py3-none-any.whl
remote:        Collecting psycopg2 (from django-heroku==0.3.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 3))
remote:          Downloading https://files.pythonhosted.org/packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz (377kB)
remote:        Collecting requests (from forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
remote:        Collecting simplejson (from forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/98/87/a7b98aa9256c8843f92878966dc3d8d914c14aad97e2c5ce4798d5743e07/simplejson-3.17.0.tar.gz (83kB)
remote:        Collecting numpy (from imageio==2.6.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 7))
remote:          Downloading https://files.pythonhosted.org/packages/62/20/4d43e141b5bc426ba38274933ef8e76e85c7adea2c321ecf9ebf7421cedf/numpy-1.18.1-cp36-cp36m-manylinux1_x86_64.whl (20.1MB)
remote:        Collecting python-dateutil>=2.6.1 (from pandas==0.25.3->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227kB)
remote:        Collecting matplotlib!=3.0.0,>=2.0.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/7e/07/4b361d6d0f4e08942575f83a11d33f36897e1aae4279046606dd1808778a/matplotlib-3.1.3-cp36-cp36m-manylinux1_x86_64.whl (13.1MB)
remote:        Collecting networkx>=2.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/41/8f/dd6a8e85946def36e4f2c69c84219af0fa5e832b018c970e92f2ad337e45/networkx-2.4-py3-none-any.whl (1.6MB)
remote:        Collecting PyWavelets>=0.4.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/59/bb/d2b85265ec9fa3c1922210c9393d4cdf7075cc87cce6fe671d7455f80fbc/PyWavelets-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (4.4MB)
remote:        Collecting scipy>=0.19.0 (from scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/dc/29/162476fd44203116e7980cfbd9352eef9db37c49445d1fec35509022f6aa/scipy-1.4.1-cp36-cp36m-manylinux1_x86_64.whl (26.1MB)
remote:        Collecting more-itertools (from zipp==0.6.0->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 19))
remote:          Downloading https://files.pythonhosted.org/packages/72/96/4297306cc270eef1e3461da034a3bebe7c84eff052326b130824e98fc3fb/more_itertools-8.2.0-py3-none-any.whl (43kB)
remote:        Collecting lxml>=2.3.2 (from python-docx->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 20))
remote:          Downloading https://files.pythonhosted.org/packages/dd/ba/a0e6866057fc0bbd17192925c1d63a3b85cf522965de9bc02364d08e5b84/lxml-4.5.0-cp36-cp36m-manylinux1_x86_64.whl (5.8MB)
remote:        Collecting soupsieve>=1.2 (from beautifulsoup4->bs4==0.0.1->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 1))
remote:          Downloading https://files.pythonhosted.org/packages/81/94/03c0f04471fc245d08d0a99f7946ac228ca98da4fa75796c507f61e688c2/soupsieve-1.9.5-py2.py3-none-any.whl
remote:        Collecting certifi>=2017.4.17 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/b9/63/df50cac98ea0d5b006c55a399c3bf1db9da7b5a24de7890bc9cfd5dd9e99/certifi-2019.11.28-py2.py3-none-any.whl (156kB)
remote:        Collecting chardet<3.1.0,>=3.0.2 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
remote:        Collecting idna<2.9,>=2.5 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/14/2c/cd551d81dbe15200be1cf41cd03869a46fe7226e7450af7a6545bfc474c9/idna-2.8-py2.py3-none-any.whl (58kB)
remote:        Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests->forex-python==1.5->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 5))
remote:          Downloading https://files.pythonhosted.org/packages/e8/74/6e4f91745020f967d09332bb2b8b9b10090957334692eb88ea4afe91b77f/urllib3-1.25.8-py2.py3-none-any.whl (125kB)
remote:        Collecting six>=1.5 (from python-dateutil>=2.6.1->pandas==0.25.3->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 11))
remote:          Downloading https://files.pythonhosted.org/packages/65/eb/1f97cb97bfc2390a276969c6fae16075da282f5058082d4cb10c6c5c1dba/six-1.14.0-py2.py3-none-any.whl
remote:        Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/5d/bc/1e58593167fade7b544bfe9502a26dc860940a79ab306e651e7f13be68c2/pyparsing-2.4.6-py2.py3-none-any.whl (67kB)
remote:        Collecting cycler>=0.10 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
remote:        Collecting kiwisolver>=1.0.1 (from matplotlib!=3.0.0,>=2.0.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/f8/a1/5742b56282449b1c0968197f63eae486eca2c35dcd334bab75ad524e0de1/kiwisolver-1.1.0-cp36-cp36m-manylinux1_x86_64.whl (90kB)
remote:        Collecting decorator>=4.3.0 (from networkx>=2.0->scikit-image==0.16.2->-r /tmp/build_460e46d9ff4616a54e3ebd7caa495280/requirements.txt (line 16))
remote:          Downloading https://files.pythonhosted.org/packages/8f/b7/f329cfdc75f3d28d12c65980e4469e2fa373f1953f5df6e370e84ea2e875/decorator-4.4.1-py2.py3-none-any.whl
remote:        Installing collected packages: soupsieve, beautifulsoup4, bs4, pytz, Django, dj-database-url, whitenoise, psycopg2, django-heroku, django-widget-tweaks, certifi, chardet, idna, urllib3, requests, simplejson, forex-python, gunicorn, numpy, Pillow, imageio, img2pdf, imutils, opencv-python-headless, six, python-dateutil, pandas, Pygments, pypandoc, PyPDF2, pyparsing, cycler, kiwisolver, matplotlib, decorator, networkx, PyWavelets, scipy, scikit-image, xlrd, more-itertools, zipp, lxml, python-docx, pymupdf
remote:          Running setup.py install for bs4: started
remote:            Running setup.py install for bs4: finished with status 'done'
remote:          Running setup.py install for psycopg2: started
remote:            Running setup.py install for psycopg2: finished with status 'done'
remote:          Running setup.py install for simplejson: started
remote:            Running setup.py install for simplejson: finished with status 'done'
remote:          Running setup.py install for forex-python: started
remote:            Running setup.py install for forex-python: finished with status 'done'
remote:          Running setup.py install for img2pdf: started
remote:            Running setup.py install for img2pdf: finished with status 'done'
remote:          Running setup.py install for imutils: started
remote:            Running setup.py install for imutils: finished with status 'done'
remote:          Running setup.py install for pypandoc: started
remote:            Running setup.py install for pypandoc: finished with status 'done'
remote:          Running setup.py install for PyPDF2: started
remote:            Running setup.py install for PyPDF2: finished with status 'done'
remote:          Running setup.py install for python-docx: started
remote:            Running setup.py install for python-docx: finished with status 'done'
remote:          Running setup.py install for pymupdf: started
remote:            Running setup.py install for pymupdf: finished with status 'error'
remote:            Complete output from command /app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-205xyxft/pymupdf/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-a457z02t-record/install-record.txt --single-version-externally-managed --compile:
remote:            running install
remote:            running build
remote:            running build_py
remote:            creating build
remote:            creating build/lib.linux-x86_64-3.6
remote:            creating build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/__init__.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/fitz.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/utils.py -> build/lib.linux-x86_64-3.6/fitz
remote:            copying fitz/__main__.py -> build/lib.linux-x86_64-3.6/fitz
remote:            running build_ext
remote:            building 'fitz._fitz' extension
remote:            creating build/temp.linux-x86_64-3.6
remote:            creating build/temp.linux-x86_64-3.6/fitz
remote:            gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/include/mupdf -I/usr/local/include/mupdf -I/app/.heroku/python/include/python3.6m -c fitz/fitz_wrap.c -o build/temp.linux-x86_64-3.6/fitz/fitz_wrap.o
remote:            fitz/fitz_wrap.c:2732:10: fatal error: fitz.h: No such file or directory
remote:             #include <fitz.h>
remote:                      ^~~~~~~~
remote:            compilation terminated.
remote:            error: command 'gcc' failed with exit status 1
remote:
remote:            ----------------------------------------
remote:        Command "/app/.heroku/python/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-205xyxft/pymupdf/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-a457z02t-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-205xyxft/pymupdf/
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to compare-tool.
remote:
To https://git.heroku.com/compare-tool.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/compare-tool.git'

`

Body:
After Some debugging , I have solved the Issue .

The issue was with the new version of PyMuPDF and therefore , instead of using the latest version of PyMuPdf , I used the old version.

In the Aptfile , Instead of adding Mupdf-tools , add

http://ftp.br.debian.org/debian/pool/main/m/mupdf/mupdf_1.14.0+ds1-4_amd64.deb

In requirements.txt , instead of adding PyMuPDF , add

PyMuPDF==1.14.20

This Should Solve it.


问:
Event handler incrementing loop issue
I'm using Xamarin.Forms to create a chatbot app. Any time I send a new message to the bot, the reply is gotten but increments itself by one i.e

```<code>User: Hi
Bot: Hello
User: How are you?
Bot: Good
Bot: Good
</code>```

In the code I'm using this:

```<code> public void Send()
        {
            if (!string.IsNullOrEmpty(TextToSend))
            {
                //This adds a new message to the messages collection
                Messages.Add(new ChatMessageModel() { Text = TextToSend, User = App.User });

                //This gets the chatbots response for each message
                chatbot.MainUser.ResponseReceived += async (sender, args) =>
                {
                    await Task.Delay(1500);
                    Messages.Add(new ChatMessageModel() { Text = args.Response.Text, User = App.ChatBot });
                };

                var result = chatbot.Evaluate(TextToSend);
                result.Invoke();

                //Removes the text in the Entry after message is sent
                TextToSend = string.Empty;
            }
        }
</code>```

After using a breakpoint on Messages.Add(new ChatMessageModel() { Text = args.Response.Text, User = App.ChatBot }); I found out that it adds a new message each and everytime, therefore incrementing upon itself. I would like a way to stop this and have it happen only once.

EDIT: Entire Class

```<code>using BluePillApp.Models;
using BluePillApp.ViewModels.Base;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text;
using System.Windows.Input;
using Xamarin.Forms;
using Syn.Bot.Siml;
using Syn.Bot.Oscova;
using Syn.Bot.Oscova.Attributes;
using System.Reflection;
using System.IO;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace BluePillApp.ViewModels
{
    /// <summary>
    /// View model for the ChatbotPage.xaml
    /// </summary>
    public class ChatbotPageViewModel : BaseViewModel
    {
        /// <summary>
        /// A field for TextToSend
        /// </summary>
        private string _texttosend;

        /// <summary>
        /// An Instance of a new SIML Oscova Chatbot
        /// </summary>
        public OscovaBot chatbot;

        /// <summary>
        /// A collection/list of chat message items
        /// </summary>
        public ObservableCollection<ChatMessageModel> Messages { get; set; } = new ObservableCollection<ChatMessageModel>();

        /// <summary>
        /// The text that the user inputs
        /// </summary>
        public string TextToSend
        {
            get
            {
                return _texttosend;
            }

            set
            {
                if (_texttosend != value)
                {
                    _texttosend = value;

                    OnPropertyChanged();
                }
            }
        }

        /// <summary>
        /// A command for sending the users messages
        /// </summary>
        public ICommand SendCommand { get; set; }

        /// <summary>
        /// ChatPageViewModel Constructor
        /// </summary>
        public ChatbotPageViewModel()
        {
            SendCommand = new RelayCommand(Send);

            chatbot = new OscovaBot();
            var assembly = IntrospectionExtensions.GetTypeInfo(typeof(MainPage)).Assembly;
            Stream stream = assembly.GetManifestResourceStream("BluePillApp.Helpers.new.siml");

            chatbot.Import(XDocument.Load(stream));
            chatbot.Trainer.StartTraining();
        }

        /// <summary>
        /// This function sends a message
        /// </summary>
        public void Send()
        {
            if (!string.IsNullOrEmpty(TextToSend))
            {
                var msgModel = new ChatMessageModel() { Text = TextToSend, User = App.User };
                //This adds a new message to the messages collection
                Messages.Add(msgModel);

                //This gets the chatbots response for each message
                chatbot.MainUser.ResponseReceived += async (sender, args) =>
                {
                    await Task.Delay(1500);
                    Messages.Add(new ChatMessageModel() { Text = args.Response.Text, User = App.ChatBot });
                };

                var result = chatbot.Evaluate(TextToSend);
                result.Invoke();

                //Removes the text in the Entry after message is sent
                TextToSend = string.Empty;
            }
        }
    }
}

</code>```

答:
every time you call Send you are adding a NEW event handler

```<code>chatbot.MainUser.ResponseReceived +=
</code>```

you should only need to assign this event handler ONCE

Title: Event handler incrementing loop issue

Body:
I'm using Xamarin.Forms to create a chatbot app. Any time I send a new message to the bot, the reply is gotten but increments itself by one i.e

User: Hi
Bot: Hello
User: How are you?
Bot: Good
Bot: Good

In the code I'm using this:

 public void Send()
        {
            if (!string.IsNullOrEmpty(TextToSend))
            {
                //This adds a new message to the messages collection
                Messages.Add(new ChatMessageModel() { Text = TextToSend, User = App.User });

                //This gets the chatbots response for each message
                chatbot.MainUser.ResponseReceived += async (sender, args) =>
                {
                    await Task.Delay(1500);
                    Messages.Add(new ChatMessageModel() { Text = args.Response.Text, User = App.ChatBot });
                };

                var result = chatbot.Evaluate(TextToSend);
                result.Invoke();

                //Removes the text in the Entry after message is sent
                TextToSend = string.Empty;
            }
        }

After using a breakpoint on Messages.Add(new ChatMessageModel() { Text = args.Response.Text, User = App.ChatBot }); I found out that it adds a new message each and everytime, therefore incrementing upon itself. I would like a way to stop this and have it happen only once.

EDIT: Entire Class

using BluePillApp.Models;
using BluePillApp.ViewModels.Base;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Text;
using System.Windows.Input;
using Xamarin.Forms;
using Syn.Bot.Siml;
using Syn.Bot.Oscova;
using Syn.Bot.Oscova.Attributes;
using System.Reflection;
using System.IO;
using System.Threading.Tasks;
using System.Xml.Linq;

namespace BluePillApp.ViewModels
{
    ///
    /// View model for the ChatbotPage.xaml
    ///
    public class ChatbotPageViewModel : BaseViewModel
    {
        ///
        /// A field for TextToSend
        ///
        private string _texttosend;

        ///
        /// An Instance of a new SIML Oscova Chatbot
        ///
        public OscovaBot chatbot;

        ///
        /// A collection/list of chat message items
        ///
        public ObservableCollection<ChatMessageModel> Messages { get; set; } = new ObservableCollection<ChatMessageModel>();

        ///
        /// The text that the user inputs
        ///
        public string TextToSend
        {
            get
            {
                return _texttosend;
            }

            set
            {
                if (_texttosend != value)
                {
                    _texttosend = value;

                    OnPropertyChanged();
                }
            }
        }

        ///
        /// A command for sending the users messages
        ///
        public ICommand SendCommand { get; set; }

        ///
        /// ChatPageViewModel Constructor
        ///
        public ChatbotPageViewModel()
        {
            SendCommand = new RelayCommand(Send);

            chatbot = new OscovaBot();
            var assembly = IntrospectionExtensions.GetTypeInfo(typeof(MainPage)).Assembly;
            Stream stream = assembly.GetManifestResourceStream("BluePillApp.Helpers.new.siml");

            chatbot.Import(XDocument.Load(stream));
            chatbot.Trainer.StartTraining();
        }

        ///
        /// This function sends a message
        ///
        public void Send()
        {
            if (!string.IsNullOrEmpty(TextToSend))
            {
                var msgModel = new ChatMessageModel() { Text = TextToSend, User = App.User };
                //This adds a new message to the messages collection
                Messages.Add(msgModel);

                //This gets the chatbots response for each message
                chatbot.MainUser.ResponseReceived += async (sender, args) =>
                {
                    await Task.Delay(1500);
                    Messages.Add(new ChatMessageModel() { Text = args.Response.Text, User = App.ChatBot });
                };

                var result = chatbot.Evaluate(TextToSend);
                result.Invoke();

                //Removes the text in the Entry after message is sent
                TextToSend = string.Empty;
            }
        }
    }
}

Body:
every time you call Send you are adding a NEW event handler

chatbot.MainUser.ResponseReceived +=

you should only need to assign this event handler ONCE


问:
Add List box to List<ListBox> to pass to foreach loop ASP.NET
Hi I'm trying to create a list of ListBox's in ASP.NET so that I can then iterate it to test if it has been selected.

```<code>    List<string> con = new List<string>();
    List<ListBox> lb = new List<ListBox>();
    foreach (Control c in _pH_Outer_MainCri.Controls)
    {
        if (c is ListBox)
        {
            con.Add(c.ID.ToString());
            lb.Add(c.??);
        }
    }
</code>```

I'm getting caught up on that last part.  Basically then I can

```<code>foreach(ListBox a in lb)
    {
        if(a.TestSelection() == true )
        {
            BuildQuery(a);
        }
    }
</code>```

Thanks in advance for the help ...

答:
If you are adding all listboxes then you would want</p>

```<code>lb.Add((ListBox)c);
</code>```

Body:
Hi I'm trying to create a list of ListBox's in ASP.NET so that I can then iterate it to test if it has been selected.

    List<string> con = new List<string>();
    List<ListBox> lb = new List<ListBox>();
    foreach (Control c in _pH_Outer_MainCri.Controls)
    {
        if (c is ListBox)
        {
            con.Add(c.ID.ToString());
            lb.Add(c.??);
        }
    }

I'm getting caught up on that last part.  Basically then I can

foreach(ListBox a in lb)
    {
        if(a.TestSelection() == true )
        {
            BuildQuery(a);
        }
    }

Thanks in advance for the help ...

Body:
If you are adding all listboxes then you would want

lb.Add((ListBox)c);


问:
PowerShell gaps in output
When I run two commands one after the other in a script, I often end up with big gaps, as you can see with these two commands (I've concatenated them with ";" so can see the issue as a one-liner, it's just a Get-Netipaddress followed by a gwmi) they end up with a three line gaps between them. Sometimes I want more compact information in my output. Is there a way to tell PowerShell to stop introducing huge gaps between output?

```<code>Get-Netipaddress | where AddressFamily -eq IPv4 | select IPAddress,InterfaceIndex,InterfaceAlias | sort InterfaceIndex ; gwmi win32_logicaldisk | Format-Table DeviceId, VolumeName, @{n="Size(GB)";e={[math]::Round($_.Size/1GB,2)}},@{n="Free(GB)";e={[math]::Round($_.FreeSpace/1GB,2)}}
</code>```

答:
You can do the following, but I'm not sure I recommend it because it ruins your ability to further process any of the originally returned objects.</p>

```<code>($(Get-Netipaddress | Where AddressFamily -eq IPv4 | Select IPAddress,InterfaceIndex,InterfaceAlias | Sort InterfaceIndex ; gwmi win32_logicaldisk | Format-Table DeviceId, VolumeName, @{n="Size(GB)";e={[math]::Round($_.Size/1GB,2)}},@{n="Free(GB)";e={[math]::Round($_.FreeSpace/1GB,2)}}) | Out-String) -replace '(?m)^\r?\n'
</code>```

Title: PowerShell gaps in output

Body:
When I run two commands one after the other in a script, I often end up with big gaps, as you can see with these two commands (I've concatenated them with ";" so can see the issue as a one-liner, it's just a Get-Netipaddress followed by a gwmi) they end up with a three line gaps between them. Sometimes I want more compact information in my output. Is there a way to tell PowerShell to stop introducing huge gaps between output?

Get-Netipaddress | where AddressFamily -eq IPv4 | select IPAddress,InterfaceIndex,InterfaceAlias | sort InterfaceIndex ; gwmi win32_logicaldisk | Format-Table DeviceId, VolumeName, @{n="Size(GB)";e={[math]::Round($_.Size/1GB,2)}},@{n="Free(GB)";e={[math]::Round($_.FreeSpace/1GB,2)}}

Body:
You can do the following, but I'm not sure I recommend it because it ruins your ability to further process any of the originally returned objects.

($(Get-Netipaddress | Where AddressFamily -eq IPv4 | Select IPAddress,InterfaceIndex,InterfaceAlias | Sort InterfaceIndex ; gwmi win32_logicaldisk | Format-Table DeviceId, VolumeName, @{n="Size(GB)";e={[math]::Round($_.Size/1GB,2)}},@{n="Free(GB)";e={[math]::Round($_.FreeSpace/1GB,2)}}) | Out-String) -replace '(?m)^\r?\n'


问:
Set up pandas as pd alias in vscode
I recently started using vscode for python. I have a problem using alias. When i try to use import pandas as pd, it gives me intelligence options like pandas, pdb,pudb. I have no idea why its doing that and pd doesn't work.

Any idea on how to make alias work in vscode

答:
for that problem you can use ; then press enter it should work

```<code>import numpy as pd;
</code>```

Title: Set up pandas as pd alias in vscode

Body:
for that problem you can use ; then press enter it should work

import numpy as pd;