问:
How to export data from bigquery to apps scripts
How to export large data from bigquery to apps scripts?
I ve tried method BigQuery.TableData.list() but with large data it just doesnt work.
Also i ve tried to do it with simple Query

```<code>SELECT * FROM table
</code>```

But it returns only 70000 of 1.2M.
How to export this data in json file with job?Or what is other solutions

答:
You may use BigQuery.Jobs.query() function to get your data and export it to JSON.

However, this function only retrieves ALL rows from one page of the query result.

For you to retrieve all other data from all pages of the query result, you will need to add the below while loop using pageToken for jobs.getQueryResults() parameter to loop and concatenate the retrieve rows per page as shown on below code. The jobs.getQueryResults() can only return up to 20MB that is why we will be needing to loop and concatenate through pages. You may refer to this Paging Through Tables Documentation for more details.

```<code>function myFunction() {
  var projectId = '<project_ID>';

  var request = {
    query: 'SELECT * ' +
      'FROM `publicdata.samples.shakespeare`;',
    useLegacySql: false
  };

  var queryResults = BigQuery.Jobs.query(request, projectId);
  var jobId = queryResults.jobReference.jobId;
  queryResults = BigQuery.Jobs.getQueryResults(projectId, jobId);

  var rows = queryResults.rows;

  while (queryResults.pageToken) {
    queryResults = BigQuery.Jobs.getQueryResults(projectId, jobId, {
      pageToken: queryResults.pageToken
    });
    rows = rows.concat(queryResults.rows);
  }

  console.log(rows.length);
}
</code>```

Below is the execution result of the code without using the while loop. I was able to retrieve only 87500 out of 164656 total rows from the shakespeare table.

Below is the execution result of the code that is using the while loop. I was able to retrieve all 164656 out of 164656 total rows from the shakespeare table.

UPDATE:
Please see below updated code:

```<code> function myFunction() {
      var projectId = '<project_ID>';

      var request = {
        query: 'SELECT * ' +
          'FROM `bigquery-public-data.census_bureau_usa.population_by_zip_2010`;',
        useLegacySql: false
      };

      var max = 10000;

      var queryResults = BigQuery.Jobs.query(request, projectId, {
          maxResults: max
        });

      var jobId = queryResults.jobReference.jobId;
      queryResults = BigQuery.Jobs.getQueryResults(projectId, jobId, {
          maxResults: max
        });

      var rows = queryResults.rows;

     let i = 0;
     while (i < 5) {
        queryResults = BigQuery.Jobs.getQueryResults(projectId, jobId, {
          pageToken: queryResults.pageToken,
          maxResults: max
        });
         i++;
        rows = rows.concat(queryResults.rows);
      }

      console.log(rows.length);
    }

</code>```

I used the bigquery-public-data.census_bureau_usa.population_by_zip_2010 since it has 1.6M records to replicate the big data similar to your scenario. I also added an iteration in order to confirm that we are able to retrieve specific number of rows from a big dataset.

See below result of successful execution that was able to retrieve 60000 rows out of 1.6M records based on our loop condition.

However, when we remove the iteration and use the while (queryResults.pageToken) as done on my first answer, we will be encountering out of memory or runtime exit (when we use BigQuery.TableData.list() method) since it will get all rows from a big dataset in which App Script might not handle due to certain limits. You may see this App Script Quota Documentation for your reference.

I suggest to use a Virtual Machine where you can host your code and be able to handle big data retrieval.

Body:
How to export large data from bigquery to apps scripts?
I ve tried method BigQuery.TableData.list() but with large data it just doesnt work.
Also i ve tried to do it with simple Query

SELECT * FROM table

But it returns only 70000 of 1.2M.
How to export this data in json file with job?Or what is other solutions

Body:
You may use BigQuery.Jobs.query() function to get your data and export it to JSON.

However, this function only retrieves ALL rows from one page of the query result.

For you to retrieve all other data from all pages of the query result, you will need to add the below while loop using pageToken for jobs.getQueryResults() parameter to loop and concatenate the retrieve rows per page as shown on below code. The jobs.getQueryResults() can only return up to 20MB that is why we will be needing to loop and concatenate through pages. You may refer to this Paging Through Tables Documentation for more details.

function myFunction() {
  var projectId = '<project_ID>';

  var request = {
    query: 'SELECT * ' +
      'FROM `publicdata.samples.shakespeare`;',
    useLegacySql: false
  };

  var queryResults = BigQuery.Jobs.query(request, projectId);
  var jobId = queryResults.jobReference.jobId;
  queryResults = BigQuery.Jobs.getQueryResults(projectId, jobId);

  var rows = queryResults.rows;

  while (queryResults.pageToken) {
    queryResults = BigQuery.Jobs.getQueryResults(projectId, jobId, {
      pageToken: queryResults.pageToken
    });
    rows = rows.concat(queryResults.rows);
  }

  console.log(rows.length);
}

Below is the execution result of the code without using the while loop. I was able to retrieve only 87500 out of 164656 total rows from the shakespeare table.

Below is the execution result of the code that is using the while loop. I was able to retrieve all 164656 out of 164656 total rows from the shakespeare table.

UPDATE:
Please see below updated code:

 function myFunction() {
      var projectId = '<project_ID>';

      var request = {
        query: 'SELECT * ' +
          'FROM `bigquery-public-data.census_bureau_usa.population_by_zip_2010`;',
        useLegacySql: false
      };

      var max = 10000;

      var queryResults = BigQuery.Jobs.query(request, projectId, {
          maxResults: max
        });

      var jobId = queryResults.jobReference.jobId;
      queryResults = BigQuery.Jobs.getQueryResults(projectId, jobId, {
          maxResults: max
        });

      var rows = queryResults.rows;

     let i = 0;
     while (i < 5) {
        queryResults = BigQuery.Jobs.getQueryResults(projectId, jobId, {
          pageToken: queryResults.pageToken,
          maxResults: max
        });
         i++;
        rows = rows.concat(queryResults.rows);
      }

      console.log(rows.length);
    }

I used the bigquery-public-data.census_bureau_usa.population_by_zip_2010 since it has 1.6M records to replicate the big data similar to your scenario. I also added an iteration in order to confirm that we are able to retrieve specific number of rows from a big dataset.

See below result of successful execution that was able to retrieve 60000 rows out of 1.6M records based on our loop condition.

However, when we remove the iteration and use the while (queryResults.pageToken) as done on my first answer, we will be encountering out of memory or runtime exit (when we use BigQuery.TableData.list() method) since it will get all rows from a big dataset in which App Script might not handle due to certain limits. You may see this App Script Quota Documentation for your reference.

I suggest to use a Virtual Machine where you can host your code and be able to handle big data retrieval.


来源: stackexchange

问:
Collection admin role not found in IAM for Azure purview
To "add a collection", I think I need to have "collection admin" role in Azure purview. However, when I am going to Azure purview account and clicks on "Access control(IAM)" -> "role assignments", I don't see "collection admin".

My question is, where can I see "collection admin"? Is it only from Azure Purview Studio?

Also, I can see I have access to a access package, and this access package has security group added as "resource role" (that is, "+Add resource roles" ) and I'm a member of the security group as "contributor eligible". The security group is created for Azure Purview.

Another question is, if I am a member of "Azure purview contributor eligible" security group, then why I'm not considered as "collection admin" and why "add a collection (+ Add a collection) is greyed out for me?

Note, I referred this link but unable to get a clear idea. How can I make +Add a collection enabled for me?

答:
To "add a collection", I think I need to have "collection admin" role
in Azure purview. However, when I am going to Azure purview account
and clicks on "Access control(IAM)" -> "role assignments", I don't see
"collection admin".

My question is, where can i see "collection admin"? Is it only from
Azure Purview Studio?
My another question is, if I am a member of "Azure purview contributor
eligible" security group, then why I'm not considered as "collection
admin" and why "add a collection (+ Add a collection) is greyed out
for me?

Collection Admin is a permission/role for Azure Purview which can be only found from Azure Purview studio. As mentioned in this Microsoft Document on how to create/manage Collections in Azure purview , you need to have Collection Admin Role assigned to you in order to perform operations related to Collection.

How can I make +Add a collection enabled for me?

As the Azure purview contributor eligible Security group is not added in collection Admin role assignment , you will have to add it by following the above shared Microsoft document or reach out to the admin to grant you the collection admin permission so that you can create/manage collections.

ContentLicense: CC BY-SA 4.0


问:
Does "new char[]" need to be release resources manually?
For this:
m_sFilename = new char [len+1];

Should I call delete[] m_sFilename; sometime?

And:

should I use delete[] m_sFilename or delete m_sFilename;?

答:
Does "new char[]" need to be release resouces manually?

Yes.

For this: m_sFilename = new char [len+1];
  Should I call delete[] m_sFilename; sometime?

Yes.

Should I use delete[] m_sFilename or delete m_sFilename;?

delete[].

But you should actually use std::string, which does all this for you, and is free.

ContentLicense: CC BY-SA 3.0


问:
Reseting number java
So i got problem in java to determine who the last kid who got the candy, n is how many children, m is how many candy, and s is the number of kid who got the first candy.
so basically if n =4, m=6, and s =2 the answer is 3, because all started from 2(number of kid who got the first candy)->3->4 and restart to 1->2->3 and 3 is the last kid who got the candy.
the code run perfectly but i encounter bug at n = 3333, m =3333, and s = 1</p>
```<code>public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int s = in.nextInt();
        int total = m%n;
        int jaw = total+s-1;
            System.out.print(jaw);

}
</code>```

答:
I assume the "bug" you're mentioning is that jaw is 0, right? That's because 3333%3333 will be 0 and thus 0 + s - 1 will be 0 as well (0+1-1 = 0).

You're on the right track, i.e. m % n would tell you how many pieces of candy are left after everyone got a fair/equal share.

Now you just distribute the "rest" (total) which means you "add" it to "first child" (s). Let's say this is c = s + total, so c is the last child that got anything. You subtract -1 because if you add anything the "cursor" advances to the next child and thus you want to track back.

However, what if you didn't have anything to distribute? Then the last child that got anything was the one before the first, which in case of 4 children and starting at 1 would be the 4th. Your calculation results in 0 which basically would express this.

Another problem you might face with your code is that if you start at the last child (say 4) and have 2 pieces of candy to distribute, then you'd get the "5th" child instead of the "1st" to be the last to get something: 2 + 4 - 1 = 5.

So how do you solve that?

Add jaw %= n to handle the "overflow" (if you start at the last child and distributed 2 more pieces of candy, the first would get it)

Check if jaw == 0 in which case the solution would be jaw = n (the last child got the last candy)

Title: Reseting number java

Body:
So i got problem in java to determine who the last kid who got the candy, n is how many children, m is how many candy, and s is the number of kid who got the first candy.
so basically if n =4, m=6, and s =2 the answer is 3, because all started from 2(number of kid who got the first candy)->3->4 and restart to 1->2->3 and 3 is the last kid who got the candy.
the code run perfectly but i encounter bug at n = 3333, m =3333, and s = 1

public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int s = in.nextInt();
        int total = m%n;
        int jaw = total+s-1;
            System.out.print(jaw);

}


问:
Compare two array of objects and remove objects from first array if a property value is matched
I have 2 array of objects like

```<code>    const arrayOne = [{id: 1, name: 'one'}, {id: 2, name: 'two'}, {id: 3, name: 'three'}];
    const arrayTwo = [{id: 2, name: 'two'}, {id: 3, name: 'three'}];
</code>```

Here, I need to compare both these arrays and remove matching objects from arrayOne, which should finally give

```<code> this.arrayOne = [{id: 1, name: 'one'}];
</code>```

I tried like below but it is removing all objects from the array

```<code>this.arrayOne = this.arrayOne.filter(o1 => this.arrayTwo.some(o2 => o1.id === o2.id));
</code>```

What I am doing wrong here? Please suggest. Thanks

答:
const arrayOne = [{
  id: 1,
  name: 'one'
}, {
  id: 2,
  name: 'two'
}, {
  id: 3,
  name: 'three'
}];

const arrayTwo = [{
  id: 2,
  name: 'two'
}, {
  id: 3,
  name: 'three'
}];
const arrayTwoId = arrayTwo.map(el => (el.id)); // extract id from arrayTwo

const result = arrayOne.filter(el => !arrayTwoId.includes(el.id));
console.log(result);```

Extract all the ids from the arrayTwo.

filter those objects who do not match the array of ids of arrayTwo.

Body:
I have 2 array of objects like

    const arrayOne = [{id: 1, name: 'one'}, {id: 2, name: 'two'}, {id: 3, name: 'three'}];
    const arrayTwo = [{id: 2, name: 'two'}, {id: 3, name: 'three'}];

Here, I need to compare both these arrays and remove matching objects from arrayOne, which should finally give

 this.arrayOne = [{id: 1, name: 'one'}];

I tried like below but it is removing all objects from the array

this.arrayOne = this.arrayOne.filter(o1 => this.arrayTwo.some(o2 => o1.id === o2.id));

What I am doing wrong here? Please suggest. Thanks

Body:
const arrayOne = [{
  id: 1,
  name: 'one'
}, {
  id: 2,
  name: 'two'
}, {
  id: 3,
  name: 'three'
}];

const arrayTwo = [{
  id: 2,
  name: 'two'
}, {
  id: 3,
  name: 'three'
}];
const arrayTwoId = arrayTwo.map(el => (el.id)); // extract id from arrayTwo

const result = arrayOne.filter(el => !arrayTwoId.includes(el.id));
console.log(result);

Extract all the ids from the arrayTwo.

filter those objects who do not match the array of ids of arrayTwo.


问:
gcp cloud function returns 404 when deployed from command line
If I deploy the example hello world within the console, the url/trigger works. If I deploy from command line it looks to be exact same code / attributes in cloud functions console, but the url is 404. I can't spot the difference/issue.

The deployed trigger/url shows - "404 page not found" for the below hello world example if deployed this way from command line.

```<code>gcloud functions deploy hellogo --entry-point=HelloWorld --trigger-http --region=us-central1 --memory=128MB --runtime=go116 --allow-unauthenticated
</code>```

// Package p contains an HTTP Cloud Function.
package p

import (
    "encoding/json"
    "fmt"
    "html"
    "io"
    "log"
    "net/http"
)

// HelloWorld prints the JSON encoded "message" field in the body
// of the request or "Hello, World!" if there isn't one.
func HelloWorld(w http.ResponseWriter, r *http.Request) {
    var d struct {
        Message string `json:"message"`
    }

    if err := json.NewDecoder(r.Body).Decode(&d); err != nil {
        switch err {
        case io.EOF:
            fmt.Fprint(w, "Hello World!")
            return
        default:
            log.Printf("json.NewDecoder: %v", err)
            http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
            return
        }
    }

    if d.Message == "" {
        fmt.Fprint(w, "Hello World!")
        return
    }
    fmt.Fprint(w, html.EscapeString(d.Message))
}```

答:
Tried to reproduce your error but couldn't replicate on my end. I've use the same command as yours and I can successfully access the url or call via HTTP trigger the deployed hello world cloud function.

gcloud functions deploy hellogo --entry-point=HelloWorld --trigger-http --region=us-central1 --memory=128MB --runtime=go116 --allow-unauthenticated```

Output of successful curl:

I suggest you check the url you're trying to access since according to this GCP doc:

If you attempt to invoke a function that does not exist, Cloud Functions responds with an HTTP/2 302 redirect which takes you to the Google account login page. This is incorrect. It should respond with an HTTP/2 404 error response code. The problem is being addressed.

The solution

Make sure you specify the name of your function correctly. You can
always check using gcloud functions call which returns the correct 404
error for a missing function.

You can also refer to this complete guide to quickstart your CF creation and deployment using the Go runtime.

Body:
If I deploy the example hello world within the console, the url/trigger works. If I deploy from command line it looks to be exact same code / attributes in cloud functions console, but the url is 404. I can't spot the difference/issue.

The deployed trigger/url shows - "404 page not found" for the below hello world example if deployed this way from command line.

gcloud functions deploy hellogo --entry-point=HelloWorld --trigger-http --region=us-central1 --memory=128MB --runtime=go116 --allow-unauthenticated

// Package p contains an HTTP Cloud Function.
package p

import (
    "encoding/json"
    "fmt"
    "html"
    "io"
    "log"
    "net/http"
)

// HelloWorld prints the JSON encoded "message" field in the body
// of the request or "Hello, World!" if there isn't one.
func HelloWorld(w http.ResponseWriter, r *http.Request) {
    var d struct {
        Message string `json:"message"`
    }

    if err := json.NewDecoder(r.Body).Decode(&d); err != nil {
        switch err {
        case io.EOF:
            fmt.Fprint(w, "Hello World!")
            return
        default:
            log.Printf("json.NewDecoder: %v", err)
            http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest)
            return
        }
    }

    if d.Message == "" {
        fmt.Fprint(w, "Hello World!")
        return
    }
    fmt.Fprint(w, html.EscapeString(d.Message))
}

Body:
Tried to reproduce your error but couldn't replicate on my end. I've use the same command as yours and I can successfully access the url or call via HTTP trigger the deployed hello world cloud function.

gcloud functions deploy hellogo --entry-point=HelloWorld --trigger-http --region=us-central1 --memory=128MB --runtime=go116 --allow-unauthenticated

Output of successful curl:

I suggest you check the url you're trying to access since according to this GCP doc:

If you attempt to invoke a function that does not exist, Cloud Functions responds with an HTTP/2 302 redirect which takes you to the Google account login page. This is incorrect. It should respond with an HTTP/2 404 error response code. The problem is being addressed.

The solution

Make sure you specify the name of your function correctly. You can
always check using gcloud functions call which returns the correct 404
error for a missing function.

You can also refer to this complete guide to quickstart your CF creation and deployment using the Go runtime.


问:
How to iterate through a nested list of dictionaries in Python
I have a bit complicated json response from a server, below is my  json:

```<code>    services = [{"Mobile": [{"name": "CompanyA", id: 0, address: "XYZ"},
    {"name": CompanyB, id: 1, address: "QWE"},
    {"name": CompanyC, id: 2, address: "TYU"}]
    },
    {"Computer": [{"name": "CompanyD", id: 3, address: "PPP"},
    {"name": CompanyD, id: 4, address: "UYU"},
    {"name": CompanyE, id: 5, address: "NMB"}]
    }]
</code>```

I need to construct new dictionary which only holds bellow data:

```<code>services = [{"Mobile": [{"name": "CompanyA"},{"name": "CompanyB"},
          {"name": "CompanyC"}]},
          {"Computer": [{"name": "CompanyD"},{"name": "CompanyD"},
          {"name": "CompanyE"}]
    }]
</code>```

in other words, delete id and address fields.

答:
You can iterate over all values in a nested dictionary  and delete:

```<code>D = {'emp1': {'name': 'Bob', 'job': 'Mgr'},
         'emp2': {'name': 'Kim', 'job': 'Dev'},
         'emp3': {'name': 'Sam', 'job': 'Dev'}}
    for id, info in D.items():
        print("\nEmployee ID:", id)
        for key in info:
            print(key + ':', info[key])
    # Prints Employee ID: emp1
    #        name: Bob
    #        job: Mgr
    #        Employee ID: emp2
    #        name: Kim
    #        job: Dev
    #        Employee ID: emp3
    #        name: Sam
    #        job: Dev
</code>```

You can see more about here: https://www.learnbyexample.org/python-nested-dictionary/

Body:
I have a bit complicated json response from a server, below is my  json:

    services = [{"Mobile": [{"name": "CompanyA", id: 0, address: "XYZ"},
    {"name": CompanyB, id: 1, address: "QWE"},
    {"name": CompanyC, id: 2, address: "TYU"}]
    },
    {"Computer": [{"name": "CompanyD", id: 3, address: "PPP"},
    {"name": CompanyD, id: 4, address: "UYU"},
    {"name": CompanyE, id: 5, address: "NMB"}]
    }]

I need to construct new dictionary which only holds bellow data:

services = [{"Mobile": [{"name": "CompanyA"},{"name": "CompanyB"},
          {"name": "CompanyC"}]},
          {"Computer": [{"name": "CompanyD"},{"name": "CompanyD"},
          {"name": "CompanyE"}]
    }]

in other words, delete id and address fields.

Body:
You can iterate over all values in a nested dictionary  and delete:

D = {'emp1': {'name': 'Bob', 'job': 'Mgr'},
         'emp2': {'name': 'Kim', 'job': 'Dev'},
         'emp3': {'name': 'Sam', 'job': 'Dev'}}
    for id, info in D.items():
        print("\nEmployee ID:", id)
        for key in info:
            print(key + ':', info[key])
    # Prints Employee ID: emp1
    #        name: Bob
    #        job: Mgr
    #        Employee ID: emp2
    #        name: Kim
    #        job: Dev
    #        Employee ID: emp3
    #        name: Sam
    #        job: Dev

You can see more about here: https://www.learnbyexample.org/python-nested-dictionary/


问:
Wcf Request Lifecycle
Is there a lifecycle that WCF requests go through?  Specifically I need to be able to intercept and possibly cancel requests made before they get to the method that was invoked.</p>

答:
You could write your code in

```<code>void Application_BeginRequest(object sender, EventArgs e)
    {
    }
</code>```

OR

```<code>void Application_EndRequest(object sender, EventArgs e)
    {
    }
</code>```

events in the global.asax on the serverside.

ContentLicense: CC BY-SA 2.5

Title: Wcf Request Lifecycle

Body:
You could write your code in

void Application_BeginRequest(object sender, EventArgs e)
    {
    }

OR

void Application_EndRequest(object sender, EventArgs e)
    {
    }

events in the global.asax on the serverside.


问:
ASP.NET Web Control shows old data after the first postback
I'm having a weird problem with a custom Web Control in an ASP.NET forms application.

For a web application, I figured that it would save me a lot of time to create a class which inherits from CompositeControl which combines a label with some other control such as a TextBox or DropDownList. This composite control has several properties that wrap properties of the underlying properties (e.g.: EnteredText wraps TextBox.Text). The controls can be used for databinding in the same way as the regular ones, but instead of txtBox.Text = someObject.someProperty you use compositeControl.EnteredText = someObject.someProperty.
These controls are then used on ASPX pages and ASCX user controls.

The first version of the web controls is written in C# and works perfectly. These controls are placed in the App_Code folder of the website. However, this folder was getting rather big and because of policy I have to write everything in VB.NET, so I decided to make a class library to put the VB.NET version of the controls in there, so that I don't have to translate the entire web application to VB.NET but only the controls.

However, the VB.NET version does not work. When I click the link in a GridView, it opens a popup and populates all the textboxes properly. When close the screen and click some other link from the same grid, the boxes are not populated properly and the data from the first postback is visible in the boxes. When using the debugger, I see that all boxes are populated with the proper data, and during the render phase the Text property of the underlying TextBox shows all of the new data. It just doesn't show that on screen. Retrieving the data after postback, like when pressing a save button, works as normal.

When I place a control from the App_Code folder on the same page, it works as expected and shows the new data and not the data from the previous postback.

Here are two paste bin URLs, the first goes to the working C# version and the second to the VB.NET version.

C# version: http://pastebin.com/SuWaHrMt

VB.NET version: http://pastebin.com/9aeV7St1

Here is an example how it's used in an ASCX file:

```<code><%@ Control Language="C#" AutoEventWireup="true" CodeFile="CustomControl.ascx.cs" Inherits="Controls_CustomControl" %>
<%@ Register Namespace="UI.CompositeControls" TagPrefix="cs" %>

<cs:TextBoxWithLabel ID="TextBoxWithLabel1" runat="server" LabelText="Voornaam" />
<cc:LabeledTextBox ID="tbwlVoornaam" runat="server" LabelText="Voornaam" />
</code>```

The cc prefix is specified in the web.config:

```<code><pages theme="Default" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
  <controls>
    <add assembly="CompositeControls" namespace="CompositeControls" tagPrefix="cc" />
  </controls>
  <namespaces>
    <add namespace="CompositeControls" />
  </namespaces>
</pages>
</code>```

What am I missing here that makes the C# version work and the VB version not?

Thanks in advance! Feel free to ask questions if you want some clarification.

Update:
I disabled the ViewState on the encompassing ASCX in question and it works:

```<code><%@ Control Language="C#" AutoEventWireup="true" CodeFile="CustomControl.ascx.cs" EnableViewState="false" Inherits="Controls_CustomControl" %>
</code>```

My colleague found the following snippet:

If you reinsert controls with each round trip, each generation of
  dynamically created controls will pick up property values from the view
  state of the preceding set of controls. In many cases, you can avoid this
  problem by setting the EnableViewState property of the container control to
  false. In that case, no information about the dynamic controls is saved, and
  there is no conflict with successive versions of the controls.

I'm just not sure how this suddenly applies to the controls. Based on this MSDN article on ViewState I'm guessing that it happens because the Controls are added in the CreateChildControls method which occurs after the postback events.

Can someone explain what exactly is going on here?

答:
In which browsers are you experiencing the issue?
I recently had a similar problem in Firefox that was solved by just disabling Firebug caching.
(http://i.stack.imgur.com/bRRjb.jpg)</p>

Body:
I'm having a weird problem with a custom Web Control in an ASP.NET forms application.

For a web application, I figured that it would save me a lot of time to create a class which inherits from CompositeControl which combines a label with some other control such as a TextBox or DropDownList. This composite control has several properties that wrap properties of the underlying properties (e.g.: EnteredText wraps TextBox.Text). The controls can be used for databinding in the same way as the regular ones, but instead of txtBox.Text = someObject.someProperty you use compositeControl.EnteredText = someObject.someProperty.
These controls are then used on ASPX pages and ASCX user controls.

The first version of the web controls is written in C# and works perfectly. These controls are placed in the App_Code folder of the website. However, this folder was getting rather big and because of policy I have to write everything in VB.NET, so I decided to make a class library to put the VB.NET version of the controls in there, so that I don't have to translate the entire web application to VB.NET but only the controls.

However, the VB.NET version does not work. When I click the link in a GridView, it opens a popup and populates all the textboxes properly. When close the screen and click some other link from the same grid, the boxes are not populated properly and the data from the first postback is visible in the boxes. When using the debugger, I see that all boxes are populated with the proper data, and during the render phase the Text property of the underlying TextBox shows all of the new data. It just doesn't show that on screen. Retrieving the data after postback, like when pressing a save button, works as normal.

When I place a control from the App_Code folder on the same page, it works as expected and shows the new data and not the data from the previous postback.

Here are two paste bin URLs, the first goes to the working C# version and the second to the VB.NET version.

C# version: http://pastebin.com/SuWaHrMt

VB.NET version: http://pastebin.com/9aeV7St1

Here is an example how it's used in an ASCX file:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CustomControl.ascx.cs" Inherits="Controls_CustomControl" %>
<%@ Register Namespace="UI.CompositeControls" TagPrefix="cs" %>

<cs:TextBoxWithLabel ID="TextBoxWithLabel1" runat="server" LabelText="Voornaam" />
<cc:LabeledTextBox ID="tbwlVoornaam" runat="server" LabelText="Voornaam" />

The cc prefix is specified in the web.config:

<pages theme="Default" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID">
  <controls>
    <add assembly="CompositeControls" namespace="CompositeControls" tagPrefix="cc" />
  </controls>
  <namespaces>
    <add namespace="CompositeControls" />
  </namespaces>
</pages>

What am I missing here that makes the C# version work and the VB version not?

Thanks in advance! Feel free to ask questions if you want some clarification.

Update:
I disabled the ViewState on the encompassing ASCX in question and it works:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CustomControl.ascx.cs" EnableViewState="false" Inherits="Controls_CustomControl" %>

My colleague found the following snippet:

If you reinsert controls with each round trip, each generation of
  dynamically created controls will pick up property values from the view
  state of the preceding set of controls. In many cases, you can avoid this
  problem by setting the EnableViewState property of the container control to
  false. In that case, no information about the dynamic controls is saved, and
  there is no conflict with successive versions of the controls.

I'm just not sure how this suddenly applies to the controls. Based on this MSDN article on ViewState I'm guessing that it happens because the Controls are added in the CreateChildControls method which occurs after the postback events.

Can someone explain what exactly is going on here?


问:
Cannot figure out how to Configure IIS Server level Failed Request Tracing Rules with PowerShell
I want to be able to set the Parent level (Web server) Failed Request Tracing Rules with PowerShell.  We are automating the configuration of our web servers and this one has me completely stumped.  We want all sites to inherit this setting from the Parent.  Appreciate any suggestions.

I have tried the suggestions here Is there a scripted way to configure Failed Request Tracing (FRT) and FRT rules but these modify the site's web.config.  Not what I am looking for although it is real nice!

答:
Try this powershell script.</p>
```<code>Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests" -name "." -value @{path='*'}

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/traceAreas" -name "." -value @{provider='ASP';verbosity='Verbose'}

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/traceAreas" -name "." -value @{provider='ASPNET';areas='Infrastructure,Module,Page,AppServices';verbosity='Verbose'}

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/traceAreas" -name "." -value @{provider='ISAPI Extension';verbosity='Verbose'}

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/traceAreas" -name "." -value @{provider='WWW Server';areas='Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket,Rewrite,ANCM';verbosity='Verbose'}
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/failureDefinitions" -name "statusCodes" -value "200-600"
</code>```

Body:
Try this powershell script.

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests" -name "." -value @{path='*'}

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/traceAreas" -name "." -value @{provider='ASP';verbosity='Verbose'}

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/traceAreas" -name "." -value @{provider='ASPNET';areas='Infrastructure,Module,Page,AppServices';verbosity='Verbose'}

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/traceAreas" -name "." -value @{provider='ISAPI Extension';verbosity='Verbose'}

Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/traceAreas" -name "." -value @{provider='WWW Server';areas='Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket,Rewrite,ANCM';verbosity='Verbose'}
Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/tracing/traceFailedRequests/add[@path='*']/failureDefinitions" -name "statusCodes" -value "200-600"


问:
Can I create something to run a google home command when I get a certain phone notification?
I am a volunteer firefighter and we have a mobile app that alerts us when we get an emergency call. Is there a way for me to turn on a light that is controlled via google home when my phone receives that notification? If so, how do I accomplish this? I have some experience with coding but not enough to get me through this, any help is appreciated!</p>

答:
Is there a way for me to turn on a light that is controlled via google home when my phone receives that notification?

Such automation, which combines customized applications with Google Home, is not supported in the smart home integration currently.

Having said that, from what you said, you seem to own the mobile app and probably the server too. If that’s the case, I can think of an alternative way which could fulfill your requirement:

First off, get some smart lights which are controllable via APIs. Try to google “programmable smart lights” to get more ideas.

Call the API to control smart lights mentioned in (1) when a notification is sent.

Theoretically this should work. It doesn’t involve Google Assistant at all though.


问:
help with drawing a wedge with opengl es
I'm trying to do some basic opengl es programming to get started on the basics.

I have a drawing function tries to draw a wedge of a circle. Something is going wrong because its actually just drawing a circle.

I'm still just trying to grasp the basics of opengl es here. Heres what I have so far.

```<code>- (void)drawView

{
    [EAGLContext setCurrentContext:context];

    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
    glViewport(0, 0, 60, 60);

    int i;
    float angle_start=90;
    float angle_stop=180;
    int segments=360;
    float const angle_step = (angle_stop - angle_start)/segments;

    GLfloat *arc_vertices;
    arc_vertices = malloc(2*sizeof(GLfloat) * (segments+2));

    arc_vertices[0] = arc_vertices[1] = 0.0;

    for(i=0; i<segments+1; i++) {
        arc_vertices[2 + 2*i    ] = cos(angle_start + i*angle_step);
        arc_vertices[2 + 2*i + 1] = sin(angle_start + i*angle_step);
    }
    glVertexPointer(2, GL_FLOAT, 0, arc_vertices);
    glEnableClientState(GL_VERTEX_ARRAY);
    glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
    glDrawArrays(GL_TRIANGLE_FAN, 0, segments+2);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
    [context presentRenderbuffer:GL_RENDERBUFFER_OES];
    free(arc_vertices);

}
</code>```

答:
sin() and cos() take radians as input:

```<code>float angle_start=90;
float angle_stop=180;
int segments=360;
float const angle_step = (angle_stop - angle_start)/segments;

GLfloat* verts = (GLfloat*)malloc(2*sizeof(GLfloat) * (segments+2));
unsigned int pos = 0;
verts[pos++] = 0;
verts[pos++] = 0;

float radius = 10;
for( unsigned int i = 0; i < segments; ++i )
{
    float rads = (angle_start + i*angle_step) * (3.14159 / 180);

    verts[pos++] = ( cos( rads ) * radius );
    verts[pos++] = ( sin( rads ) * radius );
}

glVertexPointer(2, GL_FLOAT, 0, verts);
glEnableClientState(GL_VERTEX_ARRAY);
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
glDrawArrays(GL_TRIANGLE_FAN, 0, segments+1);
glDisableClientState(GL_VERTEX_ARRAY);
</code>```

Body:
I'm trying to do some basic opengl es programming to get started on the basics.

I have a drawing function tries to draw a wedge of a circle. Something is going wrong because its actually just drawing a circle.

I'm still just trying to grasp the basics of opengl es here. Heres what I have so far.

- (void)drawView

{
    [EAGLContext setCurrentContext:context];

    glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer);
    glViewport(0, 0, 60, 60);

    int i;
    float angle_start=90;
    float angle_stop=180;
    int segments=360;
    float const angle_step = (angle_stop - angle_start)/segments;

    GLfloat *arc_vertices;
    arc_vertices = malloc(2*sizeof(GLfloat) * (segments+2));

    arc_vertices[0] = arc_vertices[1] = 0.0;

    for(i=0; i<segments+1; i++) {
        arc_vertices[2 + 2*i    ] = cos(angle_start + i*angle_step);
        arc_vertices[2 + 2*i + 1] = sin(angle_start + i*angle_step);
    }
    glVertexPointer(2, GL_FLOAT, 0, arc_vertices);
    glEnableClientState(GL_VERTEX_ARRAY);
    glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
    glDrawArrays(GL_TRIANGLE_FAN, 0, segments+2);
    glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer);
    [context presentRenderbuffer:GL_RENDERBUFFER_OES];
    free(arc_vertices);

}

Body:
sin() and cos() take radians as input:

float angle_start=90;
float angle_stop=180;
int segments=360;
float const angle_step = (angle_stop - angle_start)/segments;

GLfloat* verts = (GLfloat*)malloc(2*sizeof(GLfloat) * (segments+2));
unsigned int pos = 0;
verts[pos++] = 0;
verts[pos++] = 0;

float radius = 10;
for( unsigned int i = 0; i < segments; ++i )
{
    float rads = (angle_start + i*angle_step) * (3.14159 / 180);

    verts[pos++] = ( cos( rads ) * radius );
    verts[pos++] = ( sin( rads ) * radius );
}

glVertexPointer(2, GL_FLOAT, 0, verts);
glEnableClientState(GL_VERTEX_ARRAY);
glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
glDrawArrays(GL_TRIANGLE_FAN, 0, segments+1);
glDisableClientState(GL_VERTEX_ARRAY);


问:
rebot command running in Gitlab-CI return ERROR: Job failed: exit status 1
My job running this command:

```<code>- rebot -d ./output/$CI_COMMIT_SHORT_SHA
  --doc "Report Testing Stage on execution summit ID $CI_COMMIT_SHA"
  --output testing-stage.xml
  --log log-testing-stage.html
  --report report-testing-stage.html
  ./output/$CI_COMMIT_SHORT_SHA/*.xml
</code>```

The output reports  ERROR: Job failed: exit status 1
Loggin Error

Please let me know how to make the job run successfully. Thanks

答:
In your script section of the gitlab-ci job, add an echo to make sure the GitLab variable is indeed replaced with the correct value (see this thread for illustration)

  stage: info
  script:
    - echo ${CI_COMMIT_SHA}
    - echo ${CI_COMMIT_SHORT_SHA}
    - rebot -d ./output/${CI_COMMIT_SHORT_SHA}
      --doc "Report Testing Stage on execution summit ID ${CI_COMMIT_SHA}"
      --output testing-stage.xml
      --log log-testing-stage.html
      --report report-testing-stage.html
      ./output/${CI_COMMIT_SHORT_SHA}/*.xml
```

Use the ${var} form instead of $var.

And finally, check the logs log-testing-stage.html content for any clues.

Body:
My job running this command:

- rebot -d ./output/$CI_COMMIT_SHORT_SHA
  --doc "Report Testing Stage on execution summit ID $CI_COMMIT_SHA"
  --output testing-stage.xml
  --log log-testing-stage.html
  --report report-testing-stage.html
  ./output/$CI_COMMIT_SHORT_SHA/*.xml

The output reports  ERROR: Job failed: exit status 1
Loggin Error

Please let me know how to make the job run successfully. Thanks

Body:
In your script section of the gitlab-ci job, add an echo to make sure the GitLab variable is indeed replaced with the correct value (see this thread for illustration)

  stage: info
  script:
    - echo ${CI_COMMIT_SHA}
    - echo ${CI_COMMIT_SHORT_SHA}
    - rebot -d ./output/${CI_COMMIT_SHORT_SHA}
      --doc "Report Testing Stage on execution summit ID ${CI_COMMIT_SHA}"
      --output testing-stage.xml
      --log log-testing-stage.html
      --report report-testing-stage.html
      ./output/${CI_COMMIT_SHORT_SHA}/*.xml

Use the ${var} form instead of $var.

And finally, check the logs log-testing-stage.html content for any clues.


答:
if your data is something like this:

services = [
    {
        "Mobile":
            [
                {"name": "CompanyA", 'id': 0, 'address': "XYZ"},
                {"name": 'CompanyB', 'id': 1, 'address': "QWE"},
                {"name": 'CompanyC', 'id': 2, 'address': "TYU"}
            ]
    },
    {
        "Computer":
            [
                {"name": "CompanyD", 'id': 3, 'address': "PPP"},
                {"name": 'CompanyD', 'id': 4, 'address': "UYU"},
                {"name": 'CompanyE', 'id': 5, 'address': "NMB"}
            ]
    }
]
```
<p>you can iterate over them and save in a new variable like this:</p>
<pre class="lang-py prettyprint-override"><code>data = []
for i in services:
    for index, j in i.items():
        data.append({index : [ {'name': k['name']} for k in j]})
</code>```

and the compact command would be like this:

data = [{index: [{'name': k['name']} for k in j] for index, j in i.items()} for i in services]
```
<p>the <code>data</code> will be like this:</p>
<pre class="lang-py prettyprint-override"><code>[
   {
      "Mobile":[
         { "name":"CompanyA" },
         { "name":"CompanyB" },
         { "name":"CompanyC" }
      ]
   },
   {
      "Computer":[
         { "name":"CompanyD" },
         { "name":"CompanyD" },
         { "name":"CompanyE" }
      ]
   }
]
</code>```

Title: How to iterate through a nested list of dictionaries in Python

Body:
if your data is something like this:

services = [
    {
        "Mobile":
            [
                {"name": "CompanyA", 'id': 0, 'address': "XYZ"},
                {"name": 'CompanyB', 'id': 1, 'address': "QWE"},
                {"name": 'CompanyC', 'id': 2, 'address': "TYU"}
            ]
    },
    {
        "Computer":
            [
                {"name": "CompanyD", 'id': 3, 'address': "PPP"},
                {"name": 'CompanyD', 'id': 4, 'address': "UYU"},
                {"name": 'CompanyE', 'id': 5, 'address': "NMB"}
            ]
    }
]

you can iterate over them and save in a new variable like this:

data = []
for i in services:
    for index, j in i.items():
        data.append({index : [ {'name': k['name']} for k in j]})

and the compact command would be like this:

data = [{index: [{'name': k['name']} for k in j] for index, j in i.items()} for i in services]

the data will be like this:

[
   {
      "Mobile":[
         { "name":"CompanyA" },
         { "name":"CompanyB" },
         { "name":"CompanyC" }
      ]
   },
   {
      "Computer":[
         { "name":"CompanyD" },
         { "name":"CompanyD" },
         { "name":"CompanyE" }
      ]
   }
]


问:
How to access parent's DataContext from a UserControl
I need to access the container's DataContext from a UserControl (a grid containing textboxes and a listbox: I need to insert items in this list box) that I created in WPF: which is the best way to do it?

I was thinking to pass the DataContext as parameter to user control but think there is a cleaner way to do it.

答:
In this case, UserControl will get DataContext windows

```<code><Window>
    <local:MyUserControl DataContext="{Binding}"/>
</Window>
</code>```

Body:
In this case, UserControl will get DataContext windows

<Window>
    <local:MyUserControl DataContext="{Binding}"/>
</Window>


问:
How to save Files in Android/Media/MyFolder in Android11 and above
Hy everyone, I am new to SAF and know how to get uri from Intent.ACTION_OPEN_DOCUMENT_TREE.I have checked my logcat and receive the URI as content://com.android.externalstorage.documents/tree/primary%3AAndroid%2Fmedia%2Fcom.whatsapp%2FWhatsApp%2FMedia%2F.Statuses. Suppose I want to make a folder and save downloaded files. How can I achieve this? How can I tell DownloadManager to download to this URI. Is there any other way to achieve the same then Please tell me. Thanks</p>

答:
In the normal way as usual.

Instantiate a DocumentFile instance for the obtained uri and then use createFile on it to make your subfolder.

There is no possibility to let DownloadManager download to that folder.


问:
How to connect right click menu action to some function in QGraphicsView?
Currently in my QGraphicsScene, there are multiple items (like Text, Ellipse, Rectangle, Polyline etc ) I want to change the color of these items by right clicking on them and then choose "Color Me" option. Once clicked on "Color Me" option, color dialog box should get pop up and then, I should change the color of item.

But in my try, on right click, Color Me option is appearing but clicking on it ColorOption slot, is not getting called.

```<code>   Widget::Widget(QWidget *parent)
        : QGraphicsView(parent)
        , ui(new Ui::Widget)
    {
        .....

        myCustomAction1 = new QAction(tr("Color Me"), this);
        connect(myCustomAction1, SIGNAL(triggered()), this, SLOT(ColorOption()));
        .....
    }

 void Widget::ColorOption()
{
    QColor color = QColorDialog::getColor(currentColor);
    if(color.isValid())
        currentColor = color;
    .....

}

</code>```

Widget.h

```<code>class Widget : public QGraphicsView
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
private:
    Ui::Widget *ui;
    QGraphicsScene* scene;
    QGraphicsView* view;
    QAction* myCustomAction1;
    QColor currentColor;
};
</code>```

I would appreciate if anyone could help.

答:
In order for the signal-slot mechanism to work, the slot function must be declared in the class declaration. I.e. the following needs to be in Widget.h:</p>
```<code>public slots:
    void ColorOption();
</code>```

Body:
Currently in my QGraphicsScene, there are multiple items (like Text, Ellipse, Rectangle, Polyline etc ) I want to change the color of these items by right clicking on them and then choose "Color Me" option. Once clicked on "Color Me" option, color dialog box should get pop up and then, I should change the color of item.

But in my try, on right click, Color Me option is appearing but clicking on it ColorOption slot, is not getting called.

   Widget::Widget(QWidget *parent)
        : QGraphicsView(parent)
        , ui(new Ui::Widget)
    {
        .....

        myCustomAction1 = new QAction(tr("Color Me"), this);
        connect(myCustomAction1, SIGNAL(triggered()), this, SLOT(ColorOption()));
        .....
    }

 void Widget::ColorOption()
{
    QColor color = QColorDialog::getColor(currentColor);
    if(color.isValid())
        currentColor = color;
    .....

}

Widget.h

class Widget : public QGraphicsView
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
private:
    Ui::Widget *ui;
    QGraphicsScene* scene;
    QGraphicsView* view;
    QAction* myCustomAction1;
    QColor currentColor;
};

I would appreciate if anyone could help.

Body:
In order for the signal-slot mechanism to work, the slot function must be declared in the class declaration. I.e. the following needs to be in Widget.h:

public slots:
    void ColorOption();


问:
Where can I find a collection of a creature/character doing different actions (JSON file/ gif)?
Creature or Character doing actions like Hi, Sleeping, Walking, Smiling type of actions. I am looking for a collection of those in any kind of video format or gif or JSON (by which I can use it in my project) that would be helpful.  There are generic static character options available but they don't have animation.

I am looking for free options mostly, I need it to use it in my project (where that files will be used to display on home screen) which is open source

答:
You can download the animation in json or gif and other many formats on this link and add it to your raw directory

By The Way Its Free To Use !!

https://lottiefiles.com/search?q=HI&category=animations*

it also has an dependencies for using it in android studio

```<code>dependencies {
  implementation 'com.airbnb.android:lottie:$lottieVersion'
}
</code>```

Body:
You can download the animation in json or gif and other many formats on this link and add it to your raw directory

By The Way Its Free To Use !!

https://lottiefiles.com/search?q=HI&category=animations*

it also has an dependencies for using it in android studio

dependencies {
  implementation 'com.airbnb.android:lottie:$lottieVersion'
}


问:
Visual Studio 2019: "This site can’t provide a secure connection" on localhost
I've installed Visual Studio 2019 and uninstalled Visual Studio 2017.

Now if I start an ASP.NET (Core) site with https, it always say on Chrome:

This site can’t provide a secure connection

or on Edge

Can’t connect securely to this page

Screenshots:

Chrome:

Edge:

The URLs are correct. This also the same http://localhost:56784/ (it redirects to https)

Tried

What I've tried:

Updated Visual Studio 2019

Create a new ASP.NET Core 2 website

Tested with a ASP.NET site (non core)

Remove IIS certificates with MMC

Checking/changing the IIS settings in Visual Studio 2019 (project properties with context menu and project properties with F4)

Searching on Stackoverflow & Google ;)

Repair Visual Studio 2019

Issue

I think the issue is introduced by:

Installing Visual Studio 2019  and/or,

Uninstalling Visual Studio 2017  and/or,

Updating Windows 10 (current Version: 10.0.18362 Build 18362)

The underlining issue looks like a wrong/old/not supported TLS version?

Question

What can I do to diagnose/fix the problem?

答: In my case use SSL check box was gone in debug section of project properties. everything was fixed by checking again</p>


问:
Problems with DoctrineFixturesBundle upgrading from Symfony 5.1 to 5.2
I'm upgrading my Symfony 4.4 project to Symfony 5.4 (the current LTS version). I've tried modifying composer.json, forcing directly to the 5.4 release, but I've found lots of dependency problems, so I "solved" this migrating slowly: I moved to 5.0, then to 5.1, and now I'm trying to migrate from 5.1 to 5.2, but I have dependency problems and I don't know how to fix them.

The problem:

```<code>  Problem 1
    - Conclusion: don't install doctrine/doctrine-fixtures-bundle 3.4.1 (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[1.3.5] | install one of doctrine/persistence[1.3.7, 1.3.8, 2.2.2, 2.2.3, 2.2.4, 2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[1.3.7] | install one of doctrine/persistence[2.2.1, ..., 2.3.0] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.2.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.2.2] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.2.1] (conflict analysis result)
    - Conclusion: install doctrine/common v2.11.0 (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[1.3.8] | install one of doctrine/persistence[2.2.4, 2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[2.2.4] | install one of doctrine/common[2.13.1, 2.13.3] (conflict analysis result)
    - Conclusion: don't install doctrine/common[2.13.3] | install doctrine/persistence[2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/common[2.13.1] | install doctrine/persistence[2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence 2.3.0 (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.2.4] | install one of doctrine/common[2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[1.3.6] | install doctrine/persistence[2.2.0] (conflict analysis result)
    - Conclusion: don't install one of doctrine/persistence[1.2.0], doctrine/doctrine-fixtures-bundle[3.4.0] | install one of doctrine/persistence[1.3.7, 1.3.8, 2.2.0, ..., 2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence 2.2.0 (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.2.2] | install one of doctrine/common[2.13.0, 2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.2.1] | install one of doctrine/persistence[1.3.8], doctrine/common[2.13.0, 2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.2.0] | install one of doctrine/persistence[1.3.8], doctrine/common[2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.1.1] | install one of doctrine/persistence[1.3.8], doctrine/common[2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.1.0] | install one of doctrine/persistence[1.1.1, 1.3.5, 1.3.7, 1.3.8], doctrine/common[2.13.0, 2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install doctrine/orm[2.7.5] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8, 2.1.0, ..., 2.3.0], doctrine/common[2.13.0, 2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[2.12.0], doctrine/persistence[2.3.0] | install one of doctrine/persistence[v1.1.0, 1.1.1, 1.2.0] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[2.12.0], doctrine/persistence[2.0.0] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install doctrine/orm[2.7.4] | install one of doctrine/persistence[v1.1.0, 1.1.1, 1.2.0, 1.3.8, 2.2.4, 2.3.0], doctrine/common[2.13.1, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[2.12.0], doctrine/persistence[2.1.0] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[2.12.0], doctrine/persistence[2.0.1] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.2.2] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install one of symfony/doctrine-bridge[v5.2.10], doctrine/persistence[1.3.4] | install one of doctrine/persistence[2.1.1, ..., 2.3.0] (conflict analysis result)
    - Conclusion: don't install one of doctrine/persistence[v1.1.0], doctrine/doctrine-fixtures-bundle[3.4.0] | install one of doctrine/persistence[1.3.7, 1.3.8, 2.1.1, ..., 2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence 2.1.1 (conflict analysis result)
    - Conclusion: don't install one of symfony/doctrine-bridge[v5.2.10], doctrine/persistence[1.3.6] | install one of doctrine/persistence[2.2.2, 2.2.3, 2.2.4, 2.3.0] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[2.12.0], doctrine/persistence[2.2.4] | install one of doctrine/persistence[v1.1.0, 1.1.1, 1.2.0] (conflict analysis result)
    - Root composer.json requires doctrine/common ^2 -> satisfiable by doctrine/common[2.1.3, ..., 2.13.3].
    - Root composer.json requires doctrine/doctrine-fixtures-bundle ^3.4 -> satisfiable by doctrine/doctrine-fixtures-bundle[3.4.0, 3.4.1].
    - doctrine/doctrine-fixtures-bundle 3.4.0 requires doctrine/persistence ^1.3.7|^2.0 -> satisfiable by doctrine/persistence[1.3.7, 1.3.8, 2.0.0, ..., 2.3.0].
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.1.0] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.0.1] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.0.0] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[1.1.1] | install one of doctrine/persistence[1.3.7, 2.1.1, ..., 2.2.3] (conflict analysis result)
</code>```

I suppose than the problem is with the package doctrine/doctrine-fixtures-bundle, but I'm unsure, because I find it very hard to interpret the error message. Is this the offending package? If so, is there any way to upgrade it, or should I remove it, upgrade the application and then install it again?

I need the package because I use it to populate the test database when running tests, but maybe there is any newer package for this job?

And here is my composer.json:

```<code>{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "a2lix/translation-form-bundle": "^3.0",
        "composer/package-versions-deprecated": "1.11.99.4",
        "doctrine/annotations": "^1.0",
        "doctrine/common": "^2",
        "doctrine/doctrine-bundle": "^2",
        "doctrine/doctrine-migrations-bundle": "^2",
        "doctrine/orm": "^2",
        "friendsofsymfony/jsrouting-bundle": "^2.6",
        "gedmo/doctrine-extensions": "^2.4",
        "knplabs/doctrine-behaviors": "^2.0",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpoffice/phpspreadsheet": "^1.13",
        "ramsey/uuid-doctrine": "^1.6",
        "sensio/framework-extra-bundle": "^5.1",
        "stof/doctrine-extensions-bundle": "^1.4",
        "stripe/stripe-php": "^7.39",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "5.2.*",
        "symfony/console": "5.2.*",
        "symfony/dotenv": "5.2.*",
        "symfony/expression-language": "5.2.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "5.2.*",
        "symfony/framework-bundle": "5.2.*",
        "symfony/http-client": "5.2.*",
        "symfony/intl": "5.2.*",
        "symfony/mailer": "5.2.*",
        "symfony/monolog-bundle": "^3.5",
        "symfony/polyfill-uuid": "^1.15",
        "symfony/process": "5.2.*",
        "symfony/property-access": "5.2.*",
        "symfony/property-info": "5.2.*",
        "symfony/security-bundle": "5.2.*",
        "symfony/serializer": "5.2.*",
        "symfony/translation": "5.2.*",
        "symfony/twig-bundle": "5.2.*",
        "symfony/validator": "5.2.*",
        "symfony/web-link": "5.2.*",
        "symfony/yaml": "5.2.*",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/twig": "^2.12|^3.0",
        "vich/uploader-bundle": "^1.13"
    },
    "require-dev": {
        "dama/doctrine-test-bundle": "^6.5",
        "doctrine/doctrine-fixtures-bundle": "^3.4",
        "symfony/browser-kit": "5.2.*",
        "symfony/css-selector": "5.2.*",
        "symfony/debug-bundle": "5.2.*",
        "symfony/maker-bundle": "^1.15",
        "symfony/phpunit-bridge": "^5.2",
        "symfony/stopwatch": "5.2.*",
        "symfony/web-profiler-bundle": "5.2.*"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.2.*"
        }
    }
}
</code>```

I don't know I this can be a help, but this application started as an Symfony 3.4 app, a couple years ago I upgraded to Symfony 4.4, and now I'm working in moving to 5.4...

答:
The problem is that you require doctrine/common in v2. This depends on doctrine/persistence in v1. Updating all your packages to Symfony 5.2 will also update symfony/doctrine-bridge to 5.2 - and this requires doctrine/persistence in v2.

Updating doctrine/common to v3 in your composer.json could help to resolve the problem. Also, since you are using symfony/flex already, you can remove all explicit version constraints on the Symfony packages - it's sufficient to define the Symfony version further down in the extra section as you already did. This makes it way easier to update all Symfony packages, as you only need to change this one line

Body:
I'm upgrading my Symfony 4.4 project to Symfony 5.4 (the current LTS version). I've tried modifying composer.json, forcing directly to the 5.4 release, but I've found lots of dependency problems, so I "solved" this migrating slowly: I moved to 5.0, then to 5.1, and now I'm trying to migrate from 5.1 to 5.2, but I have dependency problems and I don't know how to fix them.

The problem:

  Problem 1
    - Conclusion: don't install doctrine/doctrine-fixtures-bundle 3.4.1 (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[1.3.5] | install one of doctrine/persistence[1.3.7, 1.3.8, 2.2.2, 2.2.3, 2.2.4, 2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[1.3.7] | install one of doctrine/persistence[2.2.1, ..., 2.3.0] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.2.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.2.2] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.2.1] (conflict analysis result)
    - Conclusion: install doctrine/common v2.11.0 (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[1.3.8] | install one of doctrine/persistence[2.2.4, 2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[2.2.4] | install one of doctrine/common[2.13.1, 2.13.3] (conflict analysis result)
    - Conclusion: don't install doctrine/common[2.13.3] | install doctrine/persistence[2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/common[2.13.1] | install doctrine/persistence[2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence 2.3.0 (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.2.4] | install one of doctrine/common[2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[1.3.6] | install doctrine/persistence[2.2.0] (conflict analysis result)
    - Conclusion: don't install one of doctrine/persistence[1.2.0], doctrine/doctrine-fixtures-bundle[3.4.0] | install one of doctrine/persistence[1.3.7, 1.3.8, 2.2.0, ..., 2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence 2.2.0 (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.2.2] | install one of doctrine/common[2.13.0, 2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.2.1] | install one of doctrine/persistence[1.3.8], doctrine/common[2.13.0, 2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.2.0] | install one of doctrine/persistence[1.3.8], doctrine/common[2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.1.1] | install one of doctrine/persistence[1.3.8], doctrine/common[2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/orm[2.7.5], doctrine/persistence[2.1.0] | install one of doctrine/persistence[1.1.1, 1.3.5, 1.3.7, 1.3.8], doctrine/common[2.13.0, 2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install doctrine/orm[2.7.5] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8, 2.1.0, ..., 2.3.0], doctrine/common[2.13.0, 2.13.1, 2.13.2, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[2.12.0], doctrine/persistence[2.3.0] | install one of doctrine/persistence[v1.1.0, 1.1.1, 1.2.0] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[2.12.0], doctrine/persistence[2.0.0] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install doctrine/orm[2.7.4] | install one of doctrine/persistence[v1.1.0, 1.1.1, 1.2.0, 1.3.8, 2.2.4, 2.3.0], doctrine/common[2.13.1, 2.13.3] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[2.12.0], doctrine/persistence[2.1.0] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[2.12.0], doctrine/persistence[2.0.1] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.2.2] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install one of symfony/doctrine-bridge[v5.2.10], doctrine/persistence[1.3.4] | install one of doctrine/persistence[2.1.1, ..., 2.3.0] (conflict analysis result)
    - Conclusion: don't install one of doctrine/persistence[v1.1.0], doctrine/doctrine-fixtures-bundle[3.4.0] | install one of doctrine/persistence[1.3.7, 1.3.8, 2.1.1, ..., 2.3.0] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence 2.1.1 (conflict analysis result)
    - Conclusion: don't install one of symfony/doctrine-bridge[v5.2.10], doctrine/persistence[1.3.6] | install one of doctrine/persistence[2.2.2, 2.2.3, 2.2.4, 2.3.0] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[2.12.0], doctrine/persistence[2.2.4] | install one of doctrine/persistence[v1.1.0, 1.1.1, 1.2.0] (conflict analysis result)
    - Root composer.json requires doctrine/common ^2 -> satisfiable by doctrine/common[2.1.3, ..., 2.13.3].
    - Root composer.json requires doctrine/doctrine-fixtures-bundle ^3.4 -> satisfiable by doctrine/doctrine-fixtures-bundle[3.4.0, 3.4.1].
    - doctrine/doctrine-fixtures-bundle 3.4.0 requires doctrine/persistence ^1.3.7|^2.0 -> satisfiable by doctrine/persistence[1.3.7, 1.3.8, 2.0.0, ..., 2.3.0].
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.1.0] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.0.1] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install one of doctrine/common[v2.11.0], doctrine/persistence[2.0.0] | install one of doctrine/persistence[v1.1.0, ..., 1.3.8] (conflict analysis result)
    - Conclusion: don't install doctrine/persistence[1.1.1] | install one of doctrine/persistence[1.3.7, 2.1.1, ..., 2.2.3] (conflict analysis result)

I suppose than the problem is with the package doctrine/doctrine-fixtures-bundle, but I'm unsure, because I find it very hard to interpret the error message. Is this the offending package? If so, is there any way to upgrade it, or should I remove it, upgrade the application and then install it again?

I need the package because I use it to populate the test database when running tests, but maybe there is any newer package for this job?

And here is my composer.json:

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "a2lix/translation-form-bundle": "^3.0",
        "composer/package-versions-deprecated": "1.11.99.4",
        "doctrine/annotations": "^1.0",
        "doctrine/common": "^2",
        "doctrine/doctrine-bundle": "^2",
        "doctrine/doctrine-migrations-bundle": "^2",
        "doctrine/orm": "^2",
        "friendsofsymfony/jsrouting-bundle": "^2.6",
        "gedmo/doctrine-extensions": "^2.4",
        "knplabs/doctrine-behaviors": "^2.0",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpoffice/phpspreadsheet": "^1.13",
        "ramsey/uuid-doctrine": "^1.6",
        "sensio/framework-extra-bundle": "^5.1",
        "stof/doctrine-extensions-bundle": "^1.4",
        "stripe/stripe-php": "^7.39",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "5.2.*",
        "symfony/console": "5.2.*",
        "symfony/dotenv": "5.2.*",
        "symfony/expression-language": "5.2.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "5.2.*",
        "symfony/framework-bundle": "5.2.*",
        "symfony/http-client": "5.2.*",
        "symfony/intl": "5.2.*",
        "symfony/mailer": "5.2.*",
        "symfony/monolog-bundle": "^3.5",
        "symfony/polyfill-uuid": "^1.15",
        "symfony/process": "5.2.*",
        "symfony/property-access": "5.2.*",
        "symfony/property-info": "5.2.*",
        "symfony/security-bundle": "5.2.*",
        "symfony/serializer": "5.2.*",
        "symfony/translation": "5.2.*",
        "symfony/twig-bundle": "5.2.*",
        "symfony/validator": "5.2.*",
        "symfony/web-link": "5.2.*",
        "symfony/yaml": "5.2.*",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/twig": "^2.12|^3.0",
        "vich/uploader-bundle": "^1.13"
    },
    "require-dev": {
        "dama/doctrine-test-bundle": "^6.5",
        "doctrine/doctrine-fixtures-bundle": "^3.4",
        "symfony/browser-kit": "5.2.*",
        "symfony/css-selector": "5.2.*",
        "symfony/debug-bundle": "5.2.*",
        "symfony/maker-bundle": "^1.15",
        "symfony/phpunit-bridge": "^5.2",
        "symfony/stopwatch": "5.2.*",
        "symfony/web-profiler-bundle": "5.2.*"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "5.2.*"
        }
    }
}

I don't know I this can be a help, but this application started as an Symfony 3.4 app, a couple years ago I upgraded to Symfony 4.4, and now I'm working in moving to 5.4...


问:
How to insert element at the beginning of a slice?
I have a slice:

```<code>mySlice := []int{4,5,6,7}
myelement := 3
</code>```

I want to insert myelement at index 0 so that my output will be [3,4,5,6,7].

How can I do that?

答:
you can use the append property here.

first, need to make a slice with the myelement. then append the slice in mySlice

```<code>mySlice = append(myelement, mySlice...)
</code>```

this is the function that will return the myelement inserting in the first place of the slice.

```<code>func addElementToFirstIndex(x []int, y int) []int {
    x = append([]int{y}, x...)
    return x
}
</code>```

See

Body:
I have a slice:

mySlice := []int{4,5,6,7}
myelement := 3

I want to insert myelement at index 0 so that my output will be [3,4,5,6,7].

How can I do that?

Body:
you can use the append property here.

first, need to make a slice with the myelement. then append the slice in mySlice

mySlice = append(myelement, mySlice...)

this is the function that will return the myelement inserting in the first place of the slice.

func addElementToFirstIndex(x []int, y int) []int {
    x = append([]int{y}, x...)
    return x
}

See


问:
Couldn't find User with id=sign_out
Sign-out link isn't working in my rails application.

I have checked my routes.rb which is listed below and my application.html.erb looks to follow the right path.

Getting the following error.

```<code>ActiveRecord::RecordNotFound in UsersController#show

Couldn't find User with id=sign_out
Rails.root: /Users/patrickwalsh/rails_projects/ytutorial

Application Trace | Framework Trace | Full Trace
app/controllers/users_controller.rb:4:in `show'
lib/disable_assets_logger.rb:11:in `call'
</code>```

My routes.rb

```<code>Refectory::Application.routes.draw do
  devise_for :users, :controllers => { :registrations => "users" }
  devise_scope :user do
    get 'login', to: "devise/sessions#new", as: "login"
    get 'logout', to: "devise/sessions#destroy", as: "logout"
    get 'logout', to: "users/sessions#destroy", as: "logout"
    get 'signup', to: "users#new", as: "signup"
    match '/users/:id', :to => 'users#show', :as => :user
  end
  root :to => 'tutorials#index'

devise_for :users do get '/users/sign_out' => 'devise/sessions#destroy'
get 'users/:id' => 'users#show'
end
  resources :tutorials
  resources :comments, only: [:show, :create, :update, :destroy]

 resources :tutorials do
    member { post :vote }
  end

  if Rails.env == "development"
    match 'errors/404' => 'errors#error_404'
    match 'errors/500' => 'errors#error_500'
  end

  unless Rails.application.config.consider_all_requests_local
    match '*not_found', to: 'errors#error_404'
  end

  match 'tagged' => 'tutorials#tagged', :as => 'tagged'
end
</code>```

and my application.html which seems to be following the right route from what I can see.

Any help is greatly appreciated!

```<code><% if current_user.present? %>
          <li><%= link_to "Log out", destroy_user_session_path, (:method => "delete") %></li>
        <% else %>
          <li><%= link_to "Log in", new_user_session_path %></li>
          <li><%= link_to "Sign up", new_user_registration_path %></li>
        <% end %>
</code>```

My users controller as well as I have a suspicion this is where the problem lies but not sure what the error is.

```<code>class UsersController < Devise::RegistrationsController
def show
  @user = User.find(params[:id])
  @tutorials = @user.tutorials
end
end
</code>```

答:
I have started noticing this error after removing rails-ujs. This was done as part of the upgrade to Rails 7 with ImportMap and Hotwire suite. Changing link_to to button_to has fixed this error in this case.

```<code><%= button_to 'Log out', destroy_user_session_path, method: :delete %>
</code>```

https://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html#replacements-for-rails-ujs-functionality

Title: Couldn't find User with id=sign_out

Body:
Sign-out link isn't working in my rails application.

I have checked my routes.rb which is listed below and my application.html.erb looks to follow the right path.

Getting the following error.

ActiveRecord::RecordNotFound in UsersController#show

Couldn't find User with id=sign_out
Rails.root: /Users/patrickwalsh/rails_projects/ytutorial

Application Trace | Framework Trace | Full Trace
app/controllers/users_controller.rb:4:in `show'
lib/disable_assets_logger.rb:11:in `call'

My routes.rb

Refectory::Application.routes.draw do
  devise_for :users, :controllers => { :registrations => "users" }
  devise_scope :user do
    get 'login', to: "devise/sessions#new", as: "login"
    get 'logout', to: "devise/sessions#destroy", as: "logout"
    get 'logout', to: "users/sessions#destroy", as: "logout"
    get 'signup', to: "users#new", as: "signup"
    match '/users/:id', :to => 'users#show', :as => :user
  end
  root :to => 'tutorials#index'

devise_for :users do get '/users/sign_out' => 'devise/sessions#destroy'
get 'users/:id' => 'users#show'
end
  resources :tutorials
  resources :comments, only: [:show, :create, :update, :destroy]

 resources :tutorials do
    member { post :vote }
  end

  if Rails.env == "development"
    match 'errors/404' => 'errors#error_404'
    match 'errors/500' => 'errors#error_500'
  end

  unless Rails.application.config.consider_all_requests_local
    match '*not_found', to: 'errors#error_404'
  end

  match 'tagged' => 'tutorials#tagged', :as => 'tagged'
end

and my application.html which seems to be following the right route from what I can see.

Any help is greatly appreciated!

<% if current_user.present? %>

<%= link_to "Log out", destroy_user_session_path, (:method => "delete") %>

        <% else %>

<%= link_to "Log in", new_user_session_path %>

<%= link_to "Sign up", new_user_registration_path %>

        <% end %>

My users controller as well as I have a suspicion this is where the problem lies but not sure what the error is.

class UsersController < Devise::RegistrationsController
def show
  @user = User.find(params[:id])
  @tutorials = @user.tutorials
end
end

Body:
I have started noticing this error after removing rails-ujs. This was done as part of the upgrade to Rails 7 with ImportMap and Hotwire suite. Changing link_to to button_to has fixed this error in this case.

<%= button_to 'Log out', destroy_user_session_path, method: :delete %>

https://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html#replacements-for-rails-ujs-functionality


问:
what should i do to solve this about android emulator?
when i try to see my program in emulator i click on launch this avd in the emulator it shows this error "the emulator process for avd has terminated". when i try by click on "open android emulator:pixel.." in the top it shows this:</p>
```<code>10:42 AM    Error Opening Emulator
                WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
                ERROR   | Failed to open /qemu.conf, err: 2
                INFO    | added library vulkan-1.dll
                INFO    | configAndStartRenderer: setting vsync to 60 hz
                HAX is working and emulator runs in fast virt mode.
                INFO    | Started GRPC server at 127.0.0.1:8554, security: Local
                INFO    | Advertising in: C:\Users\NoteBook TANDIS\AppData\Local\Temp\avd\running\pid_12724.ini
                glTexImage2D: got err :( 0x505 internal 0x1908 format 0x1908 type 0x1401
                ERROR   | Create color buffer failed.
                VCPU shutdown request
                VCPU shutdown request
                VCPU shutdown request
                INFO    | Android emulator version 31.2.8.0 (build_id 8143646) (CL:N/A)
</code>```

答:
Try the following steps first :

Delete the emulator and create a new one again.

Update the HAXM installer to the latest version

Try running the emulator for lower APIs.

If this doesn't work, consider trying the following :

Go to Tools -> SDK Manager
SDK Manager

In SDK Manager Go To SDK Tools Tab and unselect the Android Emulator and click on Apply. This uninstalls the Android Emulator.
SDK Tools

After uninstallation completes: Again follow step 2 that is : Tools -> SDK Manager -> SDK Tools -> This time check the android emulator by clicking it.This step will install the Android Emulator again.

After installation is complete, Relaunch android studio and create new emulator device. Run it to see if the error still persists.

This worked for me

Body:
when i try to see my program in emulator i click on launch this avd in the emulator it shows this error "the emulator process for avd has terminated". when i try by click on "open android emulator:pixel.." in the top it shows this:

10:42 AM    Error Opening Emulator
                WARNING | unexpected system image feature string, emulator might not function correctly, please try updating the emulator.
                ERROR   | Failed to open /qemu.conf, err: 2
                INFO    | added library vulkan-1.dll
                INFO    | configAndStartRenderer: setting vsync to 60 hz
                HAX is working and emulator runs in fast virt mode.
                INFO    | Started GRPC server at 127.0.0.1:8554, security: Local
                INFO    | Advertising in: C:\Users\NoteBook TANDIS\AppData\Local\Temp\avd\running\pid_12724.ini
                glTexImage2D: got err :( 0x505 internal 0x1908 format 0x1908 type 0x1401
                ERROR   | Create color buffer failed.
                VCPU shutdown request
                VCPU shutdown request
                VCPU shutdown request
                INFO    | Android emulator version 31.2.8.0 (build_id 8143646) (CL:N/A)


问:
Excel How to replace characters for private reason
For example cell,

A1 value is How are you!

A2 value is Hello Good Morning

I want to use some formula to make the results like this.

Result:

H** a** y***

H**** G*** M******

Would you mind letting me know are there have any suggestions on this case.
Thank you.

答:
Can't think of a formula, but this function should do it:</p>
```<code>Public Function Masker(pString As String) As String

    Dim words As Variant
    Dim i As Long

    words = Split(pString, " ")
    For i = 0 To UBound(words, 1)
        words(i) = Left(words(i), 1) & String(Len(words(i)) - 1, "*")
    Next i

    Masker = Join(words, " ")

End Function
</code>```

Body:
Can't think of a formula, but this function should do it:

Public Function Masker(pString As String) As String

    Dim words As Variant
    Dim i As Long

    words = Split(pString, " ")
    For i = 0 To UBound(words, 1)
        words(i) = Left(words(i), 1) & String(Len(words(i)) - 1, "*")
    Next i

    Masker = Join(words, " ")

End Function


问:
How to generate typings for CSS modules with Parcel?
I'm very new to Parcel. So this might seem like a dumb question to ask.

I have a project that uses typescript, react, less, parcel. And I need a way to generate typings since typescript is giving me the 'Cannot find module 'xxx' or its corresponding type declarations.' error. I know I can create a global typing file for all modules ending with the extension .less, but that way I get errors 'Property 'xxx' does not exist on type 'typeof import("*.less")'' and no IntelliSense when editing.

I'm not sure if this is even supposed to be handled by Parcel, I found an extension for VSCode CSS Modules Typed which seems to do the trick, but there are a few plugins for parcel which promise to do the same thing but I can't get them to work.

答:
Create a type declaration file (.d.ts) anywhere in your file tree with the following content:

css.d.ts

```<code>declare module "*.css" {}
</code>```

Body:
Create a type declaration file (.d.ts) anywhere in your file tree with the following content:

css.d.ts

declare module "*.css" {}


问:
How to find DIV inside div-structure by InnerText or Class
I have a div with multiple children which have a large div structure in them. Now I want to find an element with an specific innerText.
How can I do this?
I have heard something from document.evaluate but is this the right thing?

First Label

Second Label

Third Label

```

I have main and want to find the Label with the text Second Label without multiple Loops.

答:
Hello you can use path search. For more information on this check Document evaluate</p>
```<code>var xPath = "//label[contains(text(),'First Label')]";
console.log(document.evaluate(xPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue);
</code>```

Body:
I have a div with multiple children which have a large div structure in them. Now I want to find an element with an specific innerText.
How can I do this?
I have heard something from document.evaluate but is this the right thing?

First Label

Second Label

Third Label

I have main and want to find the Label with the text Second Label without multiple Loops.

Body:
Hello you can use path search. For more information on this check Document evaluate

var xPath = "//label[contains(text(),'First Label')]";
console.log(document.evaluate(xPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue);


问:
Organize registering Vue global components in Vue 3
In Vue 2 you can globally register components over multiple files by using the following code in index.js without bloating the main.js file

```<code>import Vue from 'vue'
import MyComponent from '@/components/MyComponent'

Vue.component('my-component-name', MyComponent)
</code>```

And in the main.js file use

```<code>import '@/components'
</code>```

But this method doesn't seem to work for me in Vue 3

main.js

```<code>import { createApp } from 'vue';
import '@/components'

const app = createApp({});

app.mount("#app");
</code>```

index.js

```<code>import Vue from 'vue' // doesn't work with import { createApp } from 'vue' too
import MyComponent from '@/components/MyComponent'

Vue.component('my-component-name', MyComponent)
</code>```

How can you achieve the same result in Vue 3?

答:
In Vue 3 we can have multiple application instances

const app1 = createApp({})
app1.mount('#container-1')

const app2 = createApp({})
app2.mount('#container-2')
```
<p>that can co-exist on that same page. So we can no longer use <code>Vue</code> from <code>import Vue from 'vue'</code> to register/use plugins.</p>
<hr />
<h1>My solution</h1>
<blockquote>
<p>See the implementation live on Stackblitz</p>
</blockquote>
<h3>Step 1: Create a folder to keep plugins/packages/dependencies</h3>
<p>I've called it <code>plugins</code> since they will be plugged in <code>main.js</code>.</p>
<h3>Step 2: Create <code>main-app.js</code></h3>
<p>You can also call it <code>app1.js</code> or whatever you want. Here is the content:</p>
<pre class="lang-js prettyprint-override"><code>import { createApp } from 'vue'
import App from '../App.vue'

export const app = createApp(App)
</code>```

Step 3: Plug it in main.js

import { app } from './plugins/main-app'

app.mount('#app')
```
<h3>Step 4: Create a new plugin</h3>
<p>Now let's create a <code>src/plugins/global-components.js</code></p>
<pre class="lang-js prettyprint-override"><code>import { app } from './main-app'
import MyComponent from '@/components/MyComponent'

app.component('my-component-name', MyComponent)
</code>```

Register it in main.js:

import { app } from './plugins/main-app'
import './plugins/global-components'

app.mount('#app')
```

You can go a step further and have an index.js in src/plugins where it will be like main.js and then in main.js you simply have import './plugins' but personally I don't like this extra step

Body:
In Vue 2 you can globally register components over multiple files by using the following code in index.js without bloating the main.js file

import Vue from 'vue'
import MyComponent from '@/components/MyComponent'

Vue.component('my-component-name', MyComponent)

And in the main.js file use

import '@/components'

But this method doesn't seem to work for me in Vue 3

main.js

import { createApp } from 'vue';
import '@/components'

const app = createApp({});

app.mount("#app");

index.js

import Vue from 'vue' // doesn't work with import { createApp } from 'vue' too
import MyComponent from '@/components/MyComponent'

Vue.component('my-component-name', MyComponent)

How can you achieve the same result in Vue 3?

Body:
In Vue 3 we can have multiple application instances

const app1 = createApp({})
app1.mount('#container-1')

const app2 = createApp({})
app2.mount('#container-2')

that can co-exist on that same page. So we can no longer use Vue from import Vue from 'vue' to register/use plugins.

My solution

See the implementation live on Stackblitz

Step 1: Create a folder to keep plugins/packages/dependencies

I've called it plugins since they will be plugged in main.js.

Step 2: Create main-app.js

You can also call it app1.js or whatever you want. Here is the content:

import { createApp } from 'vue'
import App from '../App.vue'

export const app = createApp(App)

Step 3: Plug it in main.js

import { app } from './plugins/main-app'

app.mount('#app')

Step 4: Create a new plugin

Now let's create a src/plugins/global-components.js

import { app } from './main-app'
import MyComponent from '@/components/MyComponent'

app.component('my-component-name', MyComponent)

Register it in main.js:

import { app } from './plugins/main-app'
import './plugins/global-components'

app.mount('#app')

You can go a step further and have an index.js in src/plugins where it will be like main.js and then in main.js you simply have import './plugins' but personally I don't like this extra step


问:
php upload: zip files
Why can't I get the .zip as type and its size through an uploading form but only can get its name only?

```<code>Array
(
    [file] => Array
        (
            [name] => Array
                (
                    [0] => attachments_2011_05_20.zip
                )

            [type] => Array
                (
                    [0] =>
                )

            [tmp_name] => Array
                (
                    [0] =>
                )

            [error] => Array
                (
                    [0] => 1
                )

            [size] => Array
                (
                    [0] => 0
                )

        )

)
</code>```

Something extra should I do to get the zip size and type?

答: Your error code is 1, which means means "file is too large" - your upload_max_filesize setting is too low, so the upload is being aborted.

Title: php upload: zip files

Body:
Why can't I get the .zip as type and its size through an uploading form but only can get its name only?

Array
(
    [file] => Array
        (
            [name] => Array
                (
                    [0] => attachments_2011_05_20.zip
                )

            [type] => Array
                (
                    [0] =>
                )

            [tmp_name] => Array
                (
                    [0] =>
                )

            [error] => Array
                (
                    [0] => 1
                )

            [size] => Array
                (
                    [0] => 0
                )

        )

)

Something extra should I do to get the zip size and type?


问:
Compare two array of objects and remove objects from first array if a property value is matched
I have 2 array of objects like

```<code>    const arrayOne = [{id: 1, name: 'one'}, {id: 2, name: 'two'}, {id: 3, name: 'three'}];
    const arrayTwo = [{id: 2, name: 'two'}, {id: 3, name: 'three'}];
</code>```

Here, I need to compare both these arrays and remove matching objects from arrayOne, which should finally give

```<code> this.arrayOne = [{id: 1, name: 'one'}];
</code>```

I tried like below but it is removing all objects from the array

```<code>this.arrayOne = this.arrayOne.filter(o1 => this.arrayTwo.some(o2 => o1.id === o2.id));
</code>```

What I am doing wrong here? Please suggest. Thanks

答:
const arrayOne = [
  { id: 1, name: "one" },
  { id: 2, name: "two" },
  { id: 3, name: "three" },
];
const arrayTwo = [
  { id: 2, name: "two" },
  { id: 3, name: "three" },
];

const arrayTwoIds = new Set(arrayTwo.map((el) => el.id));
const arrayOneFiltered = arrayOne.filter((el) => !arrayTwoIds.has(el.id));

console.log(arrayOneFiltered);
// [ { id: 1, name: 'one' } ]```
</div>
</div>
</p>
<p>Depending on the size of the array, creating a set <em>can</em> improve performance, as you do not need to loop over <code>arrayTwo</code> <code>arrayOne.length</code> times but only once. After that, you can look up the existence of an id in <code>arrayTwo</code> in constant time.</p>
<p>Yet, as pointed out in another answer, this is not necessary if the arrays are small (like in your example). In this case, you could also use this one-liner:</p>
<pre class="lang-js prettyprint-override"><code>arrayOne = arrayOne.filter((elOne) => !arrayTwo.some((elTwo) => elOne.id === elTwo.id));
</code>```

Here, arrayOne would need to be mutable, i.e. defined with let.

Body:
I have 2 array of objects like

    const arrayOne = [{id: 1, name: 'one'}, {id: 2, name: 'two'}, {id: 3, name: 'three'}];
    const arrayTwo = [{id: 2, name: 'two'}, {id: 3, name: 'three'}];

Here, I need to compare both these arrays and remove matching objects from arrayOne, which should finally give

 this.arrayOne = [{id: 1, name: 'one'}];

I tried like below but it is removing all objects from the array

this.arrayOne = this.arrayOne.filter(o1 => this.arrayTwo.some(o2 => o1.id === o2.id));

What I am doing wrong here? Please suggest. Thanks

Body:
const arrayOne = [
  { id: 1, name: "one" },
  { id: 2, name: "two" },
  { id: 3, name: "three" },
];
const arrayTwo = [
  { id: 2, name: "two" },
  { id: 3, name: "three" },
];

const arrayTwoIds = new Set(arrayTwo.map((el) => el.id));
const arrayOneFiltered = arrayOne.filter((el) => !arrayTwoIds.has(el.id));

console.log(arrayOneFiltered);
// [ { id: 1, name: 'one' } ]

Depending on the size of the array, creating a set can improve performance, as you do not need to loop over arrayTwo arrayOne.length times but only once. After that, you can look up the existence of an id in arrayTwo in constant time.

Yet, as pointed out in another answer, this is not necessary if the arrays are small (like in your example). In this case, you could also use this one-liner:

arrayOne = arrayOne.filter((elOne) => !arrayTwo.some((elTwo) => elOne.id === elTwo.id));

Here, arrayOne would need to be mutable, i.e. defined with let.


问:
What happens if I submit two CloudFormation change sets almost at the same time?
If I submit two change sets one right after the other, is the first guaranteed to complete before the second?</p>

答:
It is a bit unclear what you mean by submitting a changeset. If you're talking about creating changesets, then this shouldn't be a problem, since it won't actually execute anything on your stack.

If you're talking about executing a changeset on a stack, CloudFormation will probably not accept the second changeset you have submitted since you cannot update a stack that has an in-progress status.

After the first changeset is executed successfully, the second changeset will automatically be removed as it is no longer valid for the stack after the update has been applied. Hence, if you try to use the ID of the old changeset, you will get a ChangeSetNotFound error.

What I'm sure won't happen, is CloudFormation will execute both changesets sequentially.