问:
DataSet Value in Jquery C#
I have one page in which, URL contains Querystring Value.

QSecID=164&QTempId=55&QSecName=New%20Temp%20Bt

When the page loads them and tries to get the value it works fine.

```<code>$(document).ready(function() {

      function getUrlParameter(name) {
        name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
        var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
        var results = regex.exec(location.search);
        return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
      };
      var urlName = getUrlParameter('QSecName');
      alert(urlName);
      getImageData(urlName); //Pass Query String Value to Function
      });
</code>```

Now I am passing this value to C#, ASPX.CS page and try to fetch the data based on QSecName.
But i got error. Here is my Jquery function.

```<code>function getImageData(name) {

  // alert(nextDay);
  $.ajax({

    type: "POST",

    url: "Section.aspx/GetImageData",

    //data: '',
    data: JSON.stringify({
      "dataSecName": name
    }),

    contentType: "application/json; charset=utf-8",

    dataType: "json",

    success: function(data) {
      alert("Success");
      alert(JSON.parse(data.d));

    }

  });
}

</code>```

My C# Page returns the DataSet in Jquery.

```<code>[WebMethod()]
public static string GetImageData(string dataSecName)
//public static string GetRole()
{
  clsSection objSectNew = new clsSection();
  DataSet DS = new DataSet();
  DS = objSectNew.GetImageDataByJQ(dataSecName);
  return JsonConvert.SerializeObject(DS);
}
</code>```

Edit Code 1
Here is my SQL Statement Which is get executed when i run the page and

```<code>DS = objSectNew.GetImageDataByJQ(dataSecName);
</code>```

this method pass the query string value in to execute the Stored Procedure.

```<code>select mhp.ImageName,mhp.HotSpotID,imgdetail.XCordinate,imgdetail.YCordinate
        from tbl_SOAPDetailsInfo e inner join  M_ImageHotSpot mhp on e.ImgHotSpotName=mhp.ImgHotSpotNameByUser
        inner join M_ImageHotSpotDetail imgdetail on mhp.HotSpotID=imgdetail.HotspotIDFK where e.SOAP_D_Name='New Temp Bt'
</code>```

I want to use my XCordinate, YCordinate and ImageName to display image using jquery. but Inside the alert BOX

```<code>**[object] [object]**
</code>```

error display. How can i get and assign this value X AND Y value and display in DIV.

Edit Code 2

```<code>ImageName               XCordinate  YCordinate
$parent in angularjs.png    1146    590
$parent in angularjs.png    1216    588
$parent in angularjs.png    1188    626
$parent in angularjs.png    1162    582
$parent in angularjs.png    1193    586
</code>```

The Database Value. JSON FORMAT DATA

```<code>{"d":"{\"Table\":[{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1146\",\"YCordinate\":\"590\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1216\",\"YCordinate\":\"588\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1188\",\"YCordinate\":\"626\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1162\",\"YCordinate\":\"582\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1193\",\"YCordinate\":\"586\"}]}"}
</code>```

答:
So as per your question [object] [object] is not an error. It means you cannot fetch it in a correct manner.

Though I am not sure what kind of data you are sending from your back-end code in data But you could try following way,

```<code>     var data = "{\"Table\":[{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1146\",\"YCordinate\":\"590\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1216\",\"YCordinate\":\"588\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1188\",\"YCordinate\":\"626\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1162\",\"YCordinate\":\"582\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1193\",\"YCordinate\":\"586\"}]}"

            var obj = JSON.parse(data);

            console.log(obj.Table);
            var tableObj = obj.Table

            console.log(obj.Table);

            var arrayLength = tableObj.length;

            for (var i = 0; i < arrayLength; i++) {
                console.log(tableObj[i].ImageName);
                console.log(tableObj[i].XCordinate);
                console.log(tableObj[i].YCordinate);
                alert(tableObj[i].YCordinate);
               }
</code>```

So now if you replace your code with above sample your code should look like below:

```<code> function getImageData(name) {
            // alert(nextDay);
            $.ajax({
                type: "POST",
                url: "Section.aspx/GetImageData",
                data: JSON.stringify({
                    "dataSecName": name
                }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var obj = JSON.parse(data);

        console.log(obj.Table);
        var tableObj = obj.Table

        console.log(obj.Table);

        var arrayLength = tableObj.length;

        for (var i = 0; i < arrayLength; i++) {
            console.log(tableObj[i].ImageName);
            console.log(tableObj[i].XCordinate);
            console.log(tableObj[i].YCordinate);
            alert(tableObj[i].YCordinate);
                }

            });
        }
</code>```

Note : Try to debug in browser console you would understand object notation more details.

See the screen shot how would you do that

Hope this would help

Title: DataSet Value in Jquery C#

Body:
I have one page in which, URL contains Querystring Value.

QSecID=164&QTempId=55&QSecName=New%20Temp%20Bt

When the page loads them and tries to get the value it works fine.

$(document).ready(function() {

      function getUrlParameter(name) {
        name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
        var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
        var results = regex.exec(location.search);
        return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
      };
      var urlName = getUrlParameter('QSecName');
      alert(urlName);
      getImageData(urlName); //Pass Query String Value to Function
      });

Now I am passing this value to C#, ASPX.CS page and try to fetch the data based on QSecName.
But i got error. Here is my Jquery function.

function getImageData(name) {

  // alert(nextDay);
  $.ajax({

    type: "POST",

    url: "Section.aspx/GetImageData",

    //data: '',
    data: JSON.stringify({
      "dataSecName": name
    }),

    contentType: "application/json; charset=utf-8",

    dataType: "json",

    success: function(data) {
      alert("Success");
      alert(JSON.parse(data.d));

    }

  });
}

My C# Page returns the DataSet in Jquery.

[WebMethod()]
public static string GetImageData(string dataSecName)
//public static string GetRole()
{
  clsSection objSectNew = new clsSection();
  DataSet DS = new DataSet();
  DS = objSectNew.GetImageDataByJQ(dataSecName);
  return JsonConvert.SerializeObject(DS);
}

Edit Code 1
Here is my SQL Statement Which is get executed when i run the page and

DS = objSectNew.GetImageDataByJQ(dataSecName);

this method pass the query string value in to execute the Stored Procedure.

select mhp.ImageName,mhp.HotSpotID,imgdetail.XCordinate,imgdetail.YCordinate
        from tbl_SOAPDetailsInfo e inner join  M_ImageHotSpot mhp on e.ImgHotSpotName=mhp.ImgHotSpotNameByUser
        inner join M_ImageHotSpotDetail imgdetail on mhp.HotSpotID=imgdetail.HotspotIDFK where e.SOAP_D_Name='New Temp Bt'

I want to use my XCordinate, YCordinate and ImageName to display image using jquery. but Inside the alert BOX

**[object] [object]**

error display. How can i get and assign this value X AND Y value and display in DIV.

Edit Code 2

ImageName               XCordinate  YCordinate
$parent in angularjs.png    1146    590
$parent in angularjs.png    1216    588
$parent in angularjs.png    1188    626
$parent in angularjs.png    1162    582
$parent in angularjs.png    1193    586

The Database Value. JSON FORMAT DATA

{"d":"{\"Table\":[{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1146\",\"YCordinate\":\"590\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1216\",\"YCordinate\":\"588\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1188\",\"YCordinate\":\"626\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1162\",\"YCordinate\":\"582\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1193\",\"YCordinate\":\"586\"}]}"}

Body:
So as per your question [object] [object] is not an error. It means you cannot fetch it in a correct manner.

Though I am not sure what kind of data you are sending from your back-end code in data But you could try following way,

     var data = "{\"Table\":[{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1146\",\"YCordinate\":\"590\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1216\",\"YCordinate\":\"588\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1188\",\"YCordinate\":\"626\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1162\",\"YCordinate\":\"582\"},{\"ImageName\":\"$parent in angularjs.png\",\"ImagePath\":\"~/Administration/imageHotspot/$parent in angularjs.png\",\"HotSpotID\":11,\"XCordinate\":\"1193\",\"YCordinate\":\"586\"}]}"

            var obj = JSON.parse(data);

            console.log(obj.Table);
            var tableObj = obj.Table

            console.log(obj.Table);

            var arrayLength = tableObj.length;

            for (var i = 0; i < arrayLength; i++) {
                console.log(tableObj[i].ImageName);
                console.log(tableObj[i].XCordinate);
                console.log(tableObj[i].YCordinate);
                alert(tableObj[i].YCordinate);
               }

So now if you replace your code with above sample your code should look like below:

 function getImageData(name) {
            // alert(nextDay);
            $.ajax({
                type: "POST",
                url: "Section.aspx/GetImageData",
                data: JSON.stringify({
                    "dataSecName": name
                }),
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var obj = JSON.parse(data);

        console.log(obj.Table);
        var tableObj = obj.Table

        console.log(obj.Table);

        var arrayLength = tableObj.length;

        for (var i = 0; i < arrayLength; i++) {
            console.log(tableObj[i].ImageName);
            console.log(tableObj[i].XCordinate);
            console.log(tableObj[i].YCordinate);
            alert(tableObj[i].YCordinate);
                }

            });
        }

Note : Try to debug in browser console you would understand object notation more details.

See the screen shot how would you do that

Hope this would help


来源: stackexchange

问:
CV MSE almost equals Test MSE, but Train MSE = 0, is it an overfitting problem?

I am training a decisoin tree model and i got the (see picture) as results, so basically i am a bit confused about the result.

Given it's a school project, so i am training a model based on 969 lines only and 18 features, and without any feature engineering.

Thank you in advance for your response.

答: there is no overfitting since you got a test score almost equals CV score. However try to reproduce your system with random train/dev/test sets to assure that you get the same results </p>

ContentLicense: CC BY-SA 4.0


问:
Convert datetime string to local datetime
I have an API that returns a datetime string in this format 2020-02-15T06:51:00.000Z in the Eastern US timezone.

I am trying to convert it to my local timezone and I have tried simply passing it into a new date constructor like this new Date('2020-02-15T06:51:00.000Z') with no success.

How can I convert it to my local timezone?

答:
You could try like:

new Date().toLocaleString("en-US", {timeZone: "America/New_York"})


问:
Mono::then returns null
I'm relatively new to reactive programming.
My question is regarding Mono::then

What I want to do is, extract the body from incoming request, set it to a static variable.
Once that is done, send a response saying that the service has started.
But the following code always returns "Service started for: null".

I thought Mono::then should run after the first mono completes(in this case, after setting the static variable) and return "Service started for: a,b,c".

Is my understanding wrong?

(Also, any code criticism is appreciated)

```<code>public Mono<ServerResponse> getStatus(ServerRequest req) {
        Mono<List<Request>> body = req.bodyToFlux(Request.class).collectList();
        return ServerResponse.ok()
                .body(body.doOnNext(i -> {
                    Service.a = i;
                    logger.info("Service started for : {}", i.toString());
                })

                        .then(Mono.just("Service started for: " + Service.a)), String.class);
    }
</code>```

答:
Communicating through static variables are very discouraged (especially in functional and reactive programming). As in your question you didn't provide enough information about the Service you start, it's a bit difficult to recommend.

However, based on the available information, I would start out with something like this:

public Mono<ServerResponse> getStatus(ServerRequest req) {
    return req.bodyToFlux(Request.class)
            .collectList()
            .doOnNext(requestBody -> System.out.println("Do your service start here in the background."))
            .flatMap(requestBody -> ServerResponse.ok().syncBody("Service started for: " + requestBody));
}
```

Title: Mono::then returns null

Body:
I'm relatively new to reactive programming.
My question is regarding Mono::then

What I want to do is, extract the body from incoming request, set it to a static variable.
Once that is done, send a response saying that the service has started.
But the following code always returns "Service started for: null".

I thought Mono::then should run after the first mono completes(in this case, after setting the static variable) and return "Service started for: a,b,c".

Is my understanding wrong?

(Also, any code criticism is appreciated)

public Mono<ServerResponse> getStatus(ServerRequest req) {
        Mono<List<Request>> body = req.bodyToFlux(Request.class).collectList();
        return ServerResponse.ok()
                .body(body.doOnNext(i -> {
                    Service.a = i;
                    logger.info("Service started for : {}", i.toString());
                })

                        .then(Mono.just("Service started for: " + Service.a)), String.class);
    }


问:
SQL Select rows that have higher timestamp value
On a PostgreSQL Server i've a table like this below :

```<code>+------+------+------------------+
| Code |  kind|    timestamp     |
+------+------+------------------+
|  1   |  I   | 16-05-2011 09:17 |
|  1   |  O   | 16-05-2011 09:47 |
|  2   |  I   | 16-05-2011 09:37 |
|  3   |  I   | 16-05-2011 11:26 |
|  3   |  O   | 16-05-2011 12:11 |
|  3   |  I   | 16-05-2011 13:23 |
+------+------+------------------+
</code>```

This table represent IN and OUT of person in a pool with relative timestamp, and i want to know the person in the pool at a given moment.

Is there a way to retrieve The row of kind 'I' that not have a corresponding 'O' ?
can i do it with a single Query ?

The code represent the person code ...

答:
LEFT JOIN is one way to do it with

```<code>SELECT
       t.Code,
       t.kind,
       t.timestamp
FROM   table t
       LEFT JOIN table t2
         ON t.code = t2.code
            AND t.kind = 'I'
            AND t2.kind = 'O'
WHERE  t2.code IS NULL
</code>```

It should be doable with Not Exists as well

ContentLicense: CC BY-SA 3.0

Body:
On a PostgreSQL Server i've a table like this below :

+------+------+------------------+
| Code |  kind|    timestamp     |
+------+------+------------------+
|  1   |  I   | 16-05-2011 09:17 |
|  1   |  O   | 16-05-2011 09:47 |
|  2   |  I   | 16-05-2011 09:37 |
|  3   |  I   | 16-05-2011 11:26 |
|  3   |  O   | 16-05-2011 12:11 |
|  3   |  I   | 16-05-2011 13:23 |
+------+------+------------------+

This table represent IN and OUT of person in a pool with relative timestamp, and i want to know the person in the pool at a given moment.

Is there a way to retrieve The row of kind 'I' that not have a corresponding 'O' ?
can i do it with a single Query ?

The code represent the person code ...

Body:
LEFT JOIN is one way to do it with

SELECT
       t.Code,
       t.kind,
       t.timestamp
FROM   table t
       LEFT JOIN table t2
         ON t.code = t2.code
            AND t.kind = 'I'
            AND t2.kind = 'O'
WHERE  t2.code IS NULL

It should be doable with Not Exists as well


问:
Mongoose cast to ObjectID failed for value... but why
I know what the problem is, but can't figure out why it is happening. I have a simple recipe app using express and mongoose. User passes in recipe info via form and is saved to database via mongoose methods. This part seems to work perfectly and when I console.log using test data, I see that the following data is saved:

```<code>{
  ingredients: [ 'peanut butter', 'jelly', 'bread' ],
  _id: 5e47d564f775ce247052d01c,
  name: 'pb jelly sammich',
  author: 'rob',
  oneLiner: 'classic pb jelly sammich',
  image: 'picofpbsammich here',
  method: 'add all the ingredients together and boom! pb jelly sammich.',
  __v: 0
}

</code>```

(This is also what shows when I check mongo db using db.recipes.find() and also what displays when I pass in the object to my ejs show template.

However, when I access my show route via get request, I get a long error message using the above test data. Here is they key part of the error message:

```<code>'Cast to ObjectId failed for value "picofpbsammich here" at path "_id" for model "Recipes"',
</code>```

I understand what the problem is, but baffled as to why it is happening. Here is my show route:

```<code>app.get("/recipes/:id", function (req, res) {
    console.log(req.params.id)
    Recipe.findById(req.params.id, function (err, foundRecipe) {
        if (err) {
            console.log(err);
        } else {
            res.render("show", { recipe: foundRecipe });
        }
    })
})

</code>```

console logging the req.params.id as shown above, prints the following:

```<code>5e47d564f775ce247052d01c
picofpbsammich here
</code>```

The first line is the correct ID, the second is obviously not and the cause of the problem, but I have no idea where that could be coming from :S Why would req.params.id be pulling the VALUE of a property that is named something completely different?

I'm new to mongoose so it's probably something silly I'm doing and any explanations appreciated.

Here is the model:

```<code>var mongoose = require("mongoose");

let recipeSchema = new mongoose.Schema({
    name: {
        type: String,
        required: true
    },
    author: String,
    oneLiner: String,
    ingredients: [String],
    image: String,
    method: String
})
module.exports = mongoose.model("Recipes", recipeSchema)
</code>```

答:
You posted the following code:

```<code>app.get("/recipes/:id", function (req, res) {
    console.log(req.params.id)
    Recipe.findById(req.params.id, function (err, foundRecipe) {
        if (err) {
            console.log(err);
        } else {
            res.render("show", { recipe: foundRecipe });
        }
    })
})
</code>```

And you mention that in the console.log you receive:

```<code>5e47d564f775ce247052d01c
picofpbsammich here
</code>```

Followed by the exception being logged:

'Cast to ObjectId failed for value "picofpbsammich here" at path "_id"
  for model "Recipes"',

Makes me logically assume that you are making two requests, one of which the id is not valid, being:

```<code>picofpbsammich here
</code>```

Mongoose is not able to cast this value to an ObjectId, hence you get the exception, which makes sense imo.

Body:
I know what the problem is, but can't figure out why it is happening. I have a simple recipe app using express and mongoose. User passes in recipe info via form and is saved to database via mongoose methods. This part seems to work perfectly and when I console.log using test data, I see that the following data is saved:

{
  ingredients: [ 'peanut butter', 'jelly', 'bread' ],
  _id: 5e47d564f775ce247052d01c,
  name: 'pb jelly sammich',
  author: 'rob',
  oneLiner: 'classic pb jelly sammich',
  image: 'picofpbsammich here',
  method: 'add all the ingredients together and boom! pb jelly sammich.',
  __v: 0
}

(This is also what shows when I check mongo db using db.recipes.find() and also what displays when I pass in the object to my ejs show template.

However, when I access my show route via get request, I get a long error message using the above test data. Here is they key part of the error message:

'Cast to ObjectId failed for value "picofpbsammich here" at path "_id" for model "Recipes"',

I understand what the problem is, but baffled as to why it is happening. Here is my show route:

app.get("/recipes/:id", function (req, res) {
    console.log(req.params.id)
    Recipe.findById(req.params.id, function (err, foundRecipe) {
        if (err) {
            console.log(err);
        } else {
            res.render("show", { recipe: foundRecipe });
        }
    })
})

console logging the req.params.id as shown above, prints the following:

5e47d564f775ce247052d01c
picofpbsammich here

The first line is the correct ID, the second is obviously not and the cause of the problem, but I have no idea where that could be coming from :S Why would req.params.id be pulling the VALUE of a property that is named something completely different?

I'm new to mongoose so it's probably something silly I'm doing and any explanations appreciated.

Here is the model:

var mongoose = require("mongoose");

let recipeSchema = new mongoose.Schema({
    name: {
        type: String,
        required: true
    },
    author: String,
    oneLiner: String,
    ingredients: [String],
    image: String,
    method: String
})
module.exports = mongoose.model("Recipes", recipeSchema)

Body:
You posted the following code:

app.get("/recipes/:id", function (req, res) {
    console.log(req.params.id)
    Recipe.findById(req.params.id, function (err, foundRecipe) {
        if (err) {
            console.log(err);
        } else {
            res.render("show", { recipe: foundRecipe });
        }
    })
})

And you mention that in the console.log you receive:

5e47d564f775ce247052d01c
picofpbsammich here

Followed by the exception being logged:

'Cast to ObjectId failed for value "picofpbsammich here" at path "_id"
  for model "Recipes"',

Makes me logically assume that you are making two requests, one of which the id is not valid, being:

picofpbsammich here

Mongoose is not able to cast this value to an ObjectId, hence you get the exception, which makes sense imo.


问:
Load balancing gRPC requests using one of AWS Load Balancers
I'm trying to work out whether I could use one of the (A/E/N)LBs to load balance gRPC traffic. A simple round robin would suffice in our case.

I've read that ALB doesn't fully support HTTP2 and therefore can't be used with gRPC. Specifically lack of support of sending HTTP2 traffic downstream and lack of support for trailer headers was mentioned. Is it still true?

Couldn't find any definitive answers with regards to NLBs or "classic" ELBs. Any hints?

答:
Using gRPC on AWS had some major challenges. Without full HTTP/2 support on AWS Application Load Balancer, you have to spin up and manage your own load balancers. Neither NLB and ELB are viable alternatives on AWS due to issues with traffic to and from the same host, dynamic port mappings, SSL termination complications, and sub-optimal client and server-side round-robining of TCP connections.

gRPC demonstrated performance improvements, however, it would take considerable infrastructure efforts to adopt, whether it be using LBs such as Nginx or Envoy; or setting up a service mesh with something of the likes of Istio. Another possibility would be to make use of thick client load balancing, though this would also require additional service discovery infrastructures such as Consul or ZooKeeper.

AWS recently announced a new service called AWS App Mesh. AWS App Mesh supports HTTP2 and gRPC services

gRPC can now model and manage their inter-service communications using AWS App Mesh.

Reference:

https://aws.amazon.com/about-aws/whats-new/2019/11/aws-app-mesh-now-supports-http2-and-grpc-services/

https://aws.amazon.com/app-mesh/

https://docs.aws.amazon.com/app-mesh/latest/userguide/what-is-app-mesh.html


问:
How to find out the format of bytes? NAudio
What I'm trying to make: Receive data from microphone (IWaveIn) => lower the amplitude of the sound(lower the volume)(problem) => play it to the speakers(IWaveProvider)

The problem is: whenever I try to multiply sample by x!=1.0f gives me very noisy feedback.
I think it could be a format of bytes but I do not know how to check it. Any help/suggestion will be appreciated.

Count = 17640; Offset =0;

```<code>public int Read(byte[] buffer, int offset, int count)
    {
        int read = bufferedWaveProvider.Read(buffer, offset, count);

        /*
                waveIn.WaveFormat.Channels; //2
                waveIn.WaveFormat.BlockAlign;//4
                waveIn.WaveFormat.BitsPerSample;//16
                waveIn.WaveFormat.SampleRate;//44100
         */

        for (int i = 0; i < read / 4; i++)
        {
            int firstByte = i * 4;
            float sample = BitConverter.ToSingle(buffer, firstByte);
            sample = sample * 1.0f;

            byte[] bytes = BitConverter.GetBytes(sample);
            buffer[firstByte + 0] = bytes[0];
            buffer[firstByte + 1] = bytes[1];
            buffer[firstByte + 2] = bytes[2];
            buffer[firstByte + 3] = bytes[3];
        }

        return read;
    }
    private void OnDataAvailable(object sender, WaveInEventArgs e)
    {
        bufferedWaveProvider.AddSamples(e.Buffer, 0, e.BytesRecorded);
    }
</code>```

答:
You're receiving audio in the format specified in WaveIn.WaveFormat. Your comment shows 16 bits per sample, which means you are receiving the audio as signed 16 bit samples. So you could use BitConverter.ToInt16

But there are easier ways of accomplishing this. If you call ToSampleProvider() on your BufferedWaveProvider then you can pass that into a VolumeSampleProvider which will let you adjust the volume directly without needing to unpack samples yourself.

Body:
What I'm trying to make: Receive data from microphone (IWaveIn) => lower the amplitude of the sound(lower the volume)(problem) => play it to the speakers(IWaveProvider)

The problem is: whenever I try to multiply sample by x!=1.0f gives me very noisy feedback.
I think it could be a format of bytes but I do not know how to check it. Any help/suggestion will be appreciated.

Count = 17640; Offset =0;

public int Read(byte[] buffer, int offset, int count)
    {
        int read = bufferedWaveProvider.Read(buffer, offset, count);

        /*
                waveIn.WaveFormat.Channels; //2
                waveIn.WaveFormat.BlockAlign;//4
                waveIn.WaveFormat.BitsPerSample;//16
                waveIn.WaveFormat.SampleRate;//44100
         */

        for (int i = 0; i < read / 4; i++)
        {
            int firstByte = i * 4;
            float sample = BitConverter.ToSingle(buffer, firstByte);
            sample = sample * 1.0f;

            byte[] bytes = BitConverter.GetBytes(sample);
            buffer[firstByte + 0] = bytes[0];
            buffer[firstByte + 1] = bytes[1];
            buffer[firstByte + 2] = bytes[2];
            buffer[firstByte + 3] = bytes[3];
        }

        return read;
    }
    private void OnDataAvailable(object sender, WaveInEventArgs e)
    {
        bufferedWaveProvider.AddSamples(e.Buffer, 0, e.BytesRecorded);
    }


问:
How to access a private object within a private object in Java?
I am trying to access an object within an object here. Below are the three classes. I simplified this that it makes the same error as in the full program.
This is the main class.

```<code>import java.util.Scanner;
public class TestMain
{
    public static void main (String[] args)
    {
        createStudent();
    }

    public static Student createStudent()
    {
        Student another = new Student();
        another.depart(101,"CS");
        return another;
    }
}
</code>```

The second one,

```<code>public class Student
{
    private int sid;
    private String sname;
    private Department department;

    public int getSid()
    {
        return sid;
    }
    public String getSname()
    {
        return sname;
    }
    public void depart(int departid, String departname)
    {
        department.setDid(departid);
        department.setDname(departname);
    }

    public void setSid(int stusid)
    {
        this.sid = stusid;
    }
    public void setSname(String stusname)
    {
        this.sname = stusname;
    }

}
</code>```

The third one,

```<code>public class Department
{
    private int did;
    private String dname;

    public int getDid()
    {
        return did;
    }
    public String getDname()
    {
        return dname;
    }

    public void setDid(int deptdid)
    {
        this.did = deptdid;
    }
    public void setDname(String deptdname)
    {
        this.dname = deptdname;
    }
}
</code>```

No matter what I do, this program returns a run time error,

```<code>Exception in thread "main" java.lang.NullPointerException
    at Student.depart(Student.java:17)
    at TestMain.createStudent(TestMain.java:13)
    at TestMain.main(TestMain.java:7)
</code>```

What is NullPointerException and how to avoid this? Please help me.

答:
The problem is that when you create a Student object, you need to initialize each member object i.e. the department object is null, so when you do department.setDid(101), it returns an exception.

To fix this, create a custom constructor for the Student class as so:

```<code>Student()
{
    department = new Department();
    sid = 0;
    sname = "";
}
</code>```

Edit: As Sebastian has rightly pointed out in the comment below, it's actually pretty unnecessary to initialize primitive types in constructors. However, please note that you must do this for String types, as their default value is null, not "", which could cause problems later on.

Body:
I am trying to access an object within an object here. Below are the three classes. I simplified this that it makes the same error as in the full program.
This is the main class.

import java.util.Scanner;
public class TestMain
{
    public static void main (String[] args)
    {
        createStudent();
    }

    public static Student createStudent()
    {
        Student another = new Student();
        another.depart(101,"CS");
        return another;
    }
}

The second one,

public class Student
{
    private int sid;
    private String sname;
    private Department department;

    public int getSid()
    {
        return sid;
    }
    public String getSname()
    {
        return sname;
    }
    public void depart(int departid, String departname)
    {
        department.setDid(departid);
        department.setDname(departname);
    }

    public void setSid(int stusid)
    {
        this.sid = stusid;
    }
    public void setSname(String stusname)
    {
        this.sname = stusname;
    }

}

The third one,

public class Department
{
    private int did;
    private String dname;

    public int getDid()
    {
        return did;
    }
    public String getDname()
    {
        return dname;
    }

    public void setDid(int deptdid)
    {
        this.did = deptdid;
    }
    public void setDname(String deptdname)
    {
        this.dname = deptdname;
    }
}

No matter what I do, this program returns a run time error,

Exception in thread "main" java.lang.NullPointerException
    at Student.depart(Student.java:17)
    at TestMain.createStudent(TestMain.java:13)
    at TestMain.main(TestMain.java:7)

What is NullPointerException and how to avoid this? Please help me.

Body:
The problem is that when you create a Student object, you need to initialize each member object i.e. the department object is null, so when you do department.setDid(101), it returns an exception.

To fix this, create a custom constructor for the Student class as so:

Student()
{
    department = new Department();
    sid = 0;
    sname = "";
}

Edit: As Sebastian has rightly pointed out in the comment below, it's actually pretty unnecessary to initialize primitive types in constructors. However, please note that you must do this for String types, as their default value is null, not "", which could cause problems later on.


问:
get the mean var of all columns value and make new column
Let say we habe

```<code>      A , B , C
id
1     3, 4, 5
2     4 ,5, 2
</code>```

if I want to make a new column D with  ID 1's mean,var  and ID2's mean and var

答:
Use DataFrame.agg:

```<code>df[['avg','var']] = df.agg(['mean','var'], axis=1)
print (df)
   A  B  C       avg       var
1  3  4  5  4.000000  1.000000
2  4  5  2  3.666667  2.333333
</code>```

Another idea:

```<code>df = df.assign(avg=df.mean(axis=1),
               var=df.var(axis=1))
print (df)
   A  B  C       avg       var
1  3  4  5  4.000000  1.000000
2  4  5  2  3.666667  2.333333
</code>```

If you want variance with ddof=0 in DataFrame.var:

```<code>df = df.assign(avg=df.mean(axis=1),
               var=df.var(axis=1, ddof=0))
print (df)
   A  B  C       avg       var
1  3  4  5  4.000000  0.666667
2  4  5  2  3.666667  1.555556
</code>```

Body:
Let say we habe

      A , B , C
id
1     3, 4, 5
2     4 ,5, 2

if I want to make a new column D with  ID 1's mean,var  and ID2's mean and var

Body:
Use DataFrame.agg:

df[['avg','var']] = df.agg(['mean','var'], axis=1)
print (df)
   A  B  C       avg       var
1  3  4  5  4.000000  1.000000
2  4  5  2  3.666667  2.333333

Another idea:

df = df.assign(avg=df.mean(axis=1),
               var=df.var(axis=1))
print (df)
   A  B  C       avg       var
1  3  4  5  4.000000  1.000000
2  4  5  2  3.666667  2.333333

If you want variance with ddof=0 in DataFrame.var:

df = df.assign(avg=df.mean(axis=1),
               var=df.var(axis=1, ddof=0))
print (df)
   A  B  C       avg       var
1  3  4  5  4.000000  0.666667
2  4  5  2  3.666667  1.555556


问:
ASPX Anonymous Cookies broken when Machine Key Changed
My company recently got hit with a traffic spike, so we tried to fire up additional EC2 instances to handle the load. Unfortunately, this caused users problems with cookies (i.e. site kept asking for login even after you supplied credentials). We think this is because we had neglected to set the Machine Key in our Web.config file (the Web.config files on each load balanced machine are otherwise identical).

We're now in the position where we don't want to set a new Machine Key value in Web.config, because that will log out all of our anonymous users, who may have already added items to their cart, etc. But we also want to support scaling.

So, questions:

Is our assumption correct that the Machine Key is the culprit for user's needing new cookies?

Is there any way of determining the current or default Machine Key that is being used so that we can copy it to the other load balanced servers?

Failing 2, is there a way to set a new Machine Key without losing our anonymous user's data?

答:
You didn't mention what method of authentiation you are using, but if it's forms authentication, then yes - your machine keys need to match across all servers in your farm.  You should also make sure that all of your machines are equally patched as there have been several patches (specifically the asp.net security vulnerabilty updates) that update the cryptography bits.

If you're using the default configuration, the machine key is likey set to AutoGenerate.  As far as I know, there is no simple way to reveal what the autogenerated machine key is set to.  However, since you have access to your exising server, you can probably find it via a little reflection code as illustrated here:

http://aspnetresources.com/blog/how_to_read_auto_generated_machinekey


问:
How to make drop down box bring above and in fron to the all content in pure css?
I have created custom drop down like div's. But the problem I am facing is with display the ul.

Code:

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Drop Downn</title>
</head>

<style>

    .content{
        height: 400px;
        width: 100%;
        background-color: aliceblue;
    }
    .combo-box{

        border: 1px solid rgba(0, 0, 0, 0.089);
        background-color: #ffffff;
        width: 200px;
        height: 40px;

        font-size: 18px;

        cursor: pointer;

        align-items: center;
        display: flex;
    }

    .selections{

        background-color: beige;
    }

    ul{

    padding: 0;
    margin: 0;

    background-color: white;

    border: 1px solid rgba(97, 97, 97, 0.164);
    box-shadow: 0 1px 6px -2px #00000036;

    width: 200px;
    max-height: 300px;
    overflow: auto;

    display: none;
  }

  li{

    list-style: none;
    cursor: pointer;
    padding: 0px 14px;
    height: 32px;

    line-height: 34px;

  }

 li:hover{

    background-color: rgb(216, 9, 95);
    color: white;
 }

</style>

<script>

    function display(tag){

        let div = document.getElementsByTagName(tag)[0]
        div.style.display = div.style.display != 'block' ? 'block' : 'none'
    }
</script>
<body>

    <div class="content">
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nam laudantium possimus nulla officia tempore earum ea perspiciatis quia fugit asperiores laborum ab voluptas, dolore doloremque illo? Saepe, ex? Molestiae, doloremque?</p>
    </div>
    <div class="selections">
        <h4>Select your pet</h4>

    <div class="combo-box" onclick="display('ul')">
        <a>Tiger</a>
    </div>

    <ul>
        <li>Cat</li>
        <li>Dog</li>
        <li>Tiger</li>
        <li>Lion</li>
        <li>Parrot</li>
        <li>Peacock</li>
        <li>Rabbit</li>
        <li>Raino</li>
        <li>Kola</li>
        <li>Sea Lion</li>
        <li>Otter</li>
        <li>Turtle</li>
        <li>Rat</li>
        <li>Cow</li>
        <li>Goat</li>
        <li>Pig</li>
        <li>Fish (Fish food)</li>
        <li>Owl</li>
        <li>Squirrel</li>
    </ul>
    </div>
</body>
</html>
</code>```

From above picture, I want to show ul list over all div's & above the box Tiger and I don't want to expand the div selections. How can I make it work like that? Thank you all.

Update:
  I want to show the drop down above the .combo-box. Please refer below code and screenshot.

```<code><!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Drop Downn</title>
  </head>

  <style>
    .content {
      height: 400px;
      width: 100%;
      background-color: aliceblue;
    }

    .combo-box {
      position: relative;   /* <-- Relative position here */

      border: 1px solid rgba(0, 0, 0, 0.089);
      background-color: #ffffff;
      width: 200px;
      height: 40px;

      font-size: 18px;

      cursor: pointer;

      align-items: center;
      display: flex;
    }

    .selections {
      background-color: beige;
    }

    ul {
      padding: 0;
      margin: 0;
      background-color: white;

      border: 1px solid rgba(97, 97, 97, 0.164);
      box-shadow: 0 1px 6px -2px #00000036;

      width: 200px;
      max-height: 300px;
      overflow: auto;

      display: none;
    }

    li {

      list-style: none;
      cursor: pointer;
      padding: 0px 14px;
      height: 32px;

      line-height: 34px;

    }

    li:hover {

      background-color: rgb(216, 9, 95);
      color: white;
    }

  </style>

  <script>
    function display(tag) {

      let div = document.getElementsByTagName(tag)[0]
      div.style.display = div.style.display != 'block' ? 'block' : 'none'
    }

  </script>

  <body>

    <div class="content">
      <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Nam laudantium possimus nulla officia tempore earum ea perspiciatis quia fugit asperiores laborum ab voluptas, dolore doloremque illo? Saepe, ex? Molestiae, doloremque?</p>
    </div>
    <div class="selections">
      <h4>Select your pet</h4>

      <ul>
        <li>Cat</li>
        <li>Dog</li>
        <li>Tiger</li>
        <li>Lion</li>
        <li>Parrot</li>
        <li>Peacock</li>
        <li>Rabbit</li>
        <li>Raino</li>
        <li>Kola</li>
        <li>Sea Lion</li>
        <li>Otter</li>
        <li>Turtle</li>
        <li>Rat</li>
        <li>Cow</li>
        <li>Goat</li>
        <li>Pig</li>
        <li>Fish (Fish food)</li>
        <li>Owl</li>
        <li>Squirrel</li>
      </ul>

      <div class="combo-box" onclick="display('ul')">
        <a>Tiger</a>
      </div>

    </div>
  </body>

</html>
</code>```

Output I want like below image, but I don't want to expand that div.

答:
Give position:absolute to ul tag. will work for you.

```<code>ul{
position: absolute;
top:0;
left:0;
bottom:0;
right: 0;
}
.combo-box{
position: relative
}
</code>```

Body:
I have created custom drop down like div's. But the problem I am facing is with display the ul.

Code:

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Drop Downn</title>

Lorem ipsum dolor sit amet consectetur adipisicing elit. Nam laudantium possimus nulla officia tempore earum ea perspiciatis quia fugit asperiores laborum ab voluptas, dolore doloremque illo? Saepe, ex? Molestiae, doloremque?

Select your pet

        Tiger

Cat

Dog

Tiger

Lion

Parrot

Peacock

Rabbit

Raino

Kola

Sea Lion

Otter

Turtle

Rat

Cow

Goat

Pig

Fish (Fish food)

Owl

Squirrel

From above picture, I want to show ul list over all div's & above the box Tiger and I don't want to expand the div selections. How can I make it work like that? Thank you all.

Update:
  I want to show the drop down above the .combo-box. Please refer below code and screenshot.

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Drop Downn</title>

Lorem ipsum dolor sit amet consectetur adipisicing elit. Nam laudantium possimus nulla officia tempore earum ea perspiciatis quia fugit asperiores laborum ab voluptas, dolore doloremque illo? Saepe, ex? Molestiae, doloremque?

Select your pet

Cat

Dog

Tiger

Lion

Parrot

Peacock

Rabbit

Raino

Kola

Sea Lion

Otter

Turtle

Rat

Cow

Goat

Pig

Fish (Fish food)

Owl

Squirrel

        Tiger

Output I want like below image, but I don't want to expand that div.

Body:
Give position:absolute to ul tag. will work for you.

ul{
position: absolute;
top:0;
left:0;
bottom:0;
right: 0;
}
.combo-box{
position: relative
}


问:
Pandas: Calculating a Z-score to avoid "look ahead" bias
I have time series data in dataframe named "df", and, my code for calculating the z-score is given below:

```<code>mean = df.mean()
standard_dev = df.std()
z_score = (df - mean) / standard_dev
</code>```

I would like to calculate the z-score for each observation using the respective observation and data that was known at the point of recording the observation. i.e. I do not want to use a standard deviation and mean that incorporates data that occurs after a specific point in time. I just want to use data from time t, t-1, t-2....

How do I do this?

答:
Use .expanding() - col being the column you want to compute your statistics for (drop [col] in case, if you wish to compute it for the whole dataframe):

You might need to sort values by time column first - denoted as time_col (in case if it's not sorted already):

df=df.sort_values("time_col", axis=0)
```

<p>Then:</p>

<pre class="lang-py prettyprint-override"><code>df[col].sub(df[col].expanding().mean()).div(df[col].expanding().std())
</code>```

Ref:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.expanding.html

For the sample data:

import pandas as pd

df=pd.DataFrame({"a": list("xyzpqrstuv"), "b": [6,5,7,1,-9,0,3,5,2,8]})

df["c"]=df["b"].sub(df["b"].expanding().mean()).div(df["b"].expanding().std())
```

<p>Outputs:</p>

<pre class="lang-py prettyprint-override"><code>   a  b         c
0  x  6       NaN
1  y  5 -0.707107
2  z  7  1.000000
3  p  1 -1.425880
4  q -9 -1.677484
5  r  0 -0.281450
6  s  3  0.210502
7  t  5  0.534207
8  u  2 -0.046142
9  v  8  1.062430
</code>```

Body:
I have time series data in dataframe named "df", and, my code for calculating the z-score is given below:

mean = df.mean()
standard_dev = df.std()
z_score = (df - mean) / standard_dev

I would like to calculate the z-score for each observation using the respective observation and data that was known at the point of recording the observation. i.e. I do not want to use a standard deviation and mean that incorporates data that occurs after a specific point in time. I just want to use data from time t, t-1, t-2....

How do I do this?

Body:
Use .expanding() - col being the column you want to compute your statistics for (drop [col] in case, if you wish to compute it for the whole dataframe):

You might need to sort values by time column first - denoted as time_col (in case if it's not sorted already):

df=df.sort_values("time_col", axis=0)

Then:

df[col].sub(df[col].expanding().mean()).div(df[col].expanding().std())

Ref:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.expanding.html

For the sample data:

import pandas as pd

df=pd.DataFrame({"a": list("xyzpqrstuv"), "b": [6,5,7,1,-9,0,3,5,2,8]})

df["c"]=df["b"].sub(df["b"].expanding().mean()).div(df["b"].expanding().std())

Outputs:

   a  b         c
0  x  6       NaN
1  y  5 -0.707107
2  z  7  1.000000
3  p  1 -1.425880
4  q -9 -1.677484
5  r  0 -0.281450
6  s  3  0.210502
7  t  5  0.534207
8  u  2 -0.046142
9  v  8  1.062430


问:
When are arrays C-contiguous and F-contiguous simultaneously?
Under what conditions can arrays be C-contiguous and F-contiguous simultaneosly?

I can think of the following:

The 1D case that is trivially C- and F-contiguous.

Similarly, multi-dimensional arrays where all dimensions are singleton dimensions except for one.

Are there any others?

答: You got it.  An array is both C and Fortran contiguous (i.e. is both row major and column major) when it has at most 1 dimension longer than 1.  Basically, vectors and scalars, plus degenerate arrays with additional "unnecessary" dimensions.</p>


问:
How to add a new key value pair to existing key value pair from list of dicts?
I have a dictionary with a parent-key and its value is a dict. I want to extract a key,val pair from a list of dict.

given:

```<code>{"Premier" : {}}
</code>```

I want to extract:

```<code> all_compseasons = content: [
    {
        label: "2019/20",
        id: 274
    },
    {
        label: "2018/19",
        id: 210
    }]
</code>```

So to get:

```<code>{"Premier" :
    {"2019/20" : 274,
    "2018/19" : 210
    }
}
</code>```

I can't seem to find a good way to do it. I've tried below given other examples of the problem, but doesn't work.

```<code>compseasons = {}
for comp in all_compseasons:
    competition_id = 'Premier'
    index = competition_id
    compseasons[index]comp['label'] = comp['id']
</code>```

答:
Your very close. Dictionary keys need to be referenced with surrounding [], so comp['label'] should be [comp['label']]. You can also just use the given dictionary {"Premier" : {}} instead of creating a new one with compseasons = {}, but either will give you the same result.

Working solution:

```<code>d = {"Premier": {}}

all_compseasons = [{"label": "2019/20", "id": 274}, {"label": "2018/19", "id": 210}]

for comp in all_compseasons:
    d["Premier"][comp["label"]] = comp["id"]

print(d)
# {'Premier': {'2019/20': 274, '2018/19': 210}}
</code>```

Body:
I have a dictionary with a parent-key and its value is a dict. I want to extract a key,val pair from a list of dict.

given:

{"Premier" : {}}

I want to extract:

 all_compseasons = content: [
    {
        label: "2019/20",
        id: 274
    },
    {
        label: "2018/19",
        id: 210
    }]

So to get:

{"Premier" :
    {"2019/20" : 274,
    "2018/19" : 210
    }
}

I can't seem to find a good way to do it. I've tried below given other examples of the problem, but doesn't work.

compseasons = {}
for comp in all_compseasons:
    competition_id = 'Premier'
    index = competition_id
    compseasons[index]comp['label'] = comp['id']

Body:
Your very close. Dictionary keys need to be referenced with surrounding [], so comp['label'] should be [comp['label']]. You can also just use the given dictionary {"Premier" : {}} instead of creating a new one with compseasons = {}, but either will give you the same result.

Working solution:

d = {"Premier": {}}

all_compseasons = [{"label": "2019/20", "id": 274}, {"label": "2018/19", "id": 210}]

for comp in all_compseasons:
    d["Premier"][comp["label"]] = comp["id"]

print(d)
# {'Premier': {'2019/20': 274, '2018/19': 210}}


问:
Laravel spatie QueryBuilder GET request search
Hey I'm very new please forgive this question. I'm trying to implement a search and struggle to send correct GET request. It works when I manually put in the URL

```<code>http://127.0.0.1:8000/spsu?_token=kDRdTBZBwfO0l8UiFi1mcKmNOH7JEiNoxvUu7Fka&filter[name]=Peter&%5Bemail%5D=
</code>```

however when I send it through the form "filter[name]" is missing and I don't know how to add it.

```<code>http://127.0.0.1:8000/spsu?_token=kDRdTBZBwfO0l8UiFi1mcKmNOH7JEiNoxvUu7Fka&name=Peter&%5Bemail%5D=
</code>```

Here is my SearchController.php:

```<code><?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use Spatie\QueryBuilder\QueryBuilder;

class SearchController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function spsu() {
        $users = QueryBuilder::for(User::class)
                ->allowedFilters(['name', 'email'])
                ->get();
        return view('suche', compact('users'));
    }
}
</code>```

Here is the blade file:

```<code>@extends('layouts.app')

@section('content')
            <div id="main-content" class="col-12">
                    <div class="col-md-6 text-right">
                        <form action="/spsu" method="GET" class="form-inline">
                            @csrf
                            <div class="form-group">
                                <input type="text" class="form-control" name="name" placeholder="Keyword">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" name="[email]" placeholder="Keyword">
                            </div>
                            <div class="form-group">
                                <button class="btn btn-dark" type="submit">Search</button>
                            </div>
                        </form>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-hover">
                            <thead>
                                <tr>
                                    <th>Detail</th>
                                    <th width="10%"></th>
                                </tr>
                            </thead>
                            <tbody>
                                @forelse($users as $user)
                                    <tr>
                                        <td>
                                            <u>
                                                {{ $user->name }}
                                            </u>
                                            <br>
                                            <p>
                                                {{ $user->email }}
                                            </p>
                                        </td>
                                    </tr>
                                @empty
                                    <tr>
                                        <td colspan="2" align="center">
                                            Empty data
                                        </td>
                                    </tr>
                                @endforelse
                            </tbody>
                        </table>
                    </div>
            </div>
@endsection
</code>```

In my web.php:

```<code>Route::get('/spsu', 'SearchController@spsu');
</code>```

I hope somebody can help. Kind regards!

答:
You should use filter[<field>] as the input name.

For example instead of name='email' make it name='filter[email]'

Body:
Hey I'm very new please forgive this question. I'm trying to implement a search and struggle to send correct GET request. It works when I manually put in the URL

http://127.0.0.1:8000/spsu?_token=kDRdTBZBwfO0l8UiFi1mcKmNOH7JEiNoxvUu7Fka&filter[name]=Peter&%5Bemail%5D=

however when I send it through the form "filter[name]" is missing and I don't know how to add it.

http://127.0.0.1:8000/spsu?_token=kDRdTBZBwfO0l8UiFi1mcKmNOH7JEiNoxvUu7Fka&name=Peter&%5Bemail%5D=

Here is my SearchController.php:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use Spatie\QueryBuilder\QueryBuilder;

class SearchController extends Controller
{
    public function __construct()
    {
        $this->middleware('auth');
    }

    public function spsu() {
        $users = QueryBuilder::for(User::class)
                ->allowedFilters(['name', 'email'])
                ->get();
        return view('suche', compact('users'));
    }
}

Here is the blade file:

@extends('layouts.app')

@section('content')

                        <form action="/spsu" method="GET" class="form-inline">
                            @csrf

                                <input type="text" class="form-control" name="name" placeholder="Keyword">

                                <input type="text" class="form-control" name="[email]" placeholder="Keyword">

                                <button class="btn btn-dark" type="submit">Search</button>

                        </form>

                                    Detail

                                @forelse($users as $user)

                                                {{ $user->name }}

                                                {{ $user->email }}

                                @empty

                                            Empty data

                                @endforelse

@endsection

In my web.php:

Route::get('/spsu', 'SearchController@spsu');

I hope somebody can help. Kind regards!


问:
styling the asp:fileupload control
I have a file upload control in asp.net like so:

```<code><asp:FileUpload ID="File1" runat="server" Font-Size="Small" Width="100%" />
</code>```

For some reason the Browse... button does not apply the standard CSS that I have applied to any input[type="button"] controls.

How can I apply the same CSS to the Browse button of that control?

答:
in aspx form:

```<code><div class="fileupload-group">
    <button type="button" runat="server" id="btnFileupload" class="btnFileupload btnRed">
        Select File <i class="fa fa-folder-open"></i>
        <asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="True" />
    </button>
    <input type="text" runat="server" id="txtFileuploadName" class="fileupload-name txtRight" readonly="readonly" />
</div>
</code>```

and in javascript

```<code>$('input[id="<%= FileUpload1.ClientID %>"]').change(function () {
    var names = [];
    var length = $(this).get(0).files.length;
    for (var i = 0; i < $(this).get(0).files.length; ++i) {
        names.push($(this).get(0).files[i].name);
    }
    if (length > 2) {
        $("#<%=txtFileuploadName.ClientID%>").attr("value", length + " selected files");
    }
    else {
        $("#<%=txtFileuploadName.ClientID%>").attr("value", names);
    }
});
</code>```

and in css:

```<code>/* txtRight  ----------------------------*/
.txtRight {
    display: inline-block;
    margin-bottom: 3px;
    border: 1px solid #CCC;
    background-color: #FFF;
    font-size: 14px;
    line-height: 20px;
    color: #555;
    vertical-align: middle;
    position: relative;
    font-weight: normal;
    padding: 2px 6px;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    -ms-border-radius: 4px;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px #000000;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    -moz-box-shadow: inset 0 1px 1px #000000;
    -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    -ms-box-shadow: inset 0 1px 1px #000000;
    -ms-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    box-shadow: inset 0 1px 1px #000000;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    -webkit-transition: border linear .2s,box-shadow linear .2s;
    -moz-transition: border linear .2s,box-shadow linear .2s;
    -o-transition: border linear .2s,box-shadow linear .2s;
    -ms-transition: border linear .2s,box-shadow linear .2s;
    transition: border linear .2s,box-shadow linear .2s;
}
.txtRight:focus {
    border-color: #52a8ec;
    border-color: rgba(82,168,236,0.8);
    outline: 0;
    -webkit-box-shadow: inset 0 1px 1px #000000,0 0 8px #52a8ec;
    -moz-box-shadow: inset 0 1px 1px #000000,0 0 8px #52a8ec;
    -ms-box-shadow: inset 0 1px 1px #000000,0 0 8px #52a8ec;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
    -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
    -ms-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
    box-shadow: inset 0 1px 1px #000000,0 0 8px #52a8ec;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
}
.txtRight {
    font-family: iransans !important;
    font-weight: normal !important;
    direction: rtl;
    text-align: right;
    margin-right: 0;
    top: 0;
    right: 0;
}
.txtRight:disabled {
    background-color: #f7f7f7 !important;
}
select.txtRight {
    padding: 1px 2px !important;
    font-size: 13px !important;
}
/* --------------------------------------*/
/* btnRed ------------------------------ */
.btnRed, a.btnRed {
    -ms-text-shadow: none;
    text-shadow: none;
    background: #ed1c24;
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
    -o-transition: all 0.5s;
    -ms-transition: all 0.5s;
    transition: all 0.5s;
}
.btnRed:hover, .btnRed:focus, .btnRed, .btnRed:visited, .btnRed:disabled,
a.btnRed:hover, a.btnRed:focus, a.btnRed, a.btnRed:visited, a.btnRed:disabled, a.btnMoulinexRed:link {
    border: none;
    color: white;
    text-decoration: none;
    padding: 5px;
    font-family: iransans;
    font-weight: normal;
    font-size: 12px;
    cursor: pointer;
}
.btnRed:hover, .btnRed:hover:enabled, .btnRed:focus, .btnRed:focus:enabled,
a.btnRed:hover, a.btnRed:hover:enabled, .btnRed:focus, a.btnRed:focus:enabled {
    background: #830022;
    background-color: #830022 !important;
    color: white !important;
}
.btnRed:visited, .btnRed:link,  /*a.btnRed, */
a.btnRed:visited, a.btnRed:link {
    background: #ed1c24;
    background-color: #ed1c24;
    color: white;
}
.btnRed:active, .btnRed:active:enabled,
a.btnRed:active, a.btnRed:active:enabled
{
    background: #e6e6e6 !important;
    background-color: #e6e6e6 !important;
    color: #333 !important;
}
.btnRed:disabled,
a.btnRed:disabled, a.aspNetDisabled {
    color: #333 !important;
    background-color: #D6D1D1 !important;
}
/* --------------------------------------*/
/* FileUpload ---------------------------*/
.fileupload-group {
    position: relative;
    display: block;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    white-space: nowrap;
    margin-top: 3px;
    margin-bottom: 8px;
}
.fileupload-group .fileupload-name {
    display: inline-block;
    position: relative;
    width: 67%;
    margin-bottom: 0;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
.btnFileupload {
    display: inline-block;
    position: relative;
    white-space: nowrap;
    width: 17%;
    vertical-align: middle;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    -ms-border-top-right-radius: 4px;
    border-top-right-radius: 4px;
    -ms-border-bottom-right-radius: 4px;
    border-bottom-right-radius: 4px;
}
.fileupload-group .btnUpload {
    width: 15%;
    vertical-align: middle;
}
.fileupload-name {
    padding: 0;
    width: 100%;
    white-space: nowrap;
    height: 29px;
    padding: 4px 12px;
    font-size: 14px;
}
.fileupload-name.txtRight {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    -ms-border-top-right-radius: 0 ;
    border-top-right-radius: 0;
    -ms-border-bottom-right-radius: 0;
    border-bottom-right-radius: 0;
    display: inline-block;
    margin-right: -6px;

}
.fileupload-name.txtRight {
    background-color:#FFF;
    -ms-opacity: 1;
    opacity: 1;
    border: 1px solid #ffaaaa;
}
.fileupload-name.txtRight:disabled {
    background-color:#FFF;
    -ms-opacity: 1;
    opacity: 1;
    border: 1px solid #ccc;
}
.fileupload-group input[type=file] {
    display:inline-block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    -ms-opacity: 0;
    opacity: 0;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
/* --------------------------------------*/
</code>```

Make sure to use the latest browser version to run

Title: styling the asp:fileupload control

Body:
I have a file upload control in asp.net like so:

<asp:FileUpload ID="File1" runat="server" Font-Size="Small" Width="100%" />

For some reason the Browse... button does not apply the standard CSS that I have applied to any input[type="button"] controls.

How can I apply the same CSS to the Browse button of that control?

Body:
in aspx form:

<div class="fileupload-group">
    <button type="button" runat="server" id="btnFileupload" class="btnFileupload btnRed">
        Select File <i class="fa fa-folder-open"></i>
        <asp:FileUpload ID="FileUpload1" runat="server" AllowMultiple="True" />
    </button>
    <input type="text" runat="server" id="txtFileuploadName" class="fileupload-name txtRight" readonly="readonly" />
</div>

and in javascript

$('input[id="<%= FileUpload1.ClientID %>"]').change(function () {
    var names = [];
    var length = $(this).get(0).files.length;
    for (var i = 0; i < $(this).get(0).files.length; ++i) {
        names.push($(this).get(0).files[i].name);
    }
    if (length > 2) {
        $("#<%=txtFileuploadName.ClientID%>").attr("value", length + " selected files");
    }
    else {
        $("#<%=txtFileuploadName.ClientID%>").attr("value", names);
    }
});

and in css:

/* txtRight  ----------------------------*/
.txtRight {
    display: inline-block;
    margin-bottom: 3px;
    border: 1px solid #CCC;
    background-color: #FFF;
    font-size: 14px;
    line-height: 20px;
    color: #555;
    vertical-align: middle;
    position: relative;
    font-weight: normal;
    padding: 2px 6px;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    -ms-border-radius: 4px;
    border-radius: 4px;
    -webkit-box-shadow: inset 0 1px 1px #000000;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    -moz-box-shadow: inset 0 1px 1px #000000;
    -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    -ms-box-shadow: inset 0 1px 1px #000000;
    -ms-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    box-shadow: inset 0 1px 1px #000000;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.075);
    -webkit-transition: border linear .2s,box-shadow linear .2s;
    -moz-transition: border linear .2s,box-shadow linear .2s;
    -o-transition: border linear .2s,box-shadow linear .2s;
    -ms-transition: border linear .2s,box-shadow linear .2s;
    transition: border linear .2s,box-shadow linear .2s;
}
.txtRight:focus {
    border-color: #52a8ec;
    border-color: rgba(82,168,236,0.8);
    outline: 0;
    -webkit-box-shadow: inset 0 1px 1px #000000,0 0 8px #52a8ec;
    -moz-box-shadow: inset 0 1px 1px #000000,0 0 8px #52a8ec;
    -ms-box-shadow: inset 0 1px 1px #000000,0 0 8px #52a8ec;
    -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
    -moz-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
    -ms-box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
    box-shadow: inset 0 1px 1px #000000,0 0 8px #52a8ec;
    box-shadow: inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);
}
.txtRight {
    font-family: iransans !important;
    font-weight: normal !important;
    direction: rtl;
    text-align: right;
    margin-right: 0;
    top: 0;
    right: 0;
}
.txtRight:disabled {
    background-color: #f7f7f7 !important;
}
select.txtRight {
    padding: 1px 2px !important;
    font-size: 13px !important;
}
/* --------------------------------------*/
/* btnRed ------------------------------ */
.btnRed, a.btnRed {
    -ms-text-shadow: none;
    text-shadow: none;
    background: #ed1c24;
    -webkit-transition: all 0.5s;
    -moz-transition: all 0.5s;
    -o-transition: all 0.5s;
    -ms-transition: all 0.5s;
    transition: all 0.5s;
}
.btnRed:hover, .btnRed:focus, .btnRed, .btnRed:visited, .btnRed:disabled,
a.btnRed:hover, a.btnRed:focus, a.btnRed, a.btnRed:visited, a.btnRed:disabled, a.btnMoulinexRed:link {
    border: none;
    color: white;
    text-decoration: none;
    padding: 5px;
    font-family: iransans;
    font-weight: normal;
    font-size: 12px;
    cursor: pointer;
}
.btnRed:hover, .btnRed:hover:enabled, .btnRed:focus, .btnRed:focus:enabled,
a.btnRed:hover, a.btnRed:hover:enabled, .btnRed:focus, a.btnRed:focus:enabled {
    background: #830022;
    background-color: #830022 !important;
    color: white !important;
}
.btnRed:visited, .btnRed:link,  /*a.btnRed, */
a.btnRed:visited, a.btnRed:link {
    background: #ed1c24;
    background-color: #ed1c24;
    color: white;
}
.btnRed:active, .btnRed:active:enabled,
a.btnRed:active, a.btnRed:active:enabled
{
    background: #e6e6e6 !important;
    background-color: #e6e6e6 !important;
    color: #333 !important;
}
.btnRed:disabled,
a.btnRed:disabled, a.aspNetDisabled {
    color: #333 !important;
    background-color: #D6D1D1 !important;
}
/* --------------------------------------*/
/* FileUpload ---------------------------*/
.fileupload-group {
    position: relative;
    display: block;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    white-space: nowrap;
    margin-top: 3px;
    margin-bottom: 8px;
}
.fileupload-group .fileupload-name {
    display: inline-block;
    position: relative;
    width: 67%;
    margin-bottom: 0;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
.btnFileupload {
    display: inline-block;
    position: relative;
    white-space: nowrap;
    width: 17%;
    vertical-align: middle;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    -ms-border-top-right-radius: 4px;
    border-top-right-radius: 4px;
    -ms-border-bottom-right-radius: 4px;
    border-bottom-right-radius: 4px;
}
.fileupload-group .btnUpload {
    width: 15%;
    vertical-align: middle;
}
.fileupload-name {
    padding: 0;
    width: 100%;
    white-space: nowrap;
    height: 29px;
    padding: 4px 12px;
    font-size: 14px;
}
.fileupload-name.txtRight {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    -ms-border-top-right-radius: 0 ;
    border-top-right-radius: 0;
    -ms-border-bottom-right-radius: 0;
    border-bottom-right-radius: 0;
    display: inline-block;
    margin-right: -6px;

}
.fileupload-name.txtRight {
    background-color:#FFF;
    -ms-opacity: 1;
    opacity: 1;
    border: 1px solid #ffaaaa;
}
.fileupload-name.txtRight:disabled {
    background-color:#FFF;
    -ms-opacity: 1;
    opacity: 1;
    border: 1px solid #ccc;
}
.fileupload-group input[type=file] {
    display:inline-block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    -ms-opacity: 0;
    opacity: 0;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}
/* --------------------------------------*/

Make sure to use the latest browser version to run


问:
Execution failed for task ':app:validateSigningRelease'. Flutter error
I want to release my app but stack with this issue

```<code>FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'D:\FlutterProjects\Panaszok\02012020 - Copy (2) - Copy\Multi Restaurants Flutter App\android\app\key\panaszok.jks' not found for signing config 'release'.

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s
Running Gradle task 'assembleRelease'...                           23.9s
Gradle task assembleRelease failed with exit code 1
Process finished with exit code 1

----------------------------------Here is my build gradle-------------------------------------------------

    def localProperties = new Properties()
    def localPropertiesFile = rootProject.file('local.properties')
    if (localPropertiesFile.exists()) {
        localPropertiesFile.withReader('UTF-8') { reader ->
            localProperties.load(reader)
        }
    }

    def flutterRoot = localProperties.getProperty('flutter.sdk')
    if (flutterRoot == null) {
        throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
    }

    def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
    if (flutterVersionCode == null) {
        flutterVersionCode = '1'
    }

    def flutterVersionName = localProperties.getProperty('flutter.versionName')
    if (flutterVersionName == null) {
        flutterVersionName = '1.0'
    }

    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

    def keystorePropertiesFile = rootProject.file("key.properties")
    def keystoreProperties = new Properties()
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

    android {
        compileSdkVersion 28

        sourceSets {
            main.java.srcDirs += 'src/main/kotlin'
        }

        lintOptions {
            disable 'InvalidPackage'
        }

        defaultConfig {
            // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
            applicationId "com.panaszok.app"
            minSdkVersion 21
            targetSdkVersion 28
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }

        signingConfigs {
            release {
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
                storeFile file(keystoreProperties['storeFile'])
                storePassword keystoreProperties['storePassword']
            }
        }

        buildTypes {
            release {
                // TODO: Add your own signing config for the release build.
                // Signing with the debug keys for now, so `flutter run --release` works.
    //            signingConfig signingConfigs.debug
                signingConfig signingConfigs.release
            }
        }
    }

    flutter {
        source '../..'
    }

    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        implementation 'com.google.firebase:firebase-messaging:20.0.1'
        implementation 'androidx.annotation:annotation:1.1.0'
        implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    }

    //apply plugin: 'com.google.gms.google-services'
</code>```

----------------------------------------here is Key properties-----------------------------------------

```<code>storePassword=myPss
keyPassword=MyKpss
keyAlias=key
storeFile=D:/FlutterProjects/Panaszok/02012020 - Copy (2) - Copy/Multi Restaurants Flutter App/android/app/key/panaszok.jks
</code>```

--------------------------------------Here is flutter doctor -v-----------------------------------------

```<code>    [√] Flutter (Channel stable, v1.12.13+hotfix.7, on Microsoft Windows [Version 10.0.18363.657], locale en-US)
        • Flutter version 1.12.13+hotfix.7 at C:\src\flutter
        • Framework revision 9f5ff2306b (3 weeks ago), 2020-01-26 22:38:26 -0800
        • Engine revision a67792536c
        • Dart version 2.7.0

    [√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
        • Android SDK at C:\Users\Office\AppData\Local\Android\sdk
        • Android NDK location not configured (optional; useful for native profiling support)
        • Platform android-29, build-tools 29.0.2
        • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
        • All Android licenses accepted.

    [√] Android Studio (version 3.5)
        • Android Studio at C:\Program Files\Android\Android Studio
        • Flutter plugin version 43.0.1
        • Dart plugin version 191.8593
        • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

    [√] VS Code (version 1.41.1)
        • VS Code at C:\Users\Office\AppData\Local\Programs\Microsoft VS Code
        • Flutter extension version 3.7.1

    [√] Connected device (1 available)
        • Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator)

• No issues found!
</code>```

I tried this method but it did not help and gave another error

```<code> buildTypes {
        release {
            shrinkResources true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }
    }
</code>```

----------------------------------Error after minifyEnabled false--------------------------------------------

```<code>FAILURE: Build failed with an exception.

* Where:
Build file 'D:\FlutterProjects\Panaszok\02012020 - Copy (2) - Copy\Multi Restaurants Flutter App\android\build.gradle' line: 28

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Removing unused resources requires unused code shrinking to be turned on. See http://d.android.com/r/tools/shrink-resources.html for more information.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 870ms
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                       1.5s
Gradle task assembleRelease failed with exit code 1
</code>```

答:
The issue is clear

Keystore file not found for signing config 'release'

check this path

```<code>'D:\FlutterProjects\Panaszok\02012020 - Copy (2) - Copy\Multi Restaurants Flutter App\android\app\key\panaszok.jks'
</code>```

Body:
I want to release my app but stack with this issue

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file 'D:\FlutterProjects\Panaszok\02012020 - Copy (2) - Copy\Multi Restaurants Flutter App\android\app\key\panaszok.jks' not found for signing config 'release'.

* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 23s
Running Gradle task 'assembleRelease'...                           23.9s
Gradle task assembleRelease failed with exit code 1
Process finished with exit code 1

----------------------------------Here is my build gradle-------------------------------------------------

    def localProperties = new Properties()
    def localPropertiesFile = rootProject.file('local.properties')
    if (localPropertiesFile.exists()) {
        localPropertiesFile.withReader('UTF-8') { reader ->
            localProperties.load(reader)
        }
    }

    def flutterRoot = localProperties.getProperty('flutter.sdk')
    if (flutterRoot == null) {
        throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
    }

    def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
    if (flutterVersionCode == null) {
        flutterVersionCode = '1'
    }

    def flutterVersionName = localProperties.getProperty('flutter.versionName')
    if (flutterVersionName == null) {
        flutterVersionName = '1.0'
    }

    apply plugin: 'com.android.application'
    apply plugin: 'kotlin-android'
    apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

    def keystorePropertiesFile = rootProject.file("key.properties")
    def keystoreProperties = new Properties()
    keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

    android {
        compileSdkVersion 28

        sourceSets {
            main.java.srcDirs += 'src/main/kotlin'
        }

        lintOptions {
            disable 'InvalidPackage'
        }

        defaultConfig {
            // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
            applicationId "com.panaszok.app"
            minSdkVersion 21
            targetSdkVersion 28
            versionCode flutterVersionCode.toInteger()
            versionName flutterVersionName
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }

        signingConfigs {
            release {
                keyAlias keystoreProperties['keyAlias']
                keyPassword keystoreProperties['keyPassword']
                storeFile file(keystoreProperties['storeFile'])
                storePassword keystoreProperties['storePassword']
            }
        }

        buildTypes {
            release {
                // TODO: Add your own signing config for the release build.
                // Signing with the debug keys for now, so `flutter run --release` works.
    //            signingConfig signingConfigs.debug
                signingConfig signingConfigs.release
            }
        }
    }

    flutter {
        source '../..'
    }

    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
        implementation 'com.google.firebase:firebase-messaging:20.0.1'
        implementation 'androidx.annotation:annotation:1.1.0'
        implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    }

    //apply plugin: 'com.google.gms.google-services'

----------------------------------------here is Key properties-----------------------------------------

storePassword=myPss
keyPassword=MyKpss
keyAlias=key
storeFile=D:/FlutterProjects/Panaszok/02012020 - Copy (2) - Copy/Multi Restaurants Flutter App/android/app/key/panaszok.jks

--------------------------------------Here is flutter doctor -v-----------------------------------------

    [√] Flutter (Channel stable, v1.12.13+hotfix.7, on Microsoft Windows [Version 10.0.18363.657], locale en-US)
        • Flutter version 1.12.13+hotfix.7 at C:\src\flutter
        • Framework revision 9f5ff2306b (3 weeks ago), 2020-01-26 22:38:26 -0800
        • Engine revision a67792536c
        • Dart version 2.7.0

    [√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
        • Android SDK at C:\Users\Office\AppData\Local\Android\sdk
        • Android NDK location not configured (optional; useful for native profiling support)
        • Platform android-29, build-tools 29.0.2
        • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
        • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
        • All Android licenses accepted.

    [√] Android Studio (version 3.5)
        • Android Studio at C:\Program Files\Android\Android Studio
        • Flutter plugin version 43.0.1
        • Dart plugin version 191.8593
        • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

    [√] VS Code (version 1.41.1)
        • VS Code at C:\Users\Office\AppData\Local\Programs\Microsoft VS Code
        • Flutter extension version 3.7.1

    [√] Connected device (1 available)
        • Android SDK built for x86 • emulator-5554 • android-x86 • Android 7.1.1 (API 25) (emulator)

• No issues found!

I tried this method but it did not help and gave another error

 buildTypes {
        release {
            shrinkResources true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),
                    'proguard-rules.pro'
        }
    }

----------------------------------Error after minifyEnabled false--------------------------------------------

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\FlutterProjects\Panaszok\02012020 - Copy (2) - Copy\Multi Restaurants Flutter App\android\build.gradle' line: 28

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > Removing unused resources requires unused code shrinking to be turned on. See http://d.android.com/r/tools/shrink-resources.html for more information.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 870ms
Running Gradle task 'assembleRelease'...
Running Gradle task 'assembleRelease'... Done                       1.5s
Gradle task assembleRelease failed with exit code 1

Body:
The issue is clear

Keystore file not found for signing config 'release'

check this path

'D:\FlutterProjects\Panaszok\02012020 - Copy (2) - Copy\Multi Restaurants Flutter App\android\app\key\panaszok.jks'


问:
How to check if dropdown is toggle on and add class
I want to check if the dropdown menu is toggled. If the menu has a class: mega-toggle-on then add a class to id #submenu-new.

Here is my code:

```<code>  <div id="submenu-new" class="submenu-balk active" style="padding-top: 226px;">

      </div>

<script type="text/javascript">
if ( jQuery( "#mega-menu-wrap-max_mega_menu_1 ul li" ).is( ".mega-toggle-on" ) ) {

 jQuery("#submenu-new").addClass("active");
alert('ss');

}
</script>
</code>```

Example where you can find the mega-toggle-on class

答:
You can try like this:

if ($("#mega-menu-wrap-max_mega_menu_1 ul li").hasClass("mega-toggle-on")) {
    $("#submenu-new").addClass("active");
}
```

You can find documentation of hasClass of jQuery here

Body:
I want to check if the dropdown menu is toggled. If the menu has a class: mega-toggle-on then add a class to id #submenu-new.

Here is my code:

Example where you can find the mega-toggle-on class

Body:
You can try like this:

if ($("#mega-menu-wrap-max_mega_menu_1 ul li").hasClass("mega-toggle-on")) {
    $("#submenu-new").addClass("active");
}

You can find documentation of hasClass of jQuery here


问:
Read-only outlet?
Let's say I have a class. I would like to declare a property in the following way:

From outside of the class it should be read-only if accessed programmatically;

It should be possible to set the value from the Interface Builder using an outlet;

(From inside the class it should be writable, but I know how to do it).

The "solution" I came up with is to write a one-time setter:

```<code>- (void) setA: (ClassA *)a {
    if (aHaveBeenSet)
        return;
    else {
        // do what a setter have to do
        aHaveBeenSet == YES;
    }
}
</code>```

But this setter still can be called from the code (though only once in effect), so it's not quite a solution.

Another way is to mark the ivar as IBOutlet and make the property readonly like this:

```<code>@interface MyClass : NSObject {
     IBOutlet ClassA *a;
}
@property (readonly) ClassA *a;
@end
</code>```

But according to this answer, it's a poor style and makes memory management unclear.

Any ideas?

答:
Someone correct me if I'm wrong, but I think the NIB loading mechanism checks for a setter method only when instantiating a .nib file at runtime.  So that means you could declare your public property as readonly but write a "private" setter in your .m file:

```<code>// MyClass.h
@property (readonly, retain) IBOutlet ClassA *a;
</code>```

```<code>// MyClass.m
@interface MyClass ()
@property (readwrite, retain) ClassA *a;
@end

@implementation MyClass
@synthesize a;
...
@end
</code>```

Title: Read-only outlet?

Body:
Let's say I have a class. I would like to declare a property in the following way:

From outside of the class it should be read-only if accessed programmatically;

It should be possible to set the value from the Interface Builder using an outlet;

(From inside the class it should be writable, but I know how to do it).

The "solution" I came up with is to write a one-time setter:

- (void) setA: (ClassA *)a {
    if (aHaveBeenSet)
        return;
    else {
        // do what a setter have to do
        aHaveBeenSet == YES;
    }
}

But this setter still can be called from the code (though only once in effect), so it's not quite a solution.

Another way is to mark the ivar as IBOutlet and make the property readonly like this:

@interface MyClass : NSObject {
     IBOutlet ClassA *a;
}
@property (readonly) ClassA *a;
@end

But according to this answer, it's a poor style and makes memory management unclear.

Any ideas?

Body:
Someone correct me if I'm wrong, but I think the NIB loading mechanism checks for a setter method only when instantiating a .nib file at runtime.  So that means you could declare your public property as readonly but write a "private" setter in your .m file:

// MyClass.h
@property (readonly, retain) IBOutlet ClassA *a;

// MyClass.m
@interface MyClass ()
@property (readwrite, retain) ClassA *a;
@end

@implementation MyClass
@synthesize a;
...
@end


问:
Serializer not writing individual object from queryset
I am using a ModelForm to capture some data for a model and, while I want this data saved to a db, I also want to export it to an XML file for transformation/use in an external system.

Please see below for an example:

```<code>def warranty(request):
    WarrantyFormSet = modelformset_factory(Warranty, form=WarrantyForm)
    if request.method == 'POST':
        formset = WarrantyFormSet(request.POST, request.FILES)
        if formset.is_valid():
            new = formset.save(commit=False)
            out = open("file.xml", "w")
            XMLSerializer = serializers.get_serializer("xml")
            xml_serializer = XMLSerializer()

            for n in new:
                xml_serializer.serialize(Warranty.objects.all(), stream=out)
                #.filter(id = n.id)
                n.save()

            return HttpResponse(xml_serializer.serialize(Warranty.objects.filter(id = n.id)))
    else:
        formset = WarrantyFormSet(queryset = Warranty.objects.none())
    return render(request,'warranty.html', {'formset': formset})
</code>```

The object is serializing appropriately in the HttpResponse (ie I can see an acceptable XML output), but there is no output in the XML file itself. If I remove the QuerySet filter (i.e. call .all()), then the XML file will correctly have all objects related to the Warranty model. It seems strange that the behaviour is fine in one circumstance in not theother, so I can't trouble shoot any further.

答:
The issue is that you're trying to serialize the objects before they are actually saved to the database - so the queryset passed to the serializer will not contain this new item. Change the order around:

```<code>for n in new:
    n.save()
    xml_serializer.serialize(Warranty.objects.filter(id=n.id), stream=out)
</code>```

Also note that your current logic write a new serialization to the file inside your for loop - which I am not sure is what you want. You could instead serialize everything at once like so:

```<code>if request.method == 'POST':
    formset = WarrantyFormSet(request.POST, request.FILES)
    if formset.is_valid():
        new_items = formset.save()  # commit = True since you don't need to change anything before saving
        new_item_ids = [n.id for n in new_items]
        with open("file.xml", "w") as out:
            XMLSerializer = serializers.get_serializer("xml")
            xml_serializer = XMLSerializer()
            xml_serializer.serialize(
                Warranty.objects.filter(id__in=new_item_ids), stream=out)
</code>```

Body:
I am using a ModelForm to capture some data for a model and, while I want this data saved to a db, I also want to export it to an XML file for transformation/use in an external system.

Please see below for an example:

def warranty(request):
    WarrantyFormSet = modelformset_factory(Warranty, form=WarrantyForm)
    if request.method == 'POST':
        formset = WarrantyFormSet(request.POST, request.FILES)
        if formset.is_valid():
            new = formset.save(commit=False)
            out = open("file.xml", "w")
            XMLSerializer = serializers.get_serializer("xml")
            xml_serializer = XMLSerializer()

            for n in new:
                xml_serializer.serialize(Warranty.objects.all(), stream=out)
                #.filter(id = n.id)
                n.save()

            return HttpResponse(xml_serializer.serialize(Warranty.objects.filter(id = n.id)))
    else:
        formset = WarrantyFormSet(queryset = Warranty.objects.none())
    return render(request,'warranty.html', {'formset': formset})

The object is serializing appropriately in the HttpResponse (ie I can see an acceptable XML output), but there is no output in the XML file itself. If I remove the QuerySet filter (i.e. call .all()), then the XML file will correctly have all objects related to the Warranty model. It seems strange that the behaviour is fine in one circumstance in not theother, so I can't trouble shoot any further.

Body:
The issue is that you're trying to serialize the objects before they are actually saved to the database - so the queryset passed to the serializer will not contain this new item. Change the order around:

for n in new:
    n.save()
    xml_serializer.serialize(Warranty.objects.filter(id=n.id), stream=out)

Also note that your current logic write a new serialization to the file inside your for loop - which I am not sure is what you want. You could instead serialize everything at once like so:

if request.method == 'POST':
    formset = WarrantyFormSet(request.POST, request.FILES)
    if formset.is_valid():
        new_items = formset.save()  # commit = True since you don't need to change anything before saving
        new_item_ids = [n.id for n in new_items]
        with open("file.xml", "w") as out:
            XMLSerializer = serializers.get_serializer("xml")
            xml_serializer = XMLSerializer()
            xml_serializer.serialize(
                Warranty.objects.filter(id__in=new_item_ids), stream=out)