问:
Selenium Grid sending values to one browser in parallel
I'm trying to run selenium in parallel but I'm having some major issues.  One major issue I have is that WebDriver sends all values to one browser then another time it'll work first OK for test then second test it'll not send any values and then another test it may hang on opening.
I've seen people get it to work flawless on YouTube and even thought I've tried everything I can think of its never worked like this for me.
I know the port can be passed in as a parameter and I had this before but I don't think its mandatory.

Here's how I've got everything setup starting with my hub/node setup...

java -jar selenium-server-standalone-2.47.1.jar -role hub
  -maxInstances=10 -maxSession=10 -port 7777 -timeout 29000

java -jar selenium-server-standalone-2.47.1.jar -role webdriver -hub
  http://localhost:7777/grid/register  -maxSession=5 -maxInstance=5
  -port 4441 -timeout 30000 -browser browserName="safari",platform=WINDOWS

java -jar selenium-server-standalone-2.45.0.jar -role webdriver -hub
  http://localhost:7777/grid/register -port 4448 -timeout 30000 -browser
  browserName="firefox",platform=WINDOWS,maxSession=5,maxInstances=5

My xml file

```<code><?xml version="1.0" encoding="UTF-8"?>

<suite name = "Cross Browser Testing" verbose = "3" parallel = "tests" thread-count="5">
    <test name = "Firefox Test">
    <parameter name = "browser" value ="firefox">
    </parameter>
        <classes>
            <class name = "TestClass.Dashboard"/>
            <class name = "TestClass.Login"/>
        </classes>
    </test>

        <test name = "Safari Test">
    <parameter name = "browser" value ="safari">
    </parameter>
        <classes>
            <class name = "TestClass.Dashboard"/>
            <class name = "TestClass.Login"/>
        </classes>
    </test>
</suite>
</code>```

Here's how I'm calling my xml

```<code>import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.safari.SafariDriver;
import org.testng.annotations.*;

public class Launch extends AbstractPage {

    public Launch() {
        super();
    }

    @BeforeMethod
    @Parameters({"browser"})
    public void launchBrowsers(String browser) throws MalformedURLException {

        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setBrowserName(browser);
        capabilities.setJavascriptEnabled(true);

        // To remove message "You are using an unsupported command-line
        // flag: --ignore-certificate-errors.
        // Stability and security will suffer."
        // Add an argument 'test-type'
        ChromeOptions chrome = new ChromeOptions();
        chrome.addArguments("test-type");
        capabilities.setCapability(ChromeOptions.CAPABILITY, chrome);
        capabilities.setCapability("chrome.binary",
                "C:\\location\\chromedriver.exe");

        //setup internet explorer
        capabilities.setCapability("InternetExplorerDriverServer.IE_ENSURE_CLEAN_SESSION",true);
        System.setProperty("webdriver.ie.driver",
                "C:\\location\\IEDriverServer.exe");

        selenium = new RemoteWebDriver(new URL("http://localhost:7777/wd/hub"), capabilities);

        getSelenium().manage().window().maximize();
        getSelenium().manage().deleteAllCookies();

    }

    @AfterMethod
    public void tearDown() {
        //close down browser window
        if (selenium == null) {
            try {
                selenium.quit();
                selenium.close();
            } catch (Exception e) {

            }
        }
    }
}
</code>```

I've also tried the switch statement

```<code>switch(browser) {

        case "iexplorer":
            System.setProperty("webdriver.ie.driver",
                    "C:\\location\\IEDriverServer.exe");
            DesiredCapabilities capabilities1 = DesiredCapabilities.internetExplorer();
            selenium = new RemoteWebDriver(new URL("http://localhost:7777/wd/hub"), capabilities1);
            break;

        case "firefox":
            DesiredCapabilities capabilities2 = DesiredCapabilities.firefox();
            selenium = new RemoteWebDriver(new URL("http://localhost:7777/wd/hub"), capabilities2);
            break;

        case "safari":
            DesiredCapabilities capabilities3 = DesiredCapabilities.safari();
            selenium = new RemoteWebDriver(new URL("http://localhost:7777/wd/hub"), capabilities3);
            break;

        case "chrome":
            System.setProperty("chrome.binary",
                    "C:\\location\\chromedriver.exe");
            DesiredCapabilities capabilities = DesiredCapabilities.chrome();
            selenium = new RemoteWebDriver(new URL("http://localhost:7777/wd/hub"), capabilities);
            break;

        default:
            break;
    }
</code>```

Any help to get this working is greatly appreciated.

答:
I also had the same problem. I was also running two browsers in one node parallel, but whichever browser is initiated first it tries to do all the things in that browser only and in the second browser it does nothing (even the url is not passed into it). As what I did was that in my code the webdriver was set static which was causing all the problems so I removed the static from my webdriver and tried, then it was working fine.
You just try to declare it public adn then give it a shot. It might work.

Body:
I'm trying to run selenium in parallel but I'm having some major issues.  One major issue I have is that WebDriver sends all values to one browser then another time it'll work first OK for test then second test it'll not send any values and then another test it may hang on opening.
I've seen people get it to work flawless on YouTube and even thought I've tried everything I can think of its never worked like this for me.
I know the port can be passed in as a parameter and I had this before but I don't think its mandatory.

Here's how I've got everything setup starting with my hub/node setup...

java -jar selenium-server-standalone-2.47.1.jar -role hub
  -maxInstances=10 -maxSession=10 -port 7777 -timeout 29000

java -jar selenium-server-standalone-2.47.1.jar -role webdriver -hub
  http://localhost:7777/grid/register  -maxSession=5 -maxInstance=5
  -port 4441 -timeout 30000 -browser browserName="safari",platform=WINDOWS

java -jar selenium-server-standalone-2.45.0.jar -role webdriver -hub
  http://localhost:7777/grid/register -port 4448 -timeout 30000 -browser
  browserName="firefox",platform=WINDOWS,maxSession=5,maxInstances=5

My xml file

<?xml version="1.0" encoding="UTF-8"?>

<suite name = "Cross Browser Testing" verbose = "3" parallel = "tests" thread-count="5">
    <test name = "Firefox Test">
    <parameter name = "browser" value ="firefox">
    </parameter>
        <classes>
            <class name = "TestClass.Dashboard"/>
            <class name = "TestClass.Login"/>
        </classes>
    </test>

        <test name = "Safari Test">
    <parameter name = "browser" value ="safari">
    </parameter>
        <classes>
            <class name = "TestClass.Dashboard"/>
            <class name = "TestClass.Login"/>
        </classes>
    </test>
</suite>

Here's how I'm calling my xml

import java.net.MalformedURLException;
import java.net.URL;

import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriverService;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.safari.SafariDriver;
import org.testng.annotations.*;

public class Launch extends AbstractPage {

    public Launch() {
        super();
    }

    @BeforeMethod
    @Parameters({"browser"})
    public void launchBrowsers(String browser) throws MalformedURLException {

        DesiredCapabilities capabilities = new DesiredCapabilities();

        capabilities.setBrowserName(browser);
        capabilities.setJavascriptEnabled(true);

        // To remove message "You are using an unsupported command-line
        // flag: --ignore-certificate-errors.
        // Stability and security will suffer."
        // Add an argument 'test-type'
        ChromeOptions chrome = new ChromeOptions();
        chrome.addArguments("test-type");
        capabilities.setCapability(ChromeOptions.CAPABILITY, chrome);
        capabilities.setCapability("chrome.binary",
                "C:\\location\\chromedriver.exe");

        //setup internet explorer
        capabilities.setCapability("InternetExplorerDriverServer.IE_ENSURE_CLEAN_SESSION",true);
        System.setProperty("webdriver.ie.driver",
                "C:\\location\\IEDriverServer.exe");

        selenium = new RemoteWebDriver(new URL("http://localhost:7777/wd/hub"), capabilities);

        getSelenium().manage().window().maximize();
        getSelenium().manage().deleteAllCookies();

    }

    @AfterMethod
    public void tearDown() {
        //close down browser window
        if (selenium == null) {
            try {
                selenium.quit();
                selenium.close();
            } catch (Exception e) {

            }
        }
    }
}

I've also tried the switch statement

switch(browser) {

        case "iexplorer":
            System.setProperty("webdriver.ie.driver",
                    "C:\\location\\IEDriverServer.exe");
            DesiredCapabilities capabilities1 = DesiredCapabilities.internetExplorer();
            selenium = new RemoteWebDriver(new URL("http://localhost:7777/wd/hub"), capabilities1);
            break;

        case "firefox":
            DesiredCapabilities capabilities2 = DesiredCapabilities.firefox();
            selenium = new RemoteWebDriver(new URL("http://localhost:7777/wd/hub"), capabilities2);
            break;

        case "safari":
            DesiredCapabilities capabilities3 = DesiredCapabilities.safari();
            selenium = new RemoteWebDriver(new URL("http://localhost:7777/wd/hub"), capabilities3);
            break;

        case "chrome":
            System.setProperty("chrome.binary",
                    "C:\\location\\chromedriver.exe");
            DesiredCapabilities capabilities = DesiredCapabilities.chrome();
            selenium = new RemoteWebDriver(new URL("http://localhost:7777/wd/hub"), capabilities);
            break;

        default:
            break;
    }

Any help to get this working is greatly appreciated.


来源: stackexchange

问:
Unable to transfer twilio call to new number
We have small twilio application which we use to calls any customer number from website. Now we are trying to add transfer call functionality in our application.
But we are unable to transfer call using php api.
Here is what we are using :

We dial number from website, JS returns callid

We have another number on which we need to transfer call after few minutes

So we have "Transfer" button which makes ajax call to php file

which have following code :

```<code><?php
    $existing_call_sid = $_REQUEST['CallSid'];
    $new_number = $_REQUEST['new_number'];
    $call = $client->calls($existing_call_sid)->update(
                array(
                    "url" => "transfer_xml_main.php?new_number=".$new_number,
                    "method" => "POST"
                )
            );
    echo $call->to;
?>
</code>```

transfer_xml_main.php contains :

```<code><Response>
    <Dial><?php echo $_GET['new_number'];?></Dial>
    <Say>Please be on line we are transferring your call</Say>
</Response>
</code>```

But when this request happens existing call is dropping and no call to new number.

also $call->to is blank

Am i doing anything wrong?

Update

After implementing answer of philnash i am getting following fatal error :

```<code><b>Fatal error</b>:  Uncaught exception 'Twilio\Exceptions\RestException' with message '[HTTP 400] Unable to update record: No 'To' number is specified' in /twilo/twillo_php_master_new/Twilio/Version.php:85
Stack trace:
#0 /twilo/twillo_php_master_new/Twilio/Version.php(127): Twilio\Version->exception(Object(Twilio\Http\Response), 'Unable to updat...')
#1 /twilo/twillo_php_master_new/Twilio/Rest/Api/V2010/Account/CallContext.php(109): Twilio\Version->update('POST', '/Accounts/AC618...', Array, Array)
#2 /twilo/twilo_call_transfer.php(26): Twilio\Rest\Api\V2010\Account\CallContext->update(Array)
#3 {main}
  thrown in <b>/twilo/twillo_php_master_new/Twilio/Version.php</b> on line <b>85</b><br />
</code>```

However i am getting parent call id correctly and in $child_calls i am getting to and from correctly which is one who called first and one whom user is called. Still anything wrong ?

And yes we want exactly like you said :
1. User1 (agent) called one number (customer A) from twilio JS Client
2. Now User1 (agent) want to transfer call to another number which can be agent or some other number.

Also there is no errors in debugger

答:
In your PHP you use the POST method, but in your XML you use $_GET. You're not passing the variables.

```<code><?php
    $parent_call_sid = $_REQUEST['CallSid'];
    $child_calls = $this->client->calls->read(array("ParentCallSid" => $parent_call_sid));
    $child_call_sid = $childCalls[0]->sid;
    $new_number = $_REQUEST['new_number'];
    $call = $client->calls($child_call_sid)->update(
        array(
            "url" => "transfer_xml_main.php?new_number=".$new_number,
            "method" => "POST" // <---NOTICE THE POST
        )
    );
    echo $call->to;
?>
</code>```

Change $_GET to $_POST

```<code><Response>
    <Dial><?php echo $_POST['new_number'];?></Dial>
    <Say>Please be on line we are transferring your call</Say>
</Response>
</code>```

ContentLicense: CC BY-SA 3.0

Body:
We have small twilio application which we use to calls any customer number from website. Now we are trying to add transfer call functionality in our application.
But we are unable to transfer call using php api.
Here is what we are using :

We dial number from website, JS returns callid

We have another number on which we need to transfer call after few minutes

So we have "Transfer" button which makes ajax call to php file

which have following code :

<?php
    $existing_call_sid = $_REQUEST['CallSid'];
    $new_number = $_REQUEST['new_number'];
    $call = $client->calls($existing_call_sid)->update(
                array(
                    "url" => "transfer_xml_main.php?new_number=".$new_number,
                    "method" => "POST"
                )
            );
    echo $call->to;
?>

transfer_xml_main.php contains :

<Response>
    <Dial><?php echo $_GET['new_number'];?></Dial>
    <Say>Please be on line we are transferring your call</Say>
</Response>

But when this request happens existing call is dropping and no call to new number.

also $call->to is blank

Am i doing anything wrong?

Update

After implementing answer of philnash i am getting following fatal error :

Fatal error:  Uncaught exception 'Twilio\Exceptions\RestException' with message '[HTTP 400] Unable to update record: No 'To' number is specified' in /twilo/twillo_php_master_new/Twilio/Version.php:85
Stack trace:
#0 /twilo/twillo_php_master_new/Twilio/Version.php(127): Twilio\Version->exception(Object(Twilio\Http\Response), 'Unable to updat...')
#1 /twilo/twillo_php_master_new/Twilio/Rest/Api/V2010/Account/CallContext.php(109): Twilio\Version->update('POST', '/Accounts/AC618...', Array, Array)
#2 /twilo/twilo_call_transfer.php(26): Twilio\Rest\Api\V2010\Account\CallContext->update(Array)
#3 {main}
  thrown in /twilo/twillo_php_master_new/Twilio/Version.php on line 85

However i am getting parent call id correctly and in $child_calls i am getting to and from correctly which is one who called first and one whom user is called. Still anything wrong ?

And yes we want exactly like you said :
1. User1 (agent) called one number (customer A) from twilio JS Client
2. Now User1 (agent) want to transfer call to another number which can be agent or some other number.

Also there is no errors in debugger

Body:
In your PHP you use the POST method, but in your XML you use $_GET. You're not passing the variables.

<?php
    $parent_call_sid = $_REQUEST['CallSid'];
    $child_calls = $this->client->calls->read(array("ParentCallSid" => $parent_call_sid));
    $child_call_sid = $childCalls[0]->sid;
    $new_number = $_REQUEST['new_number'];
    $call = $client->calls($child_call_sid)->update(
        array(
            "url" => "transfer_xml_main.php?new_number=".$new_number,
            "method" => "POST" // <---NOTICE THE POST
        )
    );
    echo $call->to;
?>

Change $_GET to $_POST

<Response>
    <Dial><?php echo $_POST['new_number'];?></Dial>
    <Say>Please be on line we are transferring your call</Say>
</Response>

ContentLicense: CC BY-SA 4.0


问:
Assign sequential group ID given a group start indicator
I need to assign subgroup IDs given a group ID and an indicator showing the beginning of the new subgroup. Here's a test dataset:

```<code>group <- c(rep("A", 8), rep("B", 8))
x1 <- c(rep(0, 3), rep(1, 3), rep(0, 2))
x2 <- rep(0:1, 4)

df <- data.frame(group=group, indic=c(x1, x2))
</code>```

Here is the resulting data frame:

```<code> df
   group indic
1      A     0
2      A     0
3      A     0
4      A     1
5      A     1
6      A     1
7      A     0
8      A     0
9      B     0
10     B     1
11     B     0
12     B     1
13     B     0
14     B     1
15     B     0
16     B     1
</code>```

indic==1 means that row is the beginning of a new subgroup, and the subgroup should be numbered 1 higher than the previous subgroup. Where indic==0 the subgroup should be the same as the previous subgroup. The subgroup numbering starts at 1. When the group variable changes, the subgroup numbering resets to 1. I would like to use the tidyverse framework.
Here is the result that I want:

```<code> df
   group indic subgroup
1      A     0        1
2      A     0        1
3      A     0        1
4      A     1        2
5      A     1        3
6      A     1        4
7      A     0        4
8      A     0        4
9      B     0        1
10     B     1        2
11     B     0        2
12     B     1        3
13     B     0        3
14     B     1        4
15     B     0        4
16     B     1        5
</code>```

I would like to be able to give some methods that I've tried already but didn't work, but I haven't been able to find anything even close. Any help will be appreciated.

答:
You can just use

```<code>library(dplyr)
df %>% group_by(group) %>%
  mutate(subgroup=cumsum(indic)+1)
#   group indic subgroup
#   <fct> <dbl>    <dbl>
#  1 A         0        1
#  2 A         0        1
#  3 A         0        1
#  4 A         1        2
#  5 A         1        3
#  6 A         1        4
#  7 A         0        4
#  8 A         0        4
#  9 B         0        1
# 10 B         1        2
# 11 B         0        2
# 12 B         1        3
# 13 B         0        3
# 14 B         1        4
# 15 B         0        4
# 16 B         1        5
</code>```

We use dplyr to do the grouping and then we just use cumsum with takes the cumulative sum of the indic column so each time it sees a 1 it increases.

Body:
I need to assign subgroup IDs given a group ID and an indicator showing the beginning of the new subgroup. Here's a test dataset:

group <- c(rep("A", 8), rep("B", 8))
x1 <- c(rep(0, 3), rep(1, 3), rep(0, 2))
x2 <- rep(0:1, 4)

df <- data.frame(group=group, indic=c(x1, x2))

Here is the resulting data frame:

 df
   group indic
1      A     0
2      A     0
3      A     0
4      A     1
5      A     1
6      A     1
7      A     0
8      A     0
9      B     0
10     B     1
11     B     0
12     B     1
13     B     0
14     B     1
15     B     0
16     B     1

indic==1 means that row is the beginning of a new subgroup, and the subgroup should be numbered 1 higher than the previous subgroup. Where indic==0 the subgroup should be the same as the previous subgroup. The subgroup numbering starts at 1. When the group variable changes, the subgroup numbering resets to 1. I would like to use the tidyverse framework.
Here is the result that I want:

 df
   group indic subgroup
1      A     0        1
2      A     0        1
3      A     0        1
4      A     1        2
5      A     1        3
6      A     1        4
7      A     0        4
8      A     0        4
9      B     0        1
10     B     1        2
11     B     0        2
12     B     1        3
13     B     0        3
14     B     1        4
15     B     0        4
16     B     1        5

I would like to be able to give some methods that I've tried already but didn't work, but I haven't been able to find anything even close. Any help will be appreciated.

Body:
You can just use

library(dplyr)
df %>% group_by(group) %>%
  mutate(subgroup=cumsum(indic)+1)
#   group indic subgroup
#   <fct> <dbl>    <dbl>
#  1 A         0        1
#  2 A         0        1
#  3 A         0        1
#  4 A         1        2
#  5 A         1        3
#  6 A         1        4
#  7 A         0        4
#  8 A         0        4
#  9 B         0        1
# 10 B         1        2
# 11 B         0        2
# 12 B         1        3
# 13 B         0        3
# 14 B         1        4
# 15 B         0        4
# 16 B         1        5

We use dplyr to do the grouping and then we just use cumsum with takes the cumulative sum of the indic column so each time it sees a 1 it increases.


问:
SOLR: facet.field is working for each word in a field differently, how to apply facet.field for whole field sentence?
In facet.field, I have added "MerchantName" field, so I got result as below

```<code>"facet_fields":{
    "MerchantName":[
        "amazon",133281,
        "factory",99566,
        "club",99566,
        "fashion",4905,
        "swish",4905,
        "store",1001,
        "swank",1001,
        "the",1001
    ]
}
</code>```

In the above array, "club factory", "swish fashion" and "the swank store" are in a single field, but an array as you can see these are treated as a different word.

So how to apply facet query on the whole field which returns an array with whole field value?

答:
The field MerchantName used for faceting. This field should be defined in schema.xml as a string (type="string") in order for the facet to use the whole text.

As you are using a text based field with field type as text_general, the value will be split into multiple tokens. The same is the case with MerchantName field.

Otherwise it will divide it according to the way it has been tokenized.

You can also add docValues="true" for a field MerchantName, then DocValues will automatically be used any time the field is used for sorting, faceting or function queries.

For faceting Solr could get use of DocValues - which is special way of recording field values internally that is more efficient for some purposes, such as sorting and faceting, than traditional indexing.

Body:
In facet.field, I have added "MerchantName" field, so I got result as below

"facet_fields":{
    "MerchantName":[
        "amazon",133281,
        "factory",99566,
        "club",99566,
        "fashion",4905,
        "swish",4905,
        "store",1001,
        "swank",1001,
        "the",1001
    ]
}

In the above array, "club factory", "swish fashion" and "the swank store" are in a single field, but an array as you can see these are treated as a different word.

So how to apply facet query on the whole field which returns an array with whole field value?


问:
How Long is the Longest Class in Java Source Code?
Just curious to know which is the longest class in Java Source Code ( any version above Java 6 ) and how many lines of code is it?

Why do I want to know, what is the use-case?

Just curious.

IMHO, knowing this is also a good way to understand how Java adheres to SOLID principles i.e. How long was the longest class after all those effort to keep it as small as possible.

答:
```<code>find . -name '*.java' | xargs wc -l | sort -nr | head -n 10
</code>```

Result for jdk1.8.0:

```<code>10161 ./awt/Component.java
 7231 ./lang/Character.java
 6312 ./util/concurrent/ConcurrentHashMap.java
 5858 ./util/regex/Pattern.java
 5564 ./util/Collections.java
 5257 ./math/BigDecimal.java
 5115 ./util/Arrays.java
 4986 ./awt/Container.java
 4698 ./util/Formatter.java
</code>```

Note that the shorter idiom wc -l **/*.java is not recursive by default. You need to shopt -s globstar to make the operator recursive. Without that you'll miss large classes such as,

```<code>6312 ./util/concurrent/ConcurrentHashMap.java
4503 ./time/format/DateTimeFormatterBuilder.java
</code>```

Note for mac users:

For the accepted answer to work (wc -l **/*.java), you need bash with globstar support (≥ 4.x). macOS Catalina, for example, comes with an older version of bash (3.2.57). In that case you need to install bash with Homebrew (brew install bash), and turn on recursiveness with shopt -s globstar. You can find more details here.

Body:
find . -name '*.java' | xargs wc -l | sort -nr | head -n 10

Result for jdk1.8.0:

10161 ./awt/Component.java
 7231 ./lang/Character.java
 6312 ./util/concurrent/ConcurrentHashMap.java
 5858 ./util/regex/Pattern.java
 5564 ./util/Collections.java
 5257 ./math/BigDecimal.java
 5115 ./util/Arrays.java
 4986 ./awt/Container.java
 4698 ./util/Formatter.java

Note that the shorter idiom wc -l **/*.java is not recursive by default. You need to shopt -s globstar to make the operator recursive. Without that you'll miss large classes such as,

6312 ./util/concurrent/ConcurrentHashMap.java
4503 ./time/format/DateTimeFormatterBuilder.java

Note for mac users:

For the accepted answer to work (wc -l **/*.java), you need bash with globstar support (≥ 4.x). macOS Catalina, for example, comes with an older version of bash (3.2.57). In that case you need to install bash with Homebrew (brew install bash), and turn on recursiveness with shopt -s globstar. You can find more details here.


问:
Does windows have same maximum path lengths (name of directory entry) for different filesystems it mounts?
I have to know if a specific vulnerablity in TCL 8.4 affects Windows platform

The vulnerability is: http://www.securityfocus.com/bid/15259/info
As per the link:

Operating systems with no difference in the maximum path lengths among differing file systems are not affected by this issue

I am using TCL on windows and want to know if this vulnerablity affects TCL on windows and how ?

Further, how can a person exploit this vulnerability on Windows ?

Thanks

答:
The windows header files define MAX_PATH - as 260 - as the usual maximum path size. This isn't really universally applied. There are a number of ways to bypass this limit, in which case the effective path limit is, well, unlimited. Or 32,767 characters. Whichever is shorter.

Naming, Files, Paths and Namespaces has more info.


问:
R tidyverse mutate with all combinations of subset of columns in grouped dataframe
I'd like to run a mutate for all combinations of a subset of columns of a grouped dataframe via tidyverse.

Here's the setup:

```<code>library(tidyverse)
a <- c(2018, 2019, 2020) #years
b <- c(23, 24, 25, 26) #cities
c <- c(45, 46, 47, 48, 49) #jobs
rows <- expand.grid(a, b, c)
colnames(rows) <- c('a', 'b', 'c')
d <-  sample(c(0,1), nrow(rows), replace = TRUE)
obs <- cbind(rows, d) %>% group_by(a, b) %>% mutate(c = str_c("J", c))
wide <- obs %>% spread(c, d)
</code>```

Which produces this:

```<code>A grouped_df: 12 × 7
a       b   J45 J46 J47 J48 J49
2018    23  1   0   1   1   1
2018    24  0   0   1   1   0
2018    25  0   1   0   1   1
2018    26  1   0   1   1   1
2019    23  0   0   1   1   1
2019    24  0   1   0   0   1
2019    25  1   0   0   1   0
2019    26  0   1   1   1   1
2020    23  0   1   0   1   0
2020    24  1   0   1   0   1
2020    25  1   0   0   1   0
2020    26  0   1   0   0   0
</code>```

The dataframe data is grouped by a and b, and I want to find the sum of all combinations of the J* columns.

I've been referring to this [tidyverse: Chi Square for all combinations of columns for guidance, but it doesn't use grouping.

I've expanded the dataframe to include all combinations with

```<code>combos <- data.frame(t(combn(unique(obs$c), 2)))
data <- merge(wide, combos) %>% mutate(X1 = as.character(X1), X2 = as.character(X2))
</code>```

and head(data, 10) produces this:

```<code>    a       b   J45 J46 J47 J48 J49 X1  X2
1   2018    23  1   0   1   1   1   J45 J46
2   2018    24  0   0   1   1   0   J45 J46
3   2018    25  0   1   0   1   1   J45 J46
4   2018    26  1   0   1   1   1   J45 J46
5   2019    23  0   0   1   1   1   J45 J46
6   2019    24  0   1   0   0   1   J45 J46
7   2019    25  1   0   0   1   0   J45 J46
8   2019    26  0   1   1   1   1   J45 J46
9   2020    23  0   1   0   1   0   J45 J46
10  2020    24  1   0   1   0   1   J45 J46
</code>```

Now I want the sum for each row of the value in the X1 column and the value in the X2 column. I can't seem to make either map2 or unquoted eval work. What am I missing?

Thank you for your attention.

EDIT: Some additional info, results of what I've tried and desired output (@camille).

With data %>% mutate(d = map2(X1, X2, sum(.x, .y))) I get

```<code>Error in as_mapper(.f, ...): object '.x' not found
</code>```

and with data %>% mutate(d = sum(!!sym(X1), !!sym(X2))) I get

```<code>Error in is_symbol(x): object 'X1' not found.
</code>```

I don't understand why it can't find these elements, esp in the map2 case.

As output, I need to retain the grouping values and column combinations with the sum value (ultimately a weighted edge list). Both outputs from the responses by @andrew_reece and @42- are fine, but I am curious as to why something more straightforward along the lines of "add the values in these two columns row wise" doesn't work.

答:
I'm guessing you want something like this:

```<code>data$sum2s <- rowSums( cbind(   #make one two-column matrix
                             # by indexing with two other two-column matrices below
               as.numeric( data[cbind( 1:nrow(data), match(data$X1,names(data)))]),
               as.numeric( data[cbind( 1:nrow(data), match(data$X2,names(data)))])
                       ) )

> str(data)
'data.frame':   120 obs. of  10 variables:
 $ a    : num  2018 2018 2018 2018 2019 ...
 $ b    : num  23 24 25 26 23 24 25 26 23 24 ...
 $ J45  : num  1 1 1 1 1 0 1 1 1 1 ...
 $ J46  : num  0 1 0 0 0 0 0 1 1 1 ...
 $ J47  : num  1 1 1 0 0 1 1 0 0 1 ...
 $ J48  : num  0 1 0 0 0 1 0 0 1 1 ...
 $ J49  : num  1 1 0 1 0 1 1 0 0 1 ...
 $ X1   : chr  "J45" "J45" "J45" "J45" ...
 $ X2   : chr  "J46" "J46" "J46" "J46" ...
 $ sum2s: num  1 2 1 1 1 0 1 2 2 2 ...
</code>```

It uses indexing with a two-column matrix, which allows you to pull out non-contiguous values, instead of needing to have all values from the same row or column. See?"["

Body:
I'd like to run a mutate for all combinations of a subset of columns of a grouped dataframe via tidyverse.

Here's the setup:

library(tidyverse)
a <- c(2018, 2019, 2020) #years
b <- c(23, 24, 25, 26) #cities
c <- c(45, 46, 47, 48, 49) #jobs
rows <- expand.grid(a, b, c)
colnames(rows) <- c('a', 'b', 'c')
d <-  sample(c(0,1), nrow(rows), replace = TRUE)
obs <- cbind(rows, d) %>% group_by(a, b) %>% mutate(c = str_c("J", c))
wide <- obs %>% spread(c, d)

Which produces this:

A grouped_df: 12 × 7
a       b   J45 J46 J47 J48 J49
2018    23  1   0   1   1   1
2018    24  0   0   1   1   0
2018    25  0   1   0   1   1
2018    26  1   0   1   1   1
2019    23  0   0   1   1   1
2019    24  0   1   0   0   1
2019    25  1   0   0   1   0
2019    26  0   1   1   1   1
2020    23  0   1   0   1   0
2020    24  1   0   1   0   1
2020    25  1   0   0   1   0
2020    26  0   1   0   0   0

The dataframe data is grouped by a and b, and I want to find the sum of all combinations of the J* columns.

I've been referring to this [tidyverse: Chi Square for all combinations of columns for guidance, but it doesn't use grouping.

I've expanded the dataframe to include all combinations with

combos <- data.frame(t(combn(unique(obs$c), 2)))
data <- merge(wide, combos) %>% mutate(X1 = as.character(X1), X2 = as.character(X2))

and head(data, 10) produces this:

    a       b   J45 J46 J47 J48 J49 X1  X2
1   2018    23  1   0   1   1   1   J45 J46
2   2018    24  0   0   1   1   0   J45 J46
3   2018    25  0   1   0   1   1   J45 J46
4   2018    26  1   0   1   1   1   J45 J46
5   2019    23  0   0   1   1   1   J45 J46
6   2019    24  0   1   0   0   1   J45 J46
7   2019    25  1   0   0   1   0   J45 J46
8   2019    26  0   1   1   1   1   J45 J46
9   2020    23  0   1   0   1   0   J45 J46
10  2020    24  1   0   1   0   1   J45 J46

Now I want the sum for each row of the value in the X1 column and the value in the X2 column. I can't seem to make either map2 or unquoted eval work. What am I missing?

Thank you for your attention.

EDIT: Some additional info, results of what I've tried and desired output (@camille).

With data %>% mutate(d = map2(X1, X2, sum(.x, .y))) I get

Error in as_mapper(.f, ...): object '.x' not found

and with data %>% mutate(d = sum(!!sym(X1), !!sym(X2))) I get

Error in is_symbol(x): object 'X1' not found.

I don't understand why it can't find these elements, esp in the map2 case.

As output, I need to retain the grouping values and column combinations with the sum value (ultimately a weighted edge list). Both outputs from the responses by @andrew_reece and @42- are fine, but I am curious as to why something more straightforward along the lines of "add the values in these two columns row wise" doesn't work.

Body:
I'm guessing you want something like this:

data$sum2s <- rowSums( cbind(   #make one two-column matrix
                             # by indexing with two other two-column matrices below
               as.numeric( data[cbind( 1:nrow(data), match(data$X1,names(data)))]),
               as.numeric( data[cbind( 1:nrow(data), match(data$X2,names(data)))])
                       ) )

> str(data)
'data.frame':   120 obs. of  10 variables:
 $ a    : num  2018 2018 2018 2018 2019 ...
 $ b    : num  23 24 25 26 23 24 25 26 23 24 ...
 $ J45  : num  1 1 1 1 1 0 1 1 1 1 ...
 $ J46  : num  0 1 0 0 0 0 0 1 1 1 ...
 $ J47  : num  1 1 1 0 0 1 1 0 0 1 ...
 $ J48  : num  0 1 0 0 0 1 0 0 1 1 ...
 $ J49  : num  1 1 0 1 0 1 1 0 0 1 ...
 $ X1   : chr  "J45" "J45" "J45" "J45" ...
 $ X2   : chr  "J46" "J46" "J46" "J46" ...
 $ sum2s: num  1 2 1 1 1 0 1 2 2 2 ...

It uses indexing with a two-column matrix, which allows you to pull out non-contiguous values, instead of needing to have all values from the same row or column. See?"["


问:
(android studio) can't change the "Webpage not available" page in webview
I'm trying to display my own "no internet" page in my app.
I think something might be wrong with my code, I've been following this tutorial but for some reason, my code keeps displaying the default "Webpage not available" screen.</p>

```<code>public class MainActivity extends AppCompatActivity {

    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        webView = (WebView) findViewById(R.id.webview);
        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setAppCacheEnabled(true);
        webView.loadUrl("https://www.kasumushi.com/");

        webView.setWebViewClient(new WebViewClient() {
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                webView.loadUrl("file:///android_asset/error.html");

            }
        });
    }

    @Override
    public void onBackPressed() {
        if(webView.canGoBack()) {
            webView.goBack();
        }else {
            super.onBackPressed();
        }
    }

}
</code>```

答:
```<code>boolean errorOccurred = false; // Global variable

webView.setWebViewClient(new WebViewClient() {
    @Override
    public void onPageStarted(WebView view, String url, Bitmap favicon) {
        super.onPageStarted(view, url, favicon);
        hideError();
        showProgress();
        Toast.makeText(Test.this, "start loading", Toast.LENGTH_SHORT).show();
        errorOccurred=false;
    }
    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);
        if (!errorOccurred) {
            hideError();
        }
        hideProgress();
        Toast.makeText(Test.this, "Web view was loaded", Toast.LENGTH_SHORT).show();
    }
    @Override
    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
        errorOccurred = true;
        hideProgress();
        showError();
        Toast.makeText(Test.this, "Could not load your page", Toast.LENGTH_SHORT).show();
        super.onReceivedError(view, errorCode, description, failingUrl);
        Toast.makeText(Test.this, "error", Toast.LENGTH_SHORT).show();
    }
});
</code>```

Body:
I'm trying to display my own "no internet" page in my app.
I think something might be wrong with my code, I've been following this tutorial but for some reason, my code keeps displaying the default "Webpage not available" screen.

public class MainActivity extends AppCompatActivity {

    private WebView webView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        webView = (WebView) findViewById(R.id.webview);
        WebSettings webSettings = webView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setAppCacheEnabled(true);
        webView.loadUrl("https://www.kasumushi.com/");

        webView.setWebViewClient(new WebViewClient() {
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                webView.loadUrl("file:///android_asset/error.html");

            }
        });
    }

    @Override
    public void onBackPressed() {
        if(webView.canGoBack()) {
            webView.goBack();
        }else {
            super.onBackPressed();
        }
    }

}


问:
Concatenating columns not returning full results
I have a table that I want to concatenate 4 columns together; 2 of them are integers, 1 text & 1 date.

I have joined them together by casting the integers to varchar & formatting the date. But I have an example where the last item is not being shown

```<code>SELECT
    CAST(CONTRACT_ID VARCHAR(15)) + '-' +
    CAST(CONTRACT_TYPE AS VARCHAR(15))  + '-' +
    GENDER + '-' + FORMAT(DOB, 'yyyy') AS UNIQUE_ID
</code>```

There are 4 rows which should have the same output, then they differ.

```<code>- 12345678-70-M -1948
- 12345678-70-M
- 12345678-70-M
- 12345678-70-M
</code>```

But when run as results to text, the correct results return

```<code>- 12345678-70-M -1948
- 12345678-70-M -1948
- 12345678-70-M -1948
- 12345678-70-M -1948
</code>```

This isn't a visual error within the grid, because if I do a filter on it it will only return the 1 row.

I did notice though, if I cast the gender to varchar(1), the results do work.
Could there be a hidden character at the end of the gender field that is causing the issue.

It seems to be working fine 99% of the time.

答:
Try the below query. Here the DOB column data type is DateTime and the value is only for the sample i.e., current date.

```<code>create table test (CONTRACT_ID VARCHAR(15),
CONTRACT_TYPE VARCHAR(15),
GENDER Char(1),
DOB Datetime
)

 Insert into test Values
('12345678', '70', 'M', Getdate()),
('12345678', '70', 'M', Getdate()),
('12345678', '70', 'M', Getdate()),
('12345678', '70', 'M', Getdate())

Select * from test

SELECT
    CAST(CONTRACT_ID as VARCHAR(15)) + '-' +
    CAST(CONTRACT_TYPE AS VARCHAR(15))  + '-' +
    GENDER + '-' + FORMAT(DOB, 'yyyy') AS UNIQUE_ID
    from test
</code>```

Here is the db<>fiddle demo.

Body:
I have a table that I want to concatenate 4 columns together; 2 of them are integers, 1 text & 1 date.

I have joined them together by casting the integers to varchar & formatting the date. But I have an example where the last item is not being shown

SELECT
    CAST(CONTRACT_ID VARCHAR(15)) + '-' +
    CAST(CONTRACT_TYPE AS VARCHAR(15))  + '-' +
    GENDER + '-' + FORMAT(DOB, 'yyyy') AS UNIQUE_ID

There are 4 rows which should have the same output, then they differ.

- 12345678-70-M -1948
- 12345678-70-M
- 12345678-70-M
- 12345678-70-M

But when run as results to text, the correct results return

- 12345678-70-M -1948
- 12345678-70-M -1948
- 12345678-70-M -1948
- 12345678-70-M -1948

This isn't a visual error within the grid, because if I do a filter on it it will only return the 1 row.

I did notice though, if I cast the gender to varchar(1), the results do work.
Could there be a hidden character at the end of the gender field that is causing the issue.

It seems to be working fine 99% of the time.

Body:
Try the below query. Here the DOB column data type is DateTime and the value is only for the sample i.e., current date.

create table test (CONTRACT_ID VARCHAR(15),
CONTRACT_TYPE VARCHAR(15),
GENDER Char(1),
DOB Datetime
)

 Insert into test Values
('12345678', '70', 'M', Getdate()),
('12345678', '70', 'M', Getdate()),
('12345678', '70', 'M', Getdate()),
('12345678', '70', 'M', Getdate())

Select * from test

SELECT
    CAST(CONTRACT_ID as VARCHAR(15)) + '-' +
    CAST(CONTRACT_TYPE AS VARCHAR(15))  + '-' +
    GENDER + '-' + FORMAT(DOB, 'yyyy') AS UNIQUE_ID
    from test

Here is the db<>fiddle demo.


问:
looking for a quick and light storage solution for php - simpleXML?
i want to use simplexml & a webform to capture some simple information but i'm worried that if someone submits the form at precisely the same moment i might lose some data.

how can i ensure this doesn't happen?

答: If you don't mind those users waiting for eachother you could implement a simple lock using flock. Anything more complex will require a database of some sorts to ensure atomicity.


问:
Any ideas why my PayPal IPN Listener spontaneously started throwing errors?
As of Saturday, I'm suddenly getting "cURL error: [60] SSL certificate problem: unable to get local issuer certificate" when my PayPal IPN fires. I haven't changed any code on my site in months, and to my knowledge, I'm not running any auto-upgrades that would interfere.

I've read dozens of Stack posts, and nothing in them has worked. I've moved the .crt to other directories and updated cURLOPT_CAINFO. Restarted httpd and cpanel. Listed the cert in php.ini. (It was not there before this started, so I doubt that's it.) Downloaded and installed .pem files, which I think isn't even relevant to this. None of it has worked.

PayPal has verified that the IPN messages are being sent, and the PayPal Sandbox verifies a handshake successfully. There is a regular ol' SSL on the website, and it's operating correctly.

Server is GoDaddy VPS, CentOs Linux 7 with Apache 2.4.41.

I am not willing to turn off VERIFYPEER or operate in an insecure setup.

My code:

```<code>protected function curlPost($encoded_data)
    {
        $uri = 'https://'.$this->getPaypalHost().'/cgi-bin/webscr';
        $this->post_uri = $uri;

        $ch = curl_init();

        if ($this->verify_ssl) {
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($ch, CURLOPT_CAINFO, '/home/shopusa/public_html/app/Support/cert/api_cert_chain.crt');
        }

        curl_setopt($ch, CURLOPT_URL, $uri);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded_data);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $this->follow_location);
        curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, true);

        $this->response = curl_exec($ch);
        $this->response_status = strval(curl_getinfo($ch, CURLINFO_HTTP_CODE));

        if ($this->response === false || $this->response_status == '0') {
            $errno = curl_errno($ch);
            $errstr = curl_error($ch);
            throw new Exception("cURL error: [$errno] $errstr");
        }

        return $this->response;
    }
</code>```

The file is here, according to Terminal, and it is owned by the web user:

```<code>[root@ip-###-###-###-## cert]# cd /home/shopusa/public_html/app/Support/cert/
[root@ip-###-###-###-## cert]# ls
api_cert_chain.crt  _notes
</code>```

All permissions are 755/directory and 644/file.

Does anything jump out at anyone? I've spent about eight hours chasing this down, and I'm out of ideas for how to get the IPN listener firing again.

答:
Replace api_cert_chain.crt with an updated certificate authority bundle that is able to verify the issuer of the PayPal servers' current, cryptographically secure certificates.

Perhaps from https://curl.haxx.se/docs/caextract.html (convert the pem to crt if necessary, though I don't think it is)

Body:
As of Saturday, I'm suddenly getting "cURL error: [60] SSL certificate problem: unable to get local issuer certificate" when my PayPal IPN fires. I haven't changed any code on my site in months, and to my knowledge, I'm not running any auto-upgrades that would interfere.

I've read dozens of Stack posts, and nothing in them has worked. I've moved the .crt to other directories and updated cURLOPT_CAINFO. Restarted httpd and cpanel. Listed the cert in php.ini. (It was not there before this started, so I doubt that's it.) Downloaded and installed .pem files, which I think isn't even relevant to this. None of it has worked.

PayPal has verified that the IPN messages are being sent, and the PayPal Sandbox verifies a handshake successfully. There is a regular ol' SSL on the website, and it's operating correctly.

Server is GoDaddy VPS, CentOs Linux 7 with Apache 2.4.41.

I am not willing to turn off VERIFYPEER or operate in an insecure setup.

My code:

protected function curlPost($encoded_data)
    {
        $uri = 'https://'.$this->getPaypalHost().'/cgi-bin/webscr';
        $this->post_uri = $uri;

        $ch = curl_init();

        if ($this->verify_ssl) {
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($ch, CURLOPT_CAINFO, '/home/shopusa/public_html/app/Support/cert/api_cert_chain.crt');
        }

        curl_setopt($ch, CURLOPT_URL, $uri);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $encoded_data);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $this->follow_location);
        curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, true);

        $this->response = curl_exec($ch);
        $this->response_status = strval(curl_getinfo($ch, CURLINFO_HTTP_CODE));

        if ($this->response === false || $this->response_status == '0') {
            $errno = curl_errno($ch);
            $errstr = curl_error($ch);
            throw new Exception("cURL error: [$errno] $errstr");
        }

        return $this->response;
    }

The file is here, according to Terminal, and it is owned by the web user:

[root@ip-###-###-###-## cert]# cd /home/shopusa/public_html/app/Support/cert/
[root@ip-###-###-###-## cert]# ls
api_cert_chain.crt  _notes

All permissions are 755/directory and 644/file.

Does anything jump out at anyone? I've spent about eight hours chasing this down, and I'm out of ideas for how to get the IPN listener firing again.


问:
Xamarin iOS webview underlap behind navigation bar
I am using xamarin custom webview to load my page in app. But facing issue that title of webpage hides behind navigation bar . Or sometimes bottom of page not shown. I have tried adding scrollbar to my layout but still facing issue. Same works perfectly on android. Is it due to custom webview? I just want my webview to start below navigation bar and load completely according to device size.

my custom webview code :

```<code>public class CustomWebView : WebView
    {
        public static readonly BindableProperty UriProperty = BindableProperty.Create(
        propertyName: "Uri",
        returnType: typeof(string),
        declaringType: typeof(CustomWebView),
        defaultValue: default(string));

        public string Uri
        {
            get { return (string)GetValue(UriProperty); }
            set { SetValue(UriProperty, value); }
        }
    }
</code>```

Xaml Page :

```<code><StackLayout Orientation="Vertical" HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand">
            <StackLayout>
                <Label x:Name="type" Text="Loading..." FontSize="Medium"/>
            </StackLayout>
            <StackLayout  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
                <ScrollView Orientation="Vertical" FlowDirection="MatchParent" HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand" Visual="Material" VerticalScrollBarVisibility="Always">
                    <OnPlatform x:TypeArguments="View">
                        <On Platform="Android">
                            <WebView  x:Name="dashboard_android"  HeightRequest="1000" WidthRequest="1000"  />
                        </On>
                        <On Platform="iOS">
                            <local:CustomWebView  x:Name="dashboard_ios" VerticalOptions="StartAndExpand" HorizontalOptions="FillAndExpand"  WidthRequest="1000"  HeightRequest="1000"/>
                        </On>
                    </OnPlatform>
                </ScrollView>

            </StackLayout>
        </StackLayout>
</code>```

code behind :

```<code>dashboard_android.Source = url;
  dashboard_ios.Uri = url;
</code>```

Following are solutions i have tried but no success

Solution 1 :
I have tried adding two properties, but no use

```<code>this.EdgesForExtendedLayout = UIRectEdge.None;

   this.ExtendedLayoutIncludesOpaqueBars = false;
</code>```

Solution 2 :

Tried enabling this unsafe area property , still no success

```<code>ios:Page.UseSafeArea="true"
</code>```

Solution 3 :

Tried setting webview height on content size dynamically , but no success

```<code> public override async void DidFinishNavigation(WKWebView webView, WKNavigation navigation)
        {
            // base.DidFinishNavigation(webView, navigation);

            var wv = _webViewRenderer.Element as CustomWebView;
            if (wv != null)
            {
                await System.Threading.Tasks.Task.Delay(100); // wait here till content is rendered
                wv.HeightRequest = (double)webView.Frame.Size.Height; // ScrollView.ContentSize.Height;
            }

        }
</code>```

Updated Xaml Code :

```<code> <StackLayout  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
 <local:CustomWebView  x:Name="dashboard"  HeightRequest="1000" WidthRequest="1000" />
</StackLayout>
</code>```

Updated Code behind :

```<code>public partial class DashboardView : ContentPage
    {
        string url;
        public DashboardView()
        {
            InitializeComponent();
            url= ""; //adding url to load here
           dashboard.Uri = url;

      }
    }
</code>```

Custom WebView Renderer

```<code>    [assembly: ExportRenderer(typeof(CustomWebView), typeof(MyCustomWebViewRenderer))]
    namespace Report.iOS
    {

        public class MyCustomWebViewRenderer : ViewRenderer<CustomWebView, WKWebView>
        {
            WKWebView webView;
            protected override void OnElementChanged(ElementChangedEventArgs<CustomWebView> e)
            {
                base.OnElementChanged(e);

                if (Control == null)
                {
                    webView = new WKWebView(Frame, new WKWebViewConfiguration());

                    webView.NavigationDelegate = new WebViewDelegate();

                    SetNativeControl(webView);

                }
                if (e.NewElement != null)
                {

                   Control.LoadRequest(new NSUrlRequest(new NSUrl(Element.Uri)));

                }
            }

    }

    public  class WebViewDelegate : WKNavigationDelegate, INSUrlConnectionDataDelegate
    {
        string uname = null;
        string pass = null;

        public override async void DidReceiveAuthenticationChallenge(WKWebView webView, NSUrlAuthenticationChallenge challenge, Action<NSUrlSessionAuthChallengeDisposition, NSUrlCredential> completionHandler)
        {
            try
            {
                uname = Xamarin.Forms.Application.Current.Properties.ContainsKey("Username") ? Convert.ToString(Xamarin.Forms.Application.Current.Properties["Username"]) : null;
                pass = await SecureStorage.GetAsync("Password");
            }
            catch (Exception ex)
            {

            }
            completionHandler(NSUrlSessionAuthChallengeDisposition.UseCredential, new NSUrlCredential(uname, pass, NSUrlCredentialPersistence.ForSession));

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

Screenshot of webview screen :

Here i am loading this webpage(https://learn.microsoft.com/en-us/xamarin/essentials/device-display?tabs=android). As you can see half of footer is hidden and i am not able to scroll it.

Screenshot of app

答:
I was facing that issue just beacuse i was using custom renderer.
My solution code is as follows :

Xaml Code :

```<code> <ContentPage.Content>
        <StackLayout  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
            <WebView  x:Name="dashboard" HeightRequest="1000" WidthRequest="1000"/>
        </StackLayout>
    </ContentPage.Content>
</code>```

Code Behind :

```<code> public partial class DashboardView : ContentPage
        {
            public DashboardView()
            {
                InitializeComponent();
                dashboard.Source = "url";
            }

        }
</code>```

Authentication Renderer iOS :

```<code>[assembly: ExportRenderer(typeof(WebView), typeof(Report.iOS.WebViewRenderer))]
namespace Report.iOS
{
    class WebViewRenderer : WkWebViewRenderer
    {
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);
            this.NavigationDelegate = new WebViewDelegate();

        }
    }

    public class WebViewDelegate : WKNavigationDelegate, INSUrlConnectionDataDelegate
    {
        string uname = null;
        string pass = null;

        public override async void DidReceiveAuthenticationChallenge(WKWebView webView, NSUrlAuthenticationChallenge challenge, Action<NSUrlSessionAuthChallengeDisposition, NSUrlCredential> completionHandler)
        {
            try
            {
                uname = Xamarin.Forms.Application.Current.Properties.ContainsKey("Username") ? Convert.ToString(Xamarin.Forms.Application.Current.Properties["Username"]) : null;
                pass = await SecureStorage.GetAsync("Password");
            }
            catch (Exception ex)
            {

            }
            completionHandler(NSUrlSessionAuthChallengeDisposition.UseCredential, new NSUrlCredential(uname, pass, NSUrlCredentialPersistence.ForSession));

            return;
        }
    }

}
</code>```

Authentication Renderer Android :

```<code>[assembly: ExportRenderer(typeof(WebView), typeof(AuthWebViewRenderer))]

namespace Report.Droid
{

    public class AuthWebViewRenderer : Xamarin.Forms.Platform.Android.WebViewRenderer
    {
        AuthWebViewClient _authWebClient = null;

        public  AuthWebViewRenderer(Context context) : base(context)
        {

        }

        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<WebView> e)
        {
            base.OnElementChanged(e);
            if (_authWebClient == null)
            {
                _authWebClient = new AuthWebViewClient();

            }
            Control.SetWebViewClient(_authWebClient);
        }
    }
    public class AuthWebViewClient : WebViewClient
    {

        public AuthWebViewClient()
        {

        }

        public override async  void OnReceivedHttpAuthRequest(global::Android.Webkit.WebView view, HttpAuthHandler handler, string host, string realm)
        {
            string uname = null;
            string pass = null;
            try
            {
                uname = Application.Current.Properties.ContainsKey("Username") ? Convert.ToString(Application.Current.Properties["Username"]) : null;
                pass = await SecureStorage.GetAsync("Password");
            }
            catch (Exception ex)
            {
                Log.Error("Apprise :", "Error Occurred while getting login credentials " + ex);
            }
            handler.Proceed(uname, pass);
        }

    }
}
</code>```

Body:
I am using xamarin custom webview to load my page in app. But facing issue that title of webpage hides behind navigation bar . Or sometimes bottom of page not shown. I have tried adding scrollbar to my layout but still facing issue. Same works perfectly on android. Is it due to custom webview? I just want my webview to start below navigation bar and load completely according to device size.

my custom webview code :

public class CustomWebView : WebView
    {
        public static readonly BindableProperty UriProperty = BindableProperty.Create(
        propertyName: "Uri",
        returnType: typeof(string),
        declaringType: typeof(CustomWebView),
        defaultValue: default(string));

        public string Uri
        {
            get { return (string)GetValue(UriProperty); }
            set { SetValue(UriProperty, value); }
        }
    }

Xaml Page :

<StackLayout Orientation="Vertical" HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand">
            <StackLayout>

            </StackLayout>
            <StackLayout  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
                <ScrollView Orientation="Vertical" FlowDirection="MatchParent" HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand" Visual="Material" VerticalScrollBarVisibility="Always">
                    <OnPlatform x:TypeArguments="View">
                        <On Platform="Android">
                            <WebView  x:Name="dashboard_android"  HeightRequest="1000" WidthRequest="1000"  />
                        </On>
                        <On Platform="iOS">
                            <local:CustomWebView  x:Name="dashboard_ios" VerticalOptions="StartAndExpand" HorizontalOptions="FillAndExpand"  WidthRequest="1000"  HeightRequest="1000"/>
                        </On>
                    </OnPlatform>
                </ScrollView>

            </StackLayout>
        </StackLayout>

code behind :

dashboard_android.Source = url;
  dashboard_ios.Uri = url;

Following are solutions i have tried but no success

Solution 1 :
I have tried adding two properties, but no use

this.EdgesForExtendedLayout = UIRectEdge.None;

   this.ExtendedLayoutIncludesOpaqueBars = false;

Solution 2 :

Tried enabling this unsafe area property , still no success

ios:Page.UseSafeArea="true"

Solution 3 :

Tried setting webview height on content size dynamically , but no success

 public override async void DidFinishNavigation(WKWebView webView, WKNavigation navigation)
        {
            // base.DidFinishNavigation(webView, navigation);

            var wv = _webViewRenderer.Element as CustomWebView;
            if (wv != null)
            {
                await System.Threading.Tasks.Task.Delay(100); // wait here till content is rendered
                wv.HeightRequest = (double)webView.Frame.Size.Height; // ScrollView.ContentSize.Height;
            }

        }

Updated Xaml Code :

 <StackLayout  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
 <local:CustomWebView  x:Name="dashboard"  HeightRequest="1000" WidthRequest="1000" />
</StackLayout>

Updated Code behind :

public partial class DashboardView : ContentPage
    {
        string url;
        public DashboardView()
        {
            InitializeComponent();
            url= ""; //adding url to load here
           dashboard.Uri = url;

      }
    }

Custom WebView Renderer

    [assembly: ExportRenderer(typeof(CustomWebView), typeof(MyCustomWebViewRenderer))]
    namespace Report.iOS
    {

        public class MyCustomWebViewRenderer : ViewRenderer<CustomWebView, WKWebView>
        {
            WKWebView webView;
            protected override void OnElementChanged(ElementChangedEventArgs<CustomWebView> e)
            {
                base.OnElementChanged(e);

                if (Control == null)
                {
                    webView = new WKWebView(Frame, new WKWebViewConfiguration());

                    webView.NavigationDelegate = new WebViewDelegate();

                    SetNativeControl(webView);

                }
                if (e.NewElement != null)
                {

                   Control.LoadRequest(new NSUrlRequest(new NSUrl(Element.Uri)));

                }
            }

    }

    public  class WebViewDelegate : WKNavigationDelegate, INSUrlConnectionDataDelegate
    {
        string uname = null;
        string pass = null;

        public override async void DidReceiveAuthenticationChallenge(WKWebView webView, NSUrlAuthenticationChallenge challenge, Action<NSUrlSessionAuthChallengeDisposition, NSUrlCredential> completionHandler)
        {
            try
            {
                uname = Xamarin.Forms.Application.Current.Properties.ContainsKey("Username") ? Convert.ToString(Xamarin.Forms.Application.Current.Properties["Username"]) : null;
                pass = await SecureStorage.GetAsync("Password");
            }
            catch (Exception ex)
            {

            }
            completionHandler(NSUrlSessionAuthChallengeDisposition.UseCredential, new NSUrlCredential(uname, pass, NSUrlCredentialPersistence.ForSession));

            return;
        }
    }
}

Screenshot of webview screen :

Here i am loading this webpage(https://learn.microsoft.com/en-us/xamarin/essentials/device-display?tabs=android). As you can see half of footer is hidden and i am not able to scroll it.

Screenshot of app

Body:
I was facing that issue just beacuse i was using custom renderer.
My solution code is as follows :

Xaml Code :

 <ContentPage.Content>
        <StackLayout  VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
            <WebView  x:Name="dashboard" HeightRequest="1000" WidthRequest="1000"/>
        </StackLayout>
    </ContentPage.Content>

Code Behind :

 public partial class DashboardView : ContentPage
        {
            public DashboardView()
            {
                InitializeComponent();
                dashboard.Source = "url";
            }

        }

Authentication Renderer iOS :

[assembly: ExportRenderer(typeof(WebView), typeof(Report.iOS.WebViewRenderer))]
namespace Report.iOS
{
    class WebViewRenderer : WkWebViewRenderer
    {
        protected override void OnElementChanged(VisualElementChangedEventArgs e)
        {
            base.OnElementChanged(e);
            this.NavigationDelegate = new WebViewDelegate();

        }
    }

    public class WebViewDelegate : WKNavigationDelegate, INSUrlConnectionDataDelegate
    {
        string uname = null;
        string pass = null;

        public override async void DidReceiveAuthenticationChallenge(WKWebView webView, NSUrlAuthenticationChallenge challenge, Action<NSUrlSessionAuthChallengeDisposition, NSUrlCredential> completionHandler)
        {
            try
            {
                uname = Xamarin.Forms.Application.Current.Properties.ContainsKey("Username") ? Convert.ToString(Xamarin.Forms.Application.Current.Properties["Username"]) : null;
                pass = await SecureStorage.GetAsync("Password");
            }
            catch (Exception ex)
            {

            }
            completionHandler(NSUrlSessionAuthChallengeDisposition.UseCredential, new NSUrlCredential(uname, pass, NSUrlCredentialPersistence.ForSession));

            return;
        }
    }

}

Authentication Renderer Android :

[assembly: ExportRenderer(typeof(WebView), typeof(AuthWebViewRenderer))]

namespace Report.Droid
{

    public class AuthWebViewRenderer : Xamarin.Forms.Platform.Android.WebViewRenderer
    {
        AuthWebViewClient _authWebClient = null;

        public  AuthWebViewRenderer(Context context) : base(context)
        {

        }

        protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<WebView> e)
        {
            base.OnElementChanged(e);
            if (_authWebClient == null)
            {
                _authWebClient = new AuthWebViewClient();

            }
            Control.SetWebViewClient(_authWebClient);
        }
    }
    public class AuthWebViewClient : WebViewClient
    {

        public AuthWebViewClient()
        {

        }

        public override async  void OnReceivedHttpAuthRequest(global::Android.Webkit.WebView view, HttpAuthHandler handler, string host, string realm)
        {
            string uname = null;
            string pass = null;
            try
            {
                uname = Application.Current.Properties.ContainsKey("Username") ? Convert.ToString(Application.Current.Properties["Username"]) : null;
                pass = await SecureStorage.GetAsync("Password");
            }
            catch (Exception ex)
            {
                Log.Error("Apprise :", "Error Occurred while getting login credentials " + ex);
            }
            handler.Proceed(uname, pass);
        }

    }
}


问:
Matching file path using awk from a report
Despite many attempts, I'm not able to get a proper way to extract file names from a report using awk.

I have an output like this.

```<code>found in file /home/cloudst/homes/james/Maildir/cur/1580910042.2931_0.s3.mydomain.com:2,Sa/PURCHASE ORDER KALI-1374Wpdf.gz/PURCHASE ORDER KALI-1374Wpdf.exe/FILE:0000
found in file /home/cloudst/homes/james/Maildir/cur/1580910052.2932_0.s3.mydomain.com:2,Sa/PURCHASE ORDER KALI-1374Bpdf.gz/PURCHASE ORDER KALI-1374Bpdf.exe
found in file /home/cloudst/homes/james/Maildir/.afolder/cur/1580910152.2935_0.s3.mydomain.com:2,Sa/PURCHASE ORDER KALI-1364Cpdf.gz/PURCHASE ORDER KALI-1374Dpdf.exe
</code>```

I need to extract the actual file path. Here, the actual file path is

```<code>/home/cloudst/homes/james/Maildir/.afolder/cur/1580910152.2935_0.s3.mydomain.com:2,Sa
</code>```

for the first line. How can I extract the actual file path from this result using awk, sed or any command using regex?

The expected output will be

```<code>/home/cloudst/homes/james/Maildir/cur/1580910042.2931_0.s3.mydomain.com:2,Sa
/home/cloudst/homes/james/Maildir/cur/1580910052.2932_0.s3.mydomain.com:2,Sa
/home/cloudst/homes/james/Maildir/.afolder/cur/1580910152.2935_0.s3.mydomain.com:2,Sa
</code>```

答:
Could you please try following.

```<code>awk 'match($0,/\/[^,]*,[a-zA-Z]+/){print substr($0,RSTART,RLENGTH)}' Input_file
</code>```

Explanation: Adding detailed explanation for above code.

```<code>awk '                                ##Starting awk program from here.
match($0,/\/[^,]*,[a-zA-Z]+/){       ##Using match function of awk to match regex \/[^,]*,[a-zA-Z]+ which means match till comma then till alphabets in lines.
  print substr($0,RSTART,RLENGTH)    ##Printing sub-string whose starting point is RSTART and ending point is RLENGTH.
}
'  Input_file                        ##Mentioning Input_file here.
</code>```

Body:
Despite many attempts, I'm not able to get a proper way to extract file names from a report using awk.

I have an output like this.

found in file /home/cloudst/homes/james/Maildir/cur/1580910042.2931_0.s3.mydomain.com:2,Sa/PURCHASE ORDER KALI-1374Wpdf.gz/PURCHASE ORDER KALI-1374Wpdf.exe/FILE:0000
found in file /home/cloudst/homes/james/Maildir/cur/1580910052.2932_0.s3.mydomain.com:2,Sa/PURCHASE ORDER KALI-1374Bpdf.gz/PURCHASE ORDER KALI-1374Bpdf.exe
found in file /home/cloudst/homes/james/Maildir/.afolder/cur/1580910152.2935_0.s3.mydomain.com:2,Sa/PURCHASE ORDER KALI-1364Cpdf.gz/PURCHASE ORDER KALI-1374Dpdf.exe

I need to extract the actual file path. Here, the actual file path is

/home/cloudst/homes/james/Maildir/.afolder/cur/1580910152.2935_0.s3.mydomain.com:2,Sa

for the first line. How can I extract the actual file path from this result using awk, sed or any command using regex?

The expected output will be

/home/cloudst/homes/james/Maildir/cur/1580910042.2931_0.s3.mydomain.com:2,Sa
/home/cloudst/homes/james/Maildir/cur/1580910052.2932_0.s3.mydomain.com:2,Sa
/home/cloudst/homes/james/Maildir/.afolder/cur/1580910152.2935_0.s3.mydomain.com:2,Sa

Body:
Could you please try following.

awk 'match($0,/\/[^,]*,[a-zA-Z]+/){print substr($0,RSTART,RLENGTH)}' Input_file

Explanation: Adding detailed explanation for above code.

awk '                                ##Starting awk program from here.
match($0,/\/[^,]*,[a-zA-Z]+/){       ##Using match function of awk to match regex \/[^,]*,[a-zA-Z]+ which means match till comma then till alphabets in lines.
  print substr($0,RSTART,RLENGTH)    ##Printing sub-string whose starting point is RSTART and ending point is RLENGTH.
}
'  Input_file                        ##Mentioning Input_file here.


问:
Optimizing control resizing
I have a custom UserControl that have a StatusStrip. So, I resize this control when user drags the corner of this status strip. However, the resizing is not pretty good: temporary white areas can be observed on the parent control during the resize, and sometimes if the resizing are too fast user "loses" the control(that stops resizing).

```<code>Option Infer On

Public Class FloattingGrid
  Inherits System.Windows.Forms.UserControl

  Dim mouseDownLocation As Nullable(Of Point)

  Private Sub StatusStrip1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles StatusStrip1.MouseMove

    If mouseDownLocation.HasValue Then
      Dim newPosition = Cursor.Position
      Dim dx = newPosition.X - mouseDownLocation.Value.X
      Dim dy = newPosition.Y - mouseDownLocation.Value.Y
      'Dim oldRect = New Rectangle(Me.Location, Me.Size)'
      Me.Size = New Size(Me.Width + dx, Me.Height + dy)
      mouseDownLocation = newPosition

      If Me.Parent IsNot Nothing Then
        'Me.Parent.Invalidate(oldRect) '
        Me.Parent.Refresh()
      End If
    Else

      If e.X > Me.Width - 20 Then
        If Cursor <> Cursors.SizeNWSE Then Cursor = Cursors.SizeNWSE
      Else
        If Cursor = Cursors.SizeNWSE Then Cursor = Cursors.Default
      End If
    End If
  End Sub

  Private Sub StatusStrip1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusStrip1.MouseLeave
    Cursor = Cursors.Default
    mouseDownLocation = Nothing
    'Me.ResumeLayout() '
  End Sub

  Private Sub StatusStrip1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles StatusStrip1.MouseDown
    If Cursor = Cursors.SizeNWSE Then
      'Me.SuspendLayout() '
      mouseDownLocation = Cursor.Position
    End If
  End Sub

  Private Sub StatusStrip1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles StatusStrip1.MouseUp
    mouseDownLocation = Nothing
    'Me.ResumeLayout()'
  End Sub

  ' Private Sub FloattingGrid_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove '
  ' End Sub '

  Private Sub FloattingGrid_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.ResizeRedraw = True
  End Sub
End Class
</code>```

I think that behavior could be caused by the parent's Invalidate. Is there a way to just BeginInvalidate and not wait till parent invalidates all the region?

答:
BeginInvoke has nothing to do with painting and nothing to do with implementing a delay. It's all about cross-thread access, which you're not doing here. It's not the correct solution.

And there's nothing wrong with calling Invalidate. It just marks the area as requiring painting. It doesn't actually cause that area to get repainted multiple times. If the area you invalidate has already been invalidated, it's a no-op, so it's not responsible for slowing anything down here. If you wanted it to be repainted immediately, you would need to call something like Refresh instead.

One thing you could do is prevent the parent control from trying to resize itself and change the layout of its child controls to accommodate the new position of the StatusStrip. To do that, call the SuspendLayout method when you begin resizing and the ResumeLayout method when you finish.

Of course, that's not guaranteed to solve your problem. You're still very likely to see a lag and white or black areas appear in the regions that haven't been painted yet. This happens in other applications and even when you resize windows. The only solution to that is double-buffering, drawing everything into a temporary background buffer, and then painting that entire completed image to the screen.

Title: Optimizing control resizing

Body:
I have a custom UserControl that have a StatusStrip. So, I resize this control when user drags the corner of this status strip. However, the resizing is not pretty good: temporary white areas can be observed on the parent control during the resize, and sometimes if the resizing are too fast user "loses" the control(that stops resizing).

Option Infer On

Public Class FloattingGrid
  Inherits System.Windows.Forms.UserControl

  Dim mouseDownLocation As Nullable(Of Point)

  Private Sub StatusStrip1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles StatusStrip1.MouseMove

    If mouseDownLocation.HasValue Then
      Dim newPosition = Cursor.Position
      Dim dx = newPosition.X - mouseDownLocation.Value.X
      Dim dy = newPosition.Y - mouseDownLocation.Value.Y
      'Dim oldRect = New Rectangle(Me.Location, Me.Size)'
      Me.Size = New Size(Me.Width + dx, Me.Height + dy)
      mouseDownLocation = newPosition

      If Me.Parent IsNot Nothing Then
        'Me.Parent.Invalidate(oldRect) '
        Me.Parent.Refresh()
      End If
    Else

      If e.X > Me.Width - 20 Then
        If Cursor <> Cursors.SizeNWSE Then Cursor = Cursors.SizeNWSE
      Else
        If Cursor = Cursors.SizeNWSE Then Cursor = Cursors.Default
      End If
    End If
  End Sub

  Private Sub StatusStrip1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StatusStrip1.MouseLeave
    Cursor = Cursors.Default
    mouseDownLocation = Nothing
    'Me.ResumeLayout() '
  End Sub

  Private Sub StatusStrip1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles StatusStrip1.MouseDown
    If Cursor = Cursors.SizeNWSE Then
      'Me.SuspendLayout() '
      mouseDownLocation = Cursor.Position
    End If
  End Sub

  Private Sub StatusStrip1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles StatusStrip1.MouseUp
    mouseDownLocation = Nothing
    'Me.ResumeLayout()'
  End Sub

  ' Private Sub FloattingGrid_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove '
  ' End Sub '

  Private Sub FloattingGrid_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me.ResizeRedraw = True
  End Sub
End Class

I think that behavior could be caused by the parent's Invalidate. Is there a way to just BeginInvalidate and not wait till parent invalidates all the region?


问:
youtube_dl - Overwritting metadata
I have managed to extract the title and artist using the --metadata-from-title option, but it seems that it does not overwrite if those metadata items already exist in the video file.

I'm am using:

```<code>py -3 -m youtube_dl -o "%(title)s.%(ext)s" -x --audio-format mp3 --audio-quality 320K --embed-thumbnail --add-metadata --metadata-from-title "%(artist)s ~ %(title)s" oLNMnOYEMAA
</code>```

Is this is a bug?

If not then is it possible to overwrite the existing values?  I know that you can do it using the postprocessor-args command, but do not know if it is possible to pass the title and artist as parameters.

答:
From the youtube-dl github

--metadata-from-title

...Parse additional metadata like song title /
                                     artist from the video title...

The keyword being additional metadata, it's not supposed to remove or replace the existing just add the additional data if possible.

I also looked through the known bugs and this was not one of them.

Title: youtube_dl - Overwritting metadata

Body:
I have managed to extract the title and artist using the --metadata-from-title option, but it seems that it does not overwrite if those metadata items already exist in the video file.

I'm am using:

py -3 -m youtube_dl -o "%(title)s.%(ext)s" -x --audio-format mp3 --audio-quality 320K --embed-thumbnail --add-metadata --metadata-from-title "%(artist)s ~ %(title)s" oLNMnOYEMAA

Is this is a bug?

If not then is it possible to overwrite the existing values?  I know that you can do it using the postprocessor-args command, but do not know if it is possible to pass the title and artist as parameters.