问:
How to do voice morphing to a phone call on android?
I'm develop an android application which needs to change the callers voice to chipmunk voice in real time processing. ie.like Whenever someone calls me, i want to hear their voice in chipmunk voice. I dont find any control or any api to do that in android. Also i dont know how to stop the voice from native phone receiver. Is this feature possible in android? Please give me show ideas to do the same.</p>

答:
You don't, unless you mean VOIP calls implemented outside of the framework rather than mobile network calls.

Android does not provide access to the in-call audio.  On (many? all?) present devices that's thought to actually be a hardware limitation or at least buried in vendor-proprietary code for the radio processor, and so not alterable from the android/linux side even if you root, install a customized build, etc.


来源: stackexchange

问:
Python scope of variables in and out of a function
Consider the following code:

```<code>def square(x):
    return x**2.

def cube(x):
    return x**3.

def some_func():
    foo['a'] = 1.
    foo['b'] = 3.

    if foo['b'] > foo['a']:
        bar = square
    else:
        bar = cube

foo = dict()

bar = None

some_func()

print(foo['a'])

print(bar(2))
</code>```

Two different variables are initialised in the beginning, foo, and bar. Then I run a function which doesn't take arguments or return anything, but amends these two variables.

The result of these two is the following:

```<code>1.0
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-7e5e5ac79215> in <module>
     22 print(foo['a'])
     23
---> 24 print(bar(2))

TypeError: 'NoneType' object is not callable
</code>```

So, the dict is happily amended by some_func(), but I cannot assign a function name. Why? How can I go around this?

Edit: I have tried giving bar other values than None, similar behaviour occurs.

答:
Inside of some_func() you are adding key-value pairs to the dictionary object referenced by foo. You are editing the object directly. bar is referencing a None object. When you attempt to re-assign the value of the label bar inside of some_func() it does so, but only for the scope of the function it is in. When it leaves the function whatever the bar variable had reference to, None in this case, is what it still references.

The difference is that you are manipulating the object foo points to, but completely changing which object that bar points to. If you could do anything with a None object you would be able to manipulate it inside of some_func() too.

Some here have offered the global option, but unless you are really sure, that is probably not what you want. To truly assign a new value to bar you should return it as a result of some_func(). Also, you may consider passing in foo as a parameter into some_func() so that it is clear what variable you are referencing.

def square(x):
    return x**2.

def cube(x):
    return x**3.

def some_func(foo):
    foo['a'] = 1.
    foo['b'] = 3.

    if foo['b'] > foo['a']:
        bar = square
    else:
        bar = cube
    return bar

foo = dict()
bar = some_func(foo)
```

ContentLicense: CC BY-SA 4.0

Body:
Consider the following code:

def square(x):
    return x**2.

def cube(x):
    return x**3.

def some_func():
    foo['a'] = 1.
    foo['b'] = 3.

    if foo['b'] > foo['a']:
        bar = square
    else:
        bar = cube

foo = dict()

bar = None

some_func()

print(foo['a'])

print(bar(2))

Two different variables are initialised in the beginning, foo, and bar. Then I run a function which doesn't take arguments or return anything, but amends these two variables.

The result of these two is the following:

1.0
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-7-7e5e5ac79215> in <module>
     22 print(foo['a'])
     23
---> 24 print(bar(2))

TypeError: 'NoneType' object is not callable

So, the dict is happily amended by some_func(), but I cannot assign a function name. Why? How can I go around this?

Edit: I have tried giving bar other values than None, similar behaviour occurs.


问:
Add column CSV in existing CSV with powershell
I have a Powershell script, which collects the size of a backup, and exports it to CSV, I would like to know if it is possible that it could be added to the next csv column, or an excel.

I've been looking at the documentation, because I think it looks better on an excel, but I can't add one more column, I always believe it from scratch.

```<code>$today = (get-date).Date
$backup = Get-VBRBackup | where {$_.info.jobname -eq "A. ProduccionInterna.Infraestructura Backup Copy"}
if ($backup) {
$backup.GetAllStorages() | where {$_.CreationTime.Date -eq $today} | select {$_.PartialPath}, {$_.Stats.BackupSize/1GB} |
export-csv -Path C:\Users\acepero\Documents\test.csv -NoTypeInformation -Delimiter ';'
}
</code>```

UPDATE

I have managed to create new columns once, then it gives an error:

```<code>Select-Object : The property cannot be processed because the property "{$_.PartialPath}, {$_.Stats.BackupSize/1GB} , {$Session.BackupStats.DedupRatio} ,
{$Session.BackupStats.CompressRatio}" already exists.
</code>```

The code now has this form

```<code>$today = (get-date).Date
$backup = Get-VBRBackup | where {$_.info.jobname -eq "A. ProduccionInterna.Infraestructura Backup Copy"}
if ($backup) {
$backup.GetAllStorages() | where {$_.CreationTime.Date -eq $today} | select {$_.PartialPath}, {$_.Stats.BackupSize/1GB} , {$Session.BackupStats.DedupRatio} , {$Session.BackupStats.CompressRatio}
(Import-Csv "C:\Users\acepero\Documents\test.csv") |
    Select-Object *, {{$_.PartialPath}, {$_.Stats.BackupSize/1GB} , {$Session.BackupStats.DedupRatio} , {$Session.BackupStats.CompressRatio}} |
Export-csv -Path C:\Users\acepero\Documents\test.csv -NoTypeInformation #-Delimiter ';'
}
</code>```

答:
When you take output from a command and pipe it through select, you are creating an output object, which has the selected values as properties.  Here is an example using the Get-ChildItem command:

```<code>$result = Get-ChildItem C:\Temp | select Name, Length
</code>```

The $result array contains objects which have the "Length" and "Name" NoteProperties.  When you pipe that object to Export-CSV, it creates one column for each Property/NoteProperty the object has.  In order to 'add a column to the CSV', all you need to do is add a NoteProperty to the object.  You can do that with the Add-Member cmdlet, like this:

```<code>$result | Add-Member -MemberType NoteProperty -Name 'ColumnName' -Value 'ColumnValue'
</code>```

Be careful how you do this.  If $result is a single object, this command will add the NoteProperty/Value pair to that object.  If $result is an array of objects, it will add that NoteProperty/Value pair to all objects held in the array.  If you need to assign different values to each object, you'll need to iterate through the array:

```<code>ForEach ($res in $result)
{
    $thisvalue = '' #Assign specific value here
    $res | Add-Member -MemberType NoteProperty -Name 'ColumnName' -Value $thisvalue
}
</code>```

I hope this helps you.  If it does, please don't forget to accept the answer.

Body:
I have a Powershell script, which collects the size of a backup, and exports it to CSV, I would like to know if it is possible that it could be added to the next csv column, or an excel.

I've been looking at the documentation, because I think it looks better on an excel, but I can't add one more column, I always believe it from scratch.

$today = (get-date).Date
$backup = Get-VBRBackup | where {$_.info.jobname -eq "A. ProduccionInterna.Infraestructura Backup Copy"}
if ($backup) {
$backup.GetAllStorages() | where {$_.CreationTime.Date -eq $today} | select {$_.PartialPath}, {$_.Stats.BackupSize/1GB} |
export-csv -Path C:\Users\acepero\Documents\test.csv -NoTypeInformation -Delimiter ';'
}

UPDATE

I have managed to create new columns once, then it gives an error:

Select-Object : The property cannot be processed because the property "{$_.PartialPath}, {$_.Stats.BackupSize/1GB} , {$Session.BackupStats.DedupRatio} ,
{$Session.BackupStats.CompressRatio}" already exists.

The code now has this form

$today = (get-date).Date
$backup = Get-VBRBackup | where {$_.info.jobname -eq "A. ProduccionInterna.Infraestructura Backup Copy"}
if ($backup) {
$backup.GetAllStorages() | where {$_.CreationTime.Date -eq $today} | select {$_.PartialPath}, {$_.Stats.BackupSize/1GB} , {$Session.BackupStats.DedupRatio} , {$Session.BackupStats.CompressRatio}
(Import-Csv "C:\Users\acepero\Documents\test.csv") |
    Select-Object *, {{$_.PartialPath}, {$_.Stats.BackupSize/1GB} , {$Session.BackupStats.DedupRatio} , {$Session.BackupStats.CompressRatio}} |
Export-csv -Path C:\Users\acepero\Documents\test.csv -NoTypeInformation #-Delimiter ';'
}

Body:
When you take output from a command and pipe it through select, you are creating an output object, which has the selected values as properties.  Here is an example using the Get-ChildItem command:

$result = Get-ChildItem C:\Temp | select Name, Length

The $result array contains objects which have the "Length" and "Name" NoteProperties.  When you pipe that object to Export-CSV, it creates one column for each Property/NoteProperty the object has.  In order to 'add a column to the CSV', all you need to do is add a NoteProperty to the object.  You can do that with the Add-Member cmdlet, like this:

$result | Add-Member -MemberType NoteProperty -Name 'ColumnName' -Value 'ColumnValue'

Be careful how you do this.  If $result is a single object, this command will add the NoteProperty/Value pair to that object.  If $result is an array of objects, it will add that NoteProperty/Value pair to all objects held in the array.  If you need to assign different values to each object, you'll need to iterate through the array:

ForEach ($res in $result)
{
    $thisvalue = '' #Assign specific value here
    $res | Add-Member -MemberType NoteProperty -Name 'ColumnName' -Value $thisvalue
}

I hope this helps you.  If it does, please don't forget to accept the answer.


问:
python mocking sqlalchemy connection
I have a simple function that connects to a DB and fetches some data.

```<code>db.py

from sqlalchemy import create_engine
from sqlalchemy.pool import NullPool

def _create_engine(app):
    impac_engine = create_engine(
        app['DB'],
        poolclass=NullPool  # this setting enables NOT to use Pooling, preventing from timeout issues.
    )
    return impac_engine

def get_all_pos(app):
    engine = _create_engine(app)
    qry = """SELECT DISTINCT id, name FROM p_t ORDER BY name ASC"""
    try:
        cursor = engine.execute(qry)
        rows = cursor.fetchall()
        return rows
    except Exception as re:
        raise re
</code>```

I'm trying to write some test cases by mocking this connection -

tests.py

```<code>import unittest
from db import get_all_pos
from unittest.mock import patch
from unittest.mock import Mock

class TestPosition(unittest.TestCase):

    @patch('db.sqlalchemy')
    def test_get_all_pos(self, mock_sqlalchemy):
        mock_sqlalchemy.create_engine = Mock()
        get_all_pos({'DB': 'test'})

if __name__ == '__main__':
    unittest.main()
</code>```

When I run the above file python tests.py, I get the following error -

```<code>   "Could not parse rfc1738 URL from string '%s'" % name
sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string 'test'
</code>```

Shouldn't mock_sqlalchemy.create_engine = Mock() give me a mock object and bypass the URL check.

答:
Another option would be to mock your _create_engine function. Since this is a unit test and we want to test get_all_pos we shouldn't need to rely on the behavior of _create_engine, so we can just patch that like so.

```<code>import unittest
import db
from unittest.mock import patch

class TestPosition(unittest.TestCase):

    @patch.object(db, '_create_engine')
    def test_get_all_pos(self, mock_sqlalchemy):
        args = {'DB': 'test'}
        db.get_all_pos(args)
        mock_sqlalchemy.assert_called_once()
        mock_sqlalchemy.assert_called_with({'DB': 'test'})

if __name__ == '__main__':
    unittest.main()
</code>```

If you want to test certain results you will need to properly set all the corresponding attributes. I would recommend not chaining it into one call so that it is more readable as shown below.

```<code>import unittest
import db
from unittest.mock import patch
from unittest.mock import Mock

class Cursor:
    def __init__(self, vals):
        self.vals = vals

    def fetchall(self):
        return self.vals

class TestPosition(unittest.TestCase):

    @patch.object(db, '_create_engine')
    def test_get_all_pos(self, mock_sqlalchemy):
        to_test = [1, 2, 3]

        mock_cursor = Mock()
        cursor_attrs = {'fetchall.return_value': to_test}
        mock_cursor.configure_mock(**cursor_attrs)

        mock_execute = Mock()
        engine_attrs = {'execute.return_value': mock_cursor}
        mock_execute.configure_mock(**engine_attrs)

        mock_sqlalchemy.return_value = mock_execute

        args = {'DB': 'test'}
        rows = db.get_all_pos(args)

        mock_sqlalchemy.assert_called_once()
        mock_sqlalchemy.assert_called_with({'DB': 'test'})
        self.assertEqual(to_test, rows)
</code>```

Title: python mocking sqlalchemy connection

Body:
I have a simple function that connects to a DB and fetches some data.

db.py

from sqlalchemy import create_engine
from sqlalchemy.pool import NullPool

def _create_engine(app):
    impac_engine = create_engine(
        app['DB'],
        poolclass=NullPool  # this setting enables NOT to use Pooling, preventing from timeout issues.
    )
    return impac_engine

def get_all_pos(app):
    engine = _create_engine(app)
    qry = """SELECT DISTINCT id, name FROM p_t ORDER BY name ASC"""
    try:
        cursor = engine.execute(qry)
        rows = cursor.fetchall()
        return rows
    except Exception as re:
        raise re

I'm trying to write some test cases by mocking this connection -

tests.py

import unittest
from db import get_all_pos
from unittest.mock import patch
from unittest.mock import Mock

class TestPosition(unittest.TestCase):

    @patch('db.sqlalchemy')
    def test_get_all_pos(self, mock_sqlalchemy):
        mock_sqlalchemy.create_engine = Mock()
        get_all_pos({'DB': 'test'})

if __name__ == '__main__':
    unittest.main()

When I run the above file python tests.py, I get the following error -

   "Could not parse rfc1738 URL from string '%s'" % name
sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string 'test'

Shouldn't mock_sqlalchemy.create_engine = Mock() give me a mock object and bypass the URL check.

Body:
Another option would be to mock your _create_engine function. Since this is a unit test and we want to test get_all_pos we shouldn't need to rely on the behavior of _create_engine, so we can just patch that like so.

import unittest
import db
from unittest.mock import patch

class TestPosition(unittest.TestCase):

    @patch.object(db, '_create_engine')
    def test_get_all_pos(self, mock_sqlalchemy):
        args = {'DB': 'test'}
        db.get_all_pos(args)
        mock_sqlalchemy.assert_called_once()
        mock_sqlalchemy.assert_called_with({'DB': 'test'})

if __name__ == '__main__':
    unittest.main()

If you want to test certain results you will need to properly set all the corresponding attributes. I would recommend not chaining it into one call so that it is more readable as shown below.

import unittest
import db
from unittest.mock import patch
from unittest.mock import Mock

class Cursor:
    def __init__(self, vals):
        self.vals = vals

    def fetchall(self):
        return self.vals

class TestPosition(unittest.TestCase):

    @patch.object(db, '_create_engine')
    def test_get_all_pos(self, mock_sqlalchemy):
        to_test = [1, 2, 3]

        mock_cursor = Mock()
        cursor_attrs = {'fetchall.return_value': to_test}
        mock_cursor.configure_mock(**cursor_attrs)

        mock_execute = Mock()
        engine_attrs = {'execute.return_value': mock_cursor}
        mock_execute.configure_mock(**engine_attrs)

        mock_sqlalchemy.return_value = mock_execute

        args = {'DB': 'test'}
        rows = db.get_all_pos(args)

        mock_sqlalchemy.assert_called_once()
        mock_sqlalchemy.assert_called_with({'DB': 'test'})
        self.assertEqual(to_test, rows)


问:
What iptables knows about pods?
Let's say we have 2 Nodes in a cluster.

Node A has 1 replica of a pod, Node B has 2 replicas. According to this talk (YouTube video with a time tag) from Google Cloud engineers, a request which was routed to Node A might be rerouted to the Node B by iptables which is inside the Node A. I have several questions regarding this behavior:

What information iptables of Node A knows about replicas of a pod outside of it? How does it know where to send the traffic?

Can it be that iptables of the Node B reroutes this request to Node C? If so, then will the egress traffic go back to the Node B -> Node A -> Client?

答:
Packets can move between nodes, services and pods before reaching the final destination.

All the intra-cluster routing (node-to-node, pod-to-pod, service-to-service, pod-to-service, service-to-pod, pod-to-node, node-to-pod, etc) in kubernetes is done by:

CNI

load-balancing algorithm

kube-proxy

iptables.

Packet route in k8s also depends on many things like load in the cluster, per-node load, affinity/anti-affinity rules, nodeSelectors, taints/tolerations, autoscaling, number of pod replicas, etc.

Intra-cluster routing is transparent to the router and ideally the user need not know about it unless there are networking issues to debug.

Doing sudo iptables -L -n -v on any k8s node shows the low-level iptables rules and chains used for packet-forwarding.

Title: What iptables knows about pods?


问:
Publish Jekyll Site To Git Repository
Every time I run Jekyll it destroys the entire contents of the destination folder.  The problem with this is that my destination directory is a small git repo from which I use to push to my actual server.  Is there a way to stop Jekyll deleting the Git files so that I don't have to generate the contents then copy them over?</p>

答:
You could have:

your git repo elsewhere (i.e. not in the directory affected by a Jekyll deployment)

have your script pushing that git repo to your server specify a GIT_WORK_TREE variable with the destination folder as value

In other words, a .git don't have to be necessary in the working tree directory itself.

It can be elsewhere, and your script can refer to the actual working tree through  GIT_WORK_TREE or through a --work-tree=<path> option.

If your script is part of the destination directory where Jenkyll copies/erases files, you can do the opposite, and mention where the .git actually is with GIT_DIR variable or with --git-dir=<path> option.

To have new --work-dir as default options to your repo, you can use git-config --add core.worktree ../PATH/, where PATH - path to actual working directory relative to .git.

ContentLicense: CC BY-SA 3.0

Title: Publish Jekyll Site To Git Repository


问:
JavaScript: How to check if a array object contain specific values
I have this array:

[
  {
    "active": true,
    "name": "agency one"
  },
  {
    "active": false,
    "name": "agency two"
  },
  {
    "active": true,
    "name": "agency three"
  },
  {
    "active": false,
    "name": "agency four"
  }
]
```

<p>And some data like this:</p>

<pre class="lang-js prettyprint-override"><code>{
    "domain": "agency one",
    "url": "https://....",
    "title": "some title",
    "img": "https://.....jpg",
    "tag": "some tag",
}
</code>```

How can I check if agancy is active show data?

答:
use .filter()</p>

```<code>console.log(array.filter(items => {
  return items.active === true
//should return every "active that is set to true"
}))
</code>```

Body:
I have this array:

[
  {
    "active": true,
    "name": "agency one"
  },
  {
    "active": false,
    "name": "agency two"
  },
  {
    "active": true,
    "name": "agency three"
  },
  {
    "active": false,
    "name": "agency four"
  }
]

And some data like this:

{
    "domain": "agency one",
    "url": "https://....",
    "title": "some title",
    "img": "https://.....jpg",
    "tag": "some tag",
}

How can I check if agancy is active show data?

Body:
use .filter()

console.log(array.filter(items => {
  return items.active === true
//should return every "active that is set to true"
}))


问:
inverse cartesian product - given the product, find the index
I have a function which computes the n'th element of the cartesian product of a number of input arrays:

```<code>def prod(arrs, n):
    out = []

    for i,arr in enumerate(arrs):
        denom = numpy.prod([ len(p) for p in arrs[i+1:] ], dtype=int)
        idx = n // denom % len(arr)
        out.append( arr[idx] )

    return out
</code>```

This function works great:

```<code>a = [ 1000, 1100, 1200, 1300, 1400 ]
b = [ 1.0, 1.5, 2.0, 2.5, 3.0, 3.5 ]
c = [ -2, -1, 0, 1, 2 ]

for n in range(20, 30):
    i = prod([a, b, c], n)
    print(i)
</code>```

```<code>[1000, 3.0, -2]
[1000, 3.0, -1]
[1000, 3.0, 0]
[1000, 3.0, 1]
[1000, 3.0, 2]
[1000, 3.5, -2]
[1000, 3.5, -1]
[1000, 3.5, 0]
[1000, 3.5, 1]
[1000, 3.5, 2]
</code>```

Now I need to "go backwards".

That is, given the input arrays [ a, b, c ], and a single permutation, find which element in the cartesian product that permutation is. (each array can be assumed to contain only distinct elements.)

Eg:

```<code>def n_from_prod(arrs, arr):
    # TODO: calculate n

n = n_from_prod([a, b, c], [1000, 3.5, -2])

assert n == 25
</code>```

Question:

Given a single permutation of the cartesian product of a number of input arrays, how can I find n, which number in the series, that permutation is?

Body:
I have a function which computes the n'th element of the cartesian product of a number of input arrays:

def prod(arrs, n):
    out = []

    for i,arr in enumerate(arrs):
        denom = numpy.prod([ len(p) for p in arrs[i+1:] ], dtype=int)
        idx = n // denom % len(arr)
        out.append( arr[idx] )

    return out

This function works great:

a = [ 1000, 1100, 1200, 1300, 1400 ]
b = [ 1.0, 1.5, 2.0, 2.5, 3.0, 3.5 ]
c = [ -2, -1, 0, 1, 2 ]

for n in range(20, 30):
    i = prod([a, b, c], n)
    print(i)

[1000, 3.0, -2]
[1000, 3.0, -1]
[1000, 3.0, 0]
[1000, 3.0, 1]
[1000, 3.0, 2]
[1000, 3.5, -2]
[1000, 3.5, -1]
[1000, 3.5, 0]
[1000, 3.5, 1]
[1000, 3.5, 2]

Now I need to "go backwards".

That is, given the input arrays [ a, b, c ], and a single permutation, find which element in the cartesian product that permutation is. (each array can be assumed to contain only distinct elements.)

Eg:

def n_from_prod(arrs, arr):
    # TODO: calculate n

n = n_from_prod([a, b, c], [1000, 3.5, -2])

assert n == 25

Question:

Given a single permutation of the cartesian product of a number of input arrays, how can I find n, which number in the series, that permutation is?

Body:
I have managed to figure this out - posting here in case it is of use to anyone in the future

def n_from_prod(arrs, arr):
    assert len(arrs) == len(arr)

    n = 0
    for i in range(len(arr)):
        idx = arrs[i].index(arr[i])
        mult = numpy.prod([ len(p) for p in arrs[i+1:] ], dtype=int)
        n += idx * mult

    return n

Testing:

a = [ 1000, 1100, 1200, 1300, 1400 ]
b = [ 1.0, 1.5, 2.0, 2.5, 3.0, 3.5 ]
c = [ -2, -1, 0, 1, 2 ]

for n in range(20, 30):
    i = prod([a, b, c], n)

    n_calc = n_from_prod([a, b, c], i)

    assert n == n_calc

    print(n, n_calc, i)

Output:

20 20 [1000, 3.0, -2]
21 21 [1000, 3.0, -1]
22 22 [1000, 3.0, 0]
23 23 [1000, 3.0, 1]
24 24 [1000, 3.0, 2]
25 25 [1000, 3.5, -2]
26 26 [1000, 3.5, -1]
27 27 [1000, 3.5, 0]
28 28 [1000, 3.5, 1]
29 29 [1000, 3.5, 2]


问:
Is the AddNServiceBus() method callable on an IServiceCollection object?
I'm trying to setup NSB in a .NET Core Web Api project to send commands to a .NET Core Endpoint project containing handlers to receive messages.
Code so far to register NSB:

```<code>     public void ConfigureServices(IServiceCollection services)
        {
            ......
            ......
            //services.AddNServiceBus(endpointConfiguration);
            var endpoint = Endpoint.Start(SetupEndpointConfiguration()).GetAwaiter().GetResult();
            services.AddSingleton(endpoint);
        }
</code>```

According to NSB docs ( https://docs.particular.net/samples/dependency-injection/aspnetcore/ ), using built in DI of .net core ( 3.1 for me), we should be able to call .AddNServiceBus() on the services object. However, I am unable to do so since VS cannot resolve the method.
I have the following libraries installed:

```<code>    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.Hosting;
    using Microsoft.OpenApi.Models;
    using NServiceBus;
    using Serilog;
</code>```

What I've tried:
Made an endpoint using Endpoint.Start() and registered it using addSingleton() as shown in the first code block. But not satisfied since the docs should let me use the AddNServiceBus() to register NSB within ConfigureServices().

Why is .AddNServiceBus() not resolvable, despite having NSB installed?

答:
I think you're missing a using statement:

using NServiceBus.Extensions.DependencyInjection;

You can verify you have the correct ones by clicking "COPY USINGS" above the relevant code snippet in the sample you referenced.

Body:
I'm trying to setup NSB in a .NET Core Web Api project to send commands to a .NET Core Endpoint project containing handlers to receive messages.
Code so far to register NSB:

     public void ConfigureServices(IServiceCollection services)
        {
            ......
            ......
            //services.AddNServiceBus(endpointConfiguration);
            var endpoint = Endpoint.Start(SetupEndpointConfiguration()).GetAwaiter().GetResult();
            services.AddSingleton(endpoint);
        }

According to NSB docs ( https://docs.particular.net/samples/dependency-injection/aspnetcore/ ), using built in DI of .net core ( 3.1 for me), we should be able to call .AddNServiceBus() on the services object. However, I am unable to do so since VS cannot resolve the method.
I have the following libraries installed:

    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Configuration;
    using Microsoft.Extensions.DependencyInjection;
    using Microsoft.Extensions.Hosting;
    using Microsoft.OpenApi.Models;
    using NServiceBus;
    using Serilog;

What I've tried:
Made an endpoint using Endpoint.Start() and registered it using addSingleton() as shown in the first code block. But not satisfied since the docs should let me use the AddNServiceBus() to register NSB within ConfigureServices().

Why is .AddNServiceBus() not resolvable, despite having NSB installed?


问:
matplotlib: matshow has grid lines on top of image
I'm using pyplot.matshow to plot a matrix, and am trying to use plt.gca().set_axisbelow(True) to make the gridlines show behind the plot but they are always on top.  How can I make the grid lines plot behind a matshow?

```<code>import numpy as np
from matplotlib.colors import ListedColormap
import matplotlib.pyplot as plt
plt.rcParams['axes.axisbelow'] = True

m = np.zeros((21, 21))
m[14:17, 12:14] = -0.1

plt.matshow(np.ma.masked_equal(m, 0), cmap=ListedColormap(['k', 'w']), extent=(0.5, 20.5, 20.5, 0.5))
plt.xticks(range(1, 21));
plt.yticks(range(1, 21));
plt.gca().set_axisbelow(True)
plt.grid()
</code>```

Note: edited to plot only nonzero parts as noted in comments.

答:
You could change the color of the grid to the same color as the squares (instead of the default dark grey). So, 'black' in the case of the example in the question. (print(matplotlib.rcparams['grid.color'] shows the default grid color: '#b0b0b0'). That way the grid is invisible over the black parts of the plot.

Experiment with line style and/or line width to make the grid less prominent.

In the code below I changed the image to 20x20 to have the black squares nicely centered and removed the lower xticks. The colors don't need to be black and white, though the grid will only be invisible over the squares of the same color as the grid.

import numpy as np
from matplotlib.colors import ListedColormap
import matplotlib.pyplot as plt

m = np.zeros((20, 20))
for i in range(20):
    for j in range(20):
        if 45 <= abs(i-9.5)**2 + abs(j-9.5)**2 <= 65:
            m[i, j] = -0.1

plt.matshow(m, cmap=ListedColormap(['indigo', 'gold']), extent=(0.5, 20.5, 20.5, 0.5))
plt.xticks(range(1, 21))
plt.yticks(range(1, 21))
plt.tick_params(axis='x', bottom=False)
plt.grid(c='indigo', ls=':', lw='0.4')
plt.show()
```

Body:
I'm using pyplot.matshow to plot a matrix, and am trying to use plt.gca().set_axisbelow(True) to make the gridlines show behind the plot but they are always on top.  How can I make the grid lines plot behind a matshow?

import numpy as np
from matplotlib.colors import ListedColormap
import matplotlib.pyplot as plt
plt.rcParams['axes.axisbelow'] = True

m = np.zeros((21, 21))
m[14:17, 12:14] = -0.1

plt.matshow(np.ma.masked_equal(m, 0), cmap=ListedColormap(['k', 'w']), extent=(0.5, 20.5, 20.5, 0.5))
plt.xticks(range(1, 21));
plt.yticks(range(1, 21));
plt.gca().set_axisbelow(True)
plt.grid()

Note: edited to plot only nonzero parts as noted in comments.


问:
Unable to cast object of type 'ASP._Page_Areas_Admin__ViewStart_cshtml' to type 'System.Web.WebPages.StartPage'
I created an area named "Admin".

In /Areas/Admin/Views/, I have _ViewStart.cshtml with this:

```<code>@{
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
</code>```

I'm getting the following error when I visit a page in /Admin/: Unable to cast object of type 'ASP._Page_Areas_Admin__ViewStart_cshtml' to type 'System.Web.WebPages.StartPage'.

I made the suggested changes from How do I use a common _ViewStart in areas?.

I have this in my web.config in the root, and the web.config at /Areas/Admin/Views/:

```<code><configSections>
  <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
    <section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
  </sectionGroup>
</configSections>

<system.web.webPages.razor>
  <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  <pages pageBaseType="System.Web.Mvc.WebViewPage">
    <namespaces>
      <add namespace="System.Web.Mvc" />
      <add namespace="System.Web.Mvc.Ajax" />
      <add namespace="System.Web.Mvc.Html" />
      <add namespace="System.Web.Routing" />
    </namespaces>
  </pages>
</system.web.webPages.razor>

<appSettings>
  <add key="webpages:Version" value="1.0.0.0"/>
  <add key="webpages:Enabled" value="false" />
  <add key="ClientValidationEnabled" value="true"/>
  <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
</code>```

Anyone know what I'm doing wrong here?

EDIT: Don't know if this helps, but if I delete the code in _ViewStart.cshtml so that it's empty, I'm able to view the pages in /Admin without getting an error.

答:
_ViewStart.cshtml files can only be placed into a Views folder. The exception you are getting very strongly suggests that you have not placed the _ViewStart.cshtml inside the ~/Areas/Admin/Views/ folder (at the same level as the web.config).

Here's how a correct project structure should look like:

Body:
I created an area named "Admin".

In /Areas/Admin/Views/, I have _ViewStart.cshtml with this:

@{
    Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}

I'm getting the following error when I visit a page in /Admin/: Unable to cast object of type 'ASP._Page_Areas_Admin__ViewStart_cshtml' to type 'System.Web.WebPages.StartPage'.

I made the suggested changes from How do I use a common _ViewStart in areas?.

I have this in my web.config in the root, and the web.config at /Areas/Admin/Views/:

<configSections>
  <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

  </sectionGroup>
</configSections>

<system.web.webPages.razor>
  <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  <pages pageBaseType="System.Web.Mvc.WebViewPage">
    <namespaces>
      <add namespace="System.Web.Mvc" />
      <add namespace="System.Web.Mvc.Ajax" />
      <add namespace="System.Web.Mvc.Html" />
      <add namespace="System.Web.Routing" />
    </namespaces>
  </pages>
</system.web.webPages.razor>

<appSettings>
  <add key="webpages:Version" value="1.0.0.0"/>
  <add key="webpages:Enabled" value="false" />
  <add key="ClientValidationEnabled" value="true"/>
  <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>

Anyone know what I'm doing wrong here?

EDIT: Don't know if this helps, but if I delete the code in _ViewStart.cshtml so that it's empty, I'm able to view the pages in /Admin without getting an error.


问:
FLTK 2.0 build and demo for circa-2011 code base for VS2019
I discovered a program that may meet some needs; the source is available on sourceforge but the dependency list was lacking sufficient detail. I've managed to track down (most) of them and selected the versions based upon the release date of the software. The goal is to get the code to compile as faithfully as it initially did back in 2011, then worry about upgrading/fixing/migrating to newer libraries.

One package, FLTK, is using the abandoned 2.0 version. I found two different versions. The project files included were 'one way upgraded' to MS2019. Many properties and links needed to be fixed.

I'm attempting to compile the test 'cubeview' program, and end up with 37 unresolved dependencies.

As below, I've gone into the project, properties, configuration prope

```<code>Severity    Code    Description Project File    Line    Suppression State
Error   LNK1120 37 unresolved externals CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\Debug\CubeView.exe    1
Error   LNK2019 unresolved external symbol "public: bool __thiscall fltk::Widget::find(class fltk::AssociationType const &,void *)const " (?find@Widget@fltk@@QBE_NABVAssociationType@2@PAX@Z) referenced in function "public: bool __thiscall fltk::Widget::add_shortcut(unsigned int)" (?add_shortcut@Widget@fltk@@QAE_NI@Z)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "public: bool __thiscall fltk::Widget::remove(class fltk::AssociationType const &,void *)" (?remove@Widget@fltk@@QAE_NABVAssociationType@2@PAX@Z) referenced in function "public: bool __thiscall fltk::Widget::remove_shortcut(unsigned int)" (?remove_shortcut@Widget@fltk@@QAE_NI@Z)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "public: void * __thiscall fltk::Widget::foreach(class fltk::AssociationType const &,class fltk::AssociationFunctor &)const " (?foreach@Widget@fltk@@QBEPAXABVAssociationType@2@AAVAssociationFunctor@2@@Z) referenced in function "public: bool __thiscall fltk::Widget::test_shortcut(bool)const " (?test_shortcut@Widget@fltk@@QBE_N_N@Z) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "public: void * __thiscall fltk::Widget::get(class fltk::AssociationType const &)const " (?get@Widget@fltk@@QBEPAXABVAssociationType@2@@Z) referenced in function "public: unsigned int __thiscall fltk::Widget::shortcut(void)const " (?shortcut@Widget@fltk@@QBEIXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "public: void __thiscall fltk::Widget::add(class fltk::AssociationType const &,void *)" (?add@Widget@fltk@@QAEXABVAssociationType@2@PAX@Z) referenced in function "public: bool __thiscall fltk::Widget::add_shortcut(unsigned int)" (?add_shortcut@Widget@fltk@@QAE_NI@Z)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "public: void __thiscall fltk::Widget::set(class fltk::AssociationType const &,void *)" (?set@Widget@fltk@@QAEXABVAssociationType@2@PAX@Z) referenced in function "public: void __thiscall fltk::Widget::remove_shortcuts(void)" (?remove_shortcuts@Widget@fltk@@QAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "void * __cdecl fltk::foreach(class fltk::AssociationType const *,class fltk::Widget const *,class fltk::AssociationFunctor &)" (?foreach@fltk@@YAPAXPBVAssociationType@1@PBVWidget@1@AAVAssociationFunctor@1@@Z) referenced in function "unsigned int __cdecl fltk::foreachShortcut(class fltk::Widget const *,class fltk::ShortcutFunctor &)" (?foreachShortcut@fltk@@YAIPBVWidget@1@AAVShortcutFunctor@1@@Z)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "void __cdecl delete_associations_for(class fltk::Widget *)" (?delete_associations_for@@YAXPAVWidget@fltk@@@Z) referenced in function "public: virtual __thiscall fltk::Widget::~Widget(void)" (??1Widget@fltk@@UAE@XZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\Widget.obj    1
Error   LNK2019 unresolved external symbol _WSAAsyncSelect@16 referenced in function "void __cdecl fltk::add_fd(int,int,void (__cdecl*)(int,void *),void *)" (?add_fd@fltk@@YAXHHP6AXHPAX@Z0@Z) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\run.obj   1
Error   LNK2019 unresolved external symbol __imp__glBegin@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glBlendFunc@8 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glClear@4 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glColor3f@12 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glColor4f@16 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glCopyPixels@20 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glDisable@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glDrawBuffer@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glEnable@4 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glEnd@0 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glFlush@0 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2001 unresolved external symbol __imp__glLoadIdentity@0  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glLoadIdentity@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2001 unresolved external symbol __imp__glOrtho@48    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glOrtho@48 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glPopMatrix@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glPushMatrix@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glRasterPos2i@8 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glReadBuffer@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glRotatef@16 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glScalef@12 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glShadeModel@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glTranslatef@12 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glVertex3fv@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2001 unresolved external symbol __imp__glViewport@16 CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glViewport@16 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__wglCreateContext@4 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Choice.obj)   1
Error   LNK2019 unresolved external symbol __imp__wglCreateLayerContext@8 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Choice.obj)   1
Error   LNK2019 unresolved external symbol __imp__wglDeleteContext@4 referenced in function "void __cdecl fltk::delete_gl_context(struct HGLRC__ *)" (?delete_gl_context@fltk@@YAXPAUHGLRC__@@@Z)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Choice.obj)   1
Error   LNK2019 unresolved external symbol __imp__wglMakeCurrent@8 referenced in function "void __cdecl fltk::no_gl_context(void)" (?no_gl_context@fltk@@YAXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Choice.obj)   1
Error   LNK2019 unresolved external symbol __imp__wglShareLists@8 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Choice.obj)   1
</code>```

Another 'output' portion that I failed to include:

```<code>1>------ Build started: Project: fltk, Configuration: Debug Win32 ------
1>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(445,5): warning MSB8004: Output Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
1>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(459,5): warning MSB8028: The intermediate directory (Debug\) contains files shared from another project (boxtype.vcxproj, checkers.vcxproj, color_chooser.vcxproj, CubeView.vcxproj, cursor.vcxproj, demo.vcxproj, editor.vcxproj, file_chooser.vcxproj, fltkdll.vcxproj, fltk_images.vcxproj, fltk_opengl.vcxproj, fonts.vcxproj, hello.vcxproj, image.vcxproj, input.vcxproj, label.vcxproj, libjpeg.vcxproj, libpng.vcxproj, pack.vcxproj, qubix.vcxproj, tile.vcxproj, zlib.vcxproj).  This can lead to incorrect clean and rebuild behavior.
1>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(1455,5): warning MSB8012: TargetPath(D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\..\..\lib\fltk.lib) does not match the Library's OutputFile property value (D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\lib\fltk2d.lib). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
1>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(1457,5): warning MSB8012: TargetName(fltk) does not match the Library's OutputFile property value (fltk2d). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
1>fltk.lib.vcxproj -> D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\..\..\lib\fltk.lib
1>Done building project "fltk.lib.vcxproj".
2>------ Build started: Project: CubeView, Configuration: Debug Win32 ------
2>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(459,5): warning MSB8028: The intermediate directory (.\Debug\) contains files shared from another project (boxtype.vcxproj, checkers.vcxproj, color_chooser.vcxproj, cursor.vcxproj, demo.vcxproj, editor.vcxproj, file_chooser.vcxproj, fltk.vcxproj, fltkdll.vcxproj, fltk_images.vcxproj, fltk_opengl.vcxproj, fonts.vcxproj, hello.vcxproj, image.vcxproj, input.vcxproj, label.vcxproj, libjpeg.vcxproj, libpng.vcxproj, pack.vcxproj, qubix.vcxproj, tile.vcxproj, zlib.vcxproj).  This can lead to incorrect clean and rebuild behavior.
2>cl : command line warning D9035: option 'Gm' has been deprecated and will be removed in a future release
2>cl : command line warning D9007: '/Gm' requires '/Zi or /ZI'; option ignored
2>CubeMain.cxx
2>CubeView.cxx
2>CubeViewUI.cxx
2>Generating Code...
2>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(445,5): warning MSB8004: Output Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
2>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(459,5): warning MSB8028: The intermediate directory (Debug\) contains files shared from another project (boxtype.vcxproj, checkers.vcxproj, color_chooser.vcxproj, CubeView.vcxproj, cursor.vcxproj, demo.vcxproj, editor.vcxproj, file_chooser.vcxproj, fltk.vcxproj, fltkdll.vcxproj, fltk_images.vcxproj, fonts.vcxproj, hello.vcxproj, image.vcxproj, input.vcxproj, label.vcxproj, libjpeg.vcxproj, libpng.vcxproj, pack.vcxproj, qubix.vcxproj, tile.vcxproj, zlib.vcxproj).  This can lead to incorrect clean and rebuild behavior.
2>Done building project "fltk_opengl.vcxproj".
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glBlendFunc@8 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glColor3f@12 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glColor4f@16 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glOrtho@48 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glOrtho@48
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glPopMatrix@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glPushMatrix@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glRotatef@16 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glScalef@12 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glShadeModel@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glVertex3fv@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glViewport@16
2>run.obj : error LNK2019: unresolved external symbol _WSAAsyncSelect@16 referenced in function "void __cdecl fltk::add_fd(int,int,void (__cdecl*)(int,void *),void *)" (?add_fd@fltk@@YAXHHP6AXHPAX@Z0@Z)
2>Widget.obj : error LNK2019: unresolved external symbol "void __cdecl delete_associations_for(class fltk::Widget *)" (?delete_associations_for@@YAXPAVWidget@fltk@@@Z) referenced in function "public: virtual __thiscall fltk::Widget::~Widget(void)" (??1Widget@fltk@@UAE@XZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glCopyPixels@20 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glDisable@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glDrawBuffer@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glFlush@0 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glRasterPos2i@8 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glReadBuffer@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Choice.obj) : error LNK2019: unresolved external symbol __imp__wglCreateContext@4 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z)
2>fltk2_gld.lib(Fl_Gl_Choice.obj) : error LNK2019: unresolved external symbol __imp__wglCreateLayerContext@8 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z)
2>fltk2_gld.lib(Fl_Gl_Choice.obj) : error LNK2019: unresolved external symbol __imp__wglDeleteContext@4 referenced in function "void __cdecl fltk::delete_gl_context(struct HGLRC__ *)" (?delete_gl_context@fltk@@YAXPAUHGLRC__@@@Z)
2>fltk2_gld.lib(Fl_Gl_Choice.obj) : error LNK2019: unresolved external symbol __imp__wglMakeCurrent@8 referenced in function "void __cdecl fltk::no_gl_context(void)" (?no_gl_context@fltk@@YAXXZ)
2>fltk2_gld.lib(Fl_Gl_Choice.obj) : error LNK2019: unresolved external symbol __imp__wglShareLists@8 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z)
2>.\Debug\CubeView.exe : fatal error LNK1120: 30 unresolved externals
2>Done building project "CubeView.vcxproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
</code>```

答:
It appears that you need to add the Windows libraries to link.
I would start with adding these libraries to your linker command:
glu32.lib opengl32.lib ole32.lib uuid.lib comctl32.lib

If you are still missing things start adding these libraries if you are not already.
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib oleaut32.lib odbc32.lib odbccp32.lib

Body:
I discovered a program that may meet some needs; the source is available on sourceforge but the dependency list was lacking sufficient detail. I've managed to track down (most) of them and selected the versions based upon the release date of the software. The goal is to get the code to compile as faithfully as it initially did back in 2011, then worry about upgrading/fixing/migrating to newer libraries.

One package, FLTK, is using the abandoned 2.0 version. I found two different versions. The project files included were 'one way upgraded' to MS2019. Many properties and links needed to be fixed.

I'm attempting to compile the test 'cubeview' program, and end up with 37 unresolved dependencies.

As below, I've gone into the project, properties, configuration prope

Severity    Code    Description Project File    Line    Suppression State
Error   LNK1120 37 unresolved externals CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\Debug\CubeView.exe    1
Error   LNK2019 unresolved external symbol "public: bool __thiscall fltk::Widget::find(class fltk::AssociationType const &,void *)const " (?find@Widget@fltk@@QBE_NABVAssociationType@2@PAX@Z) referenced in function "public: bool __thiscall fltk::Widget::add_shortcut(unsigned int)" (?add_shortcut@Widget@fltk@@QAE_NI@Z)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "public: bool __thiscall fltk::Widget::remove(class fltk::AssociationType const &,void *)" (?remove@Widget@fltk@@QAE_NABVAssociationType@2@PAX@Z) referenced in function "public: bool __thiscall fltk::Widget::remove_shortcut(unsigned int)" (?remove_shortcut@Widget@fltk@@QAE_NI@Z)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "public: void * __thiscall fltk::Widget::foreach(class fltk::AssociationType const &,class fltk::AssociationFunctor &)const " (?foreach@Widget@fltk@@QBEPAXABVAssociationType@2@AAVAssociationFunctor@2@@Z) referenced in function "public: bool __thiscall fltk::Widget::test_shortcut(bool)const " (?test_shortcut@Widget@fltk@@QBE_N_N@Z) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "public: void * __thiscall fltk::Widget::get(class fltk::AssociationType const &)const " (?get@Widget@fltk@@QBEPAXABVAssociationType@2@@Z) referenced in function "public: unsigned int __thiscall fltk::Widget::shortcut(void)const " (?shortcut@Widget@fltk@@QBEIXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "public: void __thiscall fltk::Widget::add(class fltk::AssociationType const &,void *)" (?add@Widget@fltk@@QAEXABVAssociationType@2@PAX@Z) referenced in function "public: bool __thiscall fltk::Widget::add_shortcut(unsigned int)" (?add_shortcut@Widget@fltk@@QAE_NI@Z)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "public: void __thiscall fltk::Widget::set(class fltk::AssociationType const &,void *)" (?set@Widget@fltk@@QAEXABVAssociationType@2@PAX@Z) referenced in function "public: void __thiscall fltk::Widget::remove_shortcuts(void)" (?remove_shortcuts@Widget@fltk@@QAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "void * __cdecl fltk::foreach(class fltk::AssociationType const *,class fltk::Widget const *,class fltk::AssociationFunctor &)" (?foreach@fltk@@YAPAXPBVAssociationType@1@PBVWidget@1@AAVAssociationFunctor@1@@Z) referenced in function "unsigned int __cdecl fltk::foreachShortcut(class fltk::Widget const *,class fltk::ShortcutFunctor &)" (?foreachShortcut@fltk@@YAIPBVWidget@1@AAVShortcutFunctor@1@@Z)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\ShortcutAssignment.obj    1
Error   LNK2019 unresolved external symbol "void __cdecl delete_associations_for(class fltk::Widget *)" (?delete_associations_for@@YAXPAVWidget@fltk@@@Z) referenced in function "public: virtual __thiscall fltk::Widget::~Widget(void)" (??1Widget@fltk@@UAE@XZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\Widget.obj    1
Error   LNK2019 unresolved external symbol _WSAAsyncSelect@16 referenced in function "void __cdecl fltk::add_fd(int,int,void (__cdecl*)(int,void *),void *)" (?add_fd@fltk@@YAXHHP6AXHPAX@Z0@Z) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\run.obj   1
Error   LNK2019 unresolved external symbol __imp__glBegin@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glBlendFunc@8 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glClear@4 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glColor3f@12 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glColor4f@16 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glCopyPixels@20 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glDisable@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glDrawBuffer@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glEnable@4 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glEnd@0 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glFlush@0 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2001 unresolved external symbol __imp__glLoadIdentity@0  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glLoadIdentity@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2001 unresolved external symbol __imp__glOrtho@48    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glOrtho@48 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glPopMatrix@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glPushMatrix@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glRasterPos2i@8 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glReadBuffer@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glRotatef@16 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glScalef@12 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glShadeModel@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glTranslatef@12 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)    CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__glVertex3fv@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2001 unresolved external symbol __imp__glViewport@16 CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Window.obj)   1
Error   LNK2019 unresolved external symbol __imp__glViewport@16 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\CubeView.obj  1
Error   LNK2019 unresolved external symbol __imp__wglCreateContext@4 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z)  CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Choice.obj)   1
Error   LNK2019 unresolved external symbol __imp__wglCreateLayerContext@8 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Choice.obj)   1
Error   LNK2019 unresolved external symbol __imp__wglDeleteContext@4 referenced in function "void __cdecl fltk::delete_gl_context(struct HGLRC__ *)" (?delete_gl_context@fltk@@YAXPAUHGLRC__@@@Z)   CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Choice.obj)   1
Error   LNK2019 unresolved external symbol __imp__wglMakeCurrent@8 referenced in function "void __cdecl fltk::no_gl_context(void)" (?no_gl_context@fltk@@YAXXZ) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Choice.obj)   1
Error   LNK2019 unresolved external symbol __imp__wglShareLists@8 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z) CubeView    D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\fltk2_gld.lib(Fl_Gl_Choice.obj)   1

Another 'output' portion that I failed to include:

1>------ Build started: Project: fltk, Configuration: Debug Win32 ------
1>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(445,5): warning MSB8004: Output Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
1>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(459,5): warning MSB8028: The intermediate directory (Debug\) contains files shared from another project (boxtype.vcxproj, checkers.vcxproj, color_chooser.vcxproj, CubeView.vcxproj, cursor.vcxproj, demo.vcxproj, editor.vcxproj, file_chooser.vcxproj, fltkdll.vcxproj, fltk_images.vcxproj, fltk_opengl.vcxproj, fonts.vcxproj, hello.vcxproj, image.vcxproj, input.vcxproj, label.vcxproj, libjpeg.vcxproj, libpng.vcxproj, pack.vcxproj, qubix.vcxproj, tile.vcxproj, zlib.vcxproj).  This can lead to incorrect clean and rebuild behavior.
1>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(1455,5): warning MSB8012: TargetPath(D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\..\..\lib\fltk.lib) does not match the Library's OutputFile property value (D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\lib\fltk2d.lib). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
1>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(1457,5): warning MSB8012: TargetName(fltk) does not match the Library's OutputFile property value (fltk2d). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Lib.OutputFile).
1>fltk.lib.vcxproj -> D:\CodeProjects\fltk-2.0.x-master\fltk-2.0.x-master\ide\vcnet\..\..\lib\fltk.lib
1>Done building project "fltk.lib.vcxproj".
2>------ Build started: Project: CubeView, Configuration: Debug Win32 ------
2>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(459,5): warning MSB8028: The intermediate directory (.\Debug\) contains files shared from another project (boxtype.vcxproj, checkers.vcxproj, color_chooser.vcxproj, cursor.vcxproj, demo.vcxproj, editor.vcxproj, file_chooser.vcxproj, fltk.vcxproj, fltkdll.vcxproj, fltk_images.vcxproj, fltk_opengl.vcxproj, fonts.vcxproj, hello.vcxproj, image.vcxproj, input.vcxproj, label.vcxproj, libjpeg.vcxproj, libpng.vcxproj, pack.vcxproj, qubix.vcxproj, tile.vcxproj, zlib.vcxproj).  This can lead to incorrect clean and rebuild behavior.
2>cl : command line warning D9035: option 'Gm' has been deprecated and will be removed in a future release
2>cl : command line warning D9007: '/Gm' requires '/Zi or /ZI'; option ignored
2>CubeMain.cxx
2>CubeView.cxx
2>CubeViewUI.cxx
2>Generating Code...
2>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(445,5): warning MSB8004: Output Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
2>C:\Apps\MSBuild\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(459,5): warning MSB8028: The intermediate directory (Debug\) contains files shared from another project (boxtype.vcxproj, checkers.vcxproj, color_chooser.vcxproj, CubeView.vcxproj, cursor.vcxproj, demo.vcxproj, editor.vcxproj, file_chooser.vcxproj, fltk.vcxproj, fltkdll.vcxproj, fltk_images.vcxproj, fonts.vcxproj, hello.vcxproj, image.vcxproj, input.vcxproj, label.vcxproj, libjpeg.vcxproj, libpng.vcxproj, pack.vcxproj, qubix.vcxproj, tile.vcxproj, zlib.vcxproj).  This can lead to incorrect clean and rebuild behavior.
2>Done building project "fltk_opengl.vcxproj".
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glBlendFunc@8 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glColor3f@12 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glColor4f@16 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glOrtho@48 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glOrtho@48
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glPopMatrix@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glPushMatrix@0 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glRotatef@16 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glScalef@12 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glShadeModel@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glVertex3fv@4 referenced in function "private: void __thiscall CubeView::drawCube(void)" (?drawCube@CubeView@@AAEXXZ)
2>CubeView.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function "public: virtual void __thiscall CubeView::draw(void)" (?draw@CubeView@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2001: unresolved external symbol __imp__glViewport@16
2>run.obj : error LNK2019: unresolved external symbol _WSAAsyncSelect@16 referenced in function "void __cdecl fltk::add_fd(int,int,void (__cdecl*)(int,void *),void *)" (?add_fd@fltk@@YAXHHP6AXHPAX@Z0@Z)
2>Widget.obj : error LNK2019: unresolved external symbol "void __cdecl delete_associations_for(class fltk::Widget *)" (?delete_associations_for@@YAXPAVWidget@fltk@@@Z) referenced in function "public: virtual __thiscall fltk::Widget::~Widget(void)" (??1Widget@fltk@@UAE@XZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glCopyPixels@20 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glDisable@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glDrawBuffer@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glFlush@0 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glRasterPos2i@8 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Window.obj) : error LNK2019: unresolved external symbol __imp__glReadBuffer@4 referenced in function "public: virtual void __thiscall fltk::GlWindow::flush(void)" (?flush@GlWindow@fltk@@UAEXXZ)
2>fltk2_gld.lib(Fl_Gl_Choice.obj) : error LNK2019: unresolved external symbol __imp__wglCreateContext@4 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z)
2>fltk2_gld.lib(Fl_Gl_Choice.obj) : error LNK2019: unresolved external symbol __imp__wglCreateLayerContext@8 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z)
2>fltk2_gld.lib(Fl_Gl_Choice.obj) : error LNK2019: unresolved external symbol __imp__wglDeleteContext@4 referenced in function "void __cdecl fltk::delete_gl_context(struct HGLRC__ *)" (?delete_gl_context@fltk@@YAXPAUHGLRC__@@@Z)
2>fltk2_gld.lib(Fl_Gl_Choice.obj) : error LNK2019: unresolved external symbol __imp__wglMakeCurrent@8 referenced in function "void __cdecl fltk::no_gl_context(void)" (?no_gl_context@fltk@@YAXXZ)
2>fltk2_gld.lib(Fl_Gl_Choice.obj) : error LNK2019: unresolved external symbol __imp__wglShareLists@8 referenced in function "struct HGLRC__ * __cdecl fltk::create_gl_context(class fltk::Window const *,class fltk::GlChoice const *,int)" (?create_gl_context@fltk@@YAPAUHGLRC__@@PBVWindow@1@PBVGlChoice@1@H@Z)
2>.\Debug\CubeView.exe : fatal error LNK1120: 30 unresolved externals
2>Done building project "CubeView.vcxproj" -- FAILED.
========== Build: 1 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========


问:
Laravel validator fails if response is false
I have a laravel validator on my request that is set to required, the issue is that the validation fails when the responses[0]['answer'] = false. i have a checklist in the frontend that the user submits either true or false, so i want to consider false as a actual response and should pass the validation, how can i allow that to pass validation when the responses[0]['answer'] = false

```<code>{
    "id": 50,
    "type": "forum",
    "responses": [
        {
            "question_id": 89,
            "answer": false
        },
        {
            "question_id": 90,
            "answer": true
        },
        {
            "question_id": 91,
            "answer": "this is a input type answer"
        }
    ]
}
</code>```

and this is how the validator looks

```<code>$request->validate([
 'id' => 'required',
 'responses.*.question_id' => 'required',
 'responses.*.answer_id' => 'required_if:responses.*.answer,""',
 'responses.*.answer' => 'required_if:responses.*.answer_id,"",
]);
</code>```

i validate that

```<code>responses['*']['answer']
</code>```

is required but i want to allow it even if

```<code>responses['*']['answer'] = false
</code>```

答:
Add the nullable rule to the validation string:

```<code> 'responses.*.answer' => 'nullable|required_if:responses.*.answer_id,"",
</code>```

Body:
I have a laravel validator on my request that is set to required, the issue is that the validation fails when the responses[0]['answer'] = false. i have a checklist in the frontend that the user submits either true or false, so i want to consider false as a actual response and should pass the validation, how can i allow that to pass validation when the responses[0]['answer'] = false

{
    "id": 50,
    "type": "forum",
    "responses": [
        {
            "question_id": 89,
            "answer": false
        },
        {
            "question_id": 90,
            "answer": true
        },
        {
            "question_id": 91,
            "answer": "this is a input type answer"
        }
    ]
}

and this is how the validator looks

$request->validate([
 'id' => 'required',
 'responses.*.question_id' => 'required',
 'responses.*.answer_id' => 'required_if:responses.*.answer,""',
 'responses.*.answer' => 'required_if:responses.*.answer_id,"",
]);

i validate that

responses['*']['answer']

is required but i want to allow it even if

responses['*']['answer'] = false

Body:
Add the nullable rule to the validation string:

 'responses.*.answer' => 'nullable|required_if:responses.*.answer_id,"",


问:
Postgres Query Solution
```<code>with FQuery as
(
select ci_nm      as ci_nm
,     ci_nm             as ci_alias_nm
from rpt.ci_d
),
SQuery as
(
select ci_nm, ci_alias_nm from FQuery limit 10
)
insert into stg.Test1 (Select * from SQuery),
insert into stg.Test2 Select * from SQuery;
</code>```

I am trying to achieve insert in multiple tables from the second subquery. However, it is giving an error 'ERROR: 42601: syntax error at or near "insert"'

答: You can't have two "main queries". There might be something wrong with your database design if you want to insert same data to two tables.</p>

Title: Postgres Query Solution

Body:
with FQuery as
(
select ci_nm      as ci_nm
,     ci_nm             as ci_alias_nm
from rpt.ci_d
),
SQuery as
(
select ci_nm, ci_alias_nm from FQuery limit 10
)
insert into stg.Test1 (Select * from SQuery),
insert into stg.Test2 Select * from SQuery;

I am trying to achieve insert in multiple tables from the second subquery. However, it is giving an error 'ERROR: 42601: syntax error at or near "insert"'


问:
How do I delete files programmatically on Android?
I'm on 4.4.2, trying to delete a file (image) via uri. Here's my code:

```<code>File file = new File(uri.getPath());
boolean deleted = file.delete();
if(!deleted){
      boolean deleted2 = file.getCanonicalFile().delete();
      if(!deleted2){
           boolean deleted3 = getApplicationContext().deleteFile(file.getName());
      }
}
</code>```

Right now, none of these delete functions is actually deleting the file. I also have this in my AndroidManifest.xml:

```<code><uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
</code>```

答:
first call the intent

```<code>Intent intenta = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intenta, 42);
</code>```

then call the result

```<code>@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case 42:
            if (resultCode == Activity.RESULT_OK) {
                Uri sdCardUri = data.getData();
                DocumentFile pickedDir = DocumentFile.fromTreeUri(this, sdCardUri);
                for (DocumentFile file : pickedDir.listFiles()) {
                    String pp = file.getName();
                    if(pp.equals("VLC.apk"))
                        file.delete();
                    String ppdf="";
                }
                File pathFile = new File(String.valueOf(sdCardUri));
                pathFile.delete();
            }
            break;
    }
}
</code>```

Body:
I'm on 4.4.2, trying to delete a file (image) via uri. Here's my code:

File file = new File(uri.getPath());
boolean deleted = file.delete();
if(!deleted){
      boolean deleted2 = file.getCanonicalFile().delete();
      if(!deleted2){
           boolean deleted3 = getApplicationContext().deleteFile(file.getName());
      }
}

Right now, none of these delete functions is actually deleting the file. I also have this in my AndroidManifest.xml:

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />

Body:
first call the intent

Intent intenta = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
startActivityForResult(intenta, 42);

then call the result

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case 42:
            if (resultCode == Activity.RESULT_OK) {
                Uri sdCardUri = data.getData();
                DocumentFile pickedDir = DocumentFile.fromTreeUri(this, sdCardUri);
                for (DocumentFile file : pickedDir.listFiles()) {
                    String pp = file.getName();
                    if(pp.equals("VLC.apk"))
                        file.delete();
                    String ppdf="";
                }
                File pathFile = new File(String.valueOf(sdCardUri));
                pathFile.delete();
            }
            break;
    }
}


问:
Random variable in an input function
I am trying to write a simple Python program asking the user the result of a random addition. The program crashes on the 8th line. Is it not allowed to refer to a random variable in Python?

```<code>#prompts random addition
import random
r1 = random.randint(0, 10)
r2 = random.randint(0, 10)
result = r1+r2

while True:
    answer = int(input('What is',r1, '+', r2))

    if answer != result:
        print("Wrong, try again.")
    else:
        print("correct!")
        break;
</code>```

The message shown when it crashes is below:
Traceback (most recent call last):
  File "/Users/chenjin/Desktop/Module4.py", line 89, in
    answer = input('What is',r1, '+', r2)
TypeError: input expected at most 1 arguments, got 4

答:
input() takes an (optional) argument, you are passing 4 arguments to it. You need to build a string to pass to it. Example:</p>

```<code>answer = input(f'What is {r1} + {r2}? ')
</code>```

Title: Random variable in an input function

Body:
I am trying to write a simple Python program asking the user the result of a random addition. The program crashes on the 8th line. Is it not allowed to refer to a random variable in Python?

#prompts random addition
import random
r1 = random.randint(0, 10)
r2 = random.randint(0, 10)
result = r1+r2

while True:
    answer = int(input('What is',r1, '+', r2))

    if answer != result:
        print("Wrong, try again.")
    else:
        print("correct!")
        break;

The message shown when it crashes is below:
Traceback (most recent call last):
  File "/Users/chenjin/Desktop/Module4.py", line 89, in
    answer = input('What is',r1, '+', r2)
TypeError: input expected at most 1 arguments, got 4

Body:
input() takes an (optional) argument, you are passing 4 arguments to it. You need to build a string to pass to it. Example:

answer = input(f'What is {r1} + {r2}? ')


问:
Python searching in few specific / latest dirs instead of all using os.walk
I'm new here but have been here for a while trying to learn python. I was searching for hours now to come up with solution then was searching for a while and unfortunately have to give up. Wrapping it up:

I needed to write code to find files with specific names and later on merge them (pdf). Everything works great if i don't expand path with 'finaldir' BUT: there are alot of dirs with date like in 'finaldir' and i want my script to only search in dirs named as in finaldir and in range of -x days from it.

Example: finaldir = '2020-02-04' Script should look in folders named: '2020-02-04', '2020-02-03', '2020-02-02', '2020-02-01', '2020-01-31', '2020-01-30' ... etc.

```<code> finaldir = '2020-02-04'     #this is example, Script get data from excel workbook

            for path, dirs, files in os.walk(r'C:\Python\testfiles\haha'+'\\'+ str(finaldir)):
                for dir in dirs:
                    if dir == 'asd' or dir == 'qwe':                      #script get 1 file from each folder

                        for file in os.listdir(os.path.join(path, dir)):
                            if regex1.match(file) or regex2.match(file):          #patterns for file 1 and 2
                                pdf_files.append(os.path.join(path, dir, file))   #appends list for pdfmerge
</code>```

I am new to programming so any suggestion would be very apprecieted.

Thanks for you time and help.

Ps. Folder names are also when folder was created if it will help get solution.

答:
You can:

```<code>for dir in dirs:
    if dir != finaldir:
        continue
</code>```

Also, your os.listdir() is probably unnecessary - you could just iterate over files.

Also, if you see a directory with a deep hierarchy beneath it which you know you don't want to fully traverse, you can remove it from dirs.

Body:
I'm new here but have been here for a while trying to learn python. I was searching for hours now to come up with solution then was searching for a while and unfortunately have to give up. Wrapping it up:

I needed to write code to find files with specific names and later on merge them (pdf). Everything works great if i don't expand path with 'finaldir' BUT: there are alot of dirs with date like in 'finaldir' and i want my script to only search in dirs named as in finaldir and in range of -x days from it.

Example: finaldir = '2020-02-04' Script should look in folders named: '2020-02-04', '2020-02-03', '2020-02-02', '2020-02-01', '2020-01-31', '2020-01-30' ... etc.

 finaldir = '2020-02-04'     #this is example, Script get data from excel workbook

            for path, dirs, files in os.walk(r'C:\Python\testfiles\haha'+'\\'+ str(finaldir)):
                for dir in dirs:
                    if dir == 'asd' or dir == 'qwe':                      #script get 1 file from each folder

                        for file in os.listdir(os.path.join(path, dir)):
                            if regex1.match(file) or regex2.match(file):          #patterns for file 1 and 2
                                pdf_files.append(os.path.join(path, dir, file))   #appends list for pdfmerge

I am new to programming so any suggestion would be very apprecieted.

Thanks for you time and help.

Ps. Folder names are also when folder was created if it will help get solution.

Body:
You can:

for dir in dirs:
    if dir != finaldir:
        continue

Also, your os.listdir() is probably unnecessary - you could just iterate over files.

Also, if you see a directory with a deep hierarchy beneath it which you know you don't want to fully traverse, you can remove it from dirs.


问:
The server mode SSL must use a certificate with the associated private key - during TLS handshake
I have a certificate someCert.cer. I imported it into my local certificates store using MMC utility. My C# application is able to access it using following code:

```<code>var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
X509Certificate2 certificate = null;
store.Open(OpenFlags.ReadOnly);
try
{
    var certificateCollection = store.Certificates.Find(X509FindType.FindByThumbprint, "THUMBPRINT", false);
    certificate = certificateCollection[0];
}
finally
{
    store.Close();
}
</code>```

The application exposes TCP socket and when I try to connect to it with my client app I get exception:
The server mode SSL must use a certificate with the associated private key

Indeed my certificate's PrivateKey property is empty. Did I import my certificate incorrect or should I do something with the certificate before importing it into the store?

My server authentication code looks like that:

```<code>stream.AuthenticateAsServerAsync(certificate, false, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12, true);
</code>```

答:
Between Jesse's comment and Dave's answer, I could work out that I'd somehow created and installed some kind of partial certificate, sort half-jobbed it.

I had made a cert using makecert.exe and somehow managed to install it and load it into Kestrel, but it failed when a request from Chrome came in.

I couldn't find a copy of pvk2pfx.exe in order to make a PFX file from the two files that makecert.exe had kicked out, so I just tried to carry on without it.

After that failure and reading the above, I figured that the PFX step is mandatory. So I used classic PowerShell 4 (PS6 Core wouldn't load the module):

```<code>> $cert = New-SelfSignedCertificate -certstorelocation cert:\currentuser\my -dnsname windows
> $pwd = ConvertTo-SecureString -String 'password1234' -Force -AsPlainText
> $path = 'cert:\currentuser\my\' + $cert.thumbprint
> Export-PfxCertificate -cert $path -FilePath c:\DATA\~Scrap\windows.pfx -Password $pwd
</code>```

Credit to https://medium.com/the-new-control-plane/generating-self-signed-certificates-on-windows-7812a600c2d8

Tbh, I originally half-jobbed this. I stopped after the first command which produced a certificate in my store, but gave me a different strange error from Kestrel's stack when hit from Chrome. Again, the PFX step is needed for some reason.

At present I can't find a way to trust the signer, but Chrome let's me proceed so I'll sort that when I'm not so tired.

Body:
I have a certificate someCert.cer. I imported it into my local certificates store using MMC utility. My C# application is able to access it using following code:

var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
X509Certificate2 certificate = null;
store.Open(OpenFlags.ReadOnly);
try
{
    var certificateCollection = store.Certificates.Find(X509FindType.FindByThumbprint, "THUMBPRINT", false);
    certificate = certificateCollection[0];
}
finally
{
    store.Close();
}

The application exposes TCP socket and when I try to connect to it with my client app I get exception:
The server mode SSL must use a certificate with the associated private key

Indeed my certificate's PrivateKey property is empty. Did I import my certificate incorrect or should I do something with the certificate before importing it into the store?

My server authentication code looks like that:

stream.AuthenticateAsServerAsync(certificate, false, SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12, true);

Body:
Between Jesse's comment and Dave's answer, I could work out that I'd somehow created and installed some kind of partial certificate, sort half-jobbed it.

I had made a cert using makecert.exe and somehow managed to install it and load it into Kestrel, but it failed when a request from Chrome came in.

I couldn't find a copy of pvk2pfx.exe in order to make a PFX file from the two files that makecert.exe had kicked out, so I just tried to carry on without it.

After that failure and reading the above, I figured that the PFX step is mandatory. So I used classic PowerShell 4 (PS6 Core wouldn't load the module):

> $cert = New-SelfSignedCertificate -certstorelocation cert:\currentuser\my -dnsname windows
> $pwd = ConvertTo-SecureString -String 'password1234' -Force -AsPlainText
> $path = 'cert:\currentuser\my\' + $cert.thumbprint
> Export-PfxCertificate -cert $path -FilePath c:\DATA\~Scrap\windows.pfx -Password $pwd

Credit to https://medium.com/the-new-control-plane/generating-self-signed-certificates-on-windows-7812a600c2d8

Tbh, I originally half-jobbed this. I stopped after the first command which produced a certificate in my store, but gave me a different strange error from Kestrel's stack when hit from Chrome. Again, the PFX step is needed for some reason.

At present I can't find a way to trust the signer, but Chrome let's me proceed so I'll sort that when I'm not so tired.