问:
How can I show to the user it's own entered password in laravel 5.5
User can change the password once when he is login, but when I get the password in the view it's hashed, that is because when is saved in the db is hashed by bcrypt.

So I want it to have in the view exactly the password that the user entered.

My Blade Code:

```<code><input class="form-control m-input" value="{{$staff->password}}"
type="password" name="password">
</code>```

答:
This is bad practice!

instead, you shoud create an input with a current password and new password and finally re-enter password for confirmation this protect way to user editing own password secure.

```<code><form id="form-change-password" role="form" method="POST" action="{{ url('/user/credentials') }}" novalidate class="form-horizontal">
  <div class="col-md-9">
    <label for="current-password" class="col-sm-4 control-label">Current Password</label>
    <div class="col-sm-8">
      <div class="form-group">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <input type="password" class="form-control" id="current-password" name="current-password" placeholder="Password">
      </div>
    </div>
    <label for="password" class="col-sm-4 control-label">New Password</label>
    <div class="col-sm-8">
      <div class="form-group">
        <input type="password" class="form-control" id="password" name="password" placeholder="Password">
      </div>
    </div>
    <label for="password_confirmation" class="col-sm-4 control-label">Re-enter Password</label>
    <div class="col-sm-8">
      <div class="form-group">
        <input type="password" class="form-control" id="password_confirmation" name="password_confirmation" placeholder="Re-enter Password">
      </div>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-5 col-sm-6">
      <button type="submit" class="btn btn-danger">Submit</button>
    </div>
  </div>
</form>
</code>```

Body:
User can change the password once when he is login, but when I get the password in the view it's hashed, that is because when is saved in the db is hashed by bcrypt.

So I want it to have in the view exactly the password that the user entered.

My Blade Code:

<input class="form-control m-input" value="{{$staff->password}}"
type="password" name="password">

Body:
This is bad practice!

instead, you shoud create an input with a current password and new password and finally re-enter password for confirmation this protect way to user editing own password secure.

<form id="form-change-password" role="form" method="POST" action="{{ url('/user/credentials') }}" novalidate class="form-horizontal">
  <div class="col-md-9">
    <label for="current-password" class="col-sm-4 control-label">Current Password</label>
    <div class="col-sm-8">
      <div class="form-group">
        <input type="hidden" name="_token" value="{{ csrf_token() }}">
        <input type="password" class="form-control" id="current-password" name="current-password" placeholder="Password">
      </div>
    </div>
    <label for="password" class="col-sm-4 control-label">New Password</label>
    <div class="col-sm-8">
      <div class="form-group">
        <input type="password" class="form-control" id="password" name="password" placeholder="Password">
      </div>
    </div>
    <label for="password_confirmation" class="col-sm-4 control-label">Re-enter Password</label>
    <div class="col-sm-8">
      <div class="form-group">
        <input type="password" class="form-control" id="password_confirmation" name="password_confirmation" placeholder="Re-enter Password">
      </div>
    </div>
  </div>
  <div class="form-group">
    <div class="col-sm-offset-5 col-sm-6">
      <button type="submit" class="btn btn-danger">Submit</button>
    </div>
  </div>
</form>


来源: stackexchange

问:
How to change the language in a website (datascrapping) and get the response through asp.net c#
How to do i change the website content language programmatically using asp.net c#?

https://www.tnpds.gov.in/
enter image description here

```<code>        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.tnpds.gov.in");
        request.Method = "POST";
        Dictionary<string, string> postParams = new Dictionary<string, string>();
        postParams.Add("masterForm:languageSelectMenu:", "en");
        request.ContentType = "application/x-www-form-urlencoded";
        request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)";
        request.Accept = "/";

        HttpWebResponse resp = request.GetResponse() as HttpWebResponse;

        if (resp.StatusCode == HttpStatusCode.OK)
        {
            Stream receiveStream = resp.GetResponseStream();
            StreamReader readStream = null;

            if (resp.CharacterSet == null)
                readStream = new StreamReader(receiveStream);
            else
                readStream = new StreamReader(receiveStream, Encoding.GetEncoding(resp.CharacterSet));
            string data = readStream.ReadToEnd();
            htmlDoc.LoadHtml(data);
            resp.Close();
            readStream.Close();
        }
</code>```

答:
I think there is no short way to do localization.
You can use google translate plugin or nopcommerce api for translating web pages to specific language.

Refer Google Plugin article and Codeproject google plugin  or nopcommerce for more details.

ContentLicense: CC BY-SA 4.0

Body:
How to do i change the website content language programmatically using asp.net c#?

https://www.tnpds.gov.in/
enter image description here

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.tnpds.gov.in");
        request.Method = "POST";
        Dictionary<string, string> postParams = new Dictionary<string, string>();
        postParams.Add("masterForm:languageSelectMenu:", "en");
        request.ContentType = "application/x-www-form-urlencoded";
        request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 7.1; Trident/5.0)";
        request.Accept = "/";

        HttpWebResponse resp = request.GetResponse() as HttpWebResponse;

        if (resp.StatusCode == HttpStatusCode.OK)
        {
            Stream receiveStream = resp.GetResponseStream();
            StreamReader readStream = null;

            if (resp.CharacterSet == null)
                readStream = new StreamReader(receiveStream);
            else
                readStream = new StreamReader(receiveStream, Encoding.GetEncoding(resp.CharacterSet));
            string data = readStream.ReadToEnd();
            htmlDoc.LoadHtml(data);
            resp.Close();
            readStream.Close();
        }


问:
How do I use a style when putting a textView into code manually in Android?
I'm trying to make my game work in all layouts equally well, and in order to facilitate this, I'm using styles which are size dependent. The problem is, this breaks down with the function that I've coded directly, due to its high repetitiveness. So, what can I do to apply one of my styles to these text views that I'm creating in code?

Sample Style code:

```<code><style name="medText">
    <item name="android:textSize">22sp</item>
    <item name="android:layout_height">wrap_content</item>
    <item name="android:layout_width">wrap_content</item>
</style>
</code>```

Sample program code:

```<code>TableRow row=new TableRow(this);
TableLayout tlayout=new TableLayout(this);
text1.setText(R.string.name);
row.addView(text1);
text2.setText(R.string.level);
row.addView(text2);
text3.setText(R.string.score);
row.addView(text3);
tlayout.addView(row);
</code>```

I loop through re-creating these TextViews a number of times, with the later ones containing variable input.

答:
To set style in TextView

If you have declared your TextView in xml in that xml you have to pass style="@style/medText"

 Example

```<code><TextView
 android:layout_width="fill_parent"
 android:text="@string/menu_legal_termsandcondition"
 android:padding="3dip"
 style="@style/medText"
 android:layout_weight="2"/>
</code>```

If you have created TextView dynamically then you have to use text1.setTextAppearance(this, R.style.medText); in your java code

Thanks
Deepak

ContentLicense: CC BY-SA 3.0

Body:
I'm trying to make my game work in all layouts equally well, and in order to facilitate this, I'm using styles which are size dependent. The problem is, this breaks down with the function that I've coded directly, due to its high repetitiveness. So, what can I do to apply one of my styles to these text views that I'm creating in code?

Sample Style code:

Sample program code:

TableRow row=new TableRow(this);
TableLayout tlayout=new TableLayout(this);
text1.setText(R.string.name);
row.addView(text1);
text2.setText(R.string.level);
row.addView(text2);
text3.setText(R.string.score);
row.addView(text3);
tlayout.addView(row);

I loop through re-creating these TextViews a number of times, with the later ones containing variable input.

Body:
To set style in TextView

If you have declared your TextView in xml in that xml you have to pass style="@style/medText"

 Example

<TextView
 android:layout_width="fill_parent"
 android:text="@string/menu_legal_termsandcondition"
 android:padding="3dip"
 style="@style/medText"
 android:layout_weight="2"/>

If you have created TextView dynamically then you have to use text1.setTextAppearance(this, R.style.medText); in your java code

Thanks
Deepak


问:
terraform copy/upload files to aws ec2 instance
We have cronjob and shell script which we want to copy or upload to aws ec2 instance while creating instance using terraform.

we tried

file provisioner :
but its not wokring , and read this option does not work with all terraform version

```<code>      provisioner "file" {
        source      = "abc.sh"
        destination = "/home/ec2-user/basic2.sh"
      }
</code>```

tried data template file option

```<code>    data "template_file" "userdata_line" {
      template = <<EOF
    #!/bin/bash
    mkdir /home/ec2-user/files2
    cd /home/ec2-user/files2
    sudo touch basic2.sh
    sudo chmod 777 basic2.sh
    base64 basic.sh |base64 -d >basic2.sh
    EOF
    }
</code>```

tried all option but none of them working.

could u please help or advise .

I am new to terraform so struggling on this from long time.

答:
You have to use file provisioner with connection details to the ec2 instance. A sample config would look like this:

```<code>provisioner "file" {
  source      = "${path.module}/files/script.sh"
  destination = "/tmp/script.sh"

  connection {
    type     = "ssh"
    user     = "root"
    password = "${var.root_password}"
    host     = "${var.host}"
  }
}
</code>```

You can use username / password, private key or even a bastion host to connect. For more details https://www.terraform.io/docs/provisioners/connection.html

Body:
We have cronjob and shell script which we want to copy or upload to aws ec2 instance while creating instance using terraform.

we tried

file provisioner :
but its not wokring , and read this option does not work with all terraform version

      provisioner "file" {
        source      = "abc.sh"
        destination = "/home/ec2-user/basic2.sh"
      }

tried data template file option

    data "template_file" "userdata_line" {
      template = <<EOF
    #!/bin/bash
    mkdir /home/ec2-user/files2
    cd /home/ec2-user/files2
    sudo touch basic2.sh
    sudo chmod 777 basic2.sh
    base64 basic.sh |base64 -d >basic2.sh
    EOF
    }

tried all option but none of them working.

could u please help or advise .

I am new to terraform so struggling on this from long time.

Body:
You have to use file provisioner with connection details to the ec2 instance. A sample config would look like this:

provisioner "file" {
  source      = "${path.module}/files/script.sh"
  destination = "/tmp/script.sh"

  connection {
    type     = "ssh"
    user     = "root"
    password = "${var.root_password}"
    host     = "${var.host}"
  }
}

You can use username / password, private key or even a bastion host to connect. For more details https://www.terraform.io/docs/provisioners/connection.html


问:
How can I upload a picture using Glide from an external folder
I am developing an app for my auntie: the app displays recipes in a card view inside a Recycler view, the data comes from an SQLite DB.

The images at the moment are just static inside @drawable/... I have read the "@drawable" folder is compiled into the apk and not accessible after the fact. Consequently the need to store the images externally.

The DB stores the filenames.

The card displays basic info, when a card is clicked it opens another activity that displays full information.

Everything works perfectly EXCEPT

I obviously want her to be able to upload pictures and add info, the pictures will be stored in: "/sdcard/Pictures/Recipes/"

In am using Glide as recommended, however Glide reports the following error:

```<code>class com.bumptech.glide.load.engine.GlideException: Failed to load resource
    There were 3 causes:
    java.io.FileNotFoundException(/sdcard/Pictures/Recipes/carrot_cake.jpg: open failed: EFAULT (Bad address))
    java.io.FileNotFoundException(open failed: EFAULT (Bad address))
    java.io.FileNotFoundException(open failed: EFAULT (Bad address))...
</code>```

If I use the following code:

```<code>    String image = "/sdcard/Pictures/Recipes/carrot_cake.jpg"; // hard coded for example
    File file = new File( image );
    if( file.exists() && file.canRead() )
    {
        Log.d( TAG, "File exists" );
        Glide.with( context ).load( image ).into( foodImage ); // foodImage = ImageView
    }
</code>```

The log displays the "File Exists", however, Glide won't load and reports the aforementioned error.

答:
Check this:</p>

```<code>String path = Environment.getExternalStorageDirectory().toString() + "/Pictures/Recipes/carrot_cake.jpg";
if( file.exists() && file.canRead() ) {
    Log.d( TAG, "File exists" );
    Glide.with( context ).load( new File(path)).into( foodImage ); // foodImage = ImageView
}
</code>```

Body:
I am developing an app for my auntie: the app displays recipes in a card view inside a Recycler view, the data comes from an SQLite DB.

The images at the moment are just static inside @drawable/... I have read the "@drawable" folder is compiled into the apk and not accessible after the fact. Consequently the need to store the images externally.

The DB stores the filenames.

The card displays basic info, when a card is clicked it opens another activity that displays full information.

Everything works perfectly EXCEPT

I obviously want her to be able to upload pictures and add info, the pictures will be stored in: "/sdcard/Pictures/Recipes/"

In am using Glide as recommended, however Glide reports the following error:

class com.bumptech.glide.load.engine.GlideException: Failed to load resource
    There were 3 causes:
    java.io.FileNotFoundException(/sdcard/Pictures/Recipes/carrot_cake.jpg: open failed: EFAULT (Bad address))
    java.io.FileNotFoundException(open failed: EFAULT (Bad address))
    java.io.FileNotFoundException(open failed: EFAULT (Bad address))...

If I use the following code:

    String image = "/sdcard/Pictures/Recipes/carrot_cake.jpg"; // hard coded for example
    File file = new File( image );
    if( file.exists() && file.canRead() )
    {
        Log.d( TAG, "File exists" );
        Glide.with( context ).load( image ).into( foodImage ); // foodImage = ImageView
    }

The log displays the "File Exists", however, Glide won't load and reports the aforementioned error.

Body:
Check this:

String path = Environment.getExternalStorageDirectory().toString() + "/Pictures/Recipes/carrot_cake.jpg";
if( file.exists() && file.canRead() ) {
    Log.d( TAG, "File exists" );
    Glide.with( context ).load( new File(path)).into( foodImage ); // foodImage = ImageView
}


问:
AWS CloudFormation template generation issue
I have AWS Lambda service running which I had developed and deployed using the AWS SAM CLI. There are some other services as like ElasticCache, RDS, etc running in my AWS Account.

Now my requirement is to generate the CloudFormation YAML template file out of existing running service which I can use to provision later and keep as a backup. For this, I used CloudFormer template however problem is that CloudFormer does not consider or generate YAML template for AWS Lambda services which I had noticed. And also I believe CloudFormer has become obsolete as well.

Please assist me here to let me know if there any latest service from AWS that can fulfil my requirement here.

Thank you

答:
CloudFormation supports the creation of stacks from existing resources.

Take a further look: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-new-stack.html


问:
How to generate a binding for each array element
If I had a @State or an @ObservedObject variable with an array property, and I wanted to use List and pass a binding of each element of the array into some child View (e.g. Toggle or TextField), is there a standard way to do that?

Simplified example:

```<code>struct Person: Identifiable {
  var id: UUID = .init()
  var name: String
  var isFavorite: Bool = false
}

struct ContentView: View {
  @State var people = [Person(name: "Joey"), Person(name: "Chandler")]

  var body: some View {
     List(people) { person in
        HStack() {
           Text(person.name)
           Spacer
           Toggle("", isOn: $person.isFavorite) // <- this obviously doesn't work
        }
     }
  }
}
</code>```

This seems like a fairly common scenario, but I can't figure out an obvious solution aside from manually building a separate array of bindings.

The only elegant solution I came up with (I'll add it as an answer, if there isn't something better) was to create an extension of Binding of a RandomAccessCollection to itself conform to a RandomAccessCollection, which has bindings as elements, like so:

```<code>extension Binding: RandomAccessCollection
  where Value: RandomAccessCollection & MutableCollection {
  // more code here
}

  // more required extensions to Collection and Sequence here

</code>```

答:
UPDATE

In iOS13 release notes (deprecation section), SwiftUI dropped the  conformance of Binding to Collection, and instead offered a workaround, so I'm updating this answer with their suggestion.

The idea is to extend RandomAccessCollection to add a .index() method, which works similarly to .enumerated() by creating a collection of tuples of index and element, but unlike .enumerated() conforms to a RandomAccessCollection, which List and ForEach require.

The usage is:

```<code>List(people.indexed(), id: \.1.id) { (i, person) in
   HStack() {
      Toggle(person.name, isOn: $people[i].isFavorite)
   }
</code>```

And the implementation of .indexed() is:

```<code>struct IndexedCollection<Base: RandomAccessCollection>: RandomAccessCollection {
    typealias Index = Base.Index
    typealias Element = (index: Index, element: Base.Element)

    let base: Base

    var startIndex: Index { base.startIndex }

    var endIndex: Index { base.startIndex }

    func index(after i: Index) -> Index {
        base.index(after: i)
    }

    func index(before i: Index) -> Index {
        base.index(before: i)
    }

    func index(_ i: Index, offsetBy distance: Int) -> Index {
        base.index(i, offsetBy: distance)
    }

    subscript(position: Index) -> Element {
        (index: position, element: base[position])
    }
}

extension RandomAccessCollection {
    func indexed() -> IndexedCollection<Self> {
        IndexedCollection(base: self)
    }
}
</code>```

ORIGINAL
Here's what I wanted to achieve:

```<code>List($people) { personBinding in
  HStack() {
      Text(personBinding.wrappedValue.name)
      Spacer()
      Toggle("", isOn: personBinding.isFavorite)
  }
}
</code>```

In other words, pass the binding of an array, and get a binding of an element in List's closure.

To achieve that, I created an extension of Binding that makes a Binding of any RandomAccessCollection into a RandomAccessCollection of bindings:

```<code>// For all Bindings whose Value is a collection
extension Binding: RandomAccessCollection
    where Value: RandomAccessCollection & MutableCollection {

  // The Element of this collection is Binding of underlying Value.Element
  public typealias Element = Binding<Value.Element>
  public typealias Index = Value.Index
  public typealias SubSequence = Self
  public typealias Indices = Value.Indices

  // return a binding to the underlying collection element
  public subscript(position: Index) -> Element {
    get {
      .init(get: { self.wrappedValue[position] },
            set: { self.wrappedValue[position] = $0 })
    }
  }

  // other protocol conformance requirements routed to underlying collection ...

  public func index(before i: Index) -> Index {
     self.wrappedValue.index(before: i)
  }

  public func index(after i: Index) -> Index {
     self.wrappedValue.index(after: i)
  }

  public var startIndex: Index {
     self.wrappedValue.startIndex
  }

  public var endIndex: Index {
     self.wrappedValue.endIndex
  }
}
</code>```

This also requires explicit conformance to inherited protocols:

```<code>extension Binding: Sequence
    where Value: RandomAccessCollection & MutableCollection {

  public func makeIterator() -> IndexingIterator<Self> {
    IndexingIterator(_elements: self)
  }
}

extension Binding: Collection
    where Value: RandomAccessCollection & MutableCollection {

  public var indices: Value.Indices {
    self.wrappedValue.indices
  }
}

extension Binding: BidirectionalCollection
    where Value: RandomAccessCollection & MutableCollection {
}
</code>```

And, if the underlying value is an Identifiable, then it makes the Binding conform to Identifiable too, which removes the need to use id::

```<code>extension Binding: Identifiable where Value: Identifiable {
  public var id: Value.ID {
    self.wrappedValue.id
  }
}
</code>```

Body:
If I had a @State or an @ObservedObject variable with an array property, and I wanted to use List and pass a binding of each element of the array into some child View (e.g. Toggle or TextField), is there a standard way to do that?

Simplified example:

struct Person: Identifiable {
  var id: UUID = .init()
  var name: String
  var isFavorite: Bool = false
}

struct ContentView: View {
  @State var people = [Person(name: "Joey"), Person(name: "Chandler")]

  var body: some View {
     List(people) { person in
        HStack() {
           Text(person.name)
           Spacer
           Toggle("", isOn: $person.isFavorite) // <- this obviously doesn't work
        }
     }
  }
}

This seems like a fairly common scenario, but I can't figure out an obvious solution aside from manually building a separate array of bindings.

The only elegant solution I came up with (I'll add it as an answer, if there isn't something better) was to create an extension of Binding of a RandomAccessCollection to itself conform to a RandomAccessCollection, which has bindings as elements, like so:

extension Binding: RandomAccessCollection
  where Value: RandomAccessCollection & MutableCollection {
  // more code here
}

  // more required extensions to Collection and Sequence here

Body:
UPDATE

In iOS13 release notes (deprecation section), SwiftUI dropped the  conformance of Binding to Collection, and instead offered a workaround, so I'm updating this answer with their suggestion.

The idea is to extend RandomAccessCollection to add a .index() method, which works similarly to .enumerated() by creating a collection of tuples of index and element, but unlike .enumerated() conforms to a RandomAccessCollection, which List and ForEach require.

The usage is:

List(people.indexed(), id: \.1.id) { (i, person) in
   HStack() {
      Toggle(person.name, isOn: $people[i].isFavorite)
   }

And the implementation of .indexed() is:

struct IndexedCollection<Base: RandomAccessCollection>: RandomAccessCollection {
    typealias Index = Base.Index
    typealias Element = (index: Index, element: Base.Element)

    let base: Base

    var startIndex: Index { base.startIndex }

    var endIndex: Index { base.startIndex }

    func index(after i: Index) -> Index {
        base.index(after: i)
    }

    func index(before i: Index) -> Index {
        base.index(before: i)
    }

    func index(_ i: Index, offsetBy distance: Int) -> Index {
        base.index(i, offsetBy: distance)
    }

    subscript(position: Index) -> Element {
        (index: position, element: base[position])
    }
}

extension RandomAccessCollection {
    func indexed() -> IndexedCollection<Self> {
        IndexedCollection(base: self)
    }
}

ORIGINAL
Here's what I wanted to achieve:

List($people) { personBinding in
  HStack() {
      Text(personBinding.wrappedValue.name)
      Spacer()
      Toggle("", isOn: personBinding.isFavorite)
  }
}

In other words, pass the binding of an array, and get a binding of an element in List's closure.

To achieve that, I created an extension of Binding that makes a Binding of any RandomAccessCollection into a RandomAccessCollection of bindings:

// For all Bindings whose Value is a collection
extension Binding: RandomAccessCollection
    where Value: RandomAccessCollection & MutableCollection {

  // The Element of this collection is Binding of underlying Value.Element
  public typealias Element = Binding<Value.Element>
  public typealias Index = Value.Index
  public typealias SubSequence = Self
  public typealias Indices = Value.Indices

  // return a binding to the underlying collection element
  public subscript(position: Index) -> Element {
    get {
      .init(get: { self.wrappedValue[position] },
            set: { self.wrappedValue[position] = $0 })
    }
  }

  // other protocol conformance requirements routed to underlying collection ...

  public func index(before i: Index) -> Index {
     self.wrappedValue.index(before: i)
  }

  public func index(after i: Index) -> Index {
     self.wrappedValue.index(after: i)
  }

  public var startIndex: Index {
     self.wrappedValue.startIndex
  }

  public var endIndex: Index {
     self.wrappedValue.endIndex
  }
}

This also requires explicit conformance to inherited protocols:

extension Binding: Sequence
    where Value: RandomAccessCollection & MutableCollection {

  public func makeIterator() -> IndexingIterator<Self> {
    IndexingIterator(_elements: self)
  }
}

extension Binding: Collection
    where Value: RandomAccessCollection & MutableCollection {

  public var indices: Value.Indices {
    self.wrappedValue.indices
  }
}

extension Binding: BidirectionalCollection
    where Value: RandomAccessCollection & MutableCollection {
}

And, if the underlying value is an Identifiable, then it makes the Binding conform to Identifiable too, which removes the need to use id::

extension Binding: Identifiable where Value: Identifiable {
  public var id: Value.ID {
    self.wrappedValue.id
  }
}


问:
Webpack devServer proxy not working with Sapper
I have a node dev server running Sapper on http://localhost:3000, and I want all /api/ requests proxy another local dev server written on python http://localhost:8000/api/

This worked perfectly for pure Svelte:

```<code>// webpack.config.js

module.exports.devServer = {
    historyApiFallback: true,
    proxy: {
        '/api/': {
            target: 'http://localhost:8000',
            secure: false,
            changeOrigin: true
        }
    },
};
</code>```

But does absolutely nothing with Sapper - just get default Sapper's 404 error

I guess it is somehow related with Sapper's routing mechanism, but can not find how to deal with it

答:
Sapper uses Polka server. Proxy can be configured using http-proxy-middleware

src/server.js

```<code>const { createProxyMiddleware } = require('http-proxy-middleware');

polka()
    .use('/api', createProxyMiddleware({ target: 'http://localhost:8000' }))
    // other .use, .listen rules
</code>```

Body:
I have a node dev server running Sapper on http://localhost:3000, and I want all /api/ requests proxy another local dev server written on python http://localhost:8000/api/

This worked perfectly for pure Svelte:

// webpack.config.js

module.exports.devServer = {
    historyApiFallback: true,
    proxy: {
        '/api/': {
            target: 'http://localhost:8000',
            secure: false,
            changeOrigin: true
        }
    },
};

But does absolutely nothing with Sapper - just get default Sapper's 404 error

I guess it is somehow related with Sapper's routing mechanism, but can not find how to deal with it

Body:
Sapper uses Polka server. Proxy can be configured using http-proxy-middleware

src/server.js

const { createProxyMiddleware } = require('http-proxy-middleware');

polka()
    .use('/api', createProxyMiddleware({ target: 'http://localhost:8000' }))
    // other .use, .listen rules


问:
Android Studio 4.0 update
Currently a student working through a chat app module with appBrewery.  All working well until I updated to the latest Studio then this gets thrown up.

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.

Failed to notify dependency resolution listener.
  tried to access method sun.security.util.ECUtil.getECParameters(Ljava/security/Provider;)Ljava/security/AlgorithmParameters; from class sun.security.ec.ECKeyPairGenerator

Any ideas?

答:
I had a similar issue. Probably something went wrong during the update.
My andorid studio had problems connecting to internet (gave me an error when trying to check for updates and the plugin marketplace wouldn't show anything). If yours does the same then there's a good chance you can fix it like this:

Download the latest installer (if you don't have it already) and install it making sure that you confirm you want to delete your old installation when it asks

Once installed, if you have any notifications under the "configure" menu on android studio's welcome screen that asks to update something, update it and then restart android studio.

Done!

Hope this helps

Title: Android Studio 4.0 update


问:
VBA count emails module!
This is a follow-up question of one which I posted yesterday. I feel I am getting quite close to creating a module in VBA that will count the number of e-mails sent on a particular day of the week. For the moment the day chosen is Monday.

However, the code is not yet working, and Outlook refuses to see the particular module.

I am sure there are a couple of errors in it. If someone could point these out, I would greatly appreciate it.

I also think that such code could be useful for others for future reference as the code for this kind of module does not seem to be readily available on the internet (I've looked!) and yet forms a type of search parameter that many will find useful!

```<code>Sub Count2(Optional dteDate As Date)
  Dim objOutlook As Object, objnSpace As Object, objFolder As Object
  Dim EmailCount As Integer
  Set objOutlook = CreateObject("Outlook.Application")
  Set objnSpace = objOutlook.GetNamespace("MAPI")

  On Error Resume Next

  Set objFolder = objnSpace.Folders("My Personal Emails").Folders("spam")
  If Err.Number <> 0 Then
    Err.Clear
    MsgBox "No such folder."
    Exit Sub
  End If

  Select Case Weekday(dteDate)
    Case vbMonday
      dteDate = Date
    End Select

  For Each MapiItem In MapiFolderInbox.Messages
    If MapiItem.TimeReceived = Date Then
      Count = Count + 1
      Next MapiItem
    End If

  EmailCount = objFolder.Items.Count
  Set objFolder = Nothing
  Set objnSpace = Nothing
  Set objOutlook = Nothing

  MsgBox "Number of emails in the folder: " _
    & EmailCount, , "Number of spam messages sent on a Monday: " & Count
End Sub
</code>```

答:
i think time received is more of a timestamp where in addition to date it would have time too. you should probably use it like this;

```<code>For Each MapiItem In MapiFolderInbox.Messages
    If  MapiItem.TimeReceived > YTS And MapiItem.TimeReceived < TTS Then
        Count = Count + 1
    End If
Next MapiItem
</code>```

where YTS and TTS are timestamps where it would have yesterday's timestamp and today timestamp

for eg 01:06:2011:23:59:00 and 02:06:2011:23:59:00

you should comfirm this by debuging your code. hope this helps.

Title: VBA count emails module!

Body:
This is a follow-up question of one which I posted yesterday. I feel I am getting quite close to creating a module in VBA that will count the number of e-mails sent on a particular day of the week. For the moment the day chosen is Monday.

However, the code is not yet working, and Outlook refuses to see the particular module.

I am sure there are a couple of errors in it. If someone could point these out, I would greatly appreciate it.

I also think that such code could be useful for others for future reference as the code for this kind of module does not seem to be readily available on the internet (I've looked!) and yet forms a type of search parameter that many will find useful!

Sub Count2(Optional dteDate As Date)
  Dim objOutlook As Object, objnSpace As Object, objFolder As Object
  Dim EmailCount As Integer
  Set objOutlook = CreateObject("Outlook.Application")
  Set objnSpace = objOutlook.GetNamespace("MAPI")

  On Error Resume Next

  Set objFolder = objnSpace.Folders("My Personal Emails").Folders("spam")
  If Err.Number <> 0 Then
    Err.Clear
    MsgBox "No such folder."
    Exit Sub
  End If

  Select Case Weekday(dteDate)
    Case vbMonday
      dteDate = Date
    End Select

  For Each MapiItem In MapiFolderInbox.Messages
    If MapiItem.TimeReceived = Date Then
      Count = Count + 1
      Next MapiItem
    End If

  EmailCount = objFolder.Items.Count
  Set objFolder = Nothing
  Set objnSpace = Nothing
  Set objOutlook = Nothing

  MsgBox "Number of emails in the folder: " _
    & EmailCount, , "Number of spam messages sent on a Monday: " & Count
End Sub

Body:
i think time received is more of a timestamp where in addition to date it would have time too. you should probably use it like this;

For Each MapiItem In MapiFolderInbox.Messages
    If  MapiItem.TimeReceived > YTS And MapiItem.TimeReceived < TTS Then
        Count = Count + 1
    End If
Next MapiItem

where YTS and TTS are timestamps where it would have yesterday's timestamp and today timestamp

for eg 01:06:2011:23:59:00 and 02:06:2011:23:59:00

you should comfirm this by debuging your code. hope this helps.


问:
how to select rows in a data frame those are similar on basis of column values

My Dataframe is  :

```<code>col1 col2 col3 col4
'abc' 2    3    4
'asd' 4    5    6
'dfg' 7    5    6
'ghg' 2    3    4
'xyz' 1    3    4
</code>```

Here I want to find the rows( specifically list of 'col1' values) those are similar on the basis of  'col3' and 'col4'
Output :

```<code>[[asd,dfg],[abc,ghg,xyz]]
</code>```

because here both asd and dfg have similar 'col3' and 'col4' values 3 and 4 respectively

答:
Something like this might work - </p>

```<code>df['col1'] = df['col1'].str.replace('\'','')
df.groupby(['col3'])['col1'].apply(list).reset_index()['col1'].tolist()
[['abc', 'ghg', 'xyz'], ['asd', 'dfg']]
</code>```

Body:
My Dataframe is  :

col1 col2 col3 col4
'abc' 2    3    4
'asd' 4    5    6
'dfg' 7    5    6
'ghg' 2    3    4
'xyz' 1    3    4

Here I want to find the rows( specifically list of 'col1' values) those are similar on the basis of  'col3' and 'col4'
Output :

[[asd,dfg],[abc,ghg,xyz]]

because here both asd and dfg have similar 'col3' and 'col4' values 3 and 4 respectively

Body:
Something like this might work -

df['col1'] = df['col1'].str.replace('\'','')
df.groupby(['col3'])['col1'].apply(list).reset_index()['col1'].tolist()
[['abc', 'ghg', 'xyz'], ['asd', 'dfg']]


问:
Error when checking target: expected dense_3 to have 2 dimensions, but got array with shape (5, 200, 200, 1)
I've just started to learn Tensorflow (2.1.0) and Keras (2.3.7) with Python 3.7.7.

I have this network:

```<code>def vgg16(input_size = (224,224,3)):
    inputs = Input(input_size, name='input')

    conv1 = Conv2D(64, (3, 3), activation = 'relu', padding = 'same', name ='conv1_1')(inputs)
    conv1 = Conv2D(64, (3, 3), activation = 'relu', padding = 'same', name ='conv1_2')(conv1)
    pool1 = MaxPooling2D(pool_size = (2,2), strides = (2,2), name = 'pool_1')(conv1)

    conv2 = Conv2D(128, (3, 3), activation = 'relu', padding = 'same', name ='conv2_1')(pool1)
    conv2 = Conv2D(128, (3, 3), activation = 'relu', padding = 'same', name ='conv2_2')(conv2)
    pool2 = MaxPooling2D(pool_size = (2,2), strides = (2,2), name = 'pool_2')(conv2)

    conv3 = Conv2D(256, (3, 3), activation = 'relu', padding = 'same', name ='conv3_1')(pool2)
    conv3 = Conv2D(256, (3, 3), activation = 'relu', padding = 'same', name ='conv3_2')(conv3)
    conv3 = Conv2D(256, (3, 3), activation = 'relu', padding = 'same', name ='conv3_3')(conv3)
    pool3 = MaxPooling2D(pool_size = (2,2), strides = (2,2), name = 'pool_3')(conv3)

    conv4 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv4_1')(pool3)
    conv4 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv4_2')(conv4)
    conv4 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv4_3')(conv4)

    conv5 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv5_1')(pool4)
    conv5 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv5_2')(conv5)
    conv5 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv5_3')(conv5)
    pool5 = MaxPooling2D(pool_size = (2,2), strides = (2,2), name = 'pool_5')(conv5)
    flatten = Flatten(name = 'flatten')(pool5)

    dense1 = Dense(units = 4096,activation = "relu", name = 'dense_1')(flatten)
    dense2 = Dense(units = 4096,activation = "relu", name = 'dense_2')(dense1)
    dense3 = Dense(units = 2, activation = "softmax", name = 'dense_3')(dense2)

    opt = Adam(lr=0.001)

    model = Model(inputs = inputs, outputs = dense3, name ='vgg-16')

    model.compile(optimizer=opt, loss=keras.losses.categorical_crossentropy, metrics=['accuracy'])

    return model
</code>```

And this is the code that use it:

```<code>model = vgg16(input_size=(200, 200, 1))

for episode in range(num_episodes):
    selected = np.random.permutation(no_of_samples)[:num_shot + num_query]
    # Create our Support Set.
    support_set = np.array(D[selected[:num_shot]])
    # Create our Query Set.
    query_set = np.array(D[selected[num_query:]])

    X_train = support_set[:,0,:]
    y_train = support_set[:,1,:]

    X_valid = query_set[:,0,:]
    y_valid = query_set[:,1,:]

    results = model.fit(X_train, y_train, epochs=20, batch_size=5,
                        validation_data=(X_valid, y_valid))
</code>```

X_train, y_train, X_valid and y_valid have a this shape: (5, 200, 200, 1).

But I get this error:

Error when checking target: expected dense_3 to have 2 dimensions, but
  got array with shape (5, 200, 200, 1)

I don't understand why. I have changed the fit call removing the batch_size:

```<code>results = model.fit(X_train, y_train, epochs=20, validation_data=(X_valid, y_valid))
</code>```

But I get the same error:

How can I fix this error?

Maybe, the problem is that I'm using one channel images.

Model summary:

```<code>Model: "vgg-16"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
input (InputLayer)           (None, 200, 200, 1)       0
_________________________________________________________________
conv1_1 (Conv2D)             (None, 200, 200, 64)      640
_________________________________________________________________
conv1_2 (Conv2D)             (None, 200, 200, 64)      36928
_________________________________________________________________
pool_1 (MaxPooling2D)        (None, 100, 100, 64)      0
_________________________________________________________________
conv2_1 (Conv2D)             (None, 100, 100, 128)     73856
_________________________________________________________________
conv2_2 (Conv2D)             (None, 100, 100, 128)     147584
_________________________________________________________________
pool_2 (MaxPooling2D)        (None, 50, 50, 128)       0
_________________________________________________________________
conv3_1 (Conv2D)             (None, 50, 50, 256)       295168
_________________________________________________________________
conv3_2 (Conv2D)             (None, 50, 50, 256)       590080
_________________________________________________________________
conv3_3 (Conv2D)             (None, 50, 50, 256)       590080
_________________________________________________________________
pool_3 (MaxPooling2D)        (None, 25, 25, 256)       0
_________________________________________________________________
conv4_1 (Conv2D)             (None, 25, 25, 512)       1180160
_________________________________________________________________
conv4_2 (Conv2D)             (None, 25, 25, 512)       2359808
_________________________________________________________________
conv4_3 (Conv2D)             (None, 25, 25, 512)       2359808
_________________________________________________________________
pool_4 (MaxPooling2D)        (None, 12, 12, 512)       0
_________________________________________________________________
conv5_1 (Conv2D)             (None, 12, 12, 512)       2359808
_________________________________________________________________
conv5_2 (Conv2D)             (None, 12, 12, 512)       2359808
_________________________________________________________________
conv5_3 (Conv2D)             (None, 12, 12, 512)       2359808
_________________________________________________________________
pool_5 (MaxPooling2D)        (None, 6, 6, 512)         0
_________________________________________________________________
flatten (Flatten)            (None, 18432)             0
_________________________________________________________________
dense_1 (Dense)              (None, 4096)              75501568
_________________________________________________________________
dense_2 (Dense)              (None, 4096)              16781312
_________________________________________________________________
dense_3 (Dense)              (None, 2)                 8194
=================================================================
Total params: 107,004,610
Trainable params: 107,004,610
Non-trainable params: 0
_________________________________________________________________
</code>```

答: Your training data has 5, (200,200,1) images, that's correct, but target data (y) should be the 5 corresponding labels, with shape (2,). So the shape of y_train should be (5,2). Right now they have the wrong shape.

Body:
I've just started to learn Tensorflow (2.1.0) and Keras (2.3.7) with Python 3.7.7.

I have this network:

def vgg16(input_size = (224,224,3)):
    inputs = Input(input_size, name='input')

    conv1 = Conv2D(64, (3, 3), activation = 'relu', padding = 'same', name ='conv1_1')(inputs)
    conv1 = Conv2D(64, (3, 3), activation = 'relu', padding = 'same', name ='conv1_2')(conv1)
    pool1 = MaxPooling2D(pool_size = (2,2), strides = (2,2), name = 'pool_1')(conv1)

    conv2 = Conv2D(128, (3, 3), activation = 'relu', padding = 'same', name ='conv2_1')(pool1)
    conv2 = Conv2D(128, (3, 3), activation = 'relu', padding = 'same', name ='conv2_2')(conv2)
    pool2 = MaxPooling2D(pool_size = (2,2), strides = (2,2), name = 'pool_2')(conv2)

    conv3 = Conv2D(256, (3, 3), activation = 'relu', padding = 'same', name ='conv3_1')(pool2)
    conv3 = Conv2D(256, (3, 3), activation = 'relu', padding = 'same', name ='conv3_2')(conv3)
    conv3 = Conv2D(256, (3, 3), activation = 'relu', padding = 'same', name ='conv3_3')(conv3)
    pool3 = MaxPooling2D(pool_size = (2,2), strides = (2,2), name = 'pool_3')(conv3)

    conv4 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv4_1')(pool3)
    conv4 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv4_2')(conv4)
    conv4 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv4_3')(conv4)

    conv5 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv5_1')(pool4)
    conv5 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv5_2')(conv5)
    conv5 = Conv2D(512, (3, 3), activation = 'relu', padding = 'same', name ='conv5_3')(conv5)
    pool5 = MaxPooling2D(pool_size = (2,2), strides = (2,2), name = 'pool_5')(conv5)
    flatten = Flatten(name = 'flatten')(pool5)

    dense1 = Dense(units = 4096,activation = "relu", name = 'dense_1')(flatten)
    dense2 = Dense(units = 4096,activation = "relu", name = 'dense_2')(dense1)
    dense3 = Dense(units = 2, activation = "softmax", name = 'dense_3')(dense2)

    opt = Adam(lr=0.001)

    model = Model(inputs = inputs, outputs = dense3, name ='vgg-16')

    model.compile(optimizer=opt, loss=keras.losses.categorical_crossentropy, metrics=['accuracy'])

    return model

And this is the code that use it:

model = vgg16(input_size=(200, 200, 1))

for episode in range(num_episodes):
    selected = np.random.permutation(no_of_samples)[:num_shot + num_query]
    # Create our Support Set.
    support_set = np.array(D[selected[:num_shot]])
    # Create our Query Set.
    query_set = np.array(D[selected[num_query:]])

    X_train = support_set[:,0,:]
    y_train = support_set[:,1,:]

    X_valid = query_set[:,0,:]
    y_valid = query_set[:,1,:]

    results = model.fit(X_train, y_train, epochs=20, batch_size=5,
                        validation_data=(X_valid, y_valid))

X_train, y_train, X_valid and y_valid have a this shape: (5, 200, 200, 1).

But I get this error:

Error when checking target: expected dense_3 to have 2 dimensions, but
  got array with shape (5, 200, 200, 1)

I don't understand why. I have changed the fit call removing the batch_size:

results = model.fit(X_train, y_train, epochs=20, validation_data=(X_valid, y_valid))

But I get the same error:

How can I fix this error?

Maybe, the problem is that I'm using one channel images.

Model summary:

Model: "vgg-16"
_________________________________________________________________
Layer (type)                 Output Shape              Param #
=================================================================
input (InputLayer)           (None, 200, 200, 1)       0
_________________________________________________________________
conv1_1 (Conv2D)             (None, 200, 200, 64)      640
_________________________________________________________________
conv1_2 (Conv2D)             (None, 200, 200, 64)      36928
_________________________________________________________________
pool_1 (MaxPooling2D)        (None, 100, 100, 64)      0
_________________________________________________________________
conv2_1 (Conv2D)             (None, 100, 100, 128)     73856
_________________________________________________________________
conv2_2 (Conv2D)             (None, 100, 100, 128)     147584
_________________________________________________________________
pool_2 (MaxPooling2D)        (None, 50, 50, 128)       0
_________________________________________________________________
conv3_1 (Conv2D)             (None, 50, 50, 256)       295168
_________________________________________________________________
conv3_2 (Conv2D)             (None, 50, 50, 256)       590080
_________________________________________________________________
conv3_3 (Conv2D)             (None, 50, 50, 256)       590080
_________________________________________________________________
pool_3 (MaxPooling2D)        (None, 25, 25, 256)       0
_________________________________________________________________
conv4_1 (Conv2D)             (None, 25, 25, 512)       1180160
_________________________________________________________________
conv4_2 (Conv2D)             (None, 25, 25, 512)       2359808
_________________________________________________________________
conv4_3 (Conv2D)             (None, 25, 25, 512)       2359808
_________________________________________________________________
pool_4 (MaxPooling2D)        (None, 12, 12, 512)       0
_________________________________________________________________
conv5_1 (Conv2D)             (None, 12, 12, 512)       2359808
_________________________________________________________________
conv5_2 (Conv2D)             (None, 12, 12, 512)       2359808
_________________________________________________________________
conv5_3 (Conv2D)             (None, 12, 12, 512)       2359808
_________________________________________________________________
pool_5 (MaxPooling2D)        (None, 6, 6, 512)         0
_________________________________________________________________
flatten (Flatten)            (None, 18432)             0
_________________________________________________________________
dense_1 (Dense)              (None, 4096)              75501568
_________________________________________________________________
dense_2 (Dense)              (None, 4096)              16781312
_________________________________________________________________
dense_3 (Dense)              (None, 2)                 8194
=================================================================
Total params: 107,004,610
Trainable params: 107,004,610
Non-trainable params: 0
_________________________________________________________________


问:
In Hello World flask app, Flask cannot find the app
I am running the minimal Hello World app from the Flask documentation. The code is below. I get no module named "flask.hello." The traceback is also below. I would like to know how to direct the flask to resolve the location of the app. The name of the source file is hello.py. I set

```<code>FLASK_APP='hello.py' and PYTHONPATH="."
</code>```

I start Flask with the command:

```<code>flask run --host=0.0.0.0 --port=3000

</code>```

```<code>from flask import Flask
app=Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello world!"
</code>```

```<code>Traceback (most recent call last):
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 240, in locate_app
    __import__(module_name)
ModuleNotFoundError: No module named 'flask.hello'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 338, in __call__
    self._flush_bg_loading_exception()
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 326, in _flush_bg_loading_exception
    reraise(*exc_info)
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 314, in _load_app
    self._load_unlocked()
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 330, in _load_unlocked
    self._app = rv = self.loader()
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 388, in load_app
    app = locate_app(self, import_name, name)
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 250, in locate_app
    raise NoAppException('Could not import "{name}".'.format(name=module_name))
flask.cli.NoAppException: Could not import "flask.hello".
</code>```

答: Change FLASK_APP='hello.py' to FLASK_APP='hello'

Body:
I am running the minimal Hello World app from the Flask documentation. The code is below. I get no module named "flask.hello." The traceback is also below. I would like to know how to direct the flask to resolve the location of the app. The name of the source file is hello.py. I set

FLASK_APP='hello.py' and PYTHONPATH="."

I start Flask with the command:

flask run --host=0.0.0.0 --port=3000

from flask import Flask
app=Flask(__name__)

@app.route('/')
def hello_world():
    return 'Hello world!"

Traceback (most recent call last):
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 240, in locate_app
    __import__(module_name)
ModuleNotFoundError: No module named 'flask.hello'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 338, in __call__
    self._flush_bg_loading_exception()
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 326, in _flush_bg_loading_exception
    reraise(*exc_info)
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 314, in _load_app
    self._load_unlocked()
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 330, in _load_unlocked
    self._app = rv = self.loader()
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 388, in load_app
    app = locate_app(self, import_name, name)
  File "/home/anna_user2/.venv/projects/web-plots/lib/python3.7/site-packages/flask/cli.py", line 250, in locate_app
    raise NoAppException('Could not import "{name}".'.format(name=module_name))
flask.cli.NoAppException: Could not import "flask.hello".


问:
How to get jupyter cell output to update continuously
I have seen several cases of streamz as well as simple code updating live in the output from a jupyter cell, but when I try this myself I only get one value output unless I run a loop or continually press Ctrl-Enter to update. The simplest example is just a single line of code in a cell:

psutil.cpu_percent()

I've seen videos and gifs showing the output updating continuously, apparently with no extra magics or other special settings and I'd like to see my cell in jupyter lab update in this same way. What am I doing wrong?

More background: This began when I started trying to duplicate the streamz examples in Streaming Dataframes from Matthew Rocklin. I tried the following code:

```<code>source = Random(freq='5ms', interval='100ms')
source.x.sum()
</code>```

Have a look at the example about halfway down the page in the link under 'Jupyter Integration and Streaming Outputs' and you'll see what I mean. In the example, this code generates a continuously updating output below the cell, but when I try it, it delivers only a single value, which only updates if I run the cell again. Since that didn't work as advertised, I tried this other example I'd seen with psutil, and that didn't work either. So I figure there must be something wrong with my jupyter settings, but I don't know what it might be. Again, I realize I might be able to replicate this behavior using a loop, but I want to understand what I'm doing wrong to keep this from working simply as shown.

答:
So I think I've figured this out for myself, although I'm still not entirely sure. I was under the impression that the streamz examples in Streaming Dataframes were running with no additional widgets or code, but then I looked at Matthew Rocklin - Streaming Processing with Dask on YouTube, and roughly at time 12:00 he introduces an async routine to push data into a stream in a loop:

```<code>from tornado import gen
from tornado.ioloop import IOLoop

async def f():
while True:
    await gen.sleep(0.100)
    record = create_record()
    source.emit(record, asynchronous = True)

IOLoop.current().add_callback(f)
</code>```

I can't claim I understand what is going on here, because I'm still a Jupyter novice and never knew anything about asynchronous code before trying these examples, but since this appears to work, I was evidently missing this key information when asking the question.

Body:
I have seen several cases of streamz as well as simple code updating live in the output from a jupyter cell, but when I try this myself I only get one value output unless I run a loop or continually press Ctrl-Enter to update. The simplest example is just a single line of code in a cell:

psutil.cpu_percent()

I've seen videos and gifs showing the output updating continuously, apparently with no extra magics or other special settings and I'd like to see my cell in jupyter lab update in this same way. What am I doing wrong?

More background: This began when I started trying to duplicate the streamz examples in Streaming Dataframes from Matthew Rocklin. I tried the following code:

source = Random(freq='5ms', interval='100ms')
source.x.sum()

Have a look at the example about halfway down the page in the link under 'Jupyter Integration and Streaming Outputs' and you'll see what I mean. In the example, this code generates a continuously updating output below the cell, but when I try it, it delivers only a single value, which only updates if I run the cell again. Since that didn't work as advertised, I tried this other example I'd seen with psutil, and that didn't work either. So I figure there must be something wrong with my jupyter settings, but I don't know what it might be. Again, I realize I might be able to replicate this behavior using a loop, but I want to understand what I'm doing wrong to keep this from working simply as shown.

Body:
So I think I've figured this out for myself, although I'm still not entirely sure. I was under the impression that the streamz examples in Streaming Dataframes were running with no additional widgets or code, but then I looked at Matthew Rocklin - Streaming Processing with Dask on YouTube, and roughly at time 12:00 he introduces an async routine to push data into a stream in a loop:

from tornado import gen
from tornado.ioloop import IOLoop

async def f():
while True:
    await gen.sleep(0.100)
    record = create_record()
    source.emit(record, asynchronous = True)

IOLoop.current().add_callback(f)

I can't claim I understand what is going on here, because I'm still a Jupyter novice and never knew anything about asynchronous code before trying these examples, but since this appears to work, I was evidently missing this key information when asking the question.


问:
Apache 2.2 mod_rewrite help
I am trying to get Apache 2.2 mod_rewrite to get clean urls.
I have links such as

```<code><ul>
<li><a href="index.php?view=pageName">Page Name</a></li>
<li><a href="index.php?view=pageName2">Page Name2</a></li>
<li><a href="index.php?view=pageName3">Page Name3</a></li>
</ul>
</code>```

and url comes out to be

```<code>http://example.com/user/index.php?view=pageName
</code>```

I would like to clean the url in the address bar it to this

```<code>http://example.com/user/pageName
</code>```

Edit: This is what's in my httpd.conf if it's any use.

```<code><Directory "C:/Apache2.2/htdocs/user">
    Options Indexes FollowSymLinks
    AllowOverride all
    order allow,deny
    Allow from all
</Directory>
</code>```

Using phpinfo() I have verified that mod_rewrite is loaded and I have this in my .htaccess (user file, Not root .htaccess) and not virtual user on apache

```<code>RewriteEngine on
RewriteBase /user/ #Edited rewrite base added in, but not helping much.
RewriteOptions Inherit
RewriteRule ^/user/([a-zA-Z])/?$ index.php?view=$1  [NC,L]
</code>```

Edit: the rest of my .htaccess

```<code>#Ensure browser reads Header
Header unset ETag
FileETag None
Header unset Last-Modified

#Set caching expires
Header set Expires On
ExpiresDefault "access plus 30 days"

#gzip
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>
</code>```

does not work the same on all menu links which are identical in html structure, and not working properly. IE: It sends me to http://example.com/user/?view=pageName, but is loading the root HTML file content.

If I change this line

```<code>RewriteRule ^/user/([a-zA-Z])/?$ index.php?view=$1  [NC,L]
</code>```

to

```<code>RewriteRule ^index\.php$ http://www.google.com  [NC,L]
</code>```

I get sent to google as expected. So obviously I must be doing something wrong with the matching and replacing, but what am I doing wrong?
Thanks in advance.

Edit:
access.log and error.log are error free.

答:
```<code>RewriteRule ^/user/([a-zA-Z])?$ index.php?view=$1  [NC,L]
</code>```

try this..(one slash removed)

Title: Apache 2.2 mod_rewrite help

Body:
I am trying to get Apache 2.2 mod_rewrite to get clean urls.
I have links such as

Page Name

Page Name2

Page Name3

and url comes out to be

http://example.com/user/index.php?view=pageName

I would like to clean the url in the address bar it to this

http://example.com/user/pageName

Edit: This is what's in my httpd.conf if it's any use.

<Directory "C:/Apache2.2/htdocs/user">
    Options Indexes FollowSymLinks
    AllowOverride all
    order allow,deny
    Allow from all
</Directory>

Using phpinfo() I have verified that mod_rewrite is loaded and I have this in my .htaccess (user file, Not root .htaccess) and not virtual user on apache

RewriteEngine on
RewriteBase /user/ #Edited rewrite base added in, but not helping much.
RewriteOptions Inherit
RewriteRule ^/user/([a-zA-Z])/?$ index.php?view=$1  [NC,L]

Edit: the rest of my .htaccess

#Ensure browser reads Header
Header unset ETag
FileETag None
Header unset Last-Modified

#Set caching expires
Header set Expires On
ExpiresDefault "access plus 30 days"

#gzip
<FilesMatch "\.(js|css)$">
SetOutputFilter DEFLATE
</FilesMatch>

does not work the same on all menu links which are identical in html structure, and not working properly. IE: It sends me to http://example.com/user/?view=pageName, but is loading the root HTML file content.

If I change this line

RewriteRule ^/user/([a-zA-Z])/?$ index.php?view=$1  [NC,L]

to

RewriteRule ^index\.php$ http://www.google.com  [NC,L]

I get sent to google as expected. So obviously I must be doing something wrong with the matching and replacing, but what am I doing wrong?
Thanks in advance.

Edit:
access.log and error.log are error free.

Body:
RewriteRule ^/user/([a-zA-Z])?$ index.php?view=$1  [NC,L]

try this..(one slash removed)


问:
QTabWidget insert a QSplitter can't switch when the splitter disabled
I insert a QFrame and QTabWidget in the QSplitter. And I wanna forbidden to adjust the size of elements in QSplitter. So I call method of 'setDisabled' in QSplitter. It's useful for disabling resizing the elements. But I also can't switch tab of QTabWidget. Who can give me some suggestions? Thanks very much......

```<code>import sys
from PyQt5.QtWidgets import QApplication, QWidget, QSplitter, QHBoxLayout, QFrame, QTabWidget
from PyQt5.QtCore import Qt
class Example1(QWidget):
    def __init__(self):
        super().__init__()
        self.setGeometry(0, 0, 600, 600)
        self.setWindowTitle("Demo")
        self.layout = QHBoxLayout()

        top_frame = QFrame()
        top_frame.setFrameShape(QFrame.StyledPanel)

        bottom_frame = QTabWidget(self)
        tab1 = QWidget()
        tab2 = QWidget()
        bottom_frame.setTabText(0, "Generic")
        bottom_frame.setTabText(1, "Other")
        bottom_frame.addTab(tab1, "Tab 1")
        bottom_frame.addTab(tab2, "Tab 2")

        splitter = QSplitter()
        splitter.setOrientation(Qt.Vertical)
        splitter.addWidget(top_frame)
        splitter.addWidget(bottom_frame)
        splitter.setSizes([300, 300])
        **splitter.setDisabled(True)**

        self.layout.addWidget(splitter)
        self.setLayout(self.layout)
        self.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example1()
    sys.exit(app.exec_())

</code>```

the running result of the program

答:
When you disable a widget you also disable its children, so disabling the QSplitter also disables the QTabWidget.

A possible solution is enable or disable the handles:

```<code>import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
    QApplication,
    QFrame,
    QHBoxLayout,
    QSplitter,
    QSplitterHandle,
    QTabWidget,
    QWidget,
)

class CustomSplitter(QSplitter):
    @property
    def enabled(self):
        if not hasattr(self, "_enabled"):
            self._enabled = True
        return self._enabled

    @enabled.setter
    def enabled(self, d):
        self._enabled = d
        for i in range(self.count()):
            self.handle(i).setEnabled(self.enabled)

    def createHandle(self):
        handle = super().createHandle()
        handle.setEnabled(self.enabled)
        return handle

class Example1(QWidget):
    def __init__(self):
        super().__init__()
        self.setGeometry(0, 0, 600, 600)
        self.setWindowTitle("Demo")
        self.layout = QHBoxLayout()

        top_frame = QFrame()
        top_frame.setFrameShape(QFrame.StyledPanel)

        bottom_frame = QTabWidget(self)
        tab1 = QWidget()
        tab2 = QWidget()
        bottom_frame.setTabText(0, "Generic")
        bottom_frame.setTabText(1, "Other")
        bottom_frame.addTab(tab1, "Tab 1")
        bottom_frame.addTab(tab2, "Tab 2")

        splitter = CustomSplitter()
        splitter.setOrientation(Qt.Vertical)
        splitter.addWidget(top_frame)
        splitter.addWidget(bottom_frame)
        splitter.setSizes([300, 300])

        splitter.enabled = False

        self.layout.addWidget(splitter)
        self.setLayout(self.layout)
        self.show()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    ex = Example1()
    sys.exit(app.exec_())
</code>```

Body:
I insert a QFrame and QTabWidget in the QSplitter. And I wanna forbidden to adjust the size of elements in QSplitter. So I call method of 'setDisabled' in QSplitter. It's useful for disabling resizing the elements. But I also can't switch tab of QTabWidget. Who can give me some suggestions? Thanks very much......

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QSplitter, QHBoxLayout, QFrame, QTabWidget
from PyQt5.QtCore import Qt
class Example1(QWidget):
    def __init__(self):
        super().__init__()
        self.setGeometry(0, 0, 600, 600)
        self.setWindowTitle("Demo")
        self.layout = QHBoxLayout()

        top_frame = QFrame()
        top_frame.setFrameShape(QFrame.StyledPanel)

        bottom_frame = QTabWidget(self)
        tab1 = QWidget()
        tab2 = QWidget()
        bottom_frame.setTabText(0, "Generic")
        bottom_frame.setTabText(1, "Other")
        bottom_frame.addTab(tab1, "Tab 1")
        bottom_frame.addTab(tab2, "Tab 2")

        splitter = QSplitter()
        splitter.setOrientation(Qt.Vertical)
        splitter.addWidget(top_frame)
        splitter.addWidget(bottom_frame)
        splitter.setSizes([300, 300])
        **splitter.setDisabled(True)**

        self.layout.addWidget(splitter)
        self.setLayout(self.layout)
        self.show()

if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = Example1()
    sys.exit(app.exec_())

the running result of the program

Body:
When you disable a widget you also disable its children, so disabling the QSplitter also disables the QTabWidget.

A possible solution is enable or disable the handles:

import sys
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
    QApplication,
    QFrame,
    QHBoxLayout,
    QSplitter,
    QSplitterHandle,
    QTabWidget,
    QWidget,
)

class CustomSplitter(QSplitter):
    @property
    def enabled(self):
        if not hasattr(self, "_enabled"):
            self._enabled = True
        return self._enabled

    @enabled.setter
    def enabled(self, d):
        self._enabled = d
        for i in range(self.count()):
            self.handle(i).setEnabled(self.enabled)

    def createHandle(self):
        handle = super().createHandle()
        handle.setEnabled(self.enabled)
        return handle

class Example1(QWidget):
    def __init__(self):
        super().__init__()
        self.setGeometry(0, 0, 600, 600)
        self.setWindowTitle("Demo")
        self.layout = QHBoxLayout()

        top_frame = QFrame()
        top_frame.setFrameShape(QFrame.StyledPanel)

        bottom_frame = QTabWidget(self)
        tab1 = QWidget()
        tab2 = QWidget()
        bottom_frame.setTabText(0, "Generic")
        bottom_frame.setTabText(1, "Other")
        bottom_frame.addTab(tab1, "Tab 1")
        bottom_frame.addTab(tab2, "Tab 2")

        splitter = CustomSplitter()
        splitter.setOrientation(Qt.Vertical)
        splitter.addWidget(top_frame)
        splitter.addWidget(bottom_frame)
        splitter.setSizes([300, 300])

        splitter.enabled = False

        self.layout.addWidget(splitter)
        self.setLayout(self.layout)
        self.show()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    ex = Example1()
    sys.exit(app.exec_())


答:
You can use df.groupby here.

```<code>df.groupby('col3').col1.apply(list).tolist()
# [['abc', 'ghg', 'xyz'], ['asd', 'dfg']]
</code>```

Title: how to select rows in a data frame those are similar on basis of column values

Body:
You can use df.groupby here.

df.groupby('col3').col1.apply(list).tolist()
# [['abc', 'ghg', 'xyz'], ['asd', 'dfg']]


问:
Flask WT-Form not getting Validated
My Flask form is not getting validated. Tried everything. form.validate() is not validating, although, there is no validation present. Is there any way out of this situation?

HTML Code

```<code><body>
    <form method="POST" action = "{{ url_for('/generate') }}" novalidate>
        {{ form.csrf_token }}
        {{ form.hidden_tag() }} <br>
        {{ form.IsAssistantComm() }} <br>
        {{ form.Submit() }} <br>
    </form>
</body>
</code>```

Flask Code

```<code>class GeneratorForm(FlaskForm):
    To = StringField('TO')
    IsAssistantComm = BooleanField('Is Assistant Commissioner?')
    Submit = SubmitField('Generate')

@app.route('/generate', methods=['GET', 'POST'])
def generate():
    form = GeneratorForm()
    if form.is_submitted():
        print("submitted")
    if form.validate():
        print("valid")
    if form.validate_on_submit():
        print("I am here")
        IsAssistantComm = form.IsAssistantComm.data
        return redirect('/')
    return render_template('main.html', form=form)
</code>```

Program Stacktrace:

```<code>
 * Running on http://127.0.0.1:5090/ (Press CTRL+C to quit)
submitted
127.0.0.1 - - [30/May/2020 18:48:08] "POST /generate HTTP/1.1" 200 -
submitted
127.0.0.1 - - [30/May/2020 18:48:09] "POST /generate HTTP/1.1" 200 -

</code>```

答:
I might be mistaken here, but I think it just might be the fact that you have no form validation in your GenerateForm class, do something like this :

```<code>class GeneratorForm(FlaskForm):
To = StringField('TO')
IsAssistantComm = BooleanField('Is Assistant Commissioner?', validators =[DataRequired()])
Submit = SubmitField('Generate')
</code>```

Let me know if that fixes it :D

Title: Flask WT-Form not getting Validated

Body:
My Flask form is not getting validated. Tried everything. form.validate() is not validating, although, there is no validation present. Is there any way out of this situation?

HTML Code

    <form method="POST" action = "{{ url_for('/generate') }}" novalidate>
        {{ form.csrf_token }}
        {{ form.hidden_tag() }}

        {{ form.IsAssistantComm() }}

        {{ form.Submit() }}

    </form>

Flask Code

class GeneratorForm(FlaskForm):
    To = StringField('TO')
    IsAssistantComm = BooleanField('Is Assistant Commissioner?')
    Submit = SubmitField('Generate')

@app.route('/generate', methods=['GET', 'POST'])
def generate():
    form = GeneratorForm()
    if form.is_submitted():
        print("submitted")
    if form.validate():
        print("valid")
    if form.validate_on_submit():
        print("I am here")
        IsAssistantComm = form.IsAssistantComm.data
        return redirect('/')
    return render_template('main.html', form=form)

Program Stacktrace:

 * Running on http://127.0.0.1:5090/ (Press CTRL+C to quit)
submitted
127.0.0.1 - - [30/May/2020 18:48:08] "POST /generate HTTP/1.1" 200 -
submitted
127.0.0.1 - - [30/May/2020 18:48:09] "POST /generate HTTP/1.1" 200 -

Body:
I might be mistaken here, but I think it just might be the fact that you have no form validation in your GenerateForm class, do something like this :

class GeneratorForm(FlaskForm):
To = StringField('TO')
IsAssistantComm = BooleanField('Is Assistant Commissioner?', validators =[DataRequired()])
Submit = SubmitField('Generate')

Let me know if that fixes it :D


问:
How to import existing Git repository into another?
I have a Git repository in a folder called XXX, and I have second Git repository called YYY.

I want to import the XXX repository into the YYY repository as a subdirectory named ZZZ and add all XXX's change history to YYY.

Folder structure before:

```<code>├── XXX
│   ├── .git
│   └── (project files)
└── YYY
    ├── .git
    └── (project files)
</code>```

Folder structure after:

```<code>YYY
├── .git  <-- This now contains the change history from XXX
├──  ZZZ  <-- This was originally XXX
│    └── (project files)
└──  (project files)
</code>```

Can this be done, or must I resort to using sub-modules?

答:
Let me use names a (in place of XXX and ZZZ) and b (in place of YYY), since that makes the description a bit easier to read.

Say you want to merge repository a into b (I'm assuming they're located alongside one another):

```<code>cd a
git filter-repo --to-subdirectory-filter a
cd ..
cd b
git remote add a ../a
git fetch a
git merge --allow-unrelated-histories a/master
git remote remove a
</code>```

For this you need git-filter-repo installed (filter-branch is discouraged).

An example of merging 2 big repositories, putting one of them into a subdirectory: https://gist.github.com/x-yuri/9890ab1079cf4357d6f269d073fd9731

More on it here.

Body:
I have a Git repository in a folder called XXX, and I have second Git repository called YYY.

I want to import the XXX repository into the YYY repository as a subdirectory named ZZZ and add all XXX's change history to YYY.

Folder structure before:

├── XXX
│   ├── .git
│   └── (project files)
└── YYY
    ├── .git
    └── (project files)

Folder structure after:

YYY
├── .git  <-- This now contains the change history from XXX
├──  ZZZ  <-- This was originally XXX
│    └── (project files)
└──  (project files)

Can this be done, or must I resort to using sub-modules?

Body:
Let me use names a (in place of XXX and ZZZ) and b (in place of YYY), since that makes the description a bit easier to read.

Say you want to merge repository a into b (I'm assuming they're located alongside one another):

cd a
git filter-repo --to-subdirectory-filter a
cd ..
cd b
git remote add a ../a
git fetch a
git merge --allow-unrelated-histories a/master
git remote remove a

For this you need git-filter-repo installed (filter-branch is discouraged).

An example of merging 2 big repositories, putting one of them into a subdirectory: https://gist.github.com/x-yuri/9890ab1079cf4357d6f269d073fd9731

More on it here.


问:
Extract Numeric and Special Characters Separately
I have column in a table with values stored as

```<code>Cost

499.00
£ 7.75
£ 7.75
250.00
£ 5.99
$ 6.05
</code>```

Now, I need to store these values to another table like

```<code>Currency     Cost
RS           499.00
£            7.75
£            7.75
RS           250.00
£            5.99
$            6.05
</code>```

Plz let me the Query how to do this....

答:
```<code>SELECT
  Currency = COALESCE(NULLIF(LEFT(Cost, CostStart - 1), ''), 'RS'),
  Cost = SUBSTRING(Cost, CostStart, LEN(Cost) - CostStart + 1)
FROM (
  SELECT
    Cost,
    CostStart = PATINDEX('%[0-9]%', Cost)
  FROM atable
) s
</code>```

This will work even when there's no space between the currency symbol and the sum.

Body:
I have column in a table with values stored as

Cost

499.00
£ 7.75
£ 7.75
250.00
£ 5.99
$ 6.05

Now, I need to store these values to another table like

Currency     Cost
RS           499.00
£            7.75
£            7.75
RS           250.00
£            5.99
$            6.05

Plz let me the Query how to do this....

Body:
SELECT
  Currency = COALESCE(NULLIF(LEFT(Cost, CostStart - 1), ''), 'RS'),
  Cost = SUBSTRING(Cost, CostStart, LEN(Cost) - CostStart + 1)
FROM (
  SELECT
    Cost,
    CostStart = PATINDEX('%[0-9]%', Cost)
  FROM atable
) s

This will work even when there's no space between the currency symbol and the sum.


问:
Facebook and Linkedin Share buttons
I have put up facebook and Linkedin share buttons on a page in my website. I have set the fb opengraph tags for that page. I have also set up the meta tags with description i want to share on FB and Linkedin, but when i share the content on facebook i get a wrong url and description shared. Please have a look and give me any ideas where i am wrong.
This is the page</p>

答:
For those who want to test their page against both Facebook and LinkedIn...

Facebook Page Debugger

LinkedIn Post Inspector

Title: Facebook and Linkedin Share buttons


问:
error when installing pygame on mac: error: command 'gcc' failed with exit status 1
```<code>ERROR: Command errored out with exit status 1:
     command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/72/zjnf9b152hd44xpy_m0_jm2m0000gn/T/pip-install-r7jr9ckl/pygame/setup.py'"'"'; __file__='"'"'/private/var/folders/72/zjnf9b152hd44xpy_m0_jm2m0000gn/T/pip-install-r7jr9ckl/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/72/zjnf9b152hd44xpy_m0_jm2m0000gn/T/pip-record-fwxqrl0l/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/andreamathis/Library/Python/3.8/include/python3.8/pygame
         cwd: /private/var/folders/72/zjnf9b152hd44xpy_m0_jm2m0000gn/T/pip-install-r7jr9ckl/pygame/
    Complete output (219 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.8
    creating build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/_camera_opencv_highgui.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/_camera_vidcapture.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/_dummybackend.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/_numpysndarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/_numpysurfarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/camera.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/colordict.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/compat.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/cursors.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/draw_py.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/font.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/freetype.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/ftfont.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/locals.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/macosx.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/midi.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/pkgdata.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/sndarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/sprite.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/surfarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/sysfont.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    copying src_py/version.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/threads
    copying src_py/threads/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/threads
    copying src_py/threads/Py25Queue.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/threads
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/__main__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/base_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/blit_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/bufferproxy_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/camera_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/cdrom_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/cdrom_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/color_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/compat_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/constants_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/cursors_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/display_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/draw_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/event_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/fastevent_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/fastevent_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/font_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/font_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/freetype_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/freetype_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/ftfont_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/ftfont_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/gfxdraw_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/image__save_gl_surface_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/image_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/image_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/imageext_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/imageext_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/joystick_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/key_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/mask_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/math_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/midi_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/midi_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/mixer_music_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/mixer_music_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/mixer_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/mixer_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/mouse_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/overlay_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/overlay_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/pixelarray_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/pixelcopy_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/rect_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/rwobject_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/scrap_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/scrap_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/sndarray_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/sndarray_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/sprite_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/surface_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/surfarray_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/surfarray_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/surflock_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/sysfont_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/test_test_.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/threads_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/time_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/touch_tags.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/touch_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/transform_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    copying test/version_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
    copying test/test_utils/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
    copying test/test_utils/arrinter.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
    copying test/test_utils/async_sub.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
    copying test/test_utils/buftools.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
    copying test/test_utils/endian.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
    copying test/test_utils/png.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
    copying test/test_utils/run_tests.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
    copying test/test_utils/test_machinery.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
    copying test/test_utils/test_runner.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/test_utils
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests
    copying test/run_tests__tests/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests
    copying test/run_tests__tests/run_tests__test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
    copying test/run_tests__tests/all_ok/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
    copying test/run_tests__tests/all_ok/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
    copying test/run_tests__tests/all_ok/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
    copying test/run_tests__tests/all_ok/fake_4_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
    copying test/run_tests__tests/all_ok/fake_5_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
    copying test/run_tests__tests/all_ok/fake_6_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
    copying test/run_tests__tests/all_ok/no_assertions__ret_code_of_1__test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
    copying test/run_tests__tests/all_ok/zero_tests_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/all_ok
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/failures1
    copying test/run_tests__tests/failures1/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/failures1
    copying test/run_tests__tests/failures1/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/failures1
    copying test/run_tests__tests/failures1/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/failures1
    copying test/run_tests__tests/failures1/fake_4_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/failures1
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete
    copying test/run_tests__tests/incomplete/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete
    copying test/run_tests__tests/incomplete/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete
    copying test/run_tests__tests/incomplete/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/infinite_loop
    copying test/run_tests__tests/infinite_loop/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/infinite_loop
    copying test/run_tests__tests/infinite_loop/fake_1_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/infinite_loop
    copying test/run_tests__tests/infinite_loop/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/infinite_loop
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stderr
    copying test/run_tests__tests/print_stderr/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stderr
    copying test/run_tests__tests/print_stderr/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stderr
    copying test/run_tests__tests/print_stderr/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stderr
    copying test/run_tests__tests/print_stderr/fake_4_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stderr
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stdout
    copying test/run_tests__tests/print_stdout/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stdout
    copying test/run_tests__tests/print_stdout/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stdout
    copying test/run_tests__tests/print_stdout/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stdout
    copying test/run_tests__tests/print_stdout/fake_4_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/print_stdout
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete_todo
    copying test/run_tests__tests/incomplete_todo/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete_todo
    copying test/run_tests__tests/incomplete_todo/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete_todo
    copying test/run_tests__tests/incomplete_todo/fake_3_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/incomplete_todo
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/exclude
    copying test/run_tests__tests/exclude/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/exclude
    copying test/run_tests__tests/exclude/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/exclude
    copying test/run_tests__tests/exclude/invisible_tag_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/exclude
    copying test/run_tests__tests/exclude/magic_tag_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/exclude
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/timeout
    copying test/run_tests__tests/timeout/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/timeout
    copying test/run_tests__tests/timeout/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/timeout
    copying test/run_tests__tests/timeout/sleep_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/timeout
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
    copying test/run_tests__tests/everything/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
    copying test/run_tests__tests/everything/fake_2_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
    copying test/run_tests__tests/everything/incomplete_todo_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
    copying test/run_tests__tests/everything/magic_tag_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
    copying test/run_tests__tests/everything/sleep_test.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/tests/run_tests__tests/everything
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/docs
    copying docs/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/docs
    copying docs/__main__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/docs
    creating build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/__init__.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/aacircle.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/aliens.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/arraydemo.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/audiocapture.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/blend_fill.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/blit_blends.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/camera.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/chimp.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/cursors.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/dropevent.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/eventlist.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/fastevents.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/fonty.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/freetype_misc.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/glcube.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/headless_no_windows_needed.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/liquid.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/mask.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/midi.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/moveit.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/oldalien.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/overlay.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/pixelarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/playmus.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/prevent_display_stretching.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/scaletest.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/scrap_clipboard.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/scroll.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/sound.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/sound_array_demos.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/stars.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/testsprite.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/textinput.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/vgrade.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    copying examples/video.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
    running build_ext
    building 'pygame.gfxdraw' extension
    creating build/temp.macosx-10.9-x86_64-3.8
    creating build/temp.macosx-10.9-x86_64-3.8/src_c
    creating build/temp.macosx-10.9-x86_64-3.8/src_c/SDL_gfx
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DENABLE_NEWBUF=1 -I/NEED_INC_PATH_FIX -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src_c/gfxdraw.c -o build/temp.macosx-10.9-x86_64-3.8/src_c/gfxdraw.o
    In file included from src_c/gfxdraw.c:33:
    In file included from src_c/pygame.h:32:
    src_c/_pygame.h:216:10: fatal error: 'SDL.h' file not found
    #include <SDL.h>
             ^~~~~~~
    1 error generated.
    ---
    For help with compilation see:
        https://www.pygame.org/wiki/MacCompile
    To contribute to pygame development see:
        https://www.pygame.org/contribute.html
    ---
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/72/zjnf9b152hd44xpy_m0_jm2m0000gn/T/pip-install-r7jr9ckl/pygame/setup.py'"'"'; __file__='"'"'/private/var/folders/72/zjnf9b152hd44xpy_m0_jm2m0000gn/T/pip-install-r7jr9ckl/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/var/folders/72/zjnf9b152hd44xpy_m0_jm2m0000gn/T/pip-record-fwxqrl0l/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/andreamathis/Library/Python/3.8/include/python3.8/pygame Check the logs for full command output.
</code>```

答: I solved the problem creating a venv with previous Python version 3.7.7 instead version 3.8.</p>