问:
Use column in data frame as input in merge function
I am using Seurat to do some single-cell analysis. I am currently doing horizontal integration and for that I want to merge numerous Seurat Objects to do quality control.

I previously used the following code, where GSM....... are the Seurat Objects.

```<code>merged_seurat <- merge(GSM6061645, y = c(GSM6061646, GSM6061647, GSM6061648, GSM6061649, GSM6061650, GSM6061651, GSM6061652, GSM6061653, GSM6061654, GSM6061655, GSM6061656, GSM6061657, GSM6061658, GSM6061659, GSM6061660, GSM6061661, GSM6061662, GSM6061663),add.cell.ids = ls()[1:18],
project = "colon")
</code>```

This works, but I want to automate the selection of the right object names so I don't have to type them in manually.
I have these object names in the form of a data.frame and performed:

```<code>metadata.subset$ID
</code>```

to obtain a character.
How do I write the merge function, to: a) input the object names I have stored in metadata.subset$ID and b) add the correct cell IDs independent of how many objects I have in my environment (i.e. not using ls() but rather also referring to the names in metadata.subset$ID).

Thanks!

I tried something like this, but this isn't the right input format of referring to objects.

```<code>merge(noquote(ID[1]), y = c(noquote(ID[2:match(last(ID),ID)])),
                       add.cell.ids = ls()[??],
                       project = "colon")
</code>```

Body:
I am using Seurat to do some single-cell analysis. I am currently doing horizontal integration and for that I want to merge numerous Seurat Objects to do quality control.

I previously used the following code, where GSM....... are the Seurat Objects.

merged_seurat <- merge(GSM6061645, y = c(GSM6061646, GSM6061647, GSM6061648, GSM6061649, GSM6061650, GSM6061651, GSM6061652, GSM6061653, GSM6061654, GSM6061655, GSM6061656, GSM6061657, GSM6061658, GSM6061659, GSM6061660, GSM6061661, GSM6061662, GSM6061663),add.cell.ids = ls()[1:18],
project = "colon")

This works, but I want to automate the selection of the right object names so I don't have to type them in manually.
I have these object names in the form of a data.frame and performed:

metadata.subset$ID

to obtain a character.
How do I write the merge function, to: a) input the object names I have stored in metadata.subset$ID and b) add the correct cell IDs independent of how many objects I have in my environment (i.e. not using ls() but rather also referring to the names in metadata.subset$ID).

Thanks!

I tried something like this, but this isn't the right input format of referring to objects.

merge(noquote(ID[1]), y = c(noquote(ID[2:match(last(ID),ID)])),
                       add.cell.ids = ls()[??],
                       project = "colon")


来源: stackexchange

问:
Add any formulas with IF using Range(cell).Formula
```<code>Sub Gang()

Dim formula_1 As String

formula_1 = "=IF(A1<>"",1,0)"
Range("A2").Formula = formula_1

End Sub
</code>```

Very simple as you can see but its causing me an issue on another macro im working on, clearly I am doing something wrong but whenever I run this macro I get the error "Run-time Error '1004'"

So please help me understand how to correctly insert an IF statement using .Formula

I was just expecting to see the IF statement in cell A2

ContentLicense: CC BY-SA 4.0

Body:
Sub Gang()

Dim formula_1 As String

formula_1 = "=IF(A1<>"",1,0)"
Range("A2").Formula = formula_1

End Sub

Very simple as you can see but its causing me an issue on another macro im working on, clearly I am doing something wrong but whenever I run this macro I get the error "Run-time Error '1004'"

So please help me understand how to correctly insert an IF statement using .Formula

I was just expecting to see the IF statement in cell A2


问:
GetPost Information not inserting into table
I am currently using the CodeIgniter4 framework with PHP, this is supposed to get the name/id of each input form and the information inside, and then put that info into the their respective columns, I tried dd($data); to make sure it's receiving the information but when it actually does try to put in the info, it skips Street Number, City, State and Country, I have made sure that the model is getting the right columns in the table, and as far as I'm aware, there is no reason for this code to not work.

Function Code:

```<code><?php

namespace App\Controllers\Admin\Theme;
use App\Controllers\BaseController;
use CodeIgniter\API\ResponseTrait;
use App\Models\Admin\UserModel;
use \Firebase\JWT\JWT;

class Auth extends BaseController
{
    use ResponseTrait;
    public function Register()
    {
        $model = new UserModel();

        $data = [
            "name"=>$this->request->getPost('name'),
            "email"=>$this->request->getPost('email'),
            "password"=>password_hash($this->request->getPost('password'),PASSWORD_DEFAULT),
            "phone"=>$this->request->getPost('phone'),
            "street_number"=>$this->request->getPost('street_number'),
            "street"=>$this->request->getPost('route'),
            "apartment"=>$this->request->getPost('subpremise'),
            "city"=>$this->request->getPost('locality'),
            "postal_code"=>$this->request->getPost('postcode'),
            "state"=>$this->request->getPost('state'),
            "country"=>$this->request->getPost('country'),
            "latitude"=>$this->request->getPost('latitude'),
            "longitude"=>$this->request->getPost('longitude'),
            "place_id"=>$this->request->getPost('place_id'),
        ];

        $model->insert($data);
    return redirect()->back()->withInput()->with("message","
        <div class='alert alert-success solid alert-dismissible fade show'>
            <svg viewBox='0 0 24 24' width='24' height='24' stroke='currentColor' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round' class='me-2'><polyline points='9 11 12 14 22 4'></polyline><path d='M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11'></path></svg>
            <strong>Success!</strong> Account successfully created.
            <button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='btn-close'>
            </button>
        </div>
    ");
}
</code>```

Model Code:

```<code>class UserModel extends Model
{

    // Product Table
    protected $table="users";
    protected  $primaryKey="id";

    protected $allowedFields=['name',
                             'email',
                             'password',
                             'role_id',
                             'activation_code',
                             'active',
                             'phone',
                             'street_number',
                             'street',
                             'apartment',
                             'city',
                             'postal_code',
                             'state',
                             'country',
                             'latitude',
                             'longitude',
                             'place_id',
                            ];
}
</code>```

Image of Inserted Data Inside Table:

Image of Data Received:

It's VERY strange because some info is inserted but some aren't.

Body:
I am currently using the CodeIgniter4 framework with PHP, this is supposed to get the name/id of each input form and the information inside, and then put that info into the their respective columns, I tried dd($data); to make sure it's receiving the information but when it actually does try to put in the info, it skips Street Number, City, State and Country, I have made sure that the model is getting the right columns in the table, and as far as I'm aware, there is no reason for this code to not work.

Function Code:

<?php

namespace App\Controllers\Admin\Theme;
use App\Controllers\BaseController;
use CodeIgniter\API\ResponseTrait;
use App\Models\Admin\UserModel;
use \Firebase\JWT\JWT;

class Auth extends BaseController
{
    use ResponseTrait;
    public function Register()
    {
        $model = new UserModel();

        $data = [
            "name"=>$this->request->getPost('name'),
            "email"=>$this->request->getPost('email'),
            "password"=>password_hash($this->request->getPost('password'),PASSWORD_DEFAULT),
            "phone"=>$this->request->getPost('phone'),
            "street_number"=>$this->request->getPost('street_number'),
            "street"=>$this->request->getPost('route'),
            "apartment"=>$this->request->getPost('subpremise'),
            "city"=>$this->request->getPost('locality'),
            "postal_code"=>$this->request->getPost('postcode'),
            "state"=>$this->request->getPost('state'),
            "country"=>$this->request->getPost('country'),
            "latitude"=>$this->request->getPost('latitude'),
            "longitude"=>$this->request->getPost('longitude'),
            "place_id"=>$this->request->getPost('place_id'),
        ];

        $model->insert($data);
    return redirect()->back()->withInput()->with("message","

            <svg viewBox='0 0 24 24' width='24' height='24' stroke='currentColor' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round' class='me-2'><polyline points='9 11 12 14 22 4'></polyline><path d='M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11'></path></svg>
            Success! Account successfully created.
            <button type='button' class='btn-close' data-bs-dismiss='alert' aria-label='btn-close'>
            </button>

    ");
}

Model Code:

class UserModel extends Model
{

    // Product Table
    protected $table="users";
    protected  $primaryKey="id";

    protected $allowedFields=['name',
                             'email',
                             'password',
                             'role_id',
                             'activation_code',
                             'active',
                             'phone',
                             'street_number',
                             'street',
                             'apartment',
                             'city',
                             'postal_code',
                             'state',
                             'country',
                             'latitude',
                             'longitude',
                             'place_id',
                            ];
}

Image of Inserted Data Inside Table:

Image of Data Received:

It's VERY strange because some info is inserted but some aren't.


问:
CMAKE way to search for .exe file in the CLists text?
Say I have

```<code>set(CMAKE_CXX_COMPILER={$myCompilersEnvVariableName}
</code>```

and it's not configured

is there an if statement that I can place here something like

```<code>if CMAKE_CXX_COMPILER FALSE
search for cl.exe
set(CMAKE_CXX_COMPILER path/to/cl.exe

break
</code>```

It is not a problem but a theoretical question

Body:
Say I have

set(CMAKE_CXX_COMPILER={$myCompilersEnvVariableName}

and it's not configured

is there an if statement that I can place here something like

if CMAKE_CXX_COMPILER FALSE
search for cl.exe
set(CMAKE_CXX_COMPILER path/to/cl.exe

break

It is not a problem but a theoretical question


问:
How do I check a registry image creation date without pulling it for a CI CD incremental build
I want to cancel a CI CD build if none of the files changed that would go into a docker image.

For that I want to get the creation timestamp of a docker image without pulling it first.

```<code>docker pull groovy:latest
docker image inspect groovy:latest | jq -r '.[].Created'
</code>```

This would give me the creation timestamp

```<code>docker image remove groovy:latest || true
docker image inspect groovy:latest | jq -r '.[].Created'
</code>```

If the image is not locally available the result would be 'Error: No such image: groovy:latest'

I can get a manifest list like so

```<code>docker image remove groovy:latest
docker manifest inspect groovy:latest
docker images | grep groovy
</code>```

This does not give me a creation timestamp nor should it as documented in the api.

I am unable to get a timestamp without pulling the image.
Is there a way to achieve what I am looking for?

I need the creation timestamp of the image in the remote registry
So that I can cancel a build if no files are newer than the image.

Some more example code - this is not a minimal example and it takes a while to execute. I recommend testing this on an image with only a few layers. The approach has flaws:

It does not produce timestamps since the data is not in the manifests

In the current form the execution takes longer than pulling the image

Due to the long execution time I am not entirely sure the behavior is as intended.

Playing with it kills your rate limit

I removed the example since it does not help and playing with it kills your docker rate limit.

Body:
I want to cancel a CI CD build if none of the files changed that would go into a docker image.

For that I want to get the creation timestamp of a docker image without pulling it first.

docker pull groovy:latest
docker image inspect groovy:latest | jq -r '.[].Created'

This would give me the creation timestamp

docker image remove groovy:latest || true
docker image inspect groovy:latest | jq -r '.[].Created'

If the image is not locally available the result would be 'Error: No such image: groovy:latest'

I can get a manifest list like so

docker image remove groovy:latest
docker manifest inspect groovy:latest
docker images | grep groovy

This does not give me a creation timestamp nor should it as documented in the api.

I am unable to get a timestamp without pulling the image.
Is there a way to achieve what I am looking for?

I need the creation timestamp of the image in the remote registry
So that I can cancel a build if no files are newer than the image.

Some more example code - this is not a minimal example and it takes a while to execute. I recommend testing this on an image with only a few layers. The approach has flaws:

It does not produce timestamps since the data is not in the manifests

In the current form the execution takes longer than pulling the image

Due to the long execution time I am not entirely sure the behavior is as intended.

Playing with it kills your rate limit

I removed the example since it does not help and playing with it kills your docker rate limit.


问:
Need to render current date on MaterialUi DatePicker as (Tue, Dec 27th 2022) instead of (Tue, Dec 27 2022). i.e. with ordinals in dayjs extendedFormat
I have the following code for date picker:

```<code><LocalizationProvider dateAdapter={AdapterDayjs}>
  <DatePicker
    value={date}
    disablePast
    showDaysOutsideCurrentMonth
    inputFormat='ddd, MMM D YYYY'
    onChange={(newValue) => {
      if (newValue) setDate(dayjs(newValue).format('ddd, MMM Do YYYY'));
    }}
    renderInput={(params) => <TextField {...params} sx={{ width: '90%' }} />}
    InputAdornmentProps={{ position: 'start' }}
  />
</LocalizationProvider>
</code>```

This shows the placeholder date format on date picker as 'Tue, Dec 27 2022'.

I need to change the placeholder to show Tue, Dec 27th 2022.

I have tried inputFormat='ddd, MMM Do YYYY' from (https://day.js.org/docs/en/plugin/advanced-format) but it doesn't work. This advanced format is otherwise working on other date instances inside the app as

```<code>const today = dayjs(new Date()).format('ddd, MMM Do YYYY');
</code>```

and renders 'Tue, Dec 27th 2022' perfectly on plain text.

Body:
I have the following code for date picker:

<LocalizationProvider dateAdapter={AdapterDayjs}>
  <DatePicker
    value={date}
    disablePast
    showDaysOutsideCurrentMonth
    inputFormat='ddd, MMM D YYYY'
    onChange={(newValue) => {
      if (newValue) setDate(dayjs(newValue).format('ddd, MMM Do YYYY'));
    }}
    renderInput={(params) => <TextField {...params} sx={{ width: '90%' }} />}
    InputAdornmentProps={{ position: 'start' }}
  />
</LocalizationProvider>

This shows the placeholder date format on date picker as 'Tue, Dec 27 2022'.

I need to change the placeholder to show Tue, Dec 27th 2022.

I have tried inputFormat='ddd, MMM Do YYYY' from (https://day.js.org/docs/en/plugin/advanced-format) but it doesn't work. This advanced format is otherwise working on other date instances inside the app as

const today = dayjs(new Date()).format('ddd, MMM Do YYYY');

and renders 'Tue, Dec 27th 2022' perfectly on plain text.


问:
Label Position Folium
I want to change the position of an folium map legend, I searched and tried a lot but it is not working.

```<code>    fill_color="OrRd",
    fill_opacity=0.55,
    line_opacity=.35,
    highlight=True,
    show=False,
    line_color='black',
    legend_name='Amount of Accidents in District'
)
</code>```

I read the API but I do not found anything. Also the legend_position = "bottom left" did not worked out. Do somebody know how I can specify the position of this. And also make the title bold?

Title: Label Position Folium

Body:
I want to change the position of an folium map legend, I searched and tried a lot but it is not working.

    fill_color="OrRd",
    fill_opacity=0.55,
    line_opacity=.35,
    highlight=True,
    show=False,
    line_color='black',
    legend_name='Amount of Accidents in District'
)

I read the API but I do not found anything. Also the legend_position = "bottom left" did not worked out. Do somebody know how I can specify the position of this. And also make the title bold?


问:
ingress redirect to unexpected path
I am new to ingress and trying to set up ingress for Prometheus. But I am facing a redirect error about it.

Symptom:
Here is my ingress configuration file

```<code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
  name: prometheus-ingress
  namespace: prometheus
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - backend:
          service:
            name: prometheus-service
            port:
              number: 9090
        path: /prometheus/?(.*)
        pathType: Prefix
</code>```

When I am trying to access Prometheus through "http://localhost/prometheus". the URL will automatically redirect to "http://localhost/graph", but the accessible URL should be "http://localhost/prometheus/graph", so How do configure ingress so that it could be redirected to "http://localhost/prometheus/graph" automatically when I just type "http://localhost/prometheus"?

Title: ingress redirect to unexpected path

Body:
I am new to ingress and trying to set up ingress for Prometheus. But I am facing a redirect error about it.

Symptom:
Here is my ingress configuration file

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /$1
  name: prometheus-ingress
  namespace: prometheus
spec:
  ingressClassName: nginx
  rules:
  - http:
      paths:
      - backend:
          service:
            name: prometheus-service
            port:
              number: 9090
        path: /prometheus/?(.*)
        pathType: Prefix

When I am trying to access Prometheus through "http://localhost/prometheus". the URL will automatically redirect to "http://localhost/graph", but the accessible URL should be "http://localhost/prometheus/graph", so How do configure ingress so that it could be redirected to "http://localhost/prometheus/graph" automatically when I just type "http://localhost/prometheus"?


问:
how to integrate array key existence factor into a query request
I'm trying to filter a table based on two parameters if entered. What I'm doing here is that if text is entered into an input field attached to a column, "searchRecord" is sent to "action.php" file.

```<code>$(document).ready(function(){
                $('#conditions_n').keyup(function(event){
                    event.preventDefault();
                    let action = 'searchRecord';
                    let conditions = $('#conditions_n').val();
                    if(conditions != '') {
                        $.ajax({
                            url: "action.php",
                            method: "POST",
                            data: {action:action, conditions:conditions},
                            success: function(data){
                                $('#post_list').html(data);
                            }
                        });
                    }
                });
                $('#modelYears_n').keyup(function(event){
                    event.preventDefault();
                    let action = 'searchRecord';
                    let modelYears = $('#modelYears_n').val();
                    if(modelYears != '') {
                        $.ajax({
                            url: "action.php",
                            method: "POST",
                            data: {action:action, modelYears:modelYears},
                            success: function(data){
                                $('#post_list').html(data);
                            }
                        });
                    }
                });
            });
</code>```

Where I want to run a SELECT query.

```<code>if($_POST['action'] == ('searchRecord')){
        $conditons = $_POST['conditions'];
        $modelYears = $_POST['modelYears'];
        $query = "SELECT * FROM suppliers
                  WHERE (conditions LIKE '%$conditons%') AND (modelYears LIKE '%$modelYears%')";
        getData($query);
    }
</code>```

The issue of course is that if data is entered into one field, in the action.php file, the other field is empty so I get an array key error, and the query does not work, since one of the array keys ($conditions, $modelYears) does not exist. Also when you enter data into one field the other POST request gets overwritten.

I have tried to separate these two actions, but then the table does not filter on two parameters.

So at the end of the day, I have no idea what I'm doing or how I should fix it, a hint would be nice.

Body:
I'm trying to filter a table based on two parameters if entered. What I'm doing here is that if text is entered into an input field attached to a column, "searchRecord" is sent to "action.php" file.

$(document).ready(function(){
                $('#conditions_n').keyup(function(event){
                    event.preventDefault();
                    let action = 'searchRecord';
                    let conditions = $('#conditions_n').val();
                    if(conditions != '') {
                        $.ajax({
                            url: "action.php",
                            method: "POST",
                            data: {action:action, conditions:conditions},
                            success: function(data){
                                $('#post_list').html(data);
                            }
                        });
                    }
                });
                $('#modelYears_n').keyup(function(event){
                    event.preventDefault();
                    let action = 'searchRecord';
                    let modelYears = $('#modelYears_n').val();
                    if(modelYears != '') {
                        $.ajax({
                            url: "action.php",
                            method: "POST",
                            data: {action:action, modelYears:modelYears},
                            success: function(data){
                                $('#post_list').html(data);
                            }
                        });
                    }
                });
            });

Where I want to run a SELECT query.

if($_POST['action'] == ('searchRecord')){
        $conditons = $_POST['conditions'];
        $modelYears = $_POST['modelYears'];
        $query = "SELECT * FROM suppliers
                  WHERE (conditions LIKE '%$conditons%') AND (modelYears LIKE '%$modelYears%')";
        getData($query);
    }

The issue of course is that if data is entered into one field, in the action.php file, the other field is empty so I get an array key error, and the query does not work, since one of the array keys ($conditions, $modelYears) does not exist. Also when you enter data into one field the other POST request gets overwritten.

I have tried to separate these two actions, but then the table does not filter on two parameters.

So at the end of the day, I have no idea what I'm doing or how I should fix it, a hint would be nice.


问:
Delta hedging - change in portfolio value over dt (short in call and long in shares)
Equating the change in the portfolio value from 2 equations: the interest (risk-free) on the hedged portfolio, with theta dt +0.5sigma^2S^2gammadt; perhaps the functions are incorrect?

ssss<-90 #shareprice tttt<-.1  #time to expiry
new_delta<-greeks(bscall(ssss, 90, .1, .03, tttt, 0))[2] timestep<-0.001

``(greeks(bscall(ssss, 90, .1, .03, tttt, 0))[2]*ssss-callprice(ssss,90,.03,.1,tttt))0.03timestep

#calc1 - risk free return on hedged portfolio

``(-greeks(bscall(ssss, 90, .1, .03, tttt, 0))[6]timestep-0.5sigma^2ssss^2greeks(bscall(ssss, 90, .1, .03, tttt, 0))[3]*timestep)

#calc2 - using theta and gamma


问:
How I can detected referrer?
The user followed the link, for example from a telegram application, how can I determine that it was a telegram without passing get parameters in URL?

I visit suit following the link from email, telegram. In  $_SERVER['HTTP_REFERRER'] - it's empty.

Title: How I can detected referrer?


问:
nextjs swr hard to use and slow
I'm using swr to fetch data in a nextjs project, I use the error that useswr hook return to determine

open a dialog or not the problem is the dialog show up very slow take like 2 second.

```<code>
const fetcher = (url:string) =>{
    return axios.get(url).then(res=>res.data)
}

export const useUserInfo = (url:string)=>{

    const {data,error,mutate} = useSWRImmutable<Response,AxiosError>(url,fetcher,{shouldRetryOnError:false})

    return {
        data,
        error,
        mutate
    }

}

</code>```
```<code>const ErrorDialog = (props:Props) =>{

    const [open, setOpen] = React.useState(false);
    const {message,title,handleClick,isError} = props

    useEffect(()=>{

      if(isError!==undefined){
        setOpen(true)
      }

    },[isError])

      const handleClose = () => {
        setOpen(false);
      };

    return (

        <>
        <Dialog
        open={open}
        aria-labelledby="alert-dialog-title"
        aria-describedby="alert-dialog-description"
      >
        <DialogTitle id="alert-dialog-title">
        {title}
        </DialogTitle>
        <DialogContent>
          <DialogContentText id="alert-dialog-description">
           {message}
          </DialogContentText>
        </DialogContent>
        <DialogActions>
          <Button onClick={handleClose}>Disagree</Button>
          <Button onClick={handleClose} autoFocus>
            Agree
          </Button>
        </DialogActions>
      </Dialog>

        </>

    )

}
</code>```

the ui library I use is mui https://mui.com/

if I just use state to manage the dialog feel like more quickly the dialog show up.And I also have to
mutate the error to undefine when I close dialog and click back button go other page and return to the dialog page otherwise the dialog show twice because the error is not undefine before trigger the new fetch.

Title: nextjs swr hard to use and slow

Body:
I'm using swr to fetch data in a nextjs project, I use the error that useswr hook return to determine

open a dialog or not the problem is the dialog show up very slow take like 2 second.

const fetcher = (url:string) =>{
    return axios.get(url).then(res=>res.data)
}

export const useUserInfo = (url:string)=>{

    const {data,error,mutate} = useSWRImmutable<Response,AxiosError>(url,fetcher,{shouldRetryOnError:false})

    return {
        data,
        error,
        mutate
    }

}

const ErrorDialog = (props:Props) =>{

    const [open, setOpen] = React.useState(false);
    const {message,title,handleClick,isError} = props

    useEffect(()=>{

      if(isError!==undefined){
        setOpen(true)
      }

    },[isError])

      const handleClose = () => {
        setOpen(false);
      };

    return (

        <>
        <Dialog
        open={open}
        aria-labelledby="alert-dialog-title"
        aria-describedby="alert-dialog-description"
      >
        <DialogTitle id="alert-dialog-title">
        {title}
        </DialogTitle>
        <DialogContent>
          <DialogContentText id="alert-dialog-description">
           {message}
          </DialogContentText>
        </DialogContent>
        <DialogActions>
          <Button onClick={handleClose}>Disagree</Button>
          <Button onClick={handleClose} autoFocus>
            Agree
          </Button>
        </DialogActions>
      </Dialog>

        </>

    )

}

the ui library I use is mui https://mui.com/

if I just use state to manage the dialog feel like more quickly the dialog show up.And I also have to
mutate the error to undefine when I close dialog and click back button go other page and return to the dialog page otherwise the dialog show twice because the error is not undefine before trigger the new fetch.


问:
Resetting an array of numbers by repeated subtraction from a sub-array
There is an array of numbers between 0 and 6 (base 7). For example {0 4 6 2 2 0 3 1}. Its maximum length can be 501 elements.
Each step we can subtract a number from any number of elements. All of the elements must be adjacent (form a continuous sub-array). The number subtracted from all of the elements must be the same.

If an element (let's call it A) after subtraction doesn't fit in the range of 0 to 6, then A becomes A modulo 7. For example after subtracting 3 from the whole array {0 4 6 2 2 0 3 1}, we would get
{4 1 3 6 6 4 0 5}.

The task is to find the smallest amount of steps necessary to get an array with just zeros.

For example for the array {0 4 6 2 2 0 3 1} it would take 4 steps:

{0 4 6 2 2 0 3 1} subtract 2 from elements with indexes 2-4

{0 4 4 0 0 0 3 1} subtract 4 from elements with indexes 1 and 2

{0 0 0 0 0 0 3 1} subtract 3 from the second to last element

{0 0 0 0 0 0 0 1} subtract 1 from the last element

{0 0 0 0 0 0 0 0}

First of all finding the solution using brute force is not possible, as for an array of 501 numbers
there are 126 505 506 possible first steps.
(6x(1x501 + 2x500 + 3x499 + 4x498 +...+ 501x1) = 6x21084251 = 126505506).
There would be a lot more possibilities if we include the steps following the first one.

I noticed we can remove an element if it has the same number next to it.
So the array {0 4 6 2 2 0 3 1} becomes {0 4 6 2 0 3 1}. This should simplify the problem.

I've tried dividing the array into sections using zeros as the dividers.
So for the array {0 4 6 2 0 3 1} we could consider two separate arrays: {4 6 2} and {3 1}.
I thought I could find the answers for those arrays and add them together for the final answer.
But I discovered arrays for which this approach doesn't work.
For example, for the array {3 2 1 0 1 2 3} this approach would yield the answer 3 + 3 = 6 while it should be 4 steps:

{3 2 1 0 1 2 3} subtract 3 from the whole array

{0 6 5 4 5 6 0}subtract 6 for indexes 1 to 5

{0 0 6 5 6 0 0} subtract 6 for indexes 2 to 4

{0 0 0 6 0 0 0} subtract 6 from the middle element

{0 0 0 0 0 0 0}

Another approach I tried was looking for pairs of the same number and dividing the array accordingly.
For example the array: {0 3 1 5 3 5 6 2 1 5 1}
would divide into three arrays {3 1 5 3} and {5 6 2 1 5} and {6}.

This would allow me to shorten a sub-array by two elements in just one step:

{3 1 5 3} {5 6 2 1 5} {6} subtract from the first subarray

{0 5 2 0} {5 6 2 1 5} {6} subtract from the second subarray

{0 5 2 0} {0 1 4 3 0} {6} remove zeroes on the sides ->   {5 2} {1 4 3} {6}

But I couldn't find a final solution using this approach. Also I don't know how to check whether it always would return the best answer.


问:
How to store single name after face is recognized instead of saving the name repeatedly?
im trying to store name from the frame, it does store the name but does it repeatedly i want the script to only store the name once whenever the face appears[this is the codethis is the result , i want to store the data single time whenever the face is recognized](https://i.stack.imgur.com/xOdrJ.jpg)

i tried writing the lines of code out of the loop but that doesnt worked


问:
Why is my "Switch to" option is grayed out?
I have my 'switched to' option grayed out:

I need it in order to manually select columns I need...

(This is how it looks in a table that works fine)

Why/how did I lose this option?


问:
SwiftUI.PreviewProvider MainActor isolation warning
I am receiving two (duplicate) warnings about concurrency on a file that is simply a SwiftUI View. This has started to happen after I have added Swift Concurrency on other parts of the codebase.

The full warning is: SwiftUI.PreviewProvider Main actor-isolated static property '_previews' cannot be used to satisfy nonisolated protocol requirement '_previews' declared here

Warning is caused by the CloseButton_Previews below. Here's the full file:

```<code>import SwiftUI
import DesignSystem

struct CloseButton: View {
  private enum Constants {
    static let closeIconSize = CGSize(width: 32, height: 32)
  }

  var body: some View {
    HStack {
      IconButton {
        print("Close button was tapped")
      } icon: {
        Icon.closeBig
          .resizable()
          .symbolRenderingMode(.hierarchical)
          .foregroundColor(.gray)
          .frame(
            width: Constants.closeIconSize.width,
            height: Constants.closeIconSize.height,
            alignment: .center
          )
      }
    }
    .frame(
      width: Spacing.minimumTappableLength,
      height: Spacing.minimumTappableLength,
      alignment: .center
    )
  }
}

struct CloseButton_Previews: PreviewProvider {
  static var previews: some View {
    ZStack {
      Color(.systemMint)
      CloseButton()
    }
    .ignoresSafeArea()
  }
}
</code>```

And the IconButton.swift:

```<code>import SwiftUI

public struct IconButton<Icon: View>: View {
  private let action: (() -> Void)
  private let icon: Icon

  public init(action: @escaping (() -> Void), icon: () -> Icon) {
    self.action = action
    self.icon = icon()
  }

  public var body: some View {
    Button {
      action()
    } label: {
      icon
    }
    .frame(
      width: Spacing.minimumTappableLength,
      height: Spacing.minimumTappableLength,
      alignment: .center
    )
    .padding()
  }
}
</code>```

I suspect maybe the problem is somewhere else but somehow the warning is shown on the Preview. Because CloseButton is only used by another SwiftUI View that uses some Swift Concurrency. In itself it doesn't have anything that I can think of that might cause this. Any help would be much appreciated. Thanks!

Body:
I am receiving two (duplicate) warnings about concurrency on a file that is simply a SwiftUI View. This has started to happen after I have added Swift Concurrency on other parts of the codebase.

The full warning is: SwiftUI.PreviewProvider Main actor-isolated static property '_previews' cannot be used to satisfy nonisolated protocol requirement '_previews' declared here

Warning is caused by the CloseButton_Previews below. Here's the full file:

import SwiftUI
import DesignSystem

struct CloseButton: View {
  private enum Constants {
    static let closeIconSize = CGSize(width: 32, height: 32)
  }

  var body: some View {
    HStack {
      IconButton {
        print("Close button was tapped")
      } icon: {
        Icon.closeBig
          .resizable()
          .symbolRenderingMode(.hierarchical)
          .foregroundColor(.gray)
          .frame(
            width: Constants.closeIconSize.width,
            height: Constants.closeIconSize.height,
            alignment: .center
          )
      }
    }
    .frame(
      width: Spacing.minimumTappableLength,
      height: Spacing.minimumTappableLength,
      alignment: .center
    )
  }
}

struct CloseButton_Previews: PreviewProvider {
  static var previews: some View {
    ZStack {
      Color(.systemMint)
      CloseButton()
    }
    .ignoresSafeArea()
  }
}

And the IconButton.swift:

import SwiftUI

public struct IconButton<Icon: View>: View {
  private let action: (() -> Void)
  private let icon: Icon

  public init(action: @escaping (() -> Void), icon: () -> Icon) {
    self.action = action
    self.icon = icon()
  }

  public var body: some View {
    Button {
      action()
    } label: {
      icon
    }
    .frame(
      width: Spacing.minimumTappableLength,
      height: Spacing.minimumTappableLength,
      alignment: .center
    )
    .padding()
  }
}

I suspect maybe the problem is somewhere else but somehow the warning is shown on the Preview. Because CloseButton is only used by another SwiftUI View that uses some Swift Concurrency. In itself it doesn't have anything that I can think of that might cause this. Any help would be much appreciated. Thanks!


问:
How to pass path to file as parameter MySQL
I need to fill my database from file. And I want to pass path to file as parameter in sql script.

I tried this.

LOAD DATA INFILE @fileName INTO TABLE TICKETS COLUMNS terminated BY '\t' LINES TERMINATED BY '\n' (@col1,@col2,@col3) set ticket_id=@col1,win_size=@col2;

And from MySQL console:

set @fileName = "path/to/file"

But it didn't work.

And like this:

set @query = CONCAT('LOAD DATA INFILE ', @fileName, ' INTO TABLE TICKETS COLUMNS terminated BY \'\\t\' LINES TERMINATED BY \'\\n\' (@col1,@col2,@col3) set ticket_id=@col1,win_size=@col2;');

But for this there were an errors.

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'C:/ProgramData/MySQL/MySQL Server 8.0/Uploads/qwe.txt INTO TABLE TICKETS COLUMNS' at line 1

ERROR 1243 (HY000): Unknown prepared statement handler (stmt) given to EXECUTE

ERROR 1243 (HY000): Unknown prepared statement handler (stmt) given to DEALLOCATE PREPARE

How can I pass this?


问:
How to insert data in excel sheet dynamically using xlsxwriter in python?
I am trying to write some data in a sheet using xlsxwriter but the positioning of data writing in the cell is not correct.

I have a list name q_arr that contains data in lists as an example -

```<code>q_arr = [
[ "", "", "", ""],["yes","","","comp",""],["cateA","comp","mode",""]
]
</code>```

so the list does not have fixed elements also it contains blank values which I need to print.

Now I am printing some other data too before this list

```<code>row = 1
for index, result in enumerate(docs):
    sheet.write(row, 0, result["date"])
    row= row+1
</code>```

now in the for loop, I need to write code that can dynamically write q_arr values. Also, I have to make sure that data writing must start from column=36 and row=1 as row=0 is the header.

I have tried the below code but it is not working as the positioning of the row is not correct it writes everything in 1 row.

```<code>row = 1
for index, result in enumerate(docs):
    sheet.write(row, 0, result["date"])
    for row_values in q_arr:
        sheet.write(rows, cols, row_values)
        cols += 1

    cols = 36
    rows += 1
    row = row + 1
</code>```

Also for reference, I am mentioning that when I tried the below code without for index, result in enumerate(docs): loop with dummy data everything worked fine.

```<code> for row_values in q_arr:
   for val in row_values:

     sheet.write(rows, col, val)

     col += 1

 col = 36
 rows += 1
</code>```

so, How will I write the list of lists dynamically in xlsxwriter in python?

Body:
I am trying to write some data in a sheet using xlsxwriter but the positioning of data writing in the cell is not correct.

I have a list name q_arr that contains data in lists as an example -

q_arr = [
[ "", "", "", ""],["yes","","","comp",""],["cateA","comp","mode",""]
]

so the list does not have fixed elements also it contains blank values which I need to print.

Now I am printing some other data too before this list

row = 1
for index, result in enumerate(docs):
    sheet.write(row, 0, result["date"])
    row= row+1

now in the for loop, I need to write code that can dynamically write q_arr values. Also, I have to make sure that data writing must start from column=36 and row=1 as row=0 is the header.

I have tried the below code but it is not working as the positioning of the row is not correct it writes everything in 1 row.

row = 1
for index, result in enumerate(docs):
    sheet.write(row, 0, result["date"])
    for row_values in q_arr:
        sheet.write(rows, cols, row_values)
        cols += 1

    cols = 36
    rows += 1
    row = row + 1

Also for reference, I am mentioning that when I tried the below code without for index, result in enumerate(docs): loop with dummy data everything worked fine.

 for row_values in q_arr:
   for val in row_values:

     sheet.write(rows, col, val)

     col += 1

 col = 36
 rows += 1

so, How will I write the list of lists dynamically in xlsxwriter in python?


问:
java.lang.NoSuchFieldError when unit testing DataBinding in Android
we migrated our CompileSDK Version to 32 and Android Gradle Plugin from v7.2.1 to v7.3.1. But now our unit tests are failing with  DataBinding. The application builds and runs successfully but, unit tests fail with this exception.

```<code>java.lang.NoSuchFieldError: cardNumber
    at in.mintpro.account.ui.adhaar_details.AdhaarDetailsViewState.<init>(AdhaarDetailsViewState.kt:58)
    at in.mintpro.account.ui.adhaar_details.AdhaarDetailsViewState.<init>(AdhaarDetailsViewState.kt:11)
    at in.mintpro.account.ui.adhaar_details.AdhaarDetailsViewStateTest.check initial state(AdhaarDetailsViewStateTest.kt:30)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:580)
    at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$2(SandboxTestRunner.java:287)
    at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:99)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

</code>```

The unit test is unable to find the fields like BR.cardName & BR.cardNumber in the BR class that is generated by DataBinding

Here is a gist of our ViewState class, which is bound to the XML files

```<code>class AdhaarDetailsViewState(
    initCardName: String = "",
    initCardNameErrorText: String? = null,
    initCardNumber: String = "",
    initCardNumberErrorText: String? = null,

) : BaseObservable() {

    @get:Bindable
    var cardNumber by bind(BR.cardNumber, initCardNumber) { _, new ->
        val enabled = new.matches(ValidationsRegEx.AADHAAR_REGEX.toRegex())
        cardNumberErrorText = if (enabled) {
            null
        } else {
            AADHAAR_CARD_NUMBER_ERROR
        }
    }

    @get:Bindable
    var cardNumberErrorText by bind(BR.cardNumberErrorText, initCardNumberErrorText)

    @get:Bindable
    var cardName by bind(BR.cardName, initCardName) { _, new ->
        val enabled = new.isNotEmpty()
        cardNameErrorText = if (enabled) {
            null
        } else {
            AADHAAR_CARD_NAME_ERROR
        }
    }

    @get:Bindable
    var cardNameErrorText by bind(BR.cardNameErrorText, initCardNameErrorText)

}
</code>```

Any help would be appreciated, thank you!

Body:
we migrated our CompileSDK Version to 32 and Android Gradle Plugin from v7.2.1 to v7.3.1. But now our unit tests are failing with  DataBinding. The application builds and runs successfully but, unit tests fail with this exception.

java.lang.NoSuchFieldError: cardNumber
    at in.mintpro.account.ui.adhaar_details.AdhaarDetailsViewState.<init>(AdhaarDetailsViewState.kt:58)
    at in.mintpro.account.ui.adhaar_details.AdhaarDetailsViewState.<init>(AdhaarDetailsViewState.kt:11)
    at in.mintpro.account.ui.adhaar_details.AdhaarDetailsViewStateTest.check initial state(AdhaarDetailsViewStateTest.kt:30)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:580)
    at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$2(SandboxTestRunner.java:287)
    at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:99)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

The unit test is unable to find the fields like BR.cardName & BR.cardNumber in the BR class that is generated by DataBinding

Here is a gist of our ViewState class, which is bound to the XML files

class AdhaarDetailsViewState(
    initCardName: String = "",
    initCardNameErrorText: String? = null,
    initCardNumber: String = "",
    initCardNumberErrorText: String? = null,

) : BaseObservable() {

    @get:Bindable
    var cardNumber by bind(BR.cardNumber, initCardNumber) { _, new ->
        val enabled = new.matches(ValidationsRegEx.AADHAAR_REGEX.toRegex())
        cardNumberErrorText = if (enabled) {
            null
        } else {
            AADHAAR_CARD_NUMBER_ERROR
        }
    }

    @get:Bindable
    var cardNumberErrorText by bind(BR.cardNumberErrorText, initCardNumberErrorText)

    @get:Bindable
    var cardName by bind(BR.cardName, initCardName) { _, new ->
        val enabled = new.isNotEmpty()
        cardNameErrorText = if (enabled) {
            null
        } else {
            AADHAAR_CARD_NAME_ERROR
        }
    }

    @get:Bindable
    var cardNameErrorText by bind(BR.cardNameErrorText, initCardNameErrorText)

}

Any help would be appreciated, thank you!


问:
Detect that wrapping formControl's validator was changed
We have several ContrlValueAccessor (CVA) components in our project. Some are used to wrap entire forms, and some are used for wrapping complicated mat components (looking at you, autocomplete -.- ). What bugs me is that i can't figure out a nice, built-in, way of detecting that the form control in the wrapping form (the one where you put in your CVA component) had its validator changed.

so, let's say i have a MyCustomAutocompleteComponent implements ControlValueAccessor class, and then i use it in a SomeWrappingFormComponent, like so:

```<code>@Component({
    template: '
        ...
        <my-custom-autocomplete formControlName='acValue'>
        ...

    '
})
export class SomeWrappingFormComponent {
...

    this.wrappingForm = fb.group({
        acValue: [],
        ...
    })

...
}
</code>```

What i'd REALLY like is, when someone goes and says sth like

```<code>this.wrappingForm.get('acValue').setValidator([Validators.required])
</code>```

to somehow be notified about it in my MyCustomAutocompleteComponent. I really need a way to figure out there was a dynamic (programmatic) change made to external control's validator within the CVA component.

Does anyone have a nice way to do this?

i've tried implementing Validator interface as well, and then reacting in onValidatorChange, but it didn't seem to do much, as this doesn't seem to be its intended use

Body:
We have several ContrlValueAccessor (CVA) components in our project. Some are used to wrap entire forms, and some are used for wrapping complicated mat components (looking at you, autocomplete -.- ). What bugs me is that i can't figure out a nice, built-in, way of detecting that the form control in the wrapping form (the one where you put in your CVA component) had its validator changed.

so, let's say i have a MyCustomAutocompleteComponent implements ControlValueAccessor class, and then i use it in a SomeWrappingFormComponent, like so:

@Component({
    template: '
        ...
        <my-custom-autocomplete formControlName='acValue'>
        ...

    '
})
export class SomeWrappingFormComponent {
...

    this.wrappingForm = fb.group({
        acValue: [],
        ...
    })

...
}

What i'd REALLY like is, when someone goes and says sth like

this.wrappingForm.get('acValue').setValidator([Validators.required])

to somehow be notified about it in my MyCustomAutocompleteComponent. I really need a way to figure out there was a dynamic (programmatic) change made to external control's validator within the CVA component.

Does anyone have a nice way to do this?

i've tried implementing Validator interface as well, and then reacting in onValidatorChange, but it didn't seem to do much, as this doesn't seem to be its intended use


问:
SkiaSharp DrawPath, how to know what path the user has clicked
I need to have in my android app an image where the user can click on a part of the image, and than that part will color different.

I searched a lot on this, but found no use-able solution, all I could find was that SkiaSharp might be the best option for this.

So I installed it and am trying now to get some result, I think I need to cut my image in the parts that the user can click on, and then display these parts so it looks like one complete image again.

On that part I have made some progress, I cut the parts from my image, save them and then use an online converter to get that image parts as svg

After many tries and googling I managed to show 3 parts from my image.

My next problem is, how can I know which image the user clicked on ?

I added a TabGestureRecognizer but it works for the complete canvas.

this is the xaml

```<code><skia:SKCanvasView PaintSurface="OnCanvasViewPaintSurface" VerticalOptions="FillAndExpand" >
    <skia:SKCanvasView.GestureRecognizers>
        <TapGestureRecognizer x:Name="tapGestureRecognizer" />
    </skia:SKCanvasView.GestureRecognizers>
</skia:SKCanvasView>
</code>```

and this is my c# code

```<code>void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
{
    SKImageInfo info = args.Info;
    SKSurface surface = args.Surface;
    SKCanvas canvas = surface.Canvas;

    canvas.Clear();

    using (SKPaint paint = new SKPaint())
    {
        paint.Style = SKPaintStyle.StrokeAndFill;
        paint.Color = (Xamarin.Forms.Color.Black).ToSKColor();
        paint.StrokeWidth = 1;
        // region 72, the tire
        SKPath path = SKPath.ParseSvgPathData("M52 152.1c-8.8 1.5-19.4 7.1-25.9 13.7-24.4 25.1-14.7 66.8 18.3 78.2 28.1 9.6 58-8.3 62.6-37.4 4-25.5-12.2-48.7-37.8-54.2-7.5-1.5-9.3-1.6-17.2-.3zm19.7 19.8c19.8 9 23.8 34.3 7.7 49-12 11-29.9 10.2-40.8-1.9-11.1-12.3-10.7-30.2 1.1-41.1 6.5-6 11.4-7.9 20.3-7.9 5.2 0 8.8.6 11.7 1.9z");
        canvas.DrawPath(path, paint);

        paint.Style = SKPaintStyle.Stroke;
        paint.Color = StringToColor("#E7FFFF");
        paint.StrokeWidth = 1;
        // region 73, the wheel
        path = SKPath.ParseSvgPathData("M55.2 172c-1.3.6-2.8.8-3.3.4-.5-.3-.9 0-.9.6s-.4.8-1 .5c-.5-.3-1-.1-1 .4 0 .6-.9 1.1-1.9 1.1-1 0-2.1.7-2.5 1.5-.3.8-1.2 1.5-1.9 1.5-.8 0-1.9 1.1-2.5 2.5-.6 1.4-1.6 2.5-2.1 2.5-1.3 0-4.3 6.8-5.3 11.8-1.1 5.9 2 19.2 4.5 19.2.5 0 .6.4.3.9-.7 1.1 7.2 8.1 9.1 8.1.7 0 1.3.4 1.3.8 0 .5.6.9 1.3 1 .6.1 3.5.6 6.2 1.2 5.5 1.2 13.5.5 13.5-1.2 0-.6.3-.9.6-.5.4.3 1.3-.1 2.1-.9s1.9-1.2 2.4-.9c.5.4.9.1.9-.6s.3-1 .6-.6c.9.8 8.5-7.4 7.8-8.5-.3-.4 0-.8.7-.8s1-.3.6-.6c-.3-.4 0-1.2.7-2 3.5-3.5 2.5-19.3-1.6-23.8-1-1-1.5-2.4-1.1-2.9.3-.6.1-.7-.5-.3-.7.4-1.2.1-1.2-.8s-.5-1.5-1.2-1.4c-.7.2-1.2-.3-1.3-1 0-.6-.4-1.3-1-1.4-.5-.1-1.8-.9-2.8-1.8-3.3-3.1-15.6-5.6-19.5-4z");
        canvas.DrawPath(path, paint);

        paint.Style = SKPaintStyle.Stroke;
        paint.Color = (Xamarin.Forms.Color.Black).ToSKColor();
        paint.StrokeWidth = 1;
        // region 14, the black line around it anyway
        path = SKPath.ParseSvgPathData("M111 112.6c-20.7 2.6-23.5 3.6-32.6 11.5l-5.5 4.9h-7.3c-9.1 0-9.8.7-9.4 9.2l.3 6.3 7.5.8c29.3 3.2 50.1 25.6 50 54-.1 26-19.5 48.8-45 52.8-4.1.6-8.1 1.3-8.8 1.5-1.5.4-1.8 30.4-.2 30.4.6 0 1-5.5 1-14.4v-14.3l6.1-.7c22.7-2.6 41.7-19.7 47.5-42.6 2.2-8.7 1.5-23.2-1.6-31.5-3-8.1-10.1-18.6-15.8-23.5-9.4-8.1-24.3-13.9-35.5-14h-3.8l.3-5.8.3-5.7 6-.3c8.7-.3 9.8-.7 15.7-5.8 8.6-7.4 10.6-8.1 32.4-10.9 28.8-3.6 32.2-3.6 36.6-.3 2 1.5 4.5 4.7 5.7 7 3.6 7.5 17.2 75.7 26.7 133.5 2.6 16.1 5.2 29.3 5.6 29.3 1.3 0 1-2.6-4.6-36.2-6.4-37.6-12.7-71.1-19.5-103-4.2-19.4-5.4-23.3-8-27.2-1.8-2.5-4.5-5.3-6.1-6.1-4.1-2.1-15.8-1.8-38 1.1z");
        canvas.DrawPath(path, paint);

        paint.Style = SKPaintStyle.StrokeAndFill;
        paint.Color = StringToColor("#6699FF");
        paint.StrokeWidth = 1;
        // region 14, the rest
        path = SKPath.ParseSvgPathData("M133.5 112.6c-1.1.2-10.5 1.3-21 2.5-21.1 2.5-22.9 3.1-32.2 10.8-6 5-6.2 5.1-12.6 5.1-9.3 0-9.7.3-9.7 6.6v5.4h5.3c20.2 0 41.1 14.8 49.3 35 3.6 8.8 4.6 27.4 1.9 36.6-5.5 19.3-20.6 33.9-40 38.9-3.2.8-7.6 1.5-9.7 1.5H61v29h32v-20.1l4.3.3 4.2.3.3 9.7.3 9.8H186l-.5-2.8c-.3-1.5-3.2-18.7-6.5-38.2-5.9-35.7-13.2-73.8-19.6-103.5-5.3-24.6-10-29.4-25.9-26.9zM144 255v11h-8v-22h8v11z");
        canvas.DrawPath(path, paint);
    };

}
</code>```

It looks like this in the emulator, I still have many parts to do but I want to know first if I can find out what image part the user clicked on.

In this example I need to know if he clicked on the blue part, or on the black part, or on the white circle inside the black part

So, how can I do this ?

Body:
I need to have in my android app an image where the user can click on a part of the image, and than that part will color different.

I searched a lot on this, but found no use-able solution, all I could find was that SkiaSharp might be the best option for this.

So I installed it and am trying now to get some result, I think I need to cut my image in the parts that the user can click on, and then display these parts so it looks like one complete image again.

On that part I have made some progress, I cut the parts from my image, save them and then use an online converter to get that image parts as svg

After many tries and googling I managed to show 3 parts from my image.

My next problem is, how can I know which image the user clicked on ?

I added a TabGestureRecognizer but it works for the complete canvas.

this is the xaml

<skia:SKCanvasView PaintSurface="OnCanvasViewPaintSurface" VerticalOptions="FillAndExpand" >
    <skia:SKCanvasView.GestureRecognizers>
        <TapGestureRecognizer x:Name="tapGestureRecognizer" />
    </skia:SKCanvasView.GestureRecognizers>
</skia:SKCanvasView>

and this is my c# code

void OnCanvasViewPaintSurface(object sender, SKPaintSurfaceEventArgs args)
{
    SKImageInfo info = args.Info;
    SKSurface surface = args.Surface;
    SKCanvas canvas = surface.Canvas;

    canvas.Clear();

    using (SKPaint paint = new SKPaint())
    {
        paint.Style = SKPaintStyle.StrokeAndFill;
        paint.Color = (Xamarin.Forms.Color.Black).ToSKColor();
        paint.StrokeWidth = 1;
        // region 72, the tire
        SKPath path = SKPath.ParseSvgPathData("M52 152.1c-8.8 1.5-19.4 7.1-25.9 13.7-24.4 25.1-14.7 66.8 18.3 78.2 28.1 9.6 58-8.3 62.6-37.4 4-25.5-12.2-48.7-37.8-54.2-7.5-1.5-9.3-1.6-17.2-.3zm19.7 19.8c19.8 9 23.8 34.3 7.7 49-12 11-29.9 10.2-40.8-1.9-11.1-12.3-10.7-30.2 1.1-41.1 6.5-6 11.4-7.9 20.3-7.9 5.2 0 8.8.6 11.7 1.9z");
        canvas.DrawPath(path, paint);

        paint.Style = SKPaintStyle.Stroke;
        paint.Color = StringToColor("#E7FFFF");
        paint.StrokeWidth = 1;
        // region 73, the wheel
        path = SKPath.ParseSvgPathData("M55.2 172c-1.3.6-2.8.8-3.3.4-.5-.3-.9 0-.9.6s-.4.8-1 .5c-.5-.3-1-.1-1 .4 0 .6-.9 1.1-1.9 1.1-1 0-2.1.7-2.5 1.5-.3.8-1.2 1.5-1.9 1.5-.8 0-1.9 1.1-2.5 2.5-.6 1.4-1.6 2.5-2.1 2.5-1.3 0-4.3 6.8-5.3 11.8-1.1 5.9 2 19.2 4.5 19.2.5 0 .6.4.3.9-.7 1.1 7.2 8.1 9.1 8.1.7 0 1.3.4 1.3.8 0 .5.6.9 1.3 1 .6.1 3.5.6 6.2 1.2 5.5 1.2 13.5.5 13.5-1.2 0-.6.3-.9.6-.5.4.3 1.3-.1 2.1-.9s1.9-1.2 2.4-.9c.5.4.9.1.9-.6s.3-1 .6-.6c.9.8 8.5-7.4 7.8-8.5-.3-.4 0-.8.7-.8s1-.3.6-.6c-.3-.4 0-1.2.7-2 3.5-3.5 2.5-19.3-1.6-23.8-1-1-1.5-2.4-1.1-2.9.3-.6.1-.7-.5-.3-.7.4-1.2.1-1.2-.8s-.5-1.5-1.2-1.4c-.7.2-1.2-.3-1.3-1 0-.6-.4-1.3-1-1.4-.5-.1-1.8-.9-2.8-1.8-3.3-3.1-15.6-5.6-19.5-4z");
        canvas.DrawPath(path, paint);

        paint.Style = SKPaintStyle.Stroke;
        paint.Color = (Xamarin.Forms.Color.Black).ToSKColor();
        paint.StrokeWidth = 1;
        // region 14, the black line around it anyway
        path = SKPath.ParseSvgPathData("M111 112.6c-20.7 2.6-23.5 3.6-32.6 11.5l-5.5 4.9h-7.3c-9.1 0-9.8.7-9.4 9.2l.3 6.3 7.5.8c29.3 3.2 50.1 25.6 50 54-.1 26-19.5 48.8-45 52.8-4.1.6-8.1 1.3-8.8 1.5-1.5.4-1.8 30.4-.2 30.4.6 0 1-5.5 1-14.4v-14.3l6.1-.7c22.7-2.6 41.7-19.7 47.5-42.6 2.2-8.7 1.5-23.2-1.6-31.5-3-8.1-10.1-18.6-15.8-23.5-9.4-8.1-24.3-13.9-35.5-14h-3.8l.3-5.8.3-5.7 6-.3c8.7-.3 9.8-.7 15.7-5.8 8.6-7.4 10.6-8.1 32.4-10.9 28.8-3.6 32.2-3.6 36.6-.3 2 1.5 4.5 4.7 5.7 7 3.6 7.5 17.2 75.7 26.7 133.5 2.6 16.1 5.2 29.3 5.6 29.3 1.3 0 1-2.6-4.6-36.2-6.4-37.6-12.7-71.1-19.5-103-4.2-19.4-5.4-23.3-8-27.2-1.8-2.5-4.5-5.3-6.1-6.1-4.1-2.1-15.8-1.8-38 1.1z");
        canvas.DrawPath(path, paint);

        paint.Style = SKPaintStyle.StrokeAndFill;
        paint.Color = StringToColor("#6699FF");
        paint.StrokeWidth = 1;
        // region 14, the rest
        path = SKPath.ParseSvgPathData("M133.5 112.6c-1.1.2-10.5 1.3-21 2.5-21.1 2.5-22.9 3.1-32.2 10.8-6 5-6.2 5.1-12.6 5.1-9.3 0-9.7.3-9.7 6.6v5.4h5.3c20.2 0 41.1 14.8 49.3 35 3.6 8.8 4.6 27.4 1.9 36.6-5.5 19.3-20.6 33.9-40 38.9-3.2.8-7.6 1.5-9.7 1.5H61v29h32v-20.1l4.3.3 4.2.3.3 9.7.3 9.8H186l-.5-2.8c-.3-1.5-3.2-18.7-6.5-38.2-5.9-35.7-13.2-73.8-19.6-103.5-5.3-24.6-10-29.4-25.9-26.9zM144 255v11h-8v-22h8v11z");
        canvas.DrawPath(path, paint);
    };

}

It looks like this in the emulator, I still have many parts to do but I want to know first if I can find out what image part the user clicked on.

In this example I need to know if he clicked on the blue part, or on the black part, or on the white circle inside the black part

So, how can I do this ?


问:
Do I need to define comparer for values inside sortedDictionary?
I have sortedDictionary where key is float and value is some class i wrote. I try to use myDictionary.Max(), but I get an argument exception:

```<code>ArgumentException: At least one object must implement IComparable.
System.Collections.Comparer.Compare (System.Object a, System.Object b) (at <d6232873609549b8a045fa15811a5bd3>:0)
System.Collections.Generic.ObjectComparer`1[T].Compare (T x, T y) (at <d6232873609549b8a045fa15811a5bd3>:0)
System.Linq.Enumerable.Max[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <109e781b32ec464d8737a667de805742>:0)
</code>```

Isn't it that I don't need custom comparer if I use generic as key?

Body:
I have sortedDictionary where key is float and value is some class i wrote. I try to use myDictionary.Max(), but I get an argument exception:

ArgumentException: At least one object must implement IComparable.
System.Collections.Comparer.Compare (System.Object a, System.Object b) (at <d6232873609549b8a045fa15811a5bd3>:0)
System.Collections.Generic.ObjectComparer`1[T].Compare (T x, T y) (at <d6232873609549b8a045fa15811a5bd3>:0)
System.Linq.Enumerable.Max[TSource] (System.Collections.Generic.IEnumerable`1[T] source) (at <109e781b32ec464d8737a667de805742>:0)

Isn't it that I don't need custom comparer if I use generic as key?


问:
Spring Repository variable in PreAuthorize expression
```<code>@PreAuthorize(#workerId == authentication.principal.id")
Set<XY> findByWorker(Worker worker);
</code>```

In PreAuthorize I have to check for workerId. How can I do that? I cannot pass another parameter to the function, because then I get:

At least 2 parameter(s) provided but only 1 parameter(s) present in query

Body:
@PreAuthorize(#workerId == authentication.principal.id")
Set<XY> findByWorker(Worker worker);

In PreAuthorize I have to check for workerId. How can I do that? I cannot pass another parameter to the function, because then I get:

At least 2 parameter(s) provided but only 1 parameter(s) present in query


问:
IDEA Plugin 'Statistic' behave differently in different projects
When I use IDEA, the Statistic plugin works fine in one project, but not in another

IDEA 2022.2.2 with Statistic 4.2.6

one Project

Another aroject

I tried restarting IDEA and downloading Statistic again


问:
How to best make filtering in React without having a full blown backend
Good day, I am learning React and I am now trying to make a little project of my own. The project is nothing fancy, it will be a cooking website. However, I was not able to find a free API for recipes, that suited what I was trying to do, so in the end I managed to obtain a JSON file that contains all the recipes and their properties (so classical array of objects). So I created bare bones back end that basically just ships all of this recipes when I call it (id still like to mimic that I am calling some API). I call the API and save the result into state and that is all fine and well. I want to have some filtering capabilities in the app (some checkboxes and also some search bar). I've been through a lot of stuff that I could find online, but I cannot seem to find some elegant way of doing what I need. The filtering mostly relies on backend filtering. This is cool, but I am just learning the front end and I think trying to implement this on the backend is going to send me down a rabbit hole where I will spend a lot of time on this and the point is to improve my front end skills. I can make the filtering work, but it is frankly all a bit clunky and I am wondering if I am going in the right direction. The reason it does not feel so good to me, is that I am kind of forced to make copies of the state (because I always need to keep the original entire list of recipes). So application would run with entire state (full list) if no filters are engaged and it would render some filtered state if filters are engaged. To show you what I mean

```<code>    const shownRecipes =
        filters.Categories.length===0 && filters.Cousines.length===0
            ? recipes
            : recipes.filter((recipe: IRecipe) => {
                  if (filters.Categories?.length> 0 && filters.Cousines.length>0) {
                      return (
                          filters.Categories.includes(recipe.strCategory) &&
                          filters.Cousines.includes(recipe.strArea)
                      );
                  } else if (filters.Categories.length > 0)
                      {return filters.Categories.includes(recipe.strCategory)}
                  else if (filters.Cousines)
                      {return filters.Cousines.includes(recipe.strArea)};
              });
</code>```

So now for example, if I want to use search bar to search just through shown recipes, it gets complicated and it feels like it should not be so complicated.

Question:
What is the best way to make filtering only on the front end side when you load "entire state" in the app startup without making various state copies? Or for it to work in elegant way, I would need to use something like Redux and useSelector hook?

Tried going through various tutorials and also previous answers on stackoverflow.

Body:
Good day, I am learning React and I am now trying to make a little project of my own. The project is nothing fancy, it will be a cooking website. However, I was not able to find a free API for recipes, that suited what I was trying to do, so in the end I managed to obtain a JSON file that contains all the recipes and their properties (so classical array of objects). So I created bare bones back end that basically just ships all of this recipes when I call it (id still like to mimic that I am calling some API). I call the API and save the result into state and that is all fine and well. I want to have some filtering capabilities in the app (some checkboxes and also some search bar). I've been through a lot of stuff that I could find online, but I cannot seem to find some elegant way of doing what I need. The filtering mostly relies on backend filtering. This is cool, but I am just learning the front end and I think trying to implement this on the backend is going to send me down a rabbit hole where I will spend a lot of time on this and the point is to improve my front end skills. I can make the filtering work, but it is frankly all a bit clunky and I am wondering if I am going in the right direction. The reason it does not feel so good to me, is that I am kind of forced to make copies of the state (because I always need to keep the original entire list of recipes). So application would run with entire state (full list) if no filters are engaged and it would render some filtered state if filters are engaged. To show you what I mean

    const shownRecipes =
        filters.Categories.length===0 && filters.Cousines.length===0
            ? recipes
            : recipes.filter((recipe: IRecipe) => {
                  if (filters.Categories?.length> 0 && filters.Cousines.length>0) {
                      return (
                          filters.Categories.includes(recipe.strCategory) &&
                          filters.Cousines.includes(recipe.strArea)
                      );
                  } else if (filters.Categories.length > 0)
                      {return filters.Categories.includes(recipe.strCategory)}
                  else if (filters.Cousines)
                      {return filters.Cousines.includes(recipe.strArea)};
              });

So now for example, if I want to use search bar to search just through shown recipes, it gets complicated and it feels like it should not be so complicated.

Question:
What is the best way to make filtering only on the front end side when you load "entire state" in the app startup without making various state copies? Or for it to work in elegant way, I would need to use something like Redux and useSelector hook?

Tried going through various tutorials and also previous answers on stackoverflow.


问:
Text Over Figure Frame
I would like to add labels to my sns histogram. I've used plt.text but it's colliding with the edges of the frame.
How can I prevent it from doing that? Or - is there a better way to add labels?

Thanks.

plt.figure(figsize=(7, 4))
hist = sns.histplot(x='y', data=data, hue='y', palette=palette, legend=False)
for p in hist.patches:
    x = p.get_x() + p.get_width() / 2
    if p.get_height() != 0:
        txt = plt.text(x=x, y=p.get_height() + 1000, s=p.get_height(), ha='center')

```

Title: Text Over Figure Frame


问:
Can Ansible connect to netsim devices and configure them
I just want to know if Ansible can access to netsim (ncs-netsim) devices through ssh to configure them or not, cuz it doesn't seem to work for me.

it's always one of these two errors:

```<code>fatal: [localhost]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "command timeout triggered, timeout value is 10 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."}
</code>```

If it's not possible to connect to them through ansible, i would like to get suggested a network simulator that i can install on the same vm as ansible and configure its devices.

Also, i messed a bit in the hosts file changed some params like "ansible_connection" to multiple values,

```<code>[Routers]
localhost ansible_connection=local
192.168.1.103 ansible_port=10030 ansible_user=admin ansible_pass=admin

[Routers:vars]
ansible_network_os=ios
ansible_user=admin
ansible_password=admin
ansible_connection=ssh
</code>```

PS : i can connect to the netsim devices fine with the machine ssh (ssh from the same machine where ansible and netsim are installed) - Sys: CentOs7, Device_Os : iosxr

Thank you guys in advance.

Body:
I just want to know if Ansible can access to netsim (ncs-netsim) devices through ssh to configure them or not, cuz it doesn't seem to work for me.

it's always one of these two errors:

fatal: [localhost]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python"}, "changed": false, "msg": "command timeout triggered, timeout value is 10 secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide."}

If it's not possible to connect to them through ansible, i would like to get suggested a network simulator that i can install on the same vm as ansible and configure its devices.

Also, i messed a bit in the hosts file changed some params like "ansible_connection" to multiple values,

[Routers]
localhost ansible_connection=local
192.168.1.103 ansible_port=10030 ansible_user=admin ansible_pass=admin

[Routers:vars]
ansible_network_os=ios
ansible_user=admin
ansible_password=admin
ansible_connection=ssh

PS : i can connect to the netsim devices fine with the machine ssh (ssh from the same machine where ansible and netsim are installed) - Sys: CentOs7, Device_Os : iosxr

Thank you guys in advance.


问:
Filepond http uploading files IIS server setup problem 405
I'm trying to get a uploading script running, filepond, uploading files through webpage. On IIS10, on co-located server.

When uploading, using POST, I get the following error:
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

in details:

```
Module    DirectoryListingModule
Notification    ExecuteRequestHandler
Handler    StaticFile
Error Code    0x80070001
Requested URL    https://www.example.com:443/upl/files/
Physical Path    W:\www.example.com\www\upl\files\
Logon Method    Anonymous
Logon User    Anonymous
Request Tracing Directory    C:\inetpub\logs\FailedReqLogFiles
```

port 443 is open.

The folder has the following web.config:

```<code>    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <handlers accessPolicy="Read, Write, Execute, Script">
                <remove name="StaticFile" />
                <add name="StaticFile" path="*" verb="GET,HEAD,POST,DEBUG" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Write" />
        </handlers>
    </system.webServer>
</configuration>
</code>```

The folder has the following attributes:
IIS > site > folder > configuration Editor > system.webServer/handlers

FROM SITE/upl/files Web.config  > accesPolicy: Read, Write, Execute, Script

FROM SITE/upl  Web.config   > accesPolicy: Read, Execute, Script (no solution when adding "Write")

FROM ApplicationHost.config  accesPolicy: "Read, Execute, Script"

Athentication:  Anonymous Athentication status enabled, rest disabled

Handler Mappings > Static File

Path: *, State: enabled,

PathType: File or Folder,

Handler: StaticFileModule,DefaultDocumentModule,DirectoryListingModule,

Entry Type: Local

EDIT > Request Restrictions > Mapping : selected Invoke handler only if request is mapped to File or folder, Verbs: GET,HEAD,POST,DEBUG,

Access: Write ( I dont understant why there is no Read/Write option, only read / write / script / execute )

Properties > security >
even when giving full control on that folder to Everyone + IUSR + IIS_IUSRS + Users : still same error.

I did notice in Handler Mappings there is no *.js record.
In Handler Mappings changing the *.asp > edit > "file" to "file and folder" had no effect either.

Jic: I could not find Filepond using a temp folder that I forgot to give acces rights to.

Jic; these are my present FilePond server settings:

```<code>    FilePond.setOptions({
        server: {
            url: 'https://www.example.com/upl/',
            timeout: 3000,
            process: {
                url: 'files/',
                method: 'POST',
                headers: {
                    'x-customheader': 'Hello World',
                },
                withCredentials: false,
                onload: (response) => response.key,
                onerror: (response) => response.data,
                ondata: (formData) => {
                    formData.append('Hello', 'World');
                    return formData;
                },
            },
            revert: './revert',
            restore: './restore/',
            load: './load/',
            fetch: './fetch/',
        }
    });
</code>```

I looked at all the previous answers here and elsewhere for over a day now, but seem to miss a tiny vital thing. Any help is very much appreciated !!

Alex

------------ replying to Samwu:

Thank you for helping.
The above represents most of the solutions I looked at.
I followed the link, found this earlier and here are some findings:

the client makes a Hypertext Transfer Protocol (HTTP) request by using an HTTP method that doesn't comply with the HTTP specifications.
In the ApplicationHost.config file, Make sure that all the handlers use valid HTTP methods.
from my applicationHost.config:

```<code><handlers accessPolicy="Read, Execute, Script">
  <add name="ASPClassic" path="*.asp" verb="GET,HEAD,POST" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="File" />
  <add name="StaticFile" path="*" verb="GET,POST" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Write" />
</handlers>
<sectionGroup name="webdav">
    <section name="globalSettings" overrideModeDefault="Deny" />
    <section name="authoring" overrideModeDefault="Deny" />
    <section name="authoringRules" overrideModeDefault="Deny" />
</sectionGroup>
</code>```

all the modules are stated in applicationHost.config modules

I did notice however something: in the www root there is a web.config that says:

```<code>        <remove name="ASPClassic" />
        <remove name="StaticFile" />
        <add name="StaticFile" path="*" verb="GET,HEAD,POST,DEBUG" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Script" />
        <add name="ASPClassic" path="*.asp" verb="GET,HEAD,POST" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Either" requireAccess="Script" />
    </handlers>
</code>```

in the upl / files / dir there is a webconfig saying:

```<code>    <system.webServer>
    <handlers accessPolicy="Read, Write, Execute, Script">
        <remove name="StaticFile" />
        <add name="StaticFile" path="*" verb="GET,HEAD,POST,DEBUG" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Write" />
    </handlers>
    </system.webServer>
</code>```

notice the " requireAccess="Script" instead of Write

"Send the POST request to a page that's configured to be handled by a handler other than the StaticFile handler. For example, the ASPClassic handler. "

I assume that if my filepond js module is included in a .asp page that this is what I am all ready doing.

WebDav is not installed, it is still stated in the applicationHost.config. Removing that gives an error on restarting the site in IIS.

I hope that clearifies.

Body:
I'm trying to get a uploading script running, filepond, uploading files through webpage. On IIS10, on co-located server.

When uploading, using POST, I get the following error:
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.

in details:

Module    DirectoryListingModule
Notification    ExecuteRequestHandler
Handler    StaticFile
Error Code    0x80070001
Requested URL    https://www.example.com:443/upl/files/
Physical Path    W:\www.example.com\www\upl\files\
Logon Method    Anonymous
Logon User    Anonymous
Request Tracing Directory    C:\inetpub\logs\FailedReqLogFiles

port 443 is open.

The folder has the following web.config:

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <handlers accessPolicy="Read, Write, Execute, Script">
                <remove name="StaticFile" />
                <add name="StaticFile" path="*" verb="GET,HEAD,POST,DEBUG" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Write" />
        </handlers>
    </system.webServer>
</configuration>

The folder has the following attributes:
IIS > site > folder > configuration Editor > system.webServer/handlers

FROM SITE/upl/files Web.config  > accesPolicy: Read, Write, Execute, Script

FROM SITE/upl  Web.config   > accesPolicy: Read, Execute, Script (no solution when adding "Write")

FROM ApplicationHost.config  accesPolicy: "Read, Execute, Script"

Athentication:  Anonymous Athentication status enabled, rest disabled

Handler Mappings > Static File

Path: *, State: enabled,

PathType: File or Folder,

Handler: StaticFileModule,DefaultDocumentModule,DirectoryListingModule,

Entry Type: Local

EDIT > Request Restrictions > Mapping : selected Invoke handler only if request is mapped to File or folder, Verbs: GET,HEAD,POST,DEBUG,

Access: Write ( I dont understant why there is no Read/Write option, only read / write / script / execute )

Properties > security >
even when giving full control on that folder to Everyone + IUSR + IIS_IUSRS + Users : still same error.

I did notice in Handler Mappings there is no *.js record.
In Handler Mappings changing the *.asp > edit > "file" to "file and folder" had no effect either.

Jic: I could not find Filepond using a temp folder that I forgot to give acces rights to.

Jic; these are my present FilePond server settings:

    FilePond.setOptions({
        server: {
            url: 'https://www.example.com/upl/',
            timeout: 3000,
            process: {
                url: 'files/',
                method: 'POST',
                headers: {
                    'x-customheader': 'Hello World',
                },
                withCredentials: false,
                onload: (response) => response.key,
                onerror: (response) => response.data,
                ondata: (formData) => {
                    formData.append('Hello', 'World');
                    return formData;
                },
            },
            revert: './revert',
            restore: './restore/',
            load: './load/',
            fetch: './fetch/',
        }
    });

I looked at all the previous answers here and elsewhere for over a day now, but seem to miss a tiny vital thing. Any help is very much appreciated !!

Alex

------------ replying to Samwu:

Thank you for helping.
The above represents most of the solutions I looked at.
I followed the link, found this earlier and here are some findings:

the client makes a Hypertext Transfer Protocol (HTTP) request by using an HTTP method that doesn't comply with the HTTP specifications.
In the ApplicationHost.config file, Make sure that all the handlers use valid HTTP methods.
from my applicationHost.config:

<handlers accessPolicy="Read, Execute, Script">
  <add name="ASPClassic" path="*.asp" verb="GET,HEAD,POST" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="File" />
  <add name="StaticFile" path="*" verb="GET,POST" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Write" />
</handlers>
<sectionGroup name="webdav">

</sectionGroup>

all the modules are stated in applicationHost.config modules

I did notice however something: in the www root there is a web.config that says:

        <remove name="ASPClassic" />
        <remove name="StaticFile" />
        <add name="StaticFile" path="*" verb="GET,HEAD,POST,DEBUG" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Script" />
        <add name="ASPClassic" path="*.asp" verb="GET,HEAD,POST" modules="IsapiModule" scriptProcessor="%windir%\system32\inetsrv\asp.dll" resourceType="Either" requireAccess="Script" />
    </handlers>

in the upl / files / dir there is a webconfig saying:

    <system.webServer>
    <handlers accessPolicy="Read, Write, Execute, Script">
        <remove name="StaticFile" />
        <add name="StaticFile" path="*" verb="GET,HEAD,POST,DEBUG" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Write" />
    </handlers>
    </system.webServer>

notice the " requireAccess="Script" instead of Write

"Send the POST request to a page that's configured to be handled by a handler other than the StaticFile handler. For example, the ASPClassic handler. "

I assume that if my filepond js module is included in a .asp page that this is what I am all ready doing.

WebDav is not installed, it is still stated in the applicationHost.config. Removing that gives an error on restarting the site in IIS.

I hope that clearifies.


问:
Debug Failure. Unhandled SyntaxKind: ImportClause
I'm trying to build a React app using Webpack inside Docker container.

Running the command webpack --mode production --progress --config webpack.prod.js ends up with the following error:

```<code>ERROR in ./src/app/App.tsx
Module build failed (from ./node_modules/ts-loader/index.js):
Error: Debug Failure. Unhandled SyntaxKind: ImportClause.
    at pipelineEmitWithHintWorker (/app/node_modules/typescript/lib/typescript.js:114180:22)
    at pipelineEmitWithHint (/app/node_modules/typescript/lib/typescript.js:113711:17)
    at pipelineEmitWithSourceMaps (/app/node_modules/typescript/lib/typescript.js:117731:13)
    at pipelineEmitWithComments (/app/node_modules/typescript/lib/typescript.js:117399:13)
    at pipelineEmit (/app/node_modules/typescript/lib/typescript.js:113651:13)
    at emitExpression (/app/node_modules/typescript/lib/typescript.js:113635:13)
    at emitImportDeclaration (/app/node_modules/typescript/lib/typescript.js:115606:13)
    at pipelineEmitWithHintWorker (/app/node_modules/typescript/lib/typescript.js:113912:32)
    at pipelineEmitWithHint (/app/node_modules/typescript/lib/typescript.js:113711:17)
    at pipelineEmitWithSourceMaps (/app/node_modules/typescript/lib/typescript.js:117731:13)
 @ ./src/index.tsx 5:0-36 13:36-39
</code>```

Running the same command to build on host machine (MacOS) works as expected.
The container runs on node:16.13.1-alpine official image.

Body:
I'm trying to build a React app using Webpack inside Docker container.

Running the command webpack --mode production --progress --config webpack.prod.js ends up with the following error:

ERROR in ./src/app/App.tsx
Module build failed (from ./node_modules/ts-loader/index.js):
Error: Debug Failure. Unhandled SyntaxKind: ImportClause.
    at pipelineEmitWithHintWorker (/app/node_modules/typescript/lib/typescript.js:114180:22)
    at pipelineEmitWithHint (/app/node_modules/typescript/lib/typescript.js:113711:17)
    at pipelineEmitWithSourceMaps (/app/node_modules/typescript/lib/typescript.js:117731:13)
    at pipelineEmitWithComments (/app/node_modules/typescript/lib/typescript.js:117399:13)
    at pipelineEmit (/app/node_modules/typescript/lib/typescript.js:113651:13)
    at emitExpression (/app/node_modules/typescript/lib/typescript.js:113635:13)
    at emitImportDeclaration (/app/node_modules/typescript/lib/typescript.js:115606:13)
    at pipelineEmitWithHintWorker (/app/node_modules/typescript/lib/typescript.js:113912:32)
    at pipelineEmitWithHint (/app/node_modules/typescript/lib/typescript.js:113711:17)
    at pipelineEmitWithSourceMaps (/app/node_modules/typescript/lib/typescript.js:117731:13)
 @ ./src/index.tsx 5:0-36 13:36-39

Running the same command to build on host machine (MacOS) works as expected.
The container runs on node:16.13.1-alpine official image.


问:
Search function through different xlsx files with python
I would like to create a search function that reads several xlsx file (which can have different structure and columns) and return just the rows containing a specific value. Is it possible?

so far I used the glob function to get all the files I want to read

```<code>path = 'general path'
all_files = glob.glob(path + "/*.xlsx")
all_files
</code>```

Then I tried using
li = [pd.read_excel(filename, index_col=None, header=0) for
filename in all_files]

to get all the rows together but I don't know how to continue and I don't think this is the best way to search for the info I need.
Note: the specific value can be in any position of the row, in other words, there is no specific column where to look for, I have to check the whole row

Body:
I would like to create a search function that reads several xlsx file (which can have different structure and columns) and return just the rows containing a specific value. Is it possible?

so far I used the glob function to get all the files I want to read

path = 'general path'
all_files = glob.glob(path + "/*.xlsx")
all_files

Then I tried using
li = [pd.read_excel(filename, index_col=None, header=0) for
filename in all_files]

to get all the rows together but I don't know how to continue and I don't think this is the best way to search for the info I need.
Note: the specific value can be in any position of the row, in other words, there is no specific column where to look for, I have to check the whole row


问:
UnhandledPromiseRejectionWarning: MongooseError: Connection 0 was disconnected when calling `startSession
I'm working with MongoDB to save data using transactions.But its giving the below error.

```<code>(node:29448) UnhandledPromiseRejectionWarning: MongooseError: Connection 0 was disconnected when calling `startSession`
    at NativeConnection.startSession (D:\Rubix\rubixkyc\node_modules\mongoose\lib\connection.js:565:31)
    at D:\Rubix\rubixkyc\server\util\route_utils.js:35:38
    at new Promise (<anonymous>)
    at saveKycData (D:\Rubix\rubixkyc\server\util\route_utils.js:32:12)
    at D:\Rubix\rubixkyc\server\controllers\bulk_gst_verification_controller.js:48:19
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
    at processPromiseRejections (internal/process/promises.js:247:11)
    at processTicksAndRejections (internal/process/task_queues.js:96:32)
[RUBIX KYC] 27-12-2022 07:44:37.193 PM [info]: <server\controllers\bulk_gst_verification_controller.js:46> saving GST verification data ....
(node:29448) MongooseError: Connection 0 was disconnected when calling `startSession`
    at NativeConnection.startSession (D:\Rubix\rubixkyc\node_modules\mongoose\lib\connection.js:565:31)
    at D:\Rubix\rubixkyc\server\util\route_utils.js:35:38
    at new Promise (<anonymous>)
    at saveKycData (D:\Rubix\rubixkyc\server\util\route_utils.js:32:12)
    at D:\Rubix\rubixkyc\server\controllers\bulk_gst_verification_controller.js:48:19
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:29448) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    at emitDeprecationWarning (internal/process/promises.js:180:11)
    at processPromiseRejections (internal/process/promises.js:249:13)
    at processTicksAndRejections (internal/process/task_queues.js:96:32)
</code>```

Sharing the image of the code snippet.

Note:- This started happening after i started using worker pool for concurrency.
This save method i

const workerpool = require('workerpool');

Please help me with the issue

Body:
I'm working with MongoDB to save data using transactions.But its giving the below error.

(node:29448) UnhandledPromiseRejectionWarning: MongooseError: Connection 0 was disconnected when calling `startSession`
    at NativeConnection.startSession (D:\Rubix\rubixkyc\node_modules\mongoose\lib\connection.js:565:31)
    at D:\Rubix\rubixkyc\server\util\route_utils.js:35:38
    at new Promise (<anonymous>)
    at saveKycData (D:\Rubix\rubixkyc\server\util\route_utils.js:32:12)
    at D:\Rubix\rubixkyc\server\controllers\bulk_gst_verification_controller.js:48:19
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
    at processPromiseRejections (internal/process/promises.js:247:11)
    at processTicksAndRejections (internal/process/task_queues.js:96:32)
[RUBIX KYC] 27-12-2022 07:44:37.193 PM [info]: <server\controllers\bulk_gst_verification_controller.js:46> saving GST verification data ....
(node:29448) MongooseError: Connection 0 was disconnected when calling `startSession`
    at NativeConnection.startSession (D:\Rubix\rubixkyc\node_modules\mongoose\lib\connection.js:565:31)
    at D:\Rubix\rubixkyc\server\util\route_utils.js:35:38
    at new Promise (<anonymous>)
    at saveKycData (D:\Rubix\rubixkyc\server\util\route_utils.js:32:12)
    at D:\Rubix\rubixkyc\server\controllers\bulk_gst_verification_controller.js:48:19
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(node:29448) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    at emitDeprecationWarning (internal/process/promises.js:180:11)
    at processPromiseRejections (internal/process/promises.js:249:13)
    at processTicksAndRejections (internal/process/task_queues.js:96:32)

Sharing the image of the code snippet.

Note:- This started happening after i started using worker pool for concurrency.
This save method i

const workerpool = require('workerpool');

Please help me with the issue


问:
How to get first cell of selected row in datagrid wpf?
`I am trying to get id of selected user in datagrid,
the itemsource of datagrid is bound to an IEnumerable.

How to get the UserId when we select a row?
ViewModel:

```<code>public partial class UserSalaryViewModel : ObservableObject
    {
        [ObservableProperty]
        private IEnumerable userssSalarires;
        public UserSalaryViewModel()
        {
            using AppDBContext db = new();
            UserssSalarires = db.Users.Join(db.UserSalaries, u => u.UserId, us => us.UserId, (u, us) => new
            {
                u.UserId,
                u.FirstName,
                u.FatherName,
                u.NIC,
                u.Salary,
                us.Pay,
                us.Month,
                us.PayDate,
                us.Finance,
                us.Rest
            }).ToList();
        }
    }
</code>```

XAML:

```<code><DataGrid ItemsSource="{Binding UserssSalarires}" />
</code>```

Just Same to this one in windows form:

```<code>string cell = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();
</code>```

I tried a lot, I have searched a lot,
But, I couldn't find a solution for ananymos type.

Body:
`I am trying to get id of selected user in datagrid,
the itemsource of datagrid is bound to an IEnumerable.

How to get the UserId when we select a row?
ViewModel:

public partial class UserSalaryViewModel : ObservableObject
    {
        [ObservableProperty]
        private IEnumerable userssSalarires;
        public UserSalaryViewModel()
        {
            using AppDBContext db = new();
            UserssSalarires = db.Users.Join(db.UserSalaries, u => u.UserId, us => us.UserId, (u, us) => new
            {
                u.UserId,
                u.FirstName,
                u.FatherName,
                u.NIC,
                u.Salary,
                us.Pay,
                us.Month,
                us.PayDate,
                us.Finance,
                us.Rest
            }).ToList();
        }
    }

XAML:

<DataGrid ItemsSource="{Binding UserssSalarires}" />

Just Same to this one in windows form:

string cell = dataGridView1.SelectedRows[0].Cells[0].Value.ToString();

I tried a lot, I have searched a lot,
But, I couldn't find a solution for ananymos type.


问:
Difference in cv2.imshow window size with and without waitkey commented out
I'm trying to use cv2.imshow to display a specific section of my screen.

However, while running, I noticed the displayed window is smaller than expected. I've stepped through the code with the debugger and noticed that when cv2.waitKey(1) triggers the cv2.imshow window resizes itself and I'm not sure why.

If I comment out cv2.waitKey(1) the display window remains the expected size, the documentation that would suggest cv2.waitKey does anything other than wait for a specified amount of time 0 = infinite, x = time in milliseconds.

Why is waitKey resizing cv2.imshow and how do I fix this?

```<code>import cv2 as cv
import numpy as np
from mss import mss

sct = mss()

def screenshot(top, left, width, height):
    monitor = {'top': top, 'left': left, 'width': width, 'height': height}
    haystack = np.array(sct.grab(monitor))

    cv.imshow("Objects", haystack)
    cv.moveWindow("Objects",5000,50)
    cv.setWindowProperty('Objects', cv.WND_PROP_TOPMOST, 1)
    cv.waitKey(1)
    return haystack

top = 350
left = 1000
width = 500
height = 800

while True:
    screenshot(top, left, width, height)
</code>```

With cv.waitKey(1) commented out:

and with cv.waitKey(1) not commented out:

Contents of haystack saved to file using cv2.imwrite:

Body:
I'm trying to use cv2.imshow to display a specific section of my screen.

However, while running, I noticed the displayed window is smaller than expected. I've stepped through the code with the debugger and noticed that when cv2.waitKey(1) triggers the cv2.imshow window resizes itself and I'm not sure why.

If I comment out cv2.waitKey(1) the display window remains the expected size, the documentation that would suggest cv2.waitKey does anything other than wait for a specified amount of time 0 = infinite, x = time in milliseconds.

Why is waitKey resizing cv2.imshow and how do I fix this?

import cv2 as cv
import numpy as np
from mss import mss

sct = mss()

def screenshot(top, left, width, height):
    monitor = {'top': top, 'left': left, 'width': width, 'height': height}
    haystack = np.array(sct.grab(monitor))

    cv.imshow("Objects", haystack)
    cv.moveWindow("Objects",5000,50)
    cv.setWindowProperty('Objects', cv.WND_PROP_TOPMOST, 1)
    cv.waitKey(1)
    return haystack

top = 350
left = 1000
width = 500
height = 800

while True:
    screenshot(top, left, width, height)

With cv.waitKey(1) commented out:

and with cv.waitKey(1) not commented out:

Contents of haystack saved to file using cv2.imwrite: