问:
Problem when solving homogeneous system of equations related to Toeplitz hermitian matrix with Sympy
For homework they asked me to define a function that creates a Toeplitz hermitian matrix given an input vector which would be the matrix' first row. Once I did it, they then asked me to write a function which given the same vector, it'd find the matrix' eigenvalues and eigenvectors. Instead of using the built-in Sympy functions like diagonalize, eigenvalues and eigenvectors, I wanted to solve it by going through the whole process (Calculating determinant of A-kI, finding its roots, and then finding the solutions to (A-kI)x=0 for each eigenvalue k). I could find the eigenvalues for the matrix made from the vector [1,2-1j,3,4+8j,5-3j], but when it comes to solving the system of eqs., since they are all homogeneous, the solutions should depend on a parametrized variable, but instead it just yields a unique solution, the 0 vector. I don't know why this happens, and it is not due to the matrix being a 5x5, because it happens the same for 2x2 matrices too... Here're the codes I mentioned:

Function that creates the Toeplitz hermitian matrix:

```<code>def compute_herm_toeplitz_matrix(a):
  """"""
  global l
  l = len(a)
  matriu = sp.zeros(l,l)

  for i in range(l):
    for j in range(l-i):
      matriu[j,j+i]=a[i]
      matriu[j+i,j]=a[i].conjugate()
  return sp.Matrix(matriu)
</code>```

Function that finds its eigenvalues and eigenvectors:

```<code>def eigenvalues_eigenvectors_toeplitz(a):
  """"""
  k = sp.Symbol('\lambda')
  x = [sp.symbols('x%d' % i) for i in range(l)]

  matriu_toeplitz = compute_herm_toeplitz_matrix(a)
  Id = sp.eye(l)
  det_toeplitz = (matriu_toeplitz-Id*k).det()
  eigenvalues = sp.solve(det_toeplitz)
  incognites = sp.Matrix(x)
  eigenvectors = []
  for eigenvalue in eigenvalues:
    equacions = (matriu_toeplitz-Id*eigenvalue)*(incognites)
    eigenvectors.append( sp.solve( [*equacions], x ) )

  return sp.diag(*eigenvalues), eigenvectors
</code>```

Body:
For homework they asked me to define a function that creates a Toeplitz hermitian matrix given an input vector which would be the matrix' first row. Once I did it, they then asked me to write a function which given the same vector, it'd find the matrix' eigenvalues and eigenvectors. Instead of using the built-in Sympy functions like diagonalize, eigenvalues and eigenvectors, I wanted to solve it by going through the whole process (Calculating determinant of A-kI, finding its roots, and then finding the solutions to (A-kI)x=0 for each eigenvalue k). I could find the eigenvalues for the matrix made from the vector [1,2-1j,3,4+8j,5-3j], but when it comes to solving the system of eqs., since they are all homogeneous, the solutions should depend on a parametrized variable, but instead it just yields a unique solution, the 0 vector. I don't know why this happens, and it is not due to the matrix being a 5x5, because it happens the same for 2x2 matrices too... Here're the codes I mentioned:

Function that creates the Toeplitz hermitian matrix:

def compute_herm_toeplitz_matrix(a):
  """"""
  global l
  l = len(a)
  matriu = sp.zeros(l,l)

  for i in range(l):
    for j in range(l-i):
      matriu[j,j+i]=a[i]
      matriu[j+i,j]=a[i].conjugate()
  return sp.Matrix(matriu)

Function that finds its eigenvalues and eigenvectors:

def eigenvalues_eigenvectors_toeplitz(a):
  """"""
  k = sp.Symbol('\lambda')
  x = [sp.symbols('x%d' % i) for i in range(l)]

  matriu_toeplitz = compute_herm_toeplitz_matrix(a)
  Id = sp.eye(l)
  det_toeplitz = (matriu_toeplitz-Id*k).det()
  eigenvalues = sp.solve(det_toeplitz)
  incognites = sp.Matrix(x)
  eigenvectors = []
  for eigenvalue in eigenvalues:
    equacions = (matriu_toeplitz-Id*eigenvalue)*(incognites)
    eigenvectors.append( sp.solve( [*equacions], x ) )

  return sp.diag(*eigenvalues), eigenvectors


来源: stackexchange

问:
Display elements one by one from a div on an automatic scroll
I would like to know how I could make an automatic scroll top on a div with a setInterval so that each element in my div "production_list_sequence" is displayed one by one

Here is an image of the dimensions of my div:

Here is a beginning of code that I started

var elem = document.querySelector(".production_list_sequence");

setInterval(()=> {elem.scrollTop = numberScroll+=25;}, 1000)
```

ContentLicense: CC BY-SA 4.0


问:
How to compute ms_ssim with libvmaf in ffmpeg without computing vmaf score?
I would like to compute a ms_ssim score using ffmpeg. I would like to use libvmaf, but libvmaf always computes the vmaf score in parallel

With the base ffmpeg tool, we can compute the ssim score with a command like

```<code>ffmpeg -i distorded.mp4 -i source.mp4 -filter_complex "[0:v]scale2ref=flags=bicubic[distorded];[1:v][distorded]ssim" -f null -
</code>```

And if we want to compute a ms_ssim score, we can use the libvmaf like so

```<code>ffmpeg -i distorded.mp4 -i source.mp4 -filter_complex "[0:v]scale2ref=flags=bicubic[distorded];[1:v][distorded]libvmaf=feature='name=float_ms_ssim'" -f null -`
</code>```

This gives the ms_ssim score, but computes in parallel the vmaf score (which is very slow, in opposition to the ms_ssim which is very fast).

Is there a way to compute the ms_ssim score without calculating the vmaf score?

Body:
I would like to compute a ms_ssim score using ffmpeg. I would like to use libvmaf, but libvmaf always computes the vmaf score in parallel

With the base ffmpeg tool, we can compute the ssim score with a command like

ffmpeg -i distorded.mp4 -i source.mp4 -filter_complex "[0:v]scale2ref=flags=bicubic[distorded];[1:v][distorded]ssim" -f null -

And if we want to compute a ms_ssim score, we can use the libvmaf like so

ffmpeg -i distorded.mp4 -i source.mp4 -filter_complex "[0:v]scale2ref=flags=bicubic[distorded];[1:v][distorded]libvmaf=feature='name=float_ms_ssim'" -f null -`

This gives the ms_ssim score, but computes in parallel the vmaf score (which is very slow, in opposition to the ms_ssim which is very fast).

Is there a way to compute the ms_ssim score without calculating the vmaf score?


问:
Unable to get Selenium Code Working to POST data to Court (PACER) Practice/Training Site
I have been trying to create a script to do the following while I have access to a Training Web-site I am using for electronic case filings.  This requires the following steps:

Going to the following site: https://ecf-train.nvb.uscourts.gov/

clicking the html link at this site on this link: "District of Nevada Train Database - Document Filing System"

This then redirects me to this site, where I POST my login credentials (username/pw/testclientcode/flag=1): (https://train-login.uscourts.gov/csologin/login.jsf?pscCourtId=NVTBK&appurl=https://ecf-train.nvb.uscourts.gov/cgi-bin/login.pl)

the "flag" checks a "redaction" clicks in and then is supposed to land me or give me the main access page to select what I want to e-file in the testing system (this is all approved by the Court for testing, FYI).  I am attaching a screenshot of what it should look like when logged in successfully, so I can then click the "Bankruptcy" header link ECF Header Links, which then brings me to the next target page (https://ecf-train.nvb.uscourts.gov/cgi-bin/DisplayMenu.pl?BankruptcyEvents&id=1227536), where I can select the link for "Case Upload" (see attached screenshot for 'CaseUpload')Case Upload Selection Link

I am new to Python, but I believe I took all the correct steps to download the Selenium Chrome Browser and install Selenium using "pip install selenium".  However, my code is not finding the webdriver "PATH", which is a local desktop directory saved directly on my "C:" drive.

Any help getting this work is HUGELY appreciated.  Here is the code I have been using python with the errors as well:

CODE:

    import requests
    from selenium.webdriver.chrome.service import Service
    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from webdriver_manager.chrome import ChromeDriverManager
    import sys
    import os
    import json
    import time`

# pass in header info which is "Content-Type:application/json"

    url = "https://ecf-train.nvb.uscourts.gov/"

# payload contains the header information for Conent Type and Accept

    payload = {"Content-Type":"application/json", "Accept":"application/json"}
    r = requests.post(url, data=payload)
    pacer_target = requests.get(url)
    pacer_target.text
    print(r.text)

# defining the api-endpoint

    API_ENDPOINT = 'url'
    requests.get(API_ENDPOINT.text)

# data to be sent to api - I removed by userid and pw from this post

    data = {
    "loginId":"XXXXXXXXX",
    "password":"XXXXXXXXX",
    "clientCode":"anycode",
    "redactFlag":"1"}

# sending post request and saving response as response object

    r = requests.post(url = API_ENDPOINT, data = data)
    print(r.text, "STEP 1 - logged into main Traing screen!!")

# Import Selenium Executable File for Chrome from C:\\ drive on my desktop and use the location path

    PATH = 'C:\chromedriver.exe'
    driver = webdriver.Chrome(PATH)

# browser = webdriver.Chrome()

    continue_link = browser.find_element(By.PARTIAL_LINK_TEXT, 'cgi-bin/login')
    continue_link.click()

# get response from the clicked URL and print the response

    response = requests.get(url)
    print(url.text, "this is step 2 - just clicked the main login button!!!!!")

# sending post request and saving response as response object

    r = requests.post(url = API_ENDPOINT, data = data)

# extracting response text

    pastebin_url = r.text
    print("The pastebin URL is:%s"%pastebin_url)
```


问:
Extent Report is broken for Cucumber-TestNG execution
I am running Cucumber 7 with TestNG and trying to setup Extent Reports for the framework. I am able to generate the report but the report is broken when viewed in browser. There is no stylesheet and entire page is just an HTML page. In the console I see that the stylesheets and js scripts have failed to load due to MIME type as text/html.

This is how the report looks like

```<code>Refused to execute script from '<URL>/test-output/spark/spark/jsontree.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
</code>```

Below is the index.html

```<code><!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>GDS REST API QA Automation</title>
<link rel="apple-touch-icon" href="spark/logo.png">
<link rel="shortcut icon" href="spark/logo.png">
<link rel="stylesheet" href="spark/spark-style.css">
<link rel="stylesheet" href="spark/font-awesome.min.css">
<script src="spark/jsontree.js"></script>
<style type="text/css">
*
*
</code>```

I am using cucumber testng adapter.

```<code>        <dependency>
            <groupId>com.aventstack</groupId>
            <artifactId>extentreports-testng-adapter</artifactId>
            <version>1.2.2</version>
        </dependency>
</code>```

I have also tried with cucumber adapter 7 but still the same issue.

Any help on how to fix this issue.

Body:
I am running Cucumber 7 with TestNG and trying to setup Extent Reports for the framework. I am able to generate the report but the report is broken when viewed in browser. There is no stylesheet and entire page is just an HTML page. In the console I see that the stylesheets and js scripts have failed to load due to MIME type as text/html.

This is how the report looks like

Refused to execute script from '<URL>/test-output/spark/spark/jsontree.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Below is the index.html

<!DOCTYPE html>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>GDS REST API QA Automation</title>
<link rel="apple-touch-icon" href="spark/logo.png">
<link rel="shortcut icon" href="spark/logo.png">
<link rel="stylesheet" href="spark/spark-style.css">
<link rel="stylesheet" href="spark/font-awesome.min.css">


问:
I can't extends CdkScrollable in my Angular library
I have an entry point in my Angular library that simply extends the CdkScrollable class from @angular/cdk/scrolling to add custom selectors.

Here is my scrollable.ts file that does the extends:

```<code>import { Directive, ElementRef, NgZone, Optional } from '@angular/core';

import { Directionality } from '@angular/cdk/bidi';
import { CdkScrollable, ScrollDispatcher } from '@angular/cdk/scrolling';

@Directive({
  selector: '[fui-scrollable], [fuiScrollable]'
})
export class FuiScrollableDirective extends CdkScrollable {
  constructor(
    protected elementRef: ElementRef<HTMLElement>,
    protected scrollDispatcher: ScrollDispatcher,
    protected ngZone: NgZone,
    @Optional() protected dir?: Directionality
  ) {
    super(elementRef, scrollDispatcher, ngZone, dir);
  }
}
</code>```

Here is my scrollable.module.ts file:

```<code>import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { ScrollingModule } from '@angular/cdk/scrolling';

import { FuiScrollableDirective } from './scrollable';

@NgModule({
  imports: [CommonModule, ScrollingModule],
  declarations: [FuiScrollableDirective],
  exports: [ScrollingModule, FuiScrollableDirective]
})
export class FuiScrollingModule {}
</code>```

The compilation goes well when I compile my library.

Here is the tsconfig.json for my lib:

```<code>{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {
    "rootDir": ".",
    "outDir": "./out-tsc/lib",
    "target": "ES2015",
    "types": [],
    "lib": ["dom", "ES2018"],
    "module": "commonjs",
    "moduleResolution": "node",
    "importHelpers": true,
    "declaration": true,
    "inlineSources": true,
    "skipLibCheck": true,
    "stripInternal": false,
    "experimentalDecorators": true,
    "noUnusedParameters": false,
    "noUnusedLocals": false,
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "@ferui/icons": ["node_modules/@ferui/icons/dist"],
      "@ferui/icons/shapes/*": ["node_modules/@ferui/icons/dist/shapes/*"],
      "@ferui/design": ["node_modules/@ferui/design/dist"],
      "@ferui/design/*": ["node_modules/@ferui/design/dist/*"]
    },
    "isolatedModules": false,
    "strictNullChecks": false, // want to set it to true but can't yet
    "noImplicitReturns": false, // want to set it to true but can't yet
    "strictFunctionTypes": false, // want to set it to true but can't yet
    "noFallthroughCasesInSwitch": false, // want to set it to true but can't yet
    "noImplicitAny": false, // want to set it to true but can't yet
    "noImplicitThis": false, // want to set it to true but can't yet
    "strictBindCallApply": false // want to set it to true but can't yet
  },
  "angularCompilerOptions": {
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "enableResourceInlining": true,
    "strictInjectionParameters": true
  },
  "exclude": ["dist/**/*", "tests.ts", "tests.helpers.ts", "**/*.spec.ts"]
}

</code>```

Once my lib is built, I load its dist folder to my consumer app (within the same monorepo) and the compilation goes well as well, but when I try to access the app through browser, I have an error in Chrome dev console:

```<code>ERROR Error: Uncaught (in promise): TypeError: Class constructor CdkScrollable cannot be invoked without 'new'
TypeError: Class constructor CdkScrollable cannot be invoked without 'new'
    at new FuiScrollableDirective (ferui-components-scrolling.umd.js:398:33)
    at NodeInjectorFactory.FuiScrollableDirective_Factory [as factory] (ferui-components-scrolling.umd.js:408:88)
...
</code>```

Both my lib and consumer app have "target": "ES2015", "module": "commonjs", "moduleResolution": "node" and @angular/cdk is a peerDependency of my lib and added as a dependency in my consumer app so it is loaded.

I've noticed that the UMD module is used, but I guess it is normal.

Any idea what's going on?

I've red that it might be because of module set to ES5 in library but to something else on consumer app, but it is not my case.

Body:
I have an entry point in my Angular library that simply extends the CdkScrollable class from @angular/cdk/scrolling to add custom selectors.

Here is my scrollable.ts file that does the extends:

import { Directive, ElementRef, NgZone, Optional } from '@angular/core';

import { Directionality } from '@angular/cdk/bidi';
import { CdkScrollable, ScrollDispatcher } from '@angular/cdk/scrolling';

@Directive({
  selector: '[fui-scrollable], [fuiScrollable]'
})
export class FuiScrollableDirective extends CdkScrollable {
  constructor(
    protected elementRef: ElementRef<HTMLElement>,
    protected scrollDispatcher: ScrollDispatcher,
    protected ngZone: NgZone,
    @Optional() protected dir?: Directionality
  ) {
    super(elementRef, scrollDispatcher, ngZone, dir);
  }
}

Here is my scrollable.module.ts file:

import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { ScrollingModule } from '@angular/cdk/scrolling';

import { FuiScrollableDirective } from './scrollable';

@NgModule({
  imports: [CommonModule, ScrollingModule],
  declarations: [FuiScrollableDirective],
  exports: [ScrollingModule, FuiScrollableDirective]
})
export class FuiScrollingModule {}

The compilation goes well when I compile my library.

Here is the tsconfig.json for my lib:

{
  "extends": "../../tsconfig.base.json",
  "compilerOptions": {
    "rootDir": ".",
    "outDir": "./out-tsc/lib",
    "target": "ES2015",
    "types": [],
    "lib": ["dom", "ES2018"],
    "module": "commonjs",
    "moduleResolution": "node",
    "importHelpers": true,
    "declaration": true,
    "inlineSources": true,
    "skipLibCheck": true,
    "stripInternal": false,
    "experimentalDecorators": true,
    "noUnusedParameters": false,
    "noUnusedLocals": false,
    "sourceMap": true,
    "baseUrl": ".",
    "paths": {
      "@ferui/icons": ["node_modules/@ferui/icons/dist"],
      "@ferui/icons/shapes/*": ["node_modules/@ferui/icons/dist/shapes/*"],
      "@ferui/design": ["node_modules/@ferui/design/dist"],
      "@ferui/design/*": ["node_modules/@ferui/design/dist/*"]
    },
    "isolatedModules": false,
    "strictNullChecks": false, // want to set it to true but can't yet
    "noImplicitReturns": false, // want to set it to true but can't yet
    "strictFunctionTypes": false, // want to set it to true but can't yet
    "noFallthroughCasesInSwitch": false, // want to set it to true but can't yet
    "noImplicitAny": false, // want to set it to true but can't yet
    "noImplicitThis": false, // want to set it to true but can't yet
    "strictBindCallApply": false // want to set it to true but can't yet
  },
  "angularCompilerOptions": {
    "skipTemplateCodegen": true,
    "strictMetadataEmit": true,
    "enableResourceInlining": true,
    "strictInjectionParameters": true
  },
  "exclude": ["dist/**/*", "tests.ts", "tests.helpers.ts", "**/*.spec.ts"]
}

Once my lib is built, I load its dist folder to my consumer app (within the same monorepo) and the compilation goes well as well, but when I try to access the app through browser, I have an error in Chrome dev console:

ERROR Error: Uncaught (in promise): TypeError: Class constructor CdkScrollable cannot be invoked without 'new'
TypeError: Class constructor CdkScrollable cannot be invoked without 'new'
    at new FuiScrollableDirective (ferui-components-scrolling.umd.js:398:33)
    at NodeInjectorFactory.FuiScrollableDirective_Factory [as factory] (ferui-components-scrolling.umd.js:408:88)
...

Both my lib and consumer app have "target": "ES2015", "module": "commonjs", "moduleResolution": "node" and @angular/cdk is a peerDependency of my lib and added as a dependency in my consumer app so it is loaded.

I've noticed that the UMD module is used, but I guess it is normal.

Any idea what's going on?

I've red that it might be because of module set to ES5 in library but to something else on consumer app, but it is not my case.


问:
Glue crawler creating tables from file insides folders
I'm trying to crawler an S3 bucket with multiple folders, each one containing some csv files extracted by a Glue Job from Amazon RDS.

In the moment, this is basically the schema for S3:

s3://bucket/folder_table_x/files
s3://bucket/folder_table_y/files

The goal is to crawler this buckets and folders to create a new database and then query via Amazon Athena.

But i'm getting the following tables (i mean, with the name of the file, not the folder):

run-unnamed-1-part-r-00000

Most of the tables are being created correctly, but I'm not being able to deal with some.

I've already set the table level as 2 (is that right?) and also set the option that says "Create a single schema for each S3 path"

Theses files that are being created as tables it contains only the header, but none info.

Anyone can help?


问:
How to indicate to Visual studio where third party dll source code is?
I am writing a C++/CLI for a C library. I have the source code of the library. When I launch a debug session, I can't step into the C dll, VS says that the source code is not available. So how do I tell VS where it is?
Thank you... I've tried pointing Tools -> Options -> Debugging -> Symbols to add the folder where the pdb is but it changed nothing.
Regards

SOLVED:
Turns out I needed to copy the dll and .pdb files to the Debug folder of my C# project calling the C++/CLI dll.

ContentLicense: CC BY-SA 3.0


问:
TypeError when i click in checkbox
i have one issue to solve but i'm don't have idea why this error appears to me

my code is below

```<code>const [selectedUsersList, setSelectedUsersList] = useState<number[]>([]);

  const handleSelectedUserCheckbox = (value: number) => {
    if (!selectedUsersList?.includes(value)) {
      setSelectedUsersList([...selectedUsersList, value]);
    } else {
      setSelectedUsersList(selectedUsersList?.filter((id) => id !== value));
    }
  };
</code>```

and this is my checkbox

```<code>loadingUsers || userList?.getUsersForPush.length ? (
  (textToSearch?.length >= 3 && usersListSearch ? usersListSearch : userList
    )?.getUsersForPush?.map((user) => (
     <Field
     as={Checkbox}
     key={user.id}
     name="userIds"
     value={user.id}
     label={user.name}
     title={user.name}
     id={`userIds-${user.id}`}
     className={styles.fieldsCheckbox}
     checked={selectedUsersList?.includes(
     Number(user.id)
    )}
      onChange={() =>handleSelectedUserCheckbox(Number(user.id))}/>
 ))
</code>```

Title: TypeError when i click in checkbox

Body:
i have one issue to solve but i'm don't have idea why this error appears to me

my code is below

const [selectedUsersList, setSelectedUsersList] = useState<number[]>([]);

  const handleSelectedUserCheckbox = (value: number) => {
    if (!selectedUsersList?.includes(value)) {
      setSelectedUsersList([...selectedUsersList, value]);
    } else {
      setSelectedUsersList(selectedUsersList?.filter((id) => id !== value));
    }
  };

and this is my checkbox

loadingUsers || userList?.getUsersForPush.length ? (
  (textToSearch?.length >= 3 && usersListSearch ? usersListSearch : userList
    )?.getUsersForPush?.map((user) => (
     <Field
     as={Checkbox}
     key={user.id}
     name="userIds"
     value={user.id}
     label={user.name}
     title={user.name}
     id={`userIds-${user.id}`}
     className={styles.fieldsCheckbox}
     checked={selectedUsersList?.includes(
     Number(user.id)
    )}
      onChange={() =>handleSelectedUserCheckbox(Number(user.id))}/>
 ))


问:
useEffect blocking render in React18
I was trying to demonstrate the difference between useEffect and useLayoutEffect, and I stumble upon something strange. Since React 18, effects seem to be blocking render when taking a long time, while in React 17 render was done (and screen painted) before the effect was triggered.

For example, if you have this in a component :

function MyComponent() {
  React.useEffect(() => {
    sleep(1000)
    console.log('effect done!')
  })

  return ...
}

// Sleep is a small util like this:
function sleep(time = 0) {
  const wakeUpTime = Date.now() + time;
  while (Date.now() < wakeUpTime) {}
}
```

In React 17, it would render the component and only then it would get "stuck" in this long useEffect. In React 18, it's actually blocking the render. Why ? Aren't effects supposed to be triggered asynchronously after render ?

I don't see the point of useLayoutEffect if the screen doesn't get painted before useEffect runs

I made two sandboxes to show the difference :

With React 17 (working as expected) => https://codesandbox.io/s/useeffect-with-react-17-l8p0vd?file=/src/App.tsx:0-1249

With React 18 (blocking render) => https://codesandbox.io/s/useeffect-with-react-18-o2qhtb?file=/src/App.tsx:87-192

Title: useEffect blocking render in React18

Body:
I was trying to demonstrate the difference between useEffect and useLayoutEffect, and I stumble upon something strange. Since React 18, effects seem to be blocking render when taking a long time, while in React 17 render was done (and screen painted) before the effect was triggered.

For example, if you have this in a component :

function MyComponent() {
  React.useEffect(() => {
    sleep(1000)
    console.log('effect done!')
  })

  return ...
}

// Sleep is a small util like this:
function sleep(time = 0) {
  const wakeUpTime = Date.now() + time;
  while (Date.now() < wakeUpTime) {}
}

In React 17, it would render the component and only then it would get "stuck" in this long useEffect. In React 18, it's actually blocking the render. Why ? Aren't effects supposed to be triggered asynchronously after render ?

I don't see the point of useLayoutEffect if the screen doesn't get painted before useEffect runs

I made two sandboxes to show the difference :

With React 17 (working as expected) => https://codesandbox.io/s/useeffect-with-react-17-l8p0vd?file=/src/App.tsx:0-1249

With React 18 (blocking render) => https://codesandbox.io/s/useeffect-with-react-18-o2qhtb?file=/src/App.tsx:87-192


问:
toolchain build python3 kivy error with rand_unix.c compilation
I have cloned kivy-ios:
git clone https://github.com/kivy/kivy-ios.git

cd kivy-ios/

python3 -m venv venv

. venv/bin/activate

pip install -e .

pip install cython

And when try toolchain build python3 kivy, I get this error:

[DEBUG   ] In file included from crypto/rand/rand_unix.c:38:

[DEBUG   ] /usr/include/CommonCrypto/CommonRandom.h:35:9: error: unknown type name

[DEBUG   ]       'CCCryptorStatus'

[DEBUG   ] typedef CCCryptorStatus CCRNGStatus;

[DEBUG   ]         ^

[DEBUG   ] crypto/rand/rand_unix.c:385:47: error: use of undeclared identifier 'kCCSuccess'

[DEBUG   ]     if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess)

[DEBUG   ]                                               ^

[DEBUG   ] 2 errors generated.

This file was downloading with

[DEBUG   ] x openssl-1.1.1l/crypto/rand/rand_unix.c

is it a problem with openssl-1.1.1l ???

I have tried to build kivy for IOS, but i could not success.


问:
How to create a list of objects from 2 tables in KSQLDB
I currently have 2 tables in KSQLDB:

CREATE STREAM "source-mysql-person" (
  "_uid" STRING,
  "_created" TIMESTAMP,
  "_updated" TIMESTAMP,
  "_disabled" TIMESTAMP,
  "name" STRING,
  "age" INT
) WITH (
  KAFKA_TOPIC = 'source-mysql-person',
  VALUE_FORMAT = 'AVRO'
);
/*
 Field     | Type
--------------------------------------------
 _uid      | VARCHAR(STRING)  (primary key)
 _created  | TIMESTAMP
 _updated  | TIMESTAMP
 _disabled | TIMESTAMP
 name      | VARCHAR(STRING)
 age       | INTEGER
--------------------------------------------
*/
```
<pre class="lang-sql prettyprint-override"><code>CREATE TABLE "table-mysql-enriched-person_contact" WITH (
  KAFKA_TOPIC = 'table-mysql-enriched-person_contact',
  VALUE_FORMAT = 'AVRO'
) AS SELECT
  "pc"."_uid" AS "_uid",
  "pc"."_created" AS "_created",
  "pc"."_updated" AS "_updated",
  "pc"."_disabled" AS "_disabled",
  "pc"."is_default" AS "is_default",
  "pc"."value" AS "value",
  "pc"."person_uid" AS "person_uid",
  AS_MAP(
    ARRAY['_uid', 'value'],
    ARRAY["ct"."_uid", "ct"."value"]
  ) AS "contact_type"
FROM "table-mysql-person_contact" "pc"
INNER JOIN "table-mysql-contact_type" "ct" ON
  "ct"."_uid" = "pc"."contact_type_uid"
EMIT CHANGES;
/*
 Field        | Type
-----------------------------------------------
 _uid         | VARCHAR(STRING)  (primary key)
 _created     | TIMESTAMP
 _updated     | TIMESTAMP
 _disabled    | TIMESTAMP
 is_default   | INTEGER
 value        | VARCHAR(STRING)
 person_uid   | VARCHAR(STRING)
 contact_type | MAP<STRING, VARCHAR(STRING)>
-----------------------------------------------
*/
</code>```

I want to create a table table-mysql-enriched-person that has the data of table-mysql-person and for each "person", a list of "person_contact" related to that "person". For this I am trying to use the following querie:

CREATE TABLE "table-mysql-enriched-person" WITH (
  KAFKA_TOPIC = 'table-mysql-enriched-person',
  VALUE_FORMAT = 'AVRO'
) AS SELECT
  "p"."_uid" AS "_uid",
  "p"."_created" AS "_created",
  "p"."_updated" AS "_updated",
  "p"."_disabled" AS "_disabled",
  "p"."name" AS "name",
  "p"."age" AS "age",
  AS_MAP(
    ARRAY[
      '_uid',
      '_created',
      '_updated',
      '_disabled',
      'is_default',
      'value',
      'contact_type'
    ],
    ARRAY[
      "e"."_uid",
      "e"."_created",
      "e"."_updated",
      "e"."_disabled",
      "e"."is_default",
      "e"."value",
      "e"."contact_type"
    ]
  ) AS "list_person_contact"
FROM "table-mysql-enriched-person_contact" "e"
INNER JOIN "table-mysql-person" "p" ON
  "p"."_uid" = "e"."person_uid"
GROUP BY
  "p"."_uid",
  "p"."_created",
  "p"."_updated",
  "p"."_disabled",
  "p"."name",
  "p"."age"
EMIT CHANGES;
```
<p>Theoretically the query is correct because I have primary keys in the 2 queries and, thinking that the table "person_contact" is a child table of "person" and that the field <code>person._uid</code> is represented as <code>person_contact.person_uid</code>, I should manage to create the table but ksqldb is returning me the following message:</p>
```Could not determine output schema for query due to error: GROUP BY requires aggregate functions
in either the SELECT or HAVING clause.
```

Body:
I currently have 2 tables in KSQLDB:

CREATE STREAM "source-mysql-person" (
  "_uid" STRING,
  "_created" TIMESTAMP,
  "_updated" TIMESTAMP,
  "_disabled" TIMESTAMP,
  "name" STRING,
  "age" INT
) WITH (
  KAFKA_TOPIC = 'source-mysql-person',
  VALUE_FORMAT = 'AVRO'
);
/*
 Field     | Type
--------------------------------------------
 _uid      | VARCHAR(STRING)  (primary key)
 _created  | TIMESTAMP
 _updated  | TIMESTAMP
 _disabled | TIMESTAMP
 name      | VARCHAR(STRING)
 age       | INTEGER
--------------------------------------------
*/

CREATE TABLE "table-mysql-enriched-person_contact" WITH (
  KAFKA_TOPIC = 'table-mysql-enriched-person_contact',
  VALUE_FORMAT = 'AVRO'
) AS SELECT
  "pc"."_uid" AS "_uid",
  "pc"."_created" AS "_created",
  "pc"."_updated" AS "_updated",
  "pc"."_disabled" AS "_disabled",
  "pc"."is_default" AS "is_default",
  "pc"."value" AS "value",
  "pc"."person_uid" AS "person_uid",
  AS_MAP(
    ARRAY['_uid', 'value'],
    ARRAY["ct"."_uid", "ct"."value"]
  ) AS "contact_type"
FROM "table-mysql-person_contact" "pc"
INNER JOIN "table-mysql-contact_type" "ct" ON
  "ct"."_uid" = "pc"."contact_type_uid"
EMIT CHANGES;
/*
 Field        | Type
-----------------------------------------------
 _uid         | VARCHAR(STRING)  (primary key)
 _created     | TIMESTAMP
 _updated     | TIMESTAMP
 _disabled    | TIMESTAMP
 is_default   | INTEGER
 value        | VARCHAR(STRING)
 person_uid   | VARCHAR(STRING)
 contact_type | MAP<STRING, VARCHAR(STRING)>
-----------------------------------------------
*/

I want to create a table table-mysql-enriched-person that has the data of table-mysql-person and for each "person", a list of "person_contact" related to that "person". For this I am trying to use the following querie:

CREATE TABLE "table-mysql-enriched-person" WITH (
  KAFKA_TOPIC = 'table-mysql-enriched-person',
  VALUE_FORMAT = 'AVRO'
) AS SELECT
  "p"."_uid" AS "_uid",
  "p"."_created" AS "_created",
  "p"."_updated" AS "_updated",
  "p"."_disabled" AS "_disabled",
  "p"."name" AS "name",
  "p"."age" AS "age",
  AS_MAP(
    ARRAY[
      '_uid',
      '_created',
      '_updated',
      '_disabled',
      'is_default',
      'value',
      'contact_type'
    ],
    ARRAY[
      "e"."_uid",
      "e"."_created",
      "e"."_updated",
      "e"."_disabled",
      "e"."is_default",
      "e"."value",
      "e"."contact_type"
    ]
  ) AS "list_person_contact"
FROM "table-mysql-enriched-person_contact" "e"
INNER JOIN "table-mysql-person" "p" ON
  "p"."_uid" = "e"."person_uid"
GROUP BY
  "p"."_uid",
  "p"."_created",
  "p"."_updated",
  "p"."_disabled",
  "p"."name",
  "p"."age"
EMIT CHANGES;

Theoretically the query is correct because I have primary keys in the 2 queries and, thinking that the table "person_contact" is a child table of "person" and that the field person._uid is represented as person_contact.person_uid, I should manage to create the table but ksqldb is returning me the following message:

Could not determine output schema for query due to error: GROUP BY requires aggregate functions
in either the SELECT or HAVING clause.


问:
Profile a linux app to get a tree? (Find which functions have slow childrens)
I'm profiling my app on x86_64 linux, building with gcc (-O2) and using perf record. My app runs in 1.5 seconds, Using perf record -F max ./myapp myargs I've been getting false numbers. I want perf to give me a tree so I can figure out where to start looking. Using pref record -F max --call-graph fp ./myapp myargs only few functions give me an inner and look like a tree

I was wondering what build options I need to get a proper tree? Do I need to remove static from my functions (I use that when it doesn't need to be visible across files). I happen to know one specific function is > 10% of my runtime (I checked via clock_gettime and rdtscp only adding when the CPU matches the start cpu). The complex function is reported as 4% of my CPU time (which is lower than reality) and it's parent function (the only function that can call it) says children is .2 and self is .19 which isn't true

The function I timed was obvious but I wouldn't know what other functions may be slow. Is 1.5 too short of a run? Do I need to manually insert timing code when runs are that short?


问:
Can the PyCharm Database plug-in be used to develop Python code?
This is a question about usage of the database plug-in.

I'm a newcomer to PyCharm. I've set up a database connection through the Databases plug-in and can execute queries against the database in a console window. I see the value of developing SQL under the same pane of glass.

Is there a way to use the Databases plug-in to help me in the python scripts in PyCharm, ie by automatically generating a connection string or suggesting a better method among SQLAlchemy or pyodbc? Or is the plug-in not a replacement for building the connection strings and instancing the engines in the code?


问:
Custom wordpress plugin : some JS functions are ignored (priority problem)
I created a custom plugin in which I have a .js file with some jQuery functions.
These functions all work fine from the admin.

Now I need to add a form (ACF) on the frontend, so I created a single post template for my post type, added the form. My jQuery scripts weren't taken into account, so I added on top of the php template :

```<code><script src="/wp-includes/js/jquery/jquery.min.js?ver=3.6.1" id="jquery-core-js"></script>
</code>```

Now most of my jQuery functions work, except for those involving a date picker. After narrowing down the problem i understood that it was a simple priority problem. If I enqueue the script in my theme's function.php, then all works just fine ; I could do that for now, but it defeats the purpose of having all the files in a plugin (if I change theme, I'd have to think of re-enqueuing the script in my functions file.

How can I fix this issue ?

Body:
I created a custom plugin in which I have a .js file with some jQuery functions.
These functions all work fine from the admin.

Now I need to add a form (ACF) on the frontend, so I created a single post template for my post type, added the form. My jQuery scripts weren't taken into account, so I added on top of the php template :

Now most of my jQuery functions work, except for those involving a date picker. After narrowing down the problem i understood that it was a simple priority problem. If I enqueue the script in my theme's function.php, then all works just fine ; I could do that for now, but it defeats the purpose of having all the files in a plugin (if I change theme, I'd have to think of re-enqueuing the script in my functions file.

How can I fix this issue ?


问:
Sending binary data trough websockets in python
I have a service that accepts binary data (audio) via a websocket, using the format:

```<code>SEND_AUDIO\r\n
\r\n
<binary data here>
</code>```

I've tried just opening the file and adding to the message

```<code>msg = b"SEND AUDIO\r\n\r\n" + open("file.wav","rb").read()
</code>```

but I get an error, the binary data is not recognized.

What's the correct way to send binary data through websockets in python?
The library that I'm using is websockets (https://websockets.readthedocs.io/en/stable/)

Body:
I have a service that accepts binary data (audio) via a websocket, using the format:

SEND_AUDIO\r\n
\r\n
<binary data here>

I've tried just opening the file and adding to the message

msg = b"SEND AUDIO\r\n\r\n" + open("file.wav","rb").read()

but I get an error, the binary data is not recognized.

What's the correct way to send binary data through websockets in python?
The library that I'm using is websockets (https://websockets.readthedocs.io/en/stable/)


问:
How to convert gray image into colormap
enter image description here

i have a color feet image, it transform to grayscale, and then to colormap (jet)
i did it in emgucv, but the color doesnt look so diferent, i need that the result image like the second (only 4-6 color, red, orange*, yellow, green, blue, purple*)
it is possible?

i already try on emgucv and read something gdi+, but i dont understand, i just begin to program

i try this but the color are the same, just more pixel, no gradient

```<code>

int divideWith = 48;
byte[] table = new byte[256];
for (int i = 0; i < 256; i++)
                {
                    table[i] = (byte)(divideWith * (i / divideWith));
                }
                Mat mat = ConvertBitmapToMat(rgb);
                //_Stopwatch.Reset();
                int rows = mat.Rows;
                int cols = mat.Cols;
                byte[,,] data = mat.ToImage<Bgr, byte>().Data;
                byte[,,] resData = new byte[rows, cols, 3];

                Parallel.For(0, rows, i =>
                {
                    for (int j = 0; j < cols; j++)
                    {
                        resData[i, j, 0] = table[data[i, j, 0]];
                        resData[i, j, 1] = table[data[i, j, 1]];
                        resData[i, j, 2] = table[data[i, j, 2]];
                    }
                });
                Image<Bgr, byte> resImg = new Image<Bgr, byte>(resData);
                Bitmap im = resImg.ToBitmap();
                pictureBox2.Image = im;
</code>```

Title: How to convert gray image into colormap

Body:
enter image description here

i have a color feet image, it transform to grayscale, and then to colormap (jet)
i did it in emgucv, but the color doesnt look so diferent, i need that the result image like the second (only 4-6 color, red, orange*, yellow, green, blue, purple*)
it is possible?

i already try on emgucv and read something gdi+, but i dont understand, i just begin to program

i try this but the color are the same, just more pixel, no gradient

int divideWith = 48;
byte[] table = new byte[256];
for (int i = 0; i < 256; i++)
                {
                    table[i] = (byte)(divideWith * (i / divideWith));
                }
                Mat mat = ConvertBitmapToMat(rgb);
                //_Stopwatch.Reset();
                int rows = mat.Rows;
                int cols = mat.Cols;
                byte[,,] data = mat.ToImage<Bgr, byte>().Data;
                byte[,,] resData = new byte[rows, cols, 3];

                Parallel.For(0, rows, i =>
                {
                    for (int j = 0; j < cols; j++)
                    {
                        resData[i, j, 0] = table[data[i, j, 0]];
                        resData[i, j, 1] = table[data[i, j, 1]];
                        resData[i, j, 2] = table[data[i, j, 2]];
                    }
                });
                Image<Bgr, byte> resImg = new Image<Bgr, byte>(resData);
                Bitmap im = resImg.ToBitmap();
                pictureBox2.Image = im;


问:
Multiple click events get fired for dynamically created controls over time
I have a following situation in my Visual Studio 2022 Windows Forms applications.

I am creating panels after each button click in the FlowLayoutPanel and in each of those panels I am adding controls like text boxes and buttons.So the panels will be increasing after each button click.

My objective is to create a panel after a button click and each time a button is clicked a panel is created having multiple controls in it. Then I will catch click events for each of the buttons in the panels, so that , for example , If a specific button gets clicked in a specific panel , I should know which button was clicked and then I will get the values of other controls like text boxes from that panel and display them. In the meantime I also want to open another form from the button click that will ask for the editing of the labels in the specific panel and after entering the values will update labels in  the specific panel.

Following is my Effort

So I have been able to create controls after a button click inside each of the panels  and each time a button is clicked a new form appears that ask values and then a panel with those values of labels and buttons gets created. I also tried to catch the click events of the buttons inside each of the panel in a FlowLayoutPanel.

```<code>namespace WinFormsApp1

{
    public partial class Form1 : Form
    {

        public int counter = 0;
        public string text1Data = "";
        public string text2Data = "";

        public Panel singlePanel;
        public FlowLayoutPanel mainPanel;
        public Form1()
        {
            InitializeComponent();
        }

        public void createPanel(string label1Data,string label2Data)
        {
            counter += 1;
            string panelName = "panel" + counter;

            Label lblText1 = new Label();
            lblText1.Text =label1Data;
            lblText1.ForeColor = Color.Black;
            lblText1.Name = panelName+"_label1";
            lblText1.Text = label1Data;
            lblText1.Location = new System.Drawing.Point(100, 5);
            lblText1.Size = new System.Drawing.Size(120, 100);

            Label lblText2 = new Label();
            lblText2.Text = label2Data;
            lblText2.ForeColor = Color.Black;
            lblText2.Name = panelName+"_label2";
            lblText2.Text = label2Data;
            lblText2.Location = new System.Drawing.Point(220, 5);
            lblText2.Size = new System.Drawing.Size(120, 100);

            Button btnSelect = new Button();
            btnSelect.Name = panelName+"_buttonSelect";
            btnSelect.Text = "SELECT_Panel_" + counter;
            btnSelect.Location = new System.Drawing.Point(350, 5);
            btnSelect.Size = new System.Drawing.Size(150, 30);

            Button btnUpdate = new Button();
            btnUpdate.Name = panelName+"_buttonUpdate";
            btnUpdate.Text = "UPDATE_Panel_" + counter;
            btnUpdate.Location = new System.Drawing.Point(500, 5);
            btnUpdate.Size = new System.Drawing.Size(150, 30);

            Button btnDelete = new Button();
            btnDelete.Name = panelName+"_buttonDelete";
            btnDelete.Text = "DELETE_Panel_" + counter;
            btnDelete.Location = new System.Drawing.Point(650, 5);
            btnDelete.Size = new System.Drawing.Size(150, 30);

            Panel panelSample = new Panel();
            panelSample.Name = panelName;
            //panelSample.BackColor = Color.Black;
            panelSample.Size = new System.Drawing.Size(flowLayoutPanel1.Width - 10, 60);

            panelSample.Controls.Add(lblText1);
            panelSample.Controls.Add(lblText2);

            panelSample.Controls.Add(btnSelect);
            panelSample.Controls.Add(btnUpdate);
            panelSample.Controls.Add(btnDelete);

            flowLayoutPanel1.Controls.Add(panelSample);
            mainPanel = flowLayoutPanel1;

            foreach (var panel in flowLayoutPanel1.Controls.OfType<Panel>())
            {

                string name = panel.Name;

                foreach (var button in panel.Controls.OfType<Button>())
                {

                    if (button.Name == name+"_buttonSelect")
                    {
                        button.Click += Button_Click ;
                    }
                    if (button.Name==name+"_buttonUpdate")
                    {
                        button.Click += Button_Click1;
                    }
                    if (button.Name==name + "_buttonDelete")
                    {
                        button.Click += Button_Click2;
                        singlePanel = panel;
                    }
                }

                foreach (var label in panel.Controls.OfType<Label>())
                {

                    if (label.Name==name + "_label1")
                    {
                        text1Data = label.Text;
                    }
                    if (label.Name==name + "_label2")
                    {
                        text2Data=label.Text;
                    }

                }

            }

        }

        public void updatePanel(string data1, string data2)
        {
            Form3 form = new Form3();
            form.Show();
        }

        private void Button_Click(object? sender, EventArgs e)
        {
            lblFirst.Text = text1Data;
            lblSecond.Text = text2Data;
        }

        private void Button_Click2(object? sender, EventArgs e)
        {
            mainPanel.Controls.Remove(singlePanel);
        }

        private void Button_Click1(object? sender, EventArgs e)
        {
            Form2 form = new Form2();
            form.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form3 createForm = new Form3(this);
            createForm.Show();
        }
    }
}

  namespace WinFormsApp1
{
public partial class Form2 : Form
{

    public static Form1 parentForm;
    public Form2()
    {
        InitializeComponent();
    }

    public Form2(Form1 form)
    {
        parentForm = form;
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if (textBox1.Text!="" && textBox2.Text!="")
            {
            parentForm.updatePanel(textBox1.Text, textBox2.Text);
        }
        Close();
    }
}
</code>```

}

```<code>namespace WinFormsApp1
{
    public partial class Form3 : Form
    {

        public static Form1 parentForm;
        public Form3()
        {
            InitializeComponent();
        }

        public Form3(Form1 form)
        {
            parentForm = form;

            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            parentForm.createPanel(textBox1.Text, textBox2.Text);
            this.Close();
        }
    }
}
</code>```

Problems:
I am getting bunch of problems

I am getting cascased firing of button click events. For example after having three panels inside the FLowLayoutPanel , when I clicked a button to open a form for the select or update, It opened multiple copies of the form. So that means muliple event listeners of the same control are being fired because of the loop.

The select functionality gets broken after having added multiple panels , as only the select works for once  and  display information of labels and on subsequent click I am not being able to display the values of the labels .

For update functionality I created a public method and exposed it to the update form but here again , I am confused as to how to update a values inside a specific panel .

The delete button inside a panel is also not proplery working as after having couple of panels the delete does not work on the very first panel.

I worked in winforms realted applications like 06 years ago so I pardon if my question seems rubbish to the developer community.

Regards

A solution to a related problem is discussed here at Stackoverflow in the answer but the exact case of how to develope an event listener for the dynamically adding controls over time was not dicussed.

Body:
I have a following situation in my Visual Studio 2022 Windows Forms applications.

I am creating panels after each button click in the FlowLayoutPanel and in each of those panels I am adding controls like text boxes and buttons.So the panels will be increasing after each button click.

My objective is to create a panel after a button click and each time a button is clicked a panel is created having multiple controls in it. Then I will catch click events for each of the buttons in the panels, so that , for example , If a specific button gets clicked in a specific panel , I should know which button was clicked and then I will get the values of other controls like text boxes from that panel and display them. In the meantime I also want to open another form from the button click that will ask for the editing of the labels in the specific panel and after entering the values will update labels in  the specific panel.

Following is my Effort

So I have been able to create controls after a button click inside each of the panels  and each time a button is clicked a new form appears that ask values and then a panel with those values of labels and buttons gets created. I also tried to catch the click events of the buttons inside each of the panel in a FlowLayoutPanel.

namespace WinFormsApp1

{
    public partial class Form1 : Form
    {

        public int counter = 0;
        public string text1Data = "";
        public string text2Data = "";

        public Panel singlePanel;
        public FlowLayoutPanel mainPanel;
        public Form1()
        {
            InitializeComponent();
        }

        public void createPanel(string label1Data,string label2Data)
        {
            counter += 1;
            string panelName = "panel" + counter;

            Label lblText1 = new Label();
            lblText1.Text =label1Data;
            lblText1.ForeColor = Color.Black;
            lblText1.Name = panelName+"_label1";
            lblText1.Text = label1Data;
            lblText1.Location = new System.Drawing.Point(100, 5);
            lblText1.Size = new System.Drawing.Size(120, 100);

            Label lblText2 = new Label();
            lblText2.Text = label2Data;
            lblText2.ForeColor = Color.Black;
            lblText2.Name = panelName+"_label2";
            lblText2.Text = label2Data;
            lblText2.Location = new System.Drawing.Point(220, 5);
            lblText2.Size = new System.Drawing.Size(120, 100);

            Button btnSelect = new Button();
            btnSelect.Name = panelName+"_buttonSelect";
            btnSelect.Text = "SELECT_Panel_" + counter;
            btnSelect.Location = new System.Drawing.Point(350, 5);
            btnSelect.Size = new System.Drawing.Size(150, 30);

            Button btnUpdate = new Button();
            btnUpdate.Name = panelName+"_buttonUpdate";
            btnUpdate.Text = "UPDATE_Panel_" + counter;
            btnUpdate.Location = new System.Drawing.Point(500, 5);
            btnUpdate.Size = new System.Drawing.Size(150, 30);

            Button btnDelete = new Button();
            btnDelete.Name = panelName+"_buttonDelete";
            btnDelete.Text = "DELETE_Panel_" + counter;
            btnDelete.Location = new System.Drawing.Point(650, 5);
            btnDelete.Size = new System.Drawing.Size(150, 30);

            Panel panelSample = new Panel();
            panelSample.Name = panelName;
            //panelSample.BackColor = Color.Black;
            panelSample.Size = new System.Drawing.Size(flowLayoutPanel1.Width - 10, 60);

            panelSample.Controls.Add(lblText1);
            panelSample.Controls.Add(lblText2);

            panelSample.Controls.Add(btnSelect);
            panelSample.Controls.Add(btnUpdate);
            panelSample.Controls.Add(btnDelete);

            flowLayoutPanel1.Controls.Add(panelSample);
            mainPanel = flowLayoutPanel1;

            foreach (var panel in flowLayoutPanel1.Controls.OfType<Panel>())
            {

                string name = panel.Name;

                foreach (var button in panel.Controls.OfType<Button>())
                {

                    if (button.Name == name+"_buttonSelect")
                    {
                        button.Click += Button_Click ;
                    }
                    if (button.Name==name+"_buttonUpdate")
                    {
                        button.Click += Button_Click1;
                    }
                    if (button.Name==name + "_buttonDelete")
                    {
                        button.Click += Button_Click2;
                        singlePanel = panel;
                    }
                }

                foreach (var label in panel.Controls.OfType())
                {

                    if (label.Name==name + "_label1")
                    {
                        text1Data = label.Text;
                    }
                    if (label.Name==name + "_label2")
                    {
                        text2Data=label.Text;
                    }

                }

            }

        }

        public void updatePanel(string data1, string data2)
        {
            Form3 form = new Form3();
            form.Show();
        }

        private void Button_Click(object? sender, EventArgs e)
        {
            lblFirst.Text = text1Data;
            lblSecond.Text = text2Data;
        }

        private void Button_Click2(object? sender, EventArgs e)
        {
            mainPanel.Controls.Remove(singlePanel);
        }

        private void Button_Click1(object? sender, EventArgs e)
        {
            Form2 form = new Form2();
            form.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form3 createForm = new Form3(this);
            createForm.Show();
        }
    }
}

  namespace WinFormsApp1
{
public partial class Form2 : Form
{

    public static Form1 parentForm;
    public Form2()
    {
        InitializeComponent();
    }

    public Form2(Form1 form)
    {
        parentForm = form;
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        if (textBox1.Text!="" && textBox2.Text!="")
            {
            parentForm.updatePanel(textBox1.Text, textBox2.Text);
        }
        Close();
    }
}

}

namespace WinFormsApp1
{
    public partial class Form3 : Form
    {

        public static Form1 parentForm;
        public Form3()
        {
            InitializeComponent();
        }

        public Form3(Form1 form)
        {
            parentForm = form;

            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            parentForm.createPanel(textBox1.Text, textBox2.Text);
            this.Close();
        }
    }
}

Problems:
I am getting bunch of problems

I am getting cascased firing of button click events. For example after having three panels inside the FLowLayoutPanel , when I clicked a button to open a form for the select or update, It opened multiple copies of the form. So that means muliple event listeners of the same control are being fired because of the loop.

The select functionality gets broken after having added multiple panels , as only the select works for once  and  display information of labels and on subsequent click I am not being able to display the values of the labels .

For update functionality I created a public method and exposed it to the update form but here again , I am confused as to how to update a values inside a specific panel .

The delete button inside a panel is also not proplery working as after having couple of panels the delete does not work on the very first panel.

I worked in winforms realted applications like 06 years ago so I pardon if my question seems rubbish to the developer community.

Regards

A solution to a related problem is discussed here at Stackoverflow in the answer but the exact case of how to develope an event listener for the dynamically adding controls over time was not dicussed.


问:
Microsoft Graph AuthProvider C#
I'm doing a small test in ASP.net C#, where I create an event in a calendar of a user (not me) of Office365.
I'm following the instructions at https://learn.microsoft.com/en-us/graph/api/calendar-post-events?view=graph-rest-1.0&tabs=csharp but I'm stuck on creating the GraphServiceClient.
I've tried several ways but I don't think any of the ways do the proper validation of the user that I want.
I have everything configured in O365 (clientId, tenantId, clientSecret, permissions, ...).
The code does not return errors but simply does not create the event.
In the part of creating the event itself, I'm using the code given to me by Microsoft Graph Explorer.
I am more than convinced that the problem is in the authentication and in the creation of the GraphServiceClient.

Someone can help me?

Title: Microsoft Graph AuthProvider C#