问:
Is there a way to take input(email-id) from the user and automatically mail the same excel sheet using vba code?

In Thisworksheet

```<code>Private Sub CommandButton1_Click()

     On Error GoTo ErrHandler
        ' SET Outlook APPLICATION OBJECT.
        Dim objOutlook As Object
        Set objOutlook = CreateObject("Outlook.Application")

    ' CREATE EMAIL OBJECT.
    Dim objEmail As Object
    Set objEmail = objOutlook.CreateItem(olMailItem)

        With objEmail
            .to = "webadmin@encodedna.com"
            .Subject = "This is a test message from Arun Banik"
            .Body = "Hi there"
            .Display           ' DISPLAY MESSAGE.
        End With

        ' CLEAR.
        Set objEmail = Nothing:    Set objOutlook = Nothing

ErrorHandler:
        '
    End Sub
</code>```

In Module,
  So is there way where i can take input from the user and the excel sheet gets sent to respective email id

```<code>With objEmail

    .To = "arunbanik21@rediffmail.com"
        .CC = "arun@mail.com"
        .BCC = "arun@hotmail.com"
        .Subject = "This is a test message from Arun"
        .Body = "Hi there"
        .Attachments.Add ("e:\report.doc")
        .Send

  End With
</code>```

答:
This can go in whatever module your code is written in.

Just make sure the inputbox code is before you assign your values to your email fields.

Also the msgbox is just to show you what the code does.

```<code>Sub test()
Dim UserInput As String

UserInput = Application.InputBox("Your input goes here: ")

MsgBox UserInput

End Sub
</code>```

So in your application it could be something like:

```<code>Dim UserInputToEmail As String

UserInputToEmail = Application.InputBox("Please enter a To address: ")

With oOutlook
    .To = UserInputToEmail 'This will be whatever is put into the InputBox above.
    .CC = "SomeEmail@test.com"
    .Body = "Test Email"
    .Send
End With

</code>```

Body:
In Thisworksheet

Private Sub CommandButton1_Click()

     On Error GoTo ErrHandler
        ' SET Outlook APPLICATION OBJECT.
        Dim objOutlook As Object
        Set objOutlook = CreateObject("Outlook.Application")

    ' CREATE EMAIL OBJECT.
    Dim objEmail As Object
    Set objEmail = objOutlook.CreateItem(olMailItem)

        With objEmail
            .to = "webadmin@encodedna.com"
            .Subject = "This is a test message from Arun Banik"
            .Body = "Hi there"
            .Display           ' DISPLAY MESSAGE.
        End With

        ' CLEAR.
        Set objEmail = Nothing:    Set objOutlook = Nothing

ErrorHandler:
        '
    End Sub

In Module,
  So is there way where i can take input from the user and the excel sheet gets sent to respective email id

With objEmail

    .To = "arunbanik21@rediffmail.com"
        .CC = "arun@mail.com"
        .BCC = "arun@hotmail.com"
        .Subject = "This is a test message from Arun"
        .Body = "Hi there"
        .Attachments.Add ("e:\report.doc")
        .Send

  End With

Body:
This can go in whatever module your code is written in.

Just make sure the inputbox code is before you assign your values to your email fields.

Also the msgbox is just to show you what the code does.

Sub test()
Dim UserInput As String

UserInput = Application.InputBox("Your input goes here: ")

MsgBox UserInput

End Sub

So in your application it could be something like:

Dim UserInputToEmail As String

UserInputToEmail = Application.InputBox("Please enter a To address: ")

With oOutlook
    .To = UserInputToEmail 'This will be whatever is put into the InputBox above.
    .CC = "SomeEmail@test.com"
    .Body = "Test Email"
    .Send
End With


来源: stackexchange

问:
Pre warmed Java Docker image with class data sharing
I want to create a docker image that runs on a Java Service with OpenJ9's Class Data Sharing feature to improve startup performance.
I want to create the Class Cache while building the image using a multi stage docker build.
I saw a few mentions of pre warming a docker image like this online

https://github.com/barecode/adopt-openj9-spring-boot/blob/master/Dockerfile.openj9.warmed

however, i'm not able to recreate it here is my Dockerfile

```<code>FROM adoptopenjdk/openjdk11-openj9:alpine as base
ADD libs/ /libs
ADD service.jar /service.jar

RUN mkdir /hi
WORKDIR /hi
RUN ls /
RUN java -Xshareclasses:name=mycache -Xshareclasses:cacheDir=/hi -Xshareclasses -jar /usr/share/app/service.jar &
RUN sleep 5
RUN ls -la /hi
FROM adoptopenjdk/openjdk11-openj9:alpine-jre
COPY --from=base libs/ /usr/share/app/libs
COPY --from=base service.jar /usr/share/app/service.jar

RUN /bin/sh -c 'ps aux | grep java | grep service | awk '{print $2}' | xargs kill -1'
#RUN java -Xshareclasses:listAllCaches
ENTRYPOINT ["java","-jar", "-Xshareclasses" , "-Xtune:virtualized", "-XX:+UseContainerSupport", "/usr/share/app/service.jar"]
</code>```

my problem is that when I'm running

```<code>RUN java -Xshareclasses:name=mycache -Xshareclasses:cacheDir=/hi -Xshareclasses -jar /usr/share/app/service.jar &
</code>```

and then expecting the cache file to be saved on /hi, the file isn't there.

any help will be appreciated.
Thanks.

答:
OpenJ9 only reads the last -Xshareclasses option provided.  This makes it easy to replace previous options in the commandline when developing / debugging as in some environments, it's hard to modify the existing commandline args.

Change the command to:

```<code>RUN java -Xshareclasses:name=mycache,cacheDir=/hi -jar /usr/share/app/service.jar &
</code>```

and the cache will be created in the /hi directory.

For example:

```<code># java -Xshareclasses:name=mycache,cacheDir=/hi -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.15.1, JRE 11 Linux amd64-64-Bit Compressed References 20190717_286 (JIT enabled, AOT enabled)
OpenJ9   - 0f66c6431
OMR      - ec782f26
JCL      - fa49279450 based on jdk-11.0.4+11)

# ls /hi
C290M11F1A64P_mycache_G37
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I want to create a docker image that runs on a Java Service with OpenJ9's Class Data Sharing feature to improve startup performance.
I want to create the Class Cache while building the image using a multi stage docker build.
I saw a few mentions of pre warming a docker image like this online

https://github.com/barecode/adopt-openj9-spring-boot/blob/master/Dockerfile.openj9.warmed

however, i'm not able to recreate it here is my Dockerfile

FROM adoptopenjdk/openjdk11-openj9:alpine as base
ADD libs/ /libs
ADD service.jar /service.jar

RUN mkdir /hi
WORKDIR /hi
RUN ls /
RUN java -Xshareclasses:name=mycache -Xshareclasses:cacheDir=/hi -Xshareclasses -jar /usr/share/app/service.jar &
RUN sleep 5
RUN ls -la /hi
FROM adoptopenjdk/openjdk11-openj9:alpine-jre
COPY --from=base libs/ /usr/share/app/libs
COPY --from=base service.jar /usr/share/app/service.jar

RUN /bin/sh -c 'ps aux | grep java | grep service | awk '{print $2}' | xargs kill -1'
#RUN java -Xshareclasses:listAllCaches
ENTRYPOINT ["java","-jar", "-Xshareclasses" , "-Xtune:virtualized", "-XX:+UseContainerSupport", "/usr/share/app/service.jar"]

my problem is that when I'm running

RUN java -Xshareclasses:name=mycache -Xshareclasses:cacheDir=/hi -Xshareclasses -jar /usr/share/app/service.jar &

and then expecting the cache file to be saved on /hi, the file isn't there.

any help will be appreciated.
Thanks.

Body:
OpenJ9 only reads the last -Xshareclasses option provided.  This makes it easy to replace previous options in the commandline when developing / debugging as in some environments, it's hard to modify the existing commandline args.

Change the command to:

RUN java -Xshareclasses:name=mycache,cacheDir=/hi -jar /usr/share/app/service.jar &

and the cache will be created in the /hi directory.

For example:

# java -Xshareclasses:name=mycache,cacheDir=/hi -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.15.1, JRE 11 Linux amd64-64-Bit Compressed References 20190717_286 (JIT enabled, AOT enabled)
OpenJ9   - 0f66c6431
OMR      - ec782f26
JCL      - fa49279450 based on jdk-11.0.4+11)

# ls /hi
C290M11F1A64P_mycache_G37


问:
In R, extract text between headings using regular expressions
I want to extract all the text between chapter headings, including the first/opening heading but excluding the closing heading. The headings are always uppercase, always preceded by a digit-period or digit-letter-period combination, and always followed by space/s. I want to keep the subheadings (i.e. "6.1", "7A.1") as part of the extracted string. Here's some example text:

```<code>example <- "5. SCOPE This document outlines what to do in case of emergency landing (ignore for non-emergency landings) on tarmac. 6. WHEELS Never land on tarmac. Unless you have lowered the plane wheel mechanism. 6.1 Lower the wheel mechanism using the switch labelled 'wheel mechanism'. 7A WARNING 7A.1 Do not forget to warn passengers."

# The output I want is:

"5. SCOPE This document outlines what to do in case of emergency landing (ignore for non-emergency landings) on tarmac."

"6. WHEELS Never land on tarmac. Unless you have lowered the plane wheel mechanism. 6.1 Lower the wheel mechanism using the switch labelled 'wheel mechanism'."

"7A WARNING 7A.1 Do not forget to warn passengers."
</code>```

Using the stringr package, and with help from this post, I got this far:

```<code>library(stringr)
str_extract_all(example, "(\\d+\\w?\\.?[:blank:]+[:upper:]+)(.*?)(?=\\d+\\w?\\.?[:blank:]+[:upper:]+)")

# Explanation of my regex code:
# (\\d+\\w?\\.?[[:blank:]]+[[:upper:]])
# \\d+   one or more digits
# \\w?   zero or one letter
# \\.?   zero or one period
# [:blank:]+   one or more space/tab
# [:upper]+    one or more capital letters

# (.*?)   non-greedy capture, zero or one or more of any character

# (?=\\d+\\w?\\.?[:blank:]+[:upper:]+)
# ?=   followed by
# \\d+   one or more digits
# \\w?   zero or one letter
# \\.?   zero or one period
# [:blank:]+   one or more space/tab
# [:upper]+    one or more capital letters
</code>```

This came pretty close to what I want, with only two things going wrong. The first is that "6.1" it split into "6." and "1". The second is that text after the last chapter heading isn't captured, and looks like it might be getting split the same as "6.1" was:

```<code>[[1]]
[1] "5. SCOPE This document outlines what to do in case of emergency landing (ignore for non-emergency landings) on tarmac. "
[2] "6. WHEELS Never land on tarmac. Unless you have lowered the plane wheel mechanism. 6."
[3] "1 Lower the wheel mechanism using the switch labelled 'wheel mechanism'. "
[4] "7A WARNING 7A."
</code>```

Where am I going wrong??

答:
You may use

```<code>example <- "5. SCOPE This document outlines what to do in case of emergency landing (ignore for non-emergency landings) on tarmac. 6. WHEELS Never land on tarmac. Unless you have lowered the plane wheel mechanism. 6.1 Lower the wheel mechanism using the switch labelled 'wheel mechanism'. 7A WARNING 7A.1 Do not forget to warn passengers."

library(stringr)
str_split(example, "(?!^)(?<!\\d[.A-Z])(?<!\\d[A-Z]\\.)\\b(?=\\d+(?:[a-zA-Z]|\\.)\\s+\\p{Lu})")
</code>```

Output:

```<code>[[1]]
[1] "5. SCOPE This document outlines what to do in case of emergency landing (ignore for non-emergency landings) on tarmac. "
[2] "6. WHEELS Never land on tarmac. Unless you have lowered the plane wheel mechanism. 6.1 Lower the wheel mechanism using the 2 Switch labelled 'wheel mechanism'. "
[3] "7A WARNING 7A.1 Do not forget to warn passengers."
</code>```

See the R demo and the regex demo.

Details

(?!^) - not at the start of the string

(?<!\d[.A-Z]) -  not if preceded with digit and a dot or letter

(?<!\d[A-Z]\.) - not if preceded with digit, letter, dot

\b - match a word boundary location that is...

(?=\d+(?:[a-zA-Z]|\.)\s+\p{Lu}) - followed with 1+ digits, and then either a letter or a dot, then 1+ whitespaces and an uppercase letter.

Body:
I want to extract all the text between chapter headings, including the first/opening heading but excluding the closing heading. The headings are always uppercase, always preceded by a digit-period or digit-letter-period combination, and always followed by space/s. I want to keep the subheadings (i.e. "6.1", "7A.1") as part of the extracted string. Here's some example text:

example <- "5. SCOPE This document outlines what to do in case of emergency landing (ignore for non-emergency landings) on tarmac. 6. WHEELS Never land on tarmac. Unless you have lowered the plane wheel mechanism. 6.1 Lower the wheel mechanism using the switch labelled 'wheel mechanism'. 7A WARNING 7A.1 Do not forget to warn passengers."

# The output I want is:

"5. SCOPE This document outlines what to do in case of emergency landing (ignore for non-emergency landings) on tarmac."

"6. WHEELS Never land on tarmac. Unless you have lowered the plane wheel mechanism. 6.1 Lower the wheel mechanism using the switch labelled 'wheel mechanism'."

"7A WARNING 7A.1 Do not forget to warn passengers."

Using the stringr package, and with help from this post, I got this far:

library(stringr)
str_extract_all(example, "(\\d+\\w?\\.?[:blank:]+[:upper:]+)(.*?)(?=\\d+\\w?\\.?[:blank:]+[:upper:]+)")

# Explanation of my regex code:
# (\\d+\\w?\\.?[[:blank:]]+[[:upper:]])
# \\d+   one or more digits
# \\w?   zero or one letter
# \\.?   zero or one period
# [:blank:]+   one or more space/tab
# [:upper]+    one or more capital letters

# (.*?)   non-greedy capture, zero or one or more of any character

# (?=\\d+\\w?\\.?[:blank:]+[:upper:]+)
# ?=   followed by
# \\d+   one or more digits
# \\w?   zero or one letter
# \\.?   zero or one period
# [:blank:]+   one or more space/tab
# [:upper]+    one or more capital letters

This came pretty close to what I want, with only two things going wrong. The first is that "6.1" it split into "6." and "1". The second is that text after the last chapter heading isn't captured, and looks like it might be getting split the same as "6.1" was:

[[1]]
[1] "5. SCOPE This document outlines what to do in case of emergency landing (ignore for non-emergency landings) on tarmac. "
[2] "6. WHEELS Never land on tarmac. Unless you have lowered the plane wheel mechanism. 6."
[3] "1 Lower the wheel mechanism using the switch labelled 'wheel mechanism'. "
[4] "7A WARNING 7A."

Where am I going wrong??

Body:
You may use

example <- "5. SCOPE This document outlines what to do in case of emergency landing (ignore for non-emergency landings) on tarmac. 6. WHEELS Never land on tarmac. Unless you have lowered the plane wheel mechanism. 6.1 Lower the wheel mechanism using the switch labelled 'wheel mechanism'. 7A WARNING 7A.1 Do not forget to warn passengers."

library(stringr)
str_split(example, "(?!^)(?<!\\d[.A-Z])(?<!\\d[A-Z]\\.)\\b(?=\\d+(?:[a-zA-Z]|\\.)\\s+\\p{Lu})")

Output:

[[1]]
[1] "5. SCOPE This document outlines what to do in case of emergency landing (ignore for non-emergency landings) on tarmac. "
[2] "6. WHEELS Never land on tarmac. Unless you have lowered the plane wheel mechanism. 6.1 Lower the wheel mechanism using the 2 Switch labelled 'wheel mechanism'. "
[3] "7A WARNING 7A.1 Do not forget to warn passengers."

See the <a href="https://tio.run/##xZFfS8MwFMXf@ymO9WEt2oKCCkMZQ4cOxhSnDLQqWXttA2lSktQ5/3z2mUwR0QfxybfcnMO9596fXi7pkdWNIOwnCHdSTA5Pzwa4qLhBofK2JmmhWiu4JIN5xSyscgq4RM4MQd2DatIlyXwBwWTBZYmIl1Jpwr3SkEomPxwmhpKwTNcsT7GbYnoyGIwmGNMD6ZXpq34pBRmDhWpRsQeCUHPSVMBWhMaZyQUjEqgpr5jkpvYttzDytpXpm4zW@JRe2cZkzm1euZkzEsI17Xwzd1Ls9THtn4@H42P3dI2PlNvK@u1KWt1jzrREw4whWZI2aRgEgs8004vIWO1m6ThwjzvTCG6jj4tvIox6a7dx1Ntfy7LiOu0nVzeflS@yLI2zbBb1DtzPRtTrXrPkyQsv74rZyLLmedS@xmEcBMG6w0YeVtNaDF0oh46bbrD@T1xDN/kf0ZpfwfqAf2e7XL4B" rel="nofollow noreferrer">R demo and the regex demo.

Details

(?!^) - not at the start of the string

(?<!\d[.A-Z]) -  not if preceded with digit and a dot or letter

(?<!\d[A-Z]\.) - not if preceded with digit, letter, dot

\b - match a word boundary location that is...

(?=\d+(?:[a-zA-Z]|\.)\s+\p{Lu}) - followed with 1+ digits, and then either a letter or a dot, then 1+ whitespaces and an uppercase letter.


问:
Trying to log users with wp_signon()
i'm doing a whole new login form in Wordpress.
I can register users but the wp_signon does not work at all.
Users are well registered because i can log them on the classic /wp-admin but not on my custom one.
I have an error like that :

WP_Error Object ( [errors] => Array ( [empty_password] => Array ( [0] => Erreur : le champ du mot de passe est vide. ) ) [error_data] => Array ( ) )

Where "Erreur : le champ du mot de passe est vide." means "Error : the password field is empty".

Here is my code :

```<code><?php
/*
Template Name : Connexion
*/

$error = false;

if(!empty($_POST)) {
    $userlog = array(
        'user_login' => $_POST['user_login'],
        'user_pass' => $_POST['user_password'],
    );
    $user = wp_signon($userlog);
    do_action('init', $user);
    if(is_wp_error($user)){
        $user->get_error_message();
        print_r($user);
    }else{
        header("Location: /");
    };
}

get_header();?>

<div class="main_container">

    <div class="container_form">

        <h2>Se connecter</h2>
        <div class="form_logo">

        </div>

        <?php if($error) {?>
        <div class="error">
            <?php echo $error ?>
        </div>
        <?php } ?>

        <form action="<?php echo $_SERVER['REQUEST_URI'];?>" method="POST">

            <label for="user_login">Identifiant</label>
            <input type="text" name="user_login" id="user_login">

            <label for="user_password">Mot de passe</label>
            <input type="password" name="user_password" id="user_password">

            <div id="button_container">
                <input type="submit" name="button1" value="Se connecter" id='save'/>
            </div>

        </form>

    </div>

</div>

<?php get_footer(); ?>
</code>```

I have tried do call it on init, without init... Lot of things !
Thanks if you can help.

EDIT

The error came from the 'user_pass' it has to be 'user_password' for the wp_signon and 'user_pass' for wp_insert_user

Here is the register page on which the user is registered but not log in.

```<code>$error = false;

if(!empty($_POST)) {
    if($_POST['user_password'] != $_POST['user_password2']) {
        $error = "Les mots de passe ne correspondent pas";
    } else {
        if(!is_email($_POST['user_email'])) {
            $error = "Veuillez entrer un email valide";
        } else {
            $user = array(
                'user_login' => $_POST['user_login'],
                'user_pass' => $_POST['user_password'],
                'user_email' => $_POST['user_email'],
            );
            $user_add = wp_insert_user($user);
            if (is_wp_error($user_add)) {
                $error = $user_add->get_error_message();
            } else {
                update_field('player_league_of_legends', $_POST['user_login'], 'user_'.$user_add);
                $user_login = wp_signon($user);
                do_action('template_redirect', $user_login);
                if(is_wp_error($user_login)){
                    $error = $user_login->get_error_message();
                } else {
                    header("Location: /login");
                }
            }
        }
    }
}
</code>```

答:
This code is in index.php?

According to documentation https://developer.wordpress.org/reference/functions/wp_signon/ you must use wp_signon in function.php.

You can also use plugin https://wordpress.org/plugins/custom-login/#developers or by inspired by him

Title: Trying to log users with wp_signon()

Body:
i'm doing a whole new login form in Wordpress.
I can register users but the wp_signon does not work at all.
Users are well registered because i can log them on the classic /wp-admin but not on my custom one.
I have an error like that :

WP_Error Object ( [errors] => Array ( [empty_password] => Array ( [0] => Erreur : le champ du mot de passe est vide. ) ) [error_data] => Array ( ) )

Where "Erreur : le champ du mot de passe est vide." means "Error : the password field is empty".

Here is my code :

<?php
/*
Template Name : Connexion
*/

$error = false;

if(!empty($_POST)) {
    $userlog = array(
        'user_login' => $_POST['user_login'],
        'user_pass' => $_POST['user_password'],
    );
    $user = wp_signon($userlog);
    do_action('init', $user);
    if(is_wp_error($user)){
        $user->get_error_message();
        print_r($user);
    }else{
        header("Location: /");
    };
}

get_header();?>

Se connecter

        <?php if($error) {?>

            <?php echo $error ?>

        <?php } ?>

        <form action="<?php echo $_SERVER['REQUEST_URI'];?>" method="POST">

            Identifiant
            <input type="text" name="user_login" id="user_login">

            Mot de passe
            <input type="password" name="user_password" id="user_password">

                <input type="submit" name="button1" value="Se connecter" id='save'/>

        </form>

<?php get_footer(); ?>

I have tried do call it on init, without init... Lot of things !
Thanks if you can help.

EDIT

The error came from the 'user_pass' it has to be 'user_password' for the wp_signon and 'user_pass' for wp_insert_user

Here is the register page on which the user is registered but not log in.

$error = false;

if(!empty($_POST)) {
    if($_POST['user_password'] != $_POST['user_password2']) {
        $error = "Les mots de passe ne correspondent pas";
    } else {
        if(!is_email($_POST['user_email'])) {
            $error = "Veuillez entrer un email valide";
        } else {
            $user = array(
                'user_login' => $_POST['user_login'],
                'user_pass' => $_POST['user_password'],
                'user_email' => $_POST['user_email'],
            );
            $user_add = wp_insert_user($user);
            if (is_wp_error($user_add)) {
                $error = $user_add->get_error_message();
            } else {
                update_field('player_league_of_legends', $_POST['user_login'], 'user_'.$user_add);
                $user_login = wp_signon($user);
                do_action('template_redirect', $user_login);
                if(is_wp_error($user_login)){
                    $error = $user_login->get_error_message();
                } else {
                    header("Location: /login");
                }
            }
        }
    }
}


问:
IIS Web gardens and performance
Is there any performance benefit in configuring web gardens in IIS?

Anyone have any real life examples?

答:
Under most circumstances, there is very little benefit to setting up web gardens and can actually cause issues if your application uses session state.  The initial request may have come into one worker process, but then the next request might come into another.  Here is a reference:

The reference is specific to IIS6 but the concepts apply to IIS7 as well.

Edit:

Here is a good reference from Scott Forsyth's Blog about the use of web gardens and why you should not use them:  http://weblogs.asp.net/owscott/archive/2011/06/13/why-you-shouldn-t-use-web-gardens-in-iis-week-24.aspx

ContentLicense: CC BY-SA 3.0

Title: IIS Web gardens and performance


问:
How does this __iter__ and __next__ algorithem work? How does it print all those prime numbers?
```<code>class PrimesBelow():
    def __init__(self,bound):
        self.candidate_numbers = list(range(2,bound))

    def __iter__(self):
        return self

    def __next__(self):
        if len(self.candidate_numbers) == 0:
            raise StopIteration
        next_prime = self.candidate_numbers[0]
        self.candidate_numbers = [x for x in self.candidate_numbers if x % next_prime != 0]
        return next_prime
primes_to_hundread = [prime for prime in PrimesBelow(100)]
print(primes_to_hundread)
</code>```

Output:

```<code>[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]
</code>```

答:
The source of the actual information is here:

```<code>[x for x in self.candidate_numbers if x % next_prime != 0]
</code>```

which contain the sieve of Eratosthenes.

The __iter__ and __next__ method, are special Python methods to have a class behave like an iterator.

Body:
class PrimesBelow():
    def __init__(self,bound):
        self.candidate_numbers = list(range(2,bound))

    def __iter__(self):
        return self

    def __next__(self):
        if len(self.candidate_numbers) == 0:
            raise StopIteration
        next_prime = self.candidate_numbers[0]
        self.candidate_numbers = [x for x in self.candidate_numbers if x % next_prime != 0]
        return next_prime
primes_to_hundread = [prime for prime in PrimesBelow(100)]
print(primes_to_hundread)

Output:

[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

Body:
The source of the actual information is here:

[x for x in self.candidate_numbers if x % next_prime != 0]

which contain the sieve of Eratosthenes.

The __iter__ and __next__ method, are special Python methods to have a class behave like an iterator.


问:
Can't install numpy - MS Visual C++ 14.1 is required. But it is installed
I am on Windows 10 using pypy3.6-v7.3.0. I am trying to install numpy with pip install numpy, but I keep getting the error: error: Microsoft Visual C++ 14.1 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/.

However I already have Visual Studio Community 2019 installed, and my C++ build tools are fully up to date.

Edit:

Here is the new error I am getting after installing build tools manually:

```<code>Collecting numpy
  Using cached https://files.pythonhosted.org/packages/2d/f3/795e50e3ea2dc7bc9d1a2eeea9997d5dce63b801e08dfc37c2efce341977/numpy-1.18.4.zip
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    Complete output from command C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\pypy3.exe C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\site-packages\pip-19.0.3-py3.6.egg\pip\_vendor\pep517\_in_process.py prepare_metadata_for_build_wheel C:\Users\Chris\AppData\Local\Temp\tmpjxmz4c4z:
    Processing numpy/random\_bounded_integers.pxd.in
    Processing numpy/random\mtrand.pyx
    Processing numpy/random\_bit_generator.pyx
    Processing numpy/random\_bounded_integers.pyx.in
    Processing numpy/random\_common.pyx
    Processing numpy/random\_generator.pyx
    Processing numpy/random\_mt19937.pyx
    Processing numpy/random\_pcg64.pyx
    Processing numpy/random\_philox.pyx
    Processing numpy/random\_sfc64.pyx
    Cythonizing sources
    blas_opt_info:
    blas_mkl_info:
    customize MSVCCompiler
      libraries mkl_rt not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    blis_info:
      libraries blis not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    openblas_info:
      libraries openblas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
    get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
    customize GnuFCompiler
    Could not locate executable g77
    Could not locate executable f77
    customize IntelVisualFCompiler
    Could not locate executable ifort
    Could not locate executable ifl
    customize AbsoftFCompiler
    Could not locate executable f90
    customize CompaqVisualFCompiler
    Could not locate executable DF
    customize IntelItaniumVisualFCompiler
    Could not locate executable efl
    customize Gnu95FCompiler
    Could not locate executable gfortran
    Could not locate executable f95
    customize G95FCompiler
    Could not locate executable g95
    customize IntelEM64VisualFCompiler
    customize IntelEM64TFCompiler
    Could not locate executable efort
    Could not locate executable efc
    customize PGroupFlangCompiler
    Could not locate executable flang
    don't know how to compile Fortran code on platform 'nt'
      NOT AVAILABLE

    atlas_3_10_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries tatlas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    atlas_3_10_blas_info:
      libraries satlas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    atlas_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    atlas_blas_info:
      libraries f77blas,cblas,atlas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    accelerate_info:
      NOT AVAILABLE

    blas_info:
      libraries blas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    blas_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    non-existing path in 'numpy\\distutils': 'site.cfg'
    lapack_opt_info:
    lapack_mkl_info:
      libraries mkl_rt not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    openblas_lapack_info:
      libraries openblas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    openblas_clapack_info:
      libraries openblas,lapack not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    flame_info:
      libraries flame not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
      libraries lapack_atlas not found in C:\
      libraries tatlas,tatlas not found in C:\
      libraries lapack_atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
      libraries tatlas,tatlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
    <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
      NOT AVAILABLE

    atlas_3_10_info:
      libraries lapack_atlas not found in C:\
      libraries satlas,satlas not found in C:\
      libraries lapack_atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
      libraries satlas,satlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
    <class 'numpy.distutils.system_info.atlas_3_10_info'>
      NOT AVAILABLE

    atlas_threads_info:
    Setting PTATLAS=ATLAS
      libraries lapack_atlas not found in C:\
      libraries ptf77blas,ptcblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
      libraries ptf77blas,ptcblas,atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
    <class 'numpy.distutils.system_info.atlas_threads_info'>
      NOT AVAILABLE

    atlas_info:
      libraries lapack_atlas not found in C:\
      libraries f77blas,cblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
      libraries f77blas,cblas,atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
    <class 'numpy.distutils.system_info.atlas_info'>
      NOT AVAILABLE

    lapack_info:
      libraries lapack not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    lapack_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    running dist_info
    running build_src
    build_src
    building py_modules sources
    creating build
    creating build\src.win32-3.6
    creating build\src.win32-3.6\numpy
    creating build\src.win32-3.6\numpy\distutils
    building library "npymath" sources
    Running from numpy source directory.
    setup.py:461: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
      run_build = parse_setuppy_commands()
    C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\system_info.py:1896: UserWarning:
        Optimized (vendor) Blas libraries are not found.
        Falls back to netlib Blas library which has worse performance.
        A better performance should be easily gained by switching
        Blas library.
      if self._calc_info(blas):
    C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\system_info.py:1896: UserWarning:
        Blas (http://www.netlib.org/blas/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [blas]) or by setting
        the BLAS environment variable.
      if self._calc_info(blas):
    C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\system_info.py:1896: UserWarning:
        Blas (http://www.netlib.org/blas/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [blas_src]) or by setting
        the BLAS_SRC environment variable.
      if self._calc_info(blas):
    C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\system_info.py:1730: UserWarning:
        Lapack (http://www.netlib.org/lapack/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [lapack]) or by setting
        the LAPACK environment variable.
      return getattr(self, '_calc_info_{}'.format(name))()
    C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\system_info.py:1730: UserWarning:
        Lapack (http://www.netlib.org/lapack/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [lapack_src]) or by setting
        the LAPACK_SRC environment variable.
      return getattr(self, '_calc_info_{}'.format(name))()
    C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\dist.py:261: UserWarning: Unknown distribution option: 'define_macros'
      warnings.warn(msg)
    Traceback (most recent call last):
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\site-packages\pip-19.0.3-py3.6.egg\pip\_vendor\pep517\_in_process.py", line 207, in <module>
        main()
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\site-packages\pip-19.0.3-py3.6.egg\pip\_vendor\pep517\_in_process.py", line 197, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\site-packages\pip-19.0.3-py3.6.egg\pip\_vendor\pep517\_in_process.py", line 69, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "C:\Users\Chris\AppData\Local\Temp\pip-build-env-pt1e0dfd\overlay\site-packages\setuptools\build_meta.py", line 158, in prepare_metadata_for_build_wheel
        self.run_setup()
      File "C:\Users\Chris\AppData\Local\Temp\pip-build-env-pt1e0dfd\overlay\site-packages\setuptools\build_meta.py", line 250, in run_setup
        self).run_setup(setup_script=setup_script)
      File "C:\Users\Chris\AppData\Local\Temp\pip-build-env-pt1e0dfd\overlay\site-packages\setuptools\build_meta.py", line 143, in run_setup
        exec(compile(code, __file__, 'exec'), locals())
      File "setup.py", line 488, in <module>
        setup_package()
      File "setup.py", line 480, in setup_package
        setup(**metadata)
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\core.py", line 171, in setup
        return old_setup(**new_attr)
      File "C:\Users\Chris\AppData\Local\Temp\pip-build-env-pt1e0dfd\overlay\site-packages\setuptools\__init__.py", line 161, in setup
        return distutils.core.setup(**attrs)
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\Chris\AppData\Local\Temp\pip-build-env-pt1e0dfd\overlay\site-packages\setuptools\command\dist_info.py", line 31, in run
        egg_info.run()
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\command\egg_info.py", line 26, in run
        self.run_command("build_src")
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\command\build_src.py", line 146, in run
        self.build_sources()
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\command\build_src.py", line 157, in build_sources
        self.build_library_sources(*libname_info)
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\command\build_src.py", line 290, in build_library_sources
        sources = self.generate_sources(sources, (lib_name, build_info))
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\command\build_src.py", line 380, in generate_sources
        source = func(extension, build_dir)
      File "numpy\core\setup.py", line 661, in get_mathlib_info
        raise RuntimeError("Broken toolchain: cannot link a simple C program")
    RuntimeError: Broken toolchain: cannot link a simple C program

    ----------------------------------------
Command "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\pypy3.exe C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\site-packages\pip-19.0.3-py3.6.egg\pip\_vendor\pep517\_in_process.py prepare_metadata_for_build_wheel C:\Users\Chris\AppData\Local\Temp\tmpjxmz4c4z" failed with error code 1 in C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy
</code>```

I am no longer seeing the original error anymore, I am always getting this no matter what now. I tried using pip install numpy, pip3 install numpy, and pypy -m pip install numpy. All give this same output.

答:
pip install numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl

Try installing from wheel package directly.

Body:
I am on Windows 10 using pypy3.6-v7.3.0. I am trying to install numpy with pip install numpy, but I keep getting the error: error: Microsoft Visual C++ 14.1 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/.

However I already have Visual Studio Community 2019 installed, and my C++ build tools are fully up to date.

Edit:

Here is the new error I am getting after installing build tools manually:

Collecting numpy
  Using cached https://files.pythonhosted.org/packages/2d/f3/795e50e3ea2dc7bc9d1a2eeea9997d5dce63b801e08dfc37c2efce341977/numpy-1.18.4.zip
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    Complete output from command C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\pypy3.exe C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\site-packages\pip-19.0.3-py3.6.egg\pip\_vendor\pep517\_in_process.py prepare_metadata_for_build_wheel C:\Users\Chris\AppData\Local\Temp\tmpjxmz4c4z:
    Processing numpy/random\_bounded_integers.pxd.in
    Processing numpy/random\mtrand.pyx
    Processing numpy/random\_bit_generator.pyx
    Processing numpy/random\_bounded_integers.pyx.in
    Processing numpy/random\_common.pyx
    Processing numpy/random\_generator.pyx
    Processing numpy/random\_mt19937.pyx
    Processing numpy/random\_pcg64.pyx
    Processing numpy/random\_philox.pyx
    Processing numpy/random\_sfc64.pyx
    Cythonizing sources
    blas_opt_info:
    blas_mkl_info:
    customize MSVCCompiler
      libraries mkl_rt not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    blis_info:
      libraries blis not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    openblas_info:
      libraries openblas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
    get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
    customize GnuFCompiler
    Could not locate executable g77
    Could not locate executable f77
    customize IntelVisualFCompiler
    Could not locate executable ifort
    Could not locate executable ifl
    customize AbsoftFCompiler
    Could not locate executable f90
    customize CompaqVisualFCompiler
    Could not locate executable DF
    customize IntelItaniumVisualFCompiler
    Could not locate executable efl
    customize Gnu95FCompiler
    Could not locate executable gfortran
    Could not locate executable f95
    customize G95FCompiler
    Could not locate executable g95
    customize IntelEM64VisualFCompiler
    customize IntelEM64TFCompiler
    Could not locate executable efort
    Could not locate executable efc
    customize PGroupFlangCompiler
    Could not locate executable flang
    don't know how to compile Fortran code on platform 'nt'
      NOT AVAILABLE

    atlas_3_10_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries tatlas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    atlas_3_10_blas_info:
      libraries satlas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    atlas_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    atlas_blas_info:
      libraries f77blas,cblas,atlas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    accelerate_info:
      NOT AVAILABLE

    blas_info:
      libraries blas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    blas_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    non-existing path in 'numpy\\distutils': 'site.cfg'
    lapack_opt_info:
    lapack_mkl_info:
      libraries mkl_rt not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    openblas_lapack_info:
      libraries openblas not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    openblas_clapack_info:
      libraries openblas,lapack not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    flame_info:
      libraries flame not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
      libraries lapack_atlas not found in C:\
      libraries tatlas,tatlas not found in C:\
      libraries lapack_atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
      libraries tatlas,tatlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
    <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
      NOT AVAILABLE

    atlas_3_10_info:
      libraries lapack_atlas not found in C:\
      libraries satlas,satlas not found in C:\
      libraries lapack_atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
      libraries satlas,satlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
    <class 'numpy.distutils.system_info.atlas_3_10_info'>
      NOT AVAILABLE

    atlas_threads_info:
    Setting PTATLAS=ATLAS
      libraries lapack_atlas not found in C:\
      libraries ptf77blas,ptcblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
      libraries ptf77blas,ptcblas,atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
    <class 'numpy.distutils.system_info.atlas_threads_info'>
      NOT AVAILABLE

    atlas_info:
      libraries lapack_atlas not found in C:\
      libraries f77blas,cblas,atlas not found in C:\
      libraries lapack_atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
      libraries f77blas,cblas,atlas not found in C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\libs
    <class 'numpy.distutils.system_info.atlas_info'>
      NOT AVAILABLE

    lapack_info:
      libraries lapack not found in ['C:\\', 'C:\\Users\\Chris\\AppData\\Local\\Programs\\Python\\pypy3.6-v7.3.0-win32\\libs']
      NOT AVAILABLE

    lapack_src_info:
      NOT AVAILABLE

      NOT AVAILABLE

    running dist_info
    running build_src
    build_src
    building py_modules sources
    creating build
    creating build\src.win32-3.6
    creating build\src.win32-3.6\numpy
    creating build\src.win32-3.6\numpy\distutils
    building library "npymath" sources
    Running from numpy source directory.
    setup.py:461: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
      run_build = parse_setuppy_commands()
    C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\system_info.py:1896: UserWarning:
        Optimized (vendor) Blas libraries are not found.
        Falls back to netlib Blas library which has worse performance.
        A better performance should be easily gained by switching
        Blas library.
      if self._calc_info(blas):
    C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\system_info.py:1896: UserWarning:
        Blas (http://www.netlib.org/blas/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [blas]) or by setting
        the BLAS environment variable.
      if self._calc_info(blas):
    C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\system_info.py:1896: UserWarning:
        Blas (http://www.netlib.org/blas/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [blas_src]) or by setting
        the BLAS_SRC environment variable.
      if self._calc_info(blas):
    C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\system_info.py:1730: UserWarning:
        Lapack (http://www.netlib.org/lapack/) libraries not found.
        Directories to search for the libraries can be specified in the
        numpy/distutils/site.cfg file (section [lapack]) or by setting
        the LAPACK environment variable.
      return getattr(self, '_calc_info_{}'.format(name))()
    C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\system_info.py:1730: UserWarning:
        Lapack (http://www.netlib.org/lapack/) sources not found.
        Directories to search for the sources can be specified in the
        numpy/distutils/site.cfg file (section [lapack_src]) or by setting
        the LAPACK_SRC environment variable.
      return getattr(self, '_calc_info_{}'.format(name))()
    C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\dist.py:261: UserWarning: Unknown distribution option: 'define_macros'
      warnings.warn(msg)
    Traceback (most recent call last):
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\site-packages\pip-19.0.3-py3.6.egg\pip\_vendor\pep517\_in_process.py", line 207, in <module>
        main()
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\site-packages\pip-19.0.3-py3.6.egg\pip\_vendor\pep517\_in_process.py", line 197, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\site-packages\pip-19.0.3-py3.6.egg\pip\_vendor\pep517\_in_process.py", line 69, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "C:\Users\Chris\AppData\Local\Temp\pip-build-env-pt1e0dfd\overlay\site-packages\setuptools\build_meta.py", line 158, in prepare_metadata_for_build_wheel
        self.run_setup()
      File "C:\Users\Chris\AppData\Local\Temp\pip-build-env-pt1e0dfd\overlay\site-packages\setuptools\build_meta.py", line 250, in run_setup
        self).run_setup(setup_script=setup_script)
      File "C:\Users\Chris\AppData\Local\Temp\pip-build-env-pt1e0dfd\overlay\site-packages\setuptools\build_meta.py", line 143, in run_setup
        exec(compile(code, __file__, 'exec'), locals())
      File "setup.py", line 488, in <module>
        setup_package()
      File "setup.py", line 480, in setup_package
        setup(**metadata)
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\core.py", line 171, in setup
        return old_setup(**new_attr)
      File "C:\Users\Chris\AppData\Local\Temp\pip-build-env-pt1e0dfd\overlay\site-packages\setuptools\__init__.py", line 161, in setup
        return distutils.core.setup(**attrs)
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\Chris\AppData\Local\Temp\pip-build-env-pt1e0dfd\overlay\site-packages\setuptools\command\dist_info.py", line 31, in run
        egg_info.run()
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\command\egg_info.py", line 26, in run
        self.run_command("build_src")
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\lib-python\3\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\command\build_src.py", line 146, in run
        self.build_sources()
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\command\build_src.py", line 157, in build_sources
        self.build_library_sources(*libname_info)
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\command\build_src.py", line 290, in build_library_sources
        sources = self.generate_sources(sources, (lib_name, build_info))
      File "C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy\numpy\distutils\command\build_src.py", line 380, in generate_sources
        source = func(extension, build_dir)
      File "numpy\core\setup.py", line 661, in get_mathlib_info
        raise RuntimeError("Broken toolchain: cannot link a simple C program")
    RuntimeError: Broken toolchain: cannot link a simple C program

    ----------------------------------------
Command "C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\pypy3.exe C:\Users\Chris\AppData\Local\Programs\Python\pypy3.6-v7.3.0-win32\site-packages\pip-19.0.3-py3.6.egg\pip\_vendor\pep517\_in_process.py prepare_metadata_for_build_wheel C:\Users\Chris\AppData\Local\Temp\tmpjxmz4c4z" failed with error code 1 in C:\Users\Chris\AppData\Local\Temp\pip-install-1iwlc8lz\numpy

I am no longer seeing the original error anymore, I am always getting this no matter what now. I tried using pip install numpy, pip3 install numpy, and pypy -m pip install numpy. All give this same output.


问:
gitignore particular file format in all directories
I want to exclude a file format e.g *.simg in all directories. I have tried to add *.simg in .gitignore but still the files are visible in git status.

I have a folder structure as follow and .gitignore file is in root directory:

```<code>-service-foo/foo.simg
-service-bar/bar.simg
-composite-service/service-foobar/foobar.simg
-.gitignore
</code>```

How can I exclude the format in all directories?

EDIT 1:

.gitignore file as follow:

```<code>HELP.md
target/
.mvn/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**

### SINGULARITY simg###
*.simg
</code>```

When I do git status I get:

```<code>javaadmin@THNJAVA11:~/server/airadhi-server$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   .gitignore
        modified:   composite-service/foobar.simg
        modified:   composite-service/service-foobar/foobar.recipe
        deleted:    service-foo/foo.simg
        modified:   service-bar/bar.simg

no changes added to commit (use "git add" and/or "git commit -a")
</code>```

答:
What you have done in your .gitignore is correct. You need to remove the files from the staging area by doing a git rm -r --cached <filename/pathspec> and then commit the changes. When there will be any changes in the files next time, they won't cause trouble :)

You might want to refer to this as well.

Best

Body:
I want to exclude a file format e.g *.simg in all directories. I have tried to add *.simg in .gitignore but still the files are visible in git status.

I have a folder structure as follow and .gitignore file is in root directory:

-service-foo/foo.simg
-service-bar/bar.simg
-composite-service/service-foobar/foobar.simg
-.gitignore

How can I exclude the format in all directories?

EDIT 1:

.gitignore file as follow:

HELP.md
target/
.mvn/
.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**

### SINGULARITY simg###
*.simg

When I do git status I get:

javaadmin@THNJAVA11:~/server/airadhi-server$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   .gitignore
        modified:   composite-service/foobar.simg
        modified:   composite-service/service-foobar/foobar.recipe
        deleted:    service-foo/foo.simg
        modified:   service-bar/bar.simg

no changes added to commit (use "git add" and/or "git commit -a")


问:
OpenCV: Detect squares in dark background
currently I am trying to calculate optical flows of moving objects. the objects in particular are the squares that are around the circular knobs:

Here is the vanilla image I am trying to process:

my concern is about the right bottom-most strip. The two squares are usually unable to be detected when I have tried Canny Edge detection or GoodFeaturesToTrack. I am currently trying a sharpen kernel and a threshold, then morphological transformation to finding the contour areas. However, when I threshold I get the following results:

```<code>import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt

filename = 'images/Test21_1.tif'

image = cv.imread(filename)

kernel = [ [0, -1, 0], [-1, 5, -1], [0, -1, 0] ] #sharpen kernel I got from wikipedia

kernel = np.array(kernel)
dst = cv.filter2D(image, -1, kernel)
ret, thresh = cv.threshold(dst, 80, 150, cv.THRESH_BINARY_INV)

plt.subplot(121),plt.imshow(image),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(thresh),plt.title('Threshold')
plt.xticks([]), plt.yticks([])
plt.show()
</code>```

I was wondering what I could do in openCV to be able to recognize that square. These squares are the objects that move in the videos, and I wish to use them to calculate their optical flow. I am currently considering resorting to a PyTorch CNN to detect the features. I would manually label the images for training/test datasets, but I believe that may be a bit overkill. Thank you for your time.

答:
The problem is local contrast is bad near the bottom right square. Can you try by using CLAHE (Contrast Limited Adaptive Histogram Equalization).

```<code># improving local contrast
GRID_SIZE = 20
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(GRID_SIZE,GRID_SIZE))
image = clahe.apply(image)
</code>```

Then try using your algorithm to detect the squares.

Body:
currently I am trying to calculate optical flows of moving objects. the objects in particular are the squares that are around the circular knobs:

Here is the vanilla image I am trying to process:

my concern is about the right bottom-most strip. The two squares are usually unable to be detected when I have tried Canny Edge detection or GoodFeaturesToTrack. I am currently trying a sharpen kernel and a threshold, then morphological transformation to finding the contour areas. However, when I threshold I get the following results:

import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt

filename = 'images/Test21_1.tif'

image = cv.imread(filename)

kernel = [ [0, -1, 0], [-1, 5, -1], [0, -1, 0] ] #sharpen kernel I got from wikipedia

kernel = np.array(kernel)
dst = cv.filter2D(image, -1, kernel)
ret, thresh = cv.threshold(dst, 80, 150, cv.THRESH_BINARY_INV)

plt.subplot(121),plt.imshow(image),plt.title('Original')
plt.xticks([]), plt.yticks([])
plt.subplot(122),plt.imshow(thresh),plt.title('Threshold')
plt.xticks([]), plt.yticks([])
plt.show()

I was wondering what I could do in openCV to be able to recognize that square. These squares are the objects that move in the videos, and I wish to use them to calculate their optical flow. I am currently considering resorting to a PyTorch CNN to detect the features. I would manually label the images for training/test datasets, but I believe that may be a bit overkill. Thank you for your time.

Body:
The problem is local contrast is bad near the bottom right square. Can you try by using CLAHE (Contrast Limited Adaptive Histogram Equalization).

# improving local contrast
GRID_SIZE = 20
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(GRID_SIZE,GRID_SIZE))
image = clahe.apply(image)

Then try using your algorithm to detect the squares.


问:
Count items greater than a value in pandas groupby
I have the Yelp dataset and I want to count all reviews which have greater than 3 stars. I get the count of reviews by doing this:

```<code>reviews.groupby('business_id')['stars'].count()
</code>```

Now I want to get the count of reviews which had more than 3 stars, so I tried this by taking inspiration from here:

```<code>reviews.groupby('business_id')['stars'].agg({'greater':lambda val: (val > 3).count()})
</code>```

But this just gives me the count of all stars like before. I am not sure if this is the right way to do it? What am I doing incorrectly here. Does the lambda expression not go through each value of the stars column?

EDIT:
Okay I feel stupid. I should have used the sum function instead of count to get the value of elements greater than 3, like this:

```<code>reviews.groupby('business_id')['stars'].agg({'greater':lambda val: (val > 3).sum()})
</code>```

答:
I quite like using method chaining with Pandas as I find it easier to read. I haven't tried it but I think this should also work

reviews.query("stars > 3").groupby("business_id").size()
```

Body:
I have the Yelp dataset and I want to count all reviews which have greater than 3 stars. I get the count of reviews by doing this:

reviews.groupby('business_id')['stars'].count()

Now I want to get the count of reviews which had more than 3 stars, so I tried this by taking inspiration from here:

reviews.groupby('business_id')['stars'].agg({'greater':lambda val: (val > 3).count()})

But this just gives me the count of all stars like before. I am not sure if this is the right way to do it? What am I doing incorrectly here. Does the lambda expression not go through each value of the stars column?

EDIT:
Okay I feel stupid. I should have used the sum function instead of count to get the value of elements greater than 3, like this:

reviews.groupby('business_id')['stars'].agg({'greater':lambda val: (val > 3).sum()})


问:
Turning off auto-suggestions in Visual Studio 2019 without turning off IntelliSense
I am new to Visual Studio and would like to disable the IntelliSense automatic suggestions without disabling IntelliSense entirely.  More precisely, I don't want popup hints continually covering the code I'm working on, but I'd still like to be able to use Ctrl-Space to request suggestions at times.  I'm coding in C/C++.

I've seen information on how to do this for Visual Studio Code, but I haven't found anything similar for Visual Studio.

Or if this is just a matter of me not understanding how to properly use Visual Studio or IntelliSense, please help me understand or point me to a forum where true Microsoft devotees hang out.

答:
The solution is to go to Tools -> Options -> Text Editor -> C/C++ -> General and uncheck Auto list members.

Credit goes to this answer in "Intellisense “Toggle Completion Mode” doesn't work with C++ in Visual Studio 2010 Professional".


问:
Running large data set on EC2, worried about storage
I am running some sequence analysis via EC2. I expect my output files to be over 2 Tb. Before I run my command I want to make sure I have enough room.I changed my instance type to one for data processing d2.4xlarge.

My question: If I am running my command, and the output file exceeds the storage capacity of xvda, will it automatically switch to xvdf??

hopefully this info is helpful:

```<code>lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0     7:0    0   18M  1 loop /snap/amazon-ssm-agent/
loop1     7:1    0 93.9M  1 loop /snap/core/9066
loop2     7:2    0   91M  1 loop /snap/core/6350
loop3     7:3    0   18M  1 loop /snap/amazon-ssm-agent/
xvda    202:0    0  4.9T  0 disk
└─xvda1 202:1    0    2T  0 part /
xvdf    202:80   0  1.8T  0 disk
xvdg    202:96   0  1.8T  0 disk
xvdh    202:112  0  1.8T  0 disk
xvdi    202:128  0  1.8T  0 disk
xvdj    202:144  0  1.8T  0 disk
xvdk    202:160  0  1.8T  0 disk
xvdl    202:176  0  1.8T  0 disk
xvdm    202:192  0  1.8T  0 disk
</code>```

You will see that xvda1 does not match xvda, and that is because with EBS the max storage is 2tb ( I need to change the volume size on that)

```<code>df
Filesystem      1K-blocks     Used  Available Use% Mounted on
udev             62832116        0   62832116   0% /dev
tmpfs            12570936      824   12570112   1% /run
/dev/xvda1     2081729452 45739112 2035973956   3% /
tmpfs            62854676        0   62854676   0% /dev/shm
tmpfs                5120        0       5120   0% /run/lock
tmpfs            62854676        0   62854676   0% /sys/fs/cgroup
/dev/loop0          18432    18432          0 100% /snap/amazon-ssm-agent/
/dev/loop1          96256    96256          0 100% /snap/core/
/dev/loop3          18432    18432          0 100% /snap/amazon-ssm-agent/
/dev/loop2          93184    93184          0 100% /snap/core/
tmpfs            12570932        0   12570932   0% /run/user/
</code>```

thank you!!!!!

答:
"If I am running my command, and the output file exceeds the storage
  capacity of xvda, will it automatically switch to xvdf"

No. You would need to mount xvdf (it doesn't appear that you have done this yet) which will give it a path in your file system, and then you will need to configure your application to switch to that mounted location when the first location runs out of space.

"that is because with EBS the max storage is 2tb"

The official features list for AWS EBS here, states that the max volume size is 16TB.

If you need a single volume in your file system to be more than 16TB, you could look at combining EBS volumes in a RAID 0 array, as documented here.

Body:
I am running some sequence analysis via EC2. I expect my output files to be over 2 Tb. Before I run my command I want to make sure I have enough room.I changed my instance type to one for data processing d2.4xlarge.

My question: If I am running my command, and the output file exceeds the storage capacity of xvda, will it automatically switch to xvdf??

hopefully this info is helpful:

lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
loop0     7:0    0   18M  1 loop /snap/amazon-ssm-agent/
loop1     7:1    0 93.9M  1 loop /snap/core/9066
loop2     7:2    0   91M  1 loop /snap/core/6350
loop3     7:3    0   18M  1 loop /snap/amazon-ssm-agent/
xvda    202:0    0  4.9T  0 disk
└─xvda1 202:1    0    2T  0 part /
xvdf    202:80   0  1.8T  0 disk
xvdg    202:96   0  1.8T  0 disk
xvdh    202:112  0  1.8T  0 disk
xvdi    202:128  0  1.8T  0 disk
xvdj    202:144  0  1.8T  0 disk
xvdk    202:160  0  1.8T  0 disk
xvdl    202:176  0  1.8T  0 disk
xvdm    202:192  0  1.8T  0 disk

You will see that xvda1 does not match xvda, and that is because with EBS the max storage is 2tb ( I need to change the volume size on that)

df
Filesystem      1K-blocks     Used  Available Use% Mounted on
udev             62832116        0   62832116   0% /dev
tmpfs            12570936      824   12570112   1% /run
/dev/xvda1     2081729452 45739112 2035973956   3% /
tmpfs            62854676        0   62854676   0% /dev/shm
tmpfs                5120        0       5120   0% /run/lock
tmpfs            62854676        0   62854676   0% /sys/fs/cgroup
/dev/loop0          18432    18432          0 100% /snap/amazon-ssm-agent/
/dev/loop1          96256    96256          0 100% /snap/core/
/dev/loop3          18432    18432          0 100% /snap/amazon-ssm-agent/
/dev/loop2          93184    93184          0 100% /snap/core/
tmpfs            12570932        0   12570932   0% /run/user/

thank you!!!!!


问:
Losing references to objects inside containers
I am struggling to fix a piece of code, even though I believe I know the cause. I did search a lot on Stack Overflow and many people had similar issues (and good answers were provided), but still, I am not sure I understand the problem with my code.

I tried giving a smaller example, but the structure I have is not simple by itself. I hope the following is simple enough.

My objective on the excerpt:

Have a vector of points.

Have a vector of segments. (Whose endpoints are reference to points in the vector above)

Have a vector of events. (That keep a reference to the exhisting segments and points)

```<code>segment::segment (point &pt1, point&pt2, int i) {
   s = &pt1; e = &pt2; ind = i; // point *s, point *e, int ind
}
event::event (segment &s, point &pt, int tp) {
   seg = &s; type = tp; p = &pt; //segment *seg, int type, point *p
}
void pre_process (int size, std::vector<point>& pts, std::vector<event>& evts,
        std::vector<segment>& segs) {
    float x, y;
    for (int i = 0; i < size; ++ i) {
        std::cin >> x >> y;
        pts.push_back({x,y});
    }
    for (int i = 0; i < size; ++i) {
        int j = (i+1)%size;
        if (cmpXY(pts[i], pts[j]))
            segs.push_back({pts[i], pts[j], i});
        else
            segs.push_back({pts[j], pts[i], i});
        evts.push_back({segs[i], *segs[i].s, 0});
        evts.push_back({segs[i], *segs[i].e, 1});
        std::cout << 2*i << "\n";
        std::cout << segs[i].s << "\n";       //ALWAYS EQUAl
        std::cout << evts[2*i].seg->s << "\n";
    } // LINE X
    for (int i = 0; i < size; ++i) { //LINE Y
        std::cout << 2*i << "\n";
        std::cout << segs[i].s << "\n";        //DIFFERENT SOMETIMES
        std::cout << evts[2*i].seg->s << "\n";
    }
</code>```

So, the problem is that some of addresses my objects are pointing to change from LINE X to LINE Y. In particular, pts and segs remain the same.

From what I know and from what I understood here or here I cannot get the reference to an object on the stack of any function (my for loop, for example). However, I believe the lifetime of the object on the container is the same as the container itself. It makes me believe that all objects I push_back() should persist through the function pre_proccess and the function that is calling it.

答:
It looks that the vector resize itself and had to be relocated (which will invalidate all iterator references).

Try to use std::vector::reserve before processing:

```<code>void pre_process (int size, std::vector<point>& pts, std::vector<event>& evts,
        std::vector<segment>& segs) {
    pts.reserve(size);
    evts.reserve(size);
    segs.reserve(size);

    float x, y;
    for (int i = 0; i < size; ++ i) {
        std::cin >> x >> y;
        pts.push_back({x,y});
    }
    for (int i = 0; i < size; ++i) {
        int j = (i+1)%size;
        if (cmpXY(pts[i], pts[j]))
            segs.push_back({pts[i], pts[j], i});
        else
            segs.push_back({pts[j], pts[i], i});
        evts.push_back({segs[i], *segs[i].s, 0});
        evts.push_back({segs[i], *segs[i].e, 1});
        std::cout << 2*i << "\n";
        std::cout << segs[i].s << "\n";       //ALWAYS EQUAl
        std::cout << evts[2*i].seg->s << "\n";
    } // LINE X
    for (int i = 0; i < size; ++i) { //LINE Y
        std::cout << 2*i << "\n";
        std::cout << segs[i].s << "\n";        //DIFFERENT SOMETIMES
        std::cout << evts[2*i].seg->s << "\n";
}
</code>```

Body:
I am struggling to fix a piece of code, even though I believe I know the cause. I did search a lot on Stack Overflow and many people had similar issues (and good answers were provided), but still, I am not sure I understand the problem with my code.

I tried giving a smaller example, but the structure I have is not simple by itself. I hope the following is simple enough.

My objective on the excerpt:

Have a vector of points.

Have a vector of segments. (Whose endpoints are reference to points in the vector above)

Have a vector of events. (That keep a reference to the exhisting segments and points)

segment::segment (point &pt1, point&pt2, int i) {
   s = &pt1; e = &pt2; ind = i; // point *s, point *e, int ind
}
event::event (segment &s, point &pt, int tp) {
   seg = &s; type = tp; p = &pt; //segment *seg, int type, point *p
}
void pre_process (int size, std::vector<point>& pts, std::vector<event>& evts,
        std::vector<segment>& segs) {
    float x, y;
    for (int i = 0; i < size; ++ i) {
        std::cin >> x >> y;
        pts.push_back({x,y});
    }
    for (int i = 0; i < size; ++i) {
        int j = (i+1)%size;
        if (cmpXY(pts[i], pts[j]))
            segs.push_back({pts[i], pts[j], i});
        else
            segs.push_back({pts[j], pts[i], i});
        evts.push_back({segs[i], *segs[i].s, 0});
        evts.push_back({segs[i], *segs[i].e, 1});
        std::cout << 2*i << "\n";
        std::cout << segs[i].s << "\n";       //ALWAYS EQUAl
        std::cout << evts[2*i].seg->s << "\n";
    } // LINE X
    for (int i = 0; i < size; ++i) { //LINE Y
        std::cout << 2*i << "\n";
        std::cout << segs[i].s << "\n";        //DIFFERENT SOMETIMES
        std::cout << evts[2*i].seg->s << "\n";
    }

So, the problem is that some of addresses my objects are pointing to change from LINE X to LINE Y. In particular, pts and segs remain the same.

From what I know and from what I understood here or here I cannot get the reference to an object on the stack of any function (my for loop, for example). However, I believe the lifetime of the object on the container is the same as the container itself. It makes me believe that all objects I push_back() should persist through the function pre_proccess and the function that is calling it.

Body:
It looks that the vector resize itself and had to be relocated (which will invalidate all iterator references).

Try to use std::vector::reserve before processing:

void pre_process (int size, std::vector<point>& pts, std::vector<event>& evts,
        std::vector<segment>& segs) {
    pts.reserve(size);
    evts.reserve(size);
    segs.reserve(size);

    float x, y;
    for (int i = 0; i < size; ++ i) {
        std::cin >> x >> y;
        pts.push_back({x,y});
    }
    for (int i = 0; i < size; ++i) {
        int j = (i+1)%size;
        if (cmpXY(pts[i], pts[j]))
            segs.push_back({pts[i], pts[j], i});
        else
            segs.push_back({pts[j], pts[i], i});
        evts.push_back({segs[i], *segs[i].s, 0});
        evts.push_back({segs[i], *segs[i].e, 1});
        std::cout << 2*i << "\n";
        std::cout << segs[i].s << "\n";       //ALWAYS EQUAl
        std::cout << evts[2*i].seg->s << "\n";
    } // LINE X
    for (int i = 0; i < size; ++i) { //LINE Y
        std::cout << 2*i << "\n";
        std::cout << segs[i].s << "\n";        //DIFFERENT SOMETIMES
        std::cout << evts[2*i].seg->s << "\n";
}


问:
Azure App Configuration LabelFilters in .Net 4.8 Not working Correctly
I have several App Configuration Keys that are working correctly.  Now one of them I need to have based on Environment so I am trying to use labels.  So I have 2 labels "Production" and "ProductionIntranet".

```<code>labelFiler=""
</code>```

This brings back all the keys without labels.

According to the documentation this should bring back all null and ProductionIntranet

```<code>labelFilter="%00,ProductionIntranet"
</code>```

This does not get any of the keys (Not the ones with labels or the null ones)

```<code>labelFilter="%00"
</code>```

Neither does this.

I am sure this is a simple syntax issue but I am racking my head and I cannot figure it out. Any help would be greatly appreciated.

答:
I got it to work.  I am not sure it is the best solution but it works.  I created 2 buulder stores and had the first with no labelFilter (AppSettingsStore) which gave me all the keys without any labels and then I created a second that had ProductionIntranet as a filter(AppSettingsStoreIntraNet).

Then I updated appsettings like this

```<code><appSettings configBuilders="Environment,AppSettingsStore,AppSettingsStoreIntraNet">
</code>```

This might be making two calls to App Configuration.  If someone knows how to do this in one ConfigBuilder please let me know.

Body:
I have several App Configuration Keys that are working correctly.  Now one of them I need to have based on Environment so I am trying to use labels.  So I have 2 labels "Production" and "ProductionIntranet".

labelFiler=""

This brings back all the keys without labels.

According to the documentation this should bring back all null and ProductionIntranet

labelFilter="%00,ProductionIntranet"

This does not get any of the keys (Not the ones with labels or the null ones)

labelFilter="%00"

Neither does this.

I am sure this is a simple syntax issue but I am racking my head and I cannot figure it out. Any help would be greatly appreciated.

Body:
I got it to work.  I am not sure it is the best solution but it works.  I created 2 buulder stores and had the first with no labelFilter (AppSettingsStore) which gave me all the keys without any labels and then I created a second that had ProductionIntranet as a filter(AppSettingsStoreIntraNet).

Then I updated appsettings like this

<appSettings configBuilders="Environment,AppSettingsStore,AppSettingsStoreIntraNet">

This might be making two calls to App Configuration.  If someone knows how to do this in one ConfigBuilder please let me know.


问:
How to extract position input-output indeces from huggingface transformer text tokenizator?
I want to solve stress prediction task with pretrained russian bert.

Input data looks like this:

граммов сверху|000100000001000

Zeros mean no stress. Ones represent stress position character.

I want to map it as word -> vowel number index

So it will be like
граммов -> 1
сверху -> 1

So, for each token, it should be a linear layer with softmax.

I understand this part, but it's hard for me to deal with text preprocessing because text tokenizator can split a word into subword tokens.

Tokenizator takes an input string and returns tokens like this

```<code>bert_tokenizer.encode('граммов сверху')
->
[101, 44505, 26656, 102]
</code>```

So, how to get position mapping between input chars and words?

The desired output should be like [[0, 7], [8, 14]]

I tried to read docs
https://huggingface.co/transformers/main_classes/tokenizer.html

And found convert_ids_to_tokens function
It works like

```<code>encoded = bert_tokenizer.encode('граммов сверху')
bert_tokenizer.convert_ids_to_tokens(encoded)
->
['[CLS]', 'граммов', 'сверху', '[SEP]']
</code>```

But I'm not sure how to use original string and stress indices to calculate stress position number for token.

答: Its turned out, tokenizer have return_offsets_mapping param, this solve my problem.</p>

Body:
I want to solve stress prediction task with pretrained russian bert.

Input data looks like this:

граммов сверху|000100000001000

Zeros mean no stress. Ones represent stress position character.

I want to map it as word -> vowel number index

So it will be like
граммов -> 1
сверху -> 1

So, for each token, it should be a linear layer with softmax.

I understand this part, but it's hard for me to deal with text preprocessing because text tokenizator can split a word into subword tokens.

Tokenizator takes an input string and returns tokens like this

bert_tokenizer.encode('граммов сверху')
->
[101, 44505, 26656, 102]

So, how to get position mapping between input chars and words?

The desired output should be like [[0, 7], [8, 14]]

I tried to read docs
https://huggingface.co/transformers/main_classes/tokenizer.html

And found convert_ids_to_tokens function
It works like

encoded = bert_tokenizer.encode('граммов сверху')
bert_tokenizer.convert_ids_to_tokens(encoded)
->
['[CLS]', 'граммов', 'сверху', '[SEP]']

But I'm not sure how to use original string and stress indices to calculate stress position number for token.


问:
Capturing Selenium Web-driver Json-wire HTTP interactions
Selenium Webdriver interacts with any browser through HTTP, as discussed - here.
I have some automated tests written using selenium through the Protractor framework in JavaScript.

My use case is I want a clean way to record all interactions originating from my JS-based test cases to the browser, including - user action emulations and any DOM interrogations originating from test-cases.

What would be the easiest way to record these interactions?

答:
Protractor is a wrapper around Webdriverjs , so you should be able to use addEventListener command to add any browser supported events that will cover most user actions and DOM interrogations

Note, this is only supported in chrome currently

Also, this is an experimental feature in webdriver.js so have to add

```<code>var client = WebdriverJS.remote({
    logLevel: 'verbose',
    experimental: true, // <-- enables browser side eventhandling
    desiredCapabilities: {
        browserName: 'chrome'
    }
});
</code>```

And then register events like

```<code>client
    .url('http://google.com')
    .addEventListener('dblclick','#hplogo', function(e) {
        console.log(e.target); // -> 'id("hplogo")'
        console.log(e.type); // -> 'dblclick'
        console.log(e.clientX, e.clientY); // -> 239 524
    })
    .doubleClick('#hplogo') // triggers event
    .end();
</code>```

You can use removeEventListener to unregister any registered listeners

Evenhandling in Node.js environment is also supported as implied by this

WebdriverJS inherits several function from the NodeJS EventEmitter object

If you want to also capture network  traffic , you can do that with browsermob-proxy

Here is a tutorial on browsermob-proxy

Body:
Protractor is a wrapper around Webdriverjs , so you should be able to use addEventListener command to add any browser supported events that will cover most user actions and DOM interrogations

Note, this is only supported in chrome currently

Also, this is an experimental feature in webdriver.js so have to add

var client = WebdriverJS.remote({
    logLevel: 'verbose',
    experimental: true, // <-- enables browser side eventhandling
    desiredCapabilities: {
        browserName: 'chrome'
    }
});

And then register events like

client
    .url('http://google.com')
    .addEventListener('dblclick','#hplogo', function(e) {
        console.log(e.target); // -> 'id("hplogo")'
        console.log(e.type); // -> 'dblclick'
        console.log(e.clientX, e.clientY); // -> 239 524
    })
    .doubleClick('#hplogo') // triggers event
    .end();

You can use removeEventListener to unregister any registered listeners

Evenhandling in Node.js environment is also supported as implied by this

WebdriverJS inherits several function from the NodeJS EventEmitter object

If you want to also capture network  traffic , you can do that with browsermob-proxy

Here is a tutorial on browsermob-proxy


问:
Run a bash script with C++ on Windows
I am trying to write a program in C++ that can execute a bash script on Windows and then read the output of the bash script and store it into a string or something like that. Is this even possible without installing any extra software on Windows? If so, how?

Also, would it work if I wrote the program on Linux with a Posix library and then cross-compiled the C++ program for Windows inside Linux and then move it over to Windows where it needs to execute the bash script?

答:
You can use the popen function.

```<code>FILE *fp;
fp = popen("bash script.sh", "r");
</code>```

Now you can read the output just like you would read a file. Example:

```<code>char output[100];
fgets(output, sizeof(output), fp);
</code>```

Title: Run a bash script with C++ on Windows

Body:
You can use the popen function.

FILE *fp;
fp = popen("bash script.sh", "r");

Now you can read the output just like you would read a file. Example:

char output[100];
fgets(output, sizeof(output), fp);


问:
Passing Viewbag variable to Component from Theme settings
On Octobercms theme settings i use a yaml file:

```<code>product_count:
    label: Number
    type: number
    span: left
    tab: Index
    default: 3
</code>```

On index.htm page i use a partial featuredProducts of component with alias featuredProducts

On component featuredProducts viewBag i use this variable:

```<code>perPage = "{{ product_count }}"
</code>```

I try to pass variable product_count from theme settings yaml file to components viewBag but without success. Any idea on how can do it?

答:
You need to use component's property functionality and it's onRender() method.

Page's markup section

{% component 'featuredProducts' perPage=this.theme.product_count %}
```

<blockquote>
  <p>Component's <code>onRender()</code> method: <strong>make sure to use <code>onRender()</code> method as props will be available there.</strong></p>
</blockquote>

<pre class="lang-php prettyprint-override"><code>public function onRender() {
    // with default value of 3, if theme value is not already set
    $perPage = $this->property('perPage', 3);

    // now use $perPage to fetch records
    $this->page['items'] = SomeModel::limit($perPage)->get();

    // items will be available in markup for use
}
</code>```

If any doubts please comment.

Body:
On Octobercms theme settings i use a yaml file:

product_count:
    label: Number
    type: number
    span: left
    tab: Index
    default: 3

On index.htm page i use a partial featuredProducts of component with alias featuredProducts

On component featuredProducts viewBag i use this variable:

perPage = "{{ product_count }}"

I try to pass variable product_count from theme settings yaml file to components viewBag but without success. Any idea on how can do it?

Body:
You need to use component's property functionality and it's onRender() method.

Page's markup section

{% component 'featuredProducts' perPage=this.theme.product_count %}

Component's onRender() method: make sure to use onRender() method as props will be available there.

public function onRender() {
    // with default value of 3, if theme value is not already set
    $perPage = $this->property('perPage', 3);

    // now use $perPage to fetch records
    $this->page['items'] = SomeModel::limit($perPage)->get();

    // items will be available in markup for use
}

If any doubts please comment.


问:
Using a custom parser with flask_smorest and/or marshmallow
I'm using flask-smorest, the Flask/Marshmallow-based REST API framework and would like to be able to parse requests made with the axios JavaScript library, specifically for arrays passed via the querystring.

Axios sends arrays like this:

```<code>/api/v1/items/?types[]=cd&types[]=dvd
</code>```

I need to create a custom parser for this (see also the helpful responses on the ticket I created) so I was able to cobble together a rudimentary parser that serves my purpose.

But for the life of me, I can't figure out how to tell flask_smorest or marshmallow to use this custom parser for my API's MethodView-based endpoints.

I was also thinking of creating a custom field in my Schema, but there too I don't know how I can access the querystring so that it can be parsed correctly.

So what is the best way to integrate the parser for a specific type of querystring array encoding in flask_smorest/marshmallow?

答:
Assuming you created a parser as demonstrated in webargs docs, all you need to do is to tell your flask-smorest app to use this custom parser in place of default FlaskParser.

This is done by overriding Blueprint and overriding ARGUMENTS_PARSER from ArgumentsMixin:

```<code>import flask_smorest

class Blueprint(flask_smorest.Blueprint):

    ARGUMENTS_PARSER = CustomParser()
</code>```

Body:
I'm using flask-smorest, the Flask/Marshmallow-based REST API framework and would like to be able to parse requests made with the axios JavaScript library, specifically for arrays passed via the querystring.

Axios sends arrays like this:

/api/v1/items/?types[]=cd&types[]=dvd

I need to create a custom parser for this (see also the helpful responses on the ticket I created) so I was able to cobble together a rudimentary parser that serves my purpose.

But for the life of me, I can't figure out how to tell flask_smorest or marshmallow to use this custom parser for my API's MethodView-based endpoints.

I was also thinking of creating a custom field in my Schema, but there too I don't know how I can access the querystring so that it can be parsed correctly.

So what is the best way to integrate the parser for a specific type of querystring array encoding in flask_smorest/marshmallow?

Body:
Assuming you created a parser as demonstrated in webargs docs, all you need to do is to tell your flask-smorest app to use this custom parser in place of default FlaskParser.

This is done by overriding Blueprint and overriding ARGUMENTS_PARSER from ArgumentsMixin:

import flask_smorest

class Blueprint(flask_smorest.Blueprint):

    ARGUMENTS_PARSER = CustomParser()


问:
Filtering White Space from String in powershell
I am trying to filter a file name down for example, what i want to do is filter to the underscore and leave the rest.
Info10_ComputerHostName
so i run

```<code>$FileName="Info10_ComputerHostName"
$FinalFileName = $FileName -split("*._")
</code>```

When i output the variable what i get
" ComputerHostName"

What I want
"ComputerHostName"

How do I remove the whitespace that it always returns?

答:
Use $FinalFileName[1]. Proof:

```<code>$FileName="Info10_ComputerHostName"
$FinalFileName = $FileName -split ".*_"
$FinalFileName.GetType().FullName
$FinalFileName.Count
"`$FinalFileName   ='$FinalFileName'"
"`$FinalFileName[0]='$($FinalFileName[0])'"
"`$FinalFileName[1]='$($FinalFileName[1])'"
</code>```

```<code>System.String[]
2
$FinalFileName   =' ComputerHostName'
$FinalFileName[0]=''
$FinalFileName[1]='ComputerHostName'
</code>```

Another approach - use -replace operator instead of -split as follows:

```<code>$FileName="Info10_ComputerHostName"
$FinalFileName = $FileName -replace "^.*?_"
$FinalFileName.GetType().FullName
"`$FinalFileName   ='$FinalFileName'"
</code>```

```<code>System.String
$FinalFileName   ='ComputerHostName'
</code>```

Body:
I am trying to filter a file name down for example, what i want to do is filter to the underscore and leave the rest.
Info10_ComputerHostName
so i run

$FileName="Info10_ComputerHostName"
$FinalFileName = $FileName -split("*._")

When i output the variable what i get
" ComputerHostName"

What I want
"ComputerHostName"

How do I remove the whitespace that it always returns?

Body:
Use $FinalFileName[1]. Proof:

$FileName="Info10_ComputerHostName"
$FinalFileName = $FileName -split ".*_"
$FinalFileName.GetType().FullName
$FinalFileName.Count
"`$FinalFileName   ='$FinalFileName'"
"`$FinalFileName[0]='$($FinalFileName[0])'"
"`$FinalFileName[1]='$($FinalFileName[1])'"

System.String[]
2
$FinalFileName   =' ComputerHostName'
$FinalFileName[0]=''
$FinalFileName[1]='ComputerHostName'

Another approach - use -replace operator instead of -split as follows:

$FileName="Info10_ComputerHostName"
$FinalFileName = $FileName -replace "^.*?_"
$FinalFileName.GetType().FullName
"`$FinalFileName   ='$FinalFileName'"

System.String
$FinalFileName   ='ComputerHostName'