问:
Can't run Cypress successfully in Jenkins build on Windows
In Jenkins build, I set up the build environment as Node.JS, and executed windows batch command "npm install --global yarn&yarn add cypress --dev &yarn cypress:run --reporter=spec"the same way I ran in my local. All the tests can run successfully, but in Jenkins all are failed with error."Oops...we found an error preparing this test file: Error: ENOENT: no such file or directory, stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Cypress\cy\production\projects\esgr-portal2-sso-dev-cypress-b7dad7110500bea68385ec2d48f2d9df\bundles\cypress\support\e2e.js'. This occurred while Cypress was compiling and bundling your test code. This is usually caused by: A missing file or dependency. A syntax error in the file or one of its dependencies. Fix the error in your code and re-run your tests."

The console log is here:

```<code>Started by user Billy
Running as SYSTEM
Building in workspace C:\Program Files (x86)\Jenkins\workspace\project-sso-dev-cypress
using credential 78bcddd4-13b9-4582-a4fc-e86abb9ebeaa
 > C:\Program Files\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files\Git\bin\git.exe config remote.origin.url https://github.com/project-cypress.git # timeout=10
Fetching upstream changes from https://github.com/project-cypress.git
 > C:\Program Files\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials Token as password
 > C:\Program Files\Git\bin\git.exe fetch --tags --force --progress -- https://github.com/project-cypress.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/main^{commit}" # timeout=10
 > C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/main^{commit}" # timeout=10
Checking out Revision 56ab032de063bbf0e04a7bbf7482b9f795be79d4 (refs/remotes/origin/main)
 > C:\Program Files\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > C:\Program Files\Git\bin\git.exe checkout -f 56ab032de063bbf0e04a7bbf7482b9f795be79d4 # timeout=10
Commit message: "Merge branch 'main' of https://github.com/project-cypress"
 > C:\Program Files\Git\bin\git.exe rev-list --no-walk 4cd7cdcec00da10e04193706d9741f2d0a9a231e # timeout=10
[esgr-portal2-sso-dev-cypress] $ cmd /c call C:\Windows\TEMP\jenkins1758996358505508646.bat

C:\Program Files (x86)\Jenkins\workspace\project-sso-dev-cypress>npm cache clean --force  & npm install   & npm install cypress  & npm install --global yarn  & yarn add cypress --dev   & npm install cypress-react-selector  & yarn cypress:run --reporter=spec
npm WARN using --force Recommended protections disabled.

added 168 packages, removed 3 packages, and audited 169 packages in 15s

28 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

up to date, audited 169 packages in 705ms

28 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

changed 1 package in 490ms
yarn add v1.22.19
warning package.json: No license field
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
warning No license field
success Saved 1 new dependency.
info Direct dependencies
â””â”€ cypress@12.2.0
info All dependencies
â””â”€ cypress@12.2.0
Done in 10.71s.

added 3 packages, changed 8 packages, and audited 172 packages in 4s

28 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
yarn run v1.22.19
warning package.json: No license field
$ cypress run --reporter=spec

�[90m====================================================================================================�[39m

�[0m  (�[4m�[1mRun Starting�[22m�[24m)�[0m

�[90m  â”Œ�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”��[39m
�[90m  â”‚�[39m �[90mCypress:�[39m        12.2.0                                                                         �[90mâ”‚�[39m
�[90m  â”‚�[39m �[90mBrowser:�[39m        Electron 106 �[90m(headless)�[39m                                                        �[90mâ”‚�[39m
�[90m  â”‚�[39m �[90mNode Version:�[39m   �[0mv19.3.0 �[90m(C:\Program Files (x86)\Jenkins\tools\jenkins.plugins.nodejs.tool�[0m      �[90mâ”‚�[39m
�[90m  â”‚�[39m                 �[0ms.NodeJSInstallation\Node19\node.exe)�[39m�[0m                                          �[90mâ”‚�[39m
�[90m  â”‚�[39m �[90mSpecs:�[39m          �[0m30 found (1-getting-started/todo.cy.js, 2-advanced-examples/actions.cy.js, 2-a�[0m �[90mâ”‚�[39m
�[90m  â”‚�[39m                 �[0mdvanced-examples/aliasing.cy.js, 2-advanced-examples/assertions.cy.js, 2-advan�[0m �[90mâ”‚�[39m
�[90m  â”‚�[39m                 �[0mced-examples/connectors.cy.js, 2-advanced-examples/cookies.cy.js, 2-advanced-e�[0m �[90mâ”‚�[39m
�[90m  â”‚�[39m                 �[0mxamples/cypress_api.cy....)�[0m                                                    �[90mâ”‚�[39m
�[90m  â”‚�[39m �[90mSearched:�[39m       �[0mcypress/e2e/**/*.cy.{js,jsx,ts,tsx}�[0m                                            �[90mâ”‚�[39m
�[90m  â””�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”˜�[39m

�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m

  Running:  �[90m1-getting-started/todo.cy.js�[39m                                                   �[90m(1 of 30)�[39m

�[31mOops...we found an error preparing this test file:�[39m
�[31m�[39m
�[31m�[90m  > �[31m�[94mcypress\e2e\1-getting-started\todo.cy.js�[31m�[39m
�[31m�[39m
�[31mThe error was:�[39m
�[31m�[39m
�[31m�[33mError: ENOENT: no such file or directory, stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Cypress\cy\production\projects\esgr-portal2-sso-dev-cypress-b7dad7110500bea68385ec2d48f2d9df\bundles\cypress\e2e\1-getting-started\todo.cy.js'�[31m�[39m
�[31m�[39m
�[31mThis occurred while Cypress was compiling and bundling your test code. This is usually caused by:�[39m
�[31m�[39m
�[31m- A missing file or dependency�[39m
�[31m- A syntax error in the file or one of its dependencies�[39m
�[31m�[39m
�[31mFix the error in your code and re-run your tests.�[39m
</code>```

Body:
In Jenkins build, I set up the build environment as Node.JS, and executed windows batch command "npm install --global yarn&yarn add cypress --dev &yarn cypress:run --reporter=spec"the same way I ran in my local. All the tests can run successfully, but in Jenkins all are failed with error."Oops...we found an error preparing this test file: Error: ENOENT: no such file or directory, stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Cypress\cy\production\projects\esgr-portal2-sso-dev-cypress-b7dad7110500bea68385ec2d48f2d9df\bundles\cypress\support\e2e.js'. This occurred while Cypress was compiling and bundling your test code. This is usually caused by: A missing file or dependency. A syntax error in the file or one of its dependencies. Fix the error in your code and re-run your tests."

The console log is here:

Started by user Billy
Running as SYSTEM
Building in workspace C:\Program Files (x86)\Jenkins\workspace\project-sso-dev-cypress
using credential 78bcddd4-13b9-4582-a4fc-e86abb9ebeaa
 > C:\Program Files\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files\Git\bin\git.exe config remote.origin.url https://github.com/project-cypress.git # timeout=10
Fetching upstream changes from https://github.com/project-cypress.git
 > C:\Program Files\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials Token as password
 > C:\Program Files\Git\bin\git.exe fetch --tags --force --progress -- https://github.com/project-cypress.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/main^{commit}" # timeout=10
 > C:\Program Files\Git\bin\git.exe rev-parse "refs/remotes/origin/origin/main^{commit}" # timeout=10
Checking out Revision 56ab032de063bbf0e04a7bbf7482b9f795be79d4 (refs/remotes/origin/main)
 > C:\Program Files\Git\bin\git.exe config core.sparsecheckout # timeout=10
 > C:\Program Files\Git\bin\git.exe checkout -f 56ab032de063bbf0e04a7bbf7482b9f795be79d4 # timeout=10
Commit message: "Merge branch 'main' of https://github.com/project-cypress"
 > C:\Program Files\Git\bin\git.exe rev-list --no-walk 4cd7cdcec00da10e04193706d9741f2d0a9a231e # timeout=10
[esgr-portal2-sso-dev-cypress] $ cmd /c call C:\Windows\TEMP\jenkins1758996358505508646.bat

C:\Program Files (x86)\Jenkins\workspace\project-sso-dev-cypress>npm cache clean --force  & npm install   & npm install cypress  & npm install --global yarn  & yarn add cypress --dev   & npm install cypress-react-selector  & yarn cypress:run --reporter=spec
npm WARN using --force Recommended protections disabled.

added 168 packages, removed 3 packages, and audited 169 packages in 15s

28 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

up to date, audited 169 packages in 705ms

28 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

changed 1 package in 490ms
yarn add v1.22.19
warning package.json: No license field
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
warning No license field
success Saved 1 new dependency.
info Direct dependencies
â””â”€ cypress@12.2.0
info All dependencies
â””â”€ cypress@12.2.0
Done in 10.71s.

added 3 packages, changed 8 packages, and audited 172 packages in 4s

28 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
yarn run v1.22.19
warning package.json: No license field
$ cypress run --reporter=spec

�[90m====================================================================================================�[39m

�[0m  (�[4m�[1mRun Starting�[22m�[24m)�[0m

�[90m  â”Œ�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”��[39m
�[90m  â”‚�[39m �[90mCypress:�[39m        12.2.0                                                                         �[90mâ”‚�[39m
�[90m  â”‚�[39m �[90mBrowser:�[39m        Electron 106 �[90m(headless)�[39m                                                        �[90mâ”‚�[39m
�[90m  â”‚�[39m �[90mNode Version:�[39m   �[0mv19.3.0 �[90m(C:\Program Files (x86)\Jenkins\tools\jenkins.plugins.nodejs.tool�[0m      �[90mâ”‚�[39m
�[90m  â”‚�[39m                 �[0ms.NodeJSInstallation\Node19\node.exe)�[39m�[0m                                          �[90mâ”‚�[39m
�[90m  â”‚�[39m �[90mSpecs:�[39m          �[0m30 found (1-getting-started/todo.cy.js, 2-advanced-examples/actions.cy.js, 2-a�[0m �[90mâ”‚�[39m
�[90m  â”‚�[39m                 �[0mdvanced-examples/aliasing.cy.js, 2-advanced-examples/assertions.cy.js, 2-advan�[0m �[90mâ”‚�[39m
�[90m  â”‚�[39m                 �[0mced-examples/connectors.cy.js, 2-advanced-examples/cookies.cy.js, 2-advanced-e�[0m �[90mâ”‚�[39m
�[90m  â”‚�[39m                 �[0mxamples/cypress_api.cy....)�[0m                                                    �[90mâ”‚�[39m
�[90m  â”‚�[39m �[90mSearched:�[39m       �[0mcypress/e2e/**/*.cy.{js,jsx,ts,tsx}�[0m                                            �[90mâ”‚�[39m
�[90m  â””�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”˜�[39m

�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m�[90mâ”€�[39m

  Running:  �[90m1-getting-started/todo.cy.js�[39m                                                   �[90m(1 of 30)�[39m

�[31mOops...we found an error preparing this test file:�[39m
�[31m�[39m
�[31m�[90m  > �[31m�[94mcypress\e2e\1-getting-started\todo.cy.js�[31m�[39m
�[31m�[39m
�[31mThe error was:�[39m
�[31m�[39m
�[31m�[33mError: ENOENT: no such file or directory, stat 'C:\Windows\system32\config\systemprofile\AppData\Roaming\Cypress\cy\production\projects\esgr-portal2-sso-dev-cypress-b7dad7110500bea68385ec2d48f2d9df\bundles\cypress\e2e\1-getting-started\todo.cy.js'�[31m�[39m
�[31m�[39m
�[31mThis occurred while Cypress was compiling and bundling your test code. This is usually caused by:�[39m
�[31m�[39m
�[31m- A missing file or dependency�[39m
�[31m- A syntax error in the file or one of its dependencies�[39m
�[31m�[39m
�[31mFix the error in your code and re-run your tests.�[39m


来源: stackexchange

问:
Memory-efficient DataFrame.stack()
If I memray the following code, df.stack() allocates 22MB, when the df is only 5MB.

```<code>import numpy as np
import pandas as pd

columns = list('abcdefghijklmnopqrstuvwxyz')
df = pd.DataFrame(np.random.randint(0,100,size=(1000, 26*26)), columns=pd.MultiIndex.from_product([columns, columns]))
print(df.memory_usage().sum()) # 5408128, ~5MB
df.stack() # reshape: (1000,26*26) -> (1000*26,26)
</code>```

Why DataFrame.stack() consumes so much memory? It allocates 30% on dropna and remaining 70% re-allocating the underlying array 3 times to reshape. Shall I move to native numpy.reshape or is there anything I can do to make it slimmer?

ContentLicense: CC BY-SA 4.0

Title: Memory-efficient DataFrame.stack()

Body:
If I memray the following code, df.stack() allocates 22MB, when the df is only 5MB.

import numpy as np
import pandas as pd

columns = list('abcdefghijklmnopqrstuvwxyz')
df = pd.DataFrame(np.random.randint(0,100,size=(1000, 26*26)), columns=pd.MultiIndex.from_product([columns, columns]))
print(df.memory_usage().sum()) # 5408128, ~5MB
df.stack() # reshape: (1000,26*26) -> (1000*26,26)

Why DataFrame.stack() consumes so much memory? It allocates 30% on dropna and remaining 70% re-allocating the underlying array 3 times to reshape. Shall I move to native numpy.reshape or is there anything I can do to make it slimmer?


问:
Regex for password
recently they sent me an exercise to check a password with regular expressions, which would have to have a capital letter, lower case letters, and two numbers, since I have no experience with regex I created a class to experiment with, what happened was that I found the solution, but for separate expressions and coincidentally joining them in a single expression returns false. Could someone please help me with this?
`

```<code>public class main {

    public static void main(String[] args) {

        String cadena="12Aaniel";

        //return true 8 characters minimum

        System.out.println("ejemplo10: "+cadena.matches(".{8,}"));

        //return true has at least one capital letter

        System.out.println("ejemplo10: "+cadena.matches("(.*[A-Z]+.*)"));

        //return true has at least 2 numbers

        System.out.println("ejemplo10: "+cadena.matches("(.*[0-9]{2,}.*)"));

        //return false all together

        System.out.println("ejemplo10: "+cadena.matches(".{8,}(.*[A-Z]+.*)(.*[0-9]{2,}.*)"));

    }

}
</code>```

`

I need all in one expresion

Title: Regex for password

Body:
recently they sent me an exercise to check a password with regular expressions, which would have to have a capital letter, lower case letters, and two numbers, since I have no experience with regex I created a class to experiment with, what happened was that I found the solution, but for separate expressions and coincidentally joining them in a single expression returns false. Could someone please help me with this?
`

public class main {

    public static void main(String[] args) {

        String cadena="12Aaniel";

        //return true 8 characters minimum

        System.out.println("ejemplo10: "+cadena.matches(".{8,}"));

        //return true has at least one capital letter

        System.out.println("ejemplo10: "+cadena.matches("(.*[A-Z]+.*)"));

        //return true has at least 2 numbers

        System.out.println("ejemplo10: "+cadena.matches("(.*[0-9]{2,}.*)"));

        //return false all together

        System.out.println("ejemplo10: "+cadena.matches(".{8,}(.*[A-Z]+.*)(.*[0-9]{2,}.*)"));

    }

}

`

I need all in one expresion


问:
Get XPath of selected text using window.getSelection in javascript
I am developing a highlighter chrome extension. It highlights and removes highlights without a problem. But I wanna save those highlights in storage and I need a path for each highlight. I can get the dom path of the element which is highlighted, but it's not enough. I also need a text node path for the text.

For more clarification:
Image
Assume those words are highlighted, How could I find the path of each highlighted item? As you see all of those are in the same parent element (div.max-w-3xl);

This is my highlight code:

```<code>      const selection = window.getSelection();
      const selectionRange = selection.getRangeAt(0);
      const id = nanoid();
      const mark = document.createElement("mark");
      const selectionIndexes = [
        selectionRange.startOffset,
        selectionRange.endOffset,
      ];

      mark.textContent = selection.toString();
      mark.dataset.highlightId = id;
      mark.classList.add("highlight");

      selectionRange.deleteContents();
      selectionRange.insertNode(mark);

      console.log(
        getElementPath(selectionRange.commonAncestorContainer as Element),
        selectionIndexes
      );
</code>```

getElementPath function:

```<code>const getElementPath = (element): string => {
  let nodeName = element.nodeName.toLowerCase();
  if (element === document.body) return "body";
  if (element.id) nodeName += "#" + element.id;
  else if (element.classList.length)
    nodeName += "." + [...element.classList].join(".");
  return getElementPath(element.parentNode) + " " + nodeName;
};
</code>```

The log result:

body div.bg-base-100.drawer.drawer-mobile div.drawer-content div.px-6.xl:pr-2.pb-16 div.flex.flex-col-reverse.justify-between.gap-6.xl:flex-row div.prose.w-full.max-w-4xl.flex-grow div.max-w-3xl (2) [8, 10]

Body:
I am developing a highlighter chrome extension. It highlights and removes highlights without a problem. But I wanna save those highlights in storage and I need a path for each highlight. I can get the dom path of the element which is highlighted, but it's not enough. I also need a text node path for the text.

For more clarification:
Image
Assume those words are highlighted, How could I find the path of each highlighted item? As you see all of those are in the same parent element (div.max-w-3xl);

This is my highlight code:

      const selection = window.getSelection();
      const selectionRange = selection.getRangeAt(0);
      const id = nanoid();
      const mark = document.createElement("mark");
      const selectionIndexes = [
        selectionRange.startOffset,
        selectionRange.endOffset,
      ];

      mark.textContent = selection.toString();
      mark.dataset.highlightId = id;
      mark.classList.add("highlight");

      selectionRange.deleteContents();
      selectionRange.insertNode(mark);

      console.log(
        getElementPath(selectionRange.commonAncestorContainer as Element),
        selectionIndexes
      );

getElementPath function:

const getElementPath = (element): string => {
  let nodeName = element.nodeName.toLowerCase();
  if (element === document.body) return "body";
  if (element.id) nodeName += "#" + element.id;
  else if (element.classList.length)
    nodeName += "." + [...element.classList].join(".");
  return getElementPath(element.parentNode) + " " + nodeName;
};

The log result:

body div.bg-base-100.drawer.drawer-mobile div.drawer-content div.px-6.xl:pr-2.pb-16 div.flex.flex-col-reverse.justify-between.gap-6.xl:flex-row div.prose.w-full.max-w-4xl.flex-grow div.max-w-3xl (2) [8, 10]


问:
msaPrettyPrint not generating graph in R
I've been trying to run the example in the msa documentation. I get a fasta file, but no graph. Instead I get text detailing the msa file. I don't need to create a pdf, I just want to see the graph in Rstudio.

```<code>filepath <- system.file("examples", "exampleAA.fasta", package="msa")
mySeqs <- readAAStringSet(filepath)
myAlignment <- msa(mySeqs)
msaPrettyPrint(myAlignment, output="asis", askForOverwrite=FALSE)
</code>```

\begin{texshade}{C:/Users/d.guillotin/AppData/Local/Temp/Rtmp6RWxwQ/seq2e0c4ae64ed7.fasta}
\seqtype{P}
\shadingmode{identical}
\threshold{50}
\showconsensus[ColdHot]{bottom}
\shadingcolors{blues}
\showsequencelogo[chemical]{top}
\hidelogoscale
\shownames{left}
\nameseq{1}{PH4H Rattus norvegicus}
\nameseq{2}{PH4H Mus musculus}
\nameseq{3}{PH4H Homo sapiens}
\nameseq{4}{PH4H Bos taurus}
\nameseq{5}{PH4H Chromobacterium violaceum}
\nameseq{6}{PH4H Ralstonia solanacearum}
\nameseq{7}{PH4H Caulobacter crescentus}
\nameseq{8}{PH4H Pseudomonas aeruginosa}
\nameseq{9}{PH4H Rhizobium loti}
\shownumbering{right}
\showlegend
\end{texshade}

Body:
I've been trying to run the example in the msa documentation. I get a fasta file, but no graph. Instead I get text detailing the msa file. I don't need to create a pdf, I just want to see the graph in Rstudio.

filepath <- system.file("examples", "exampleAA.fasta", package="msa")
mySeqs <- readAAStringSet(filepath)
myAlignment <- msa(mySeqs)
msaPrettyPrint(myAlignment, output="asis", askForOverwrite=FALSE)

\begin{texshade}{C:/Users/d.guillotin/AppData/Local/Temp/Rtmp6RWxwQ/seq2e0c4ae64ed7.fasta}
\seqtype{P}
\shadingmode{identical}
\threshold{50}
\showconsensus[ColdHot]{bottom}
\shadingcolors{blues}
\showsequencelogo[chemical]{top}
\hidelogoscale
\shownames{left}
\nameseq{1}{PH4H Rattus norvegicus}
\nameseq{2}{PH4H Mus musculus}
\nameseq{3}{PH4H Homo sapiens}
\nameseq{4}{PH4H Bos taurus}
\nameseq{5}{PH4H Chromobacterium violaceum}
\nameseq{6}{PH4H Ralstonia solanacearum}
\nameseq{7}{PH4H Caulobacter crescentus}
\nameseq{8}{PH4H Pseudomonas aeruginosa}
\nameseq{9}{PH4H Rhizobium loti}
\shownumbering{right}
\showlegend
\end{texshade}


问:
Python Dill or Pickle gives error when use in a new file
I need help with my code. I have built a recommendation system using cosine similarity on a colab and used pickle to serialized it. when I deserialized it inside a colab file, it works perfectly fine but when I deserialize it in a new colab file. it gives me an error

```<code>name 'data' is not defined
</code>```

data is a variable that is initialized with my dataset which is outside of the class InstaPost.

```<code>import pandas as pd
import numpy as np
from sklearn.feature_extraction import text
from sklearn.metrics.pairwise import cosine_similarity
import dill as pickle

data = pd.read_csv("/content/instaData.txt")
data

data = data[["Caption", "Hashtags"]]

captions = data["Caption"].tolist()
uni_tfidf = text.TfidfVectorizer(input=captions, stop_words="english")
uni_matrix = uni_tfidf.fit_transform(captions)
uni_sim = cosine_similarity(uni_matrix)

def recommend_post(x):
  return ", ".join(data["Caption"].loc[x.argsort()[-7:-1]])

data["Recommended Post"] = [recommend_post(x) for x in uni_sim]

class InstaPost:

    def Post(number):
      count = 0
      wordy = (data["Recommended Post"][number])
      sentence = wordy.split(',')

      for i in sentence:
        count=count+1
        print(count," ",i)

obj = InstaPost

obj.Post(1)

</code>```
```<code>pickle_out = open("modelREC", "wb")
pickle.dump(obj, pickle_out)
pickle_out.close()

</code>```
```<code>
pickle_in = open("modelREC", "rb")
exe = pickle.load(pickle_in)

print(exe.Post(10))
</code>```

NOTE: on a different file

```<code>print(exe.Post)
</code>```

works

and give output

```<code><function InstaPost.Post at 0x7efc0b4c3f70>
</code>```

if I need to give the reference of the data than please guide me how should I do it. It will be a great help to me

Thanks in advance

Body:
I need help with my code. I have built a recommendation system using cosine similarity on a colab and used pickle to serialized it. when I deserialized it inside a colab file, it works perfectly fine but when I deserialize it in a new colab file. it gives me an error

name 'data' is not defined

data is a variable that is initialized with my dataset which is outside of the class InstaPost.

import pandas as pd
import numpy as np
from sklearn.feature_extraction import text
from sklearn.metrics.pairwise import cosine_similarity
import dill as pickle

data = pd.read_csv("/content/instaData.txt")
data

data = data[["Caption", "Hashtags"]]

captions = data["Caption"].tolist()
uni_tfidf = text.TfidfVectorizer(input=captions, stop_words="english")
uni_matrix = uni_tfidf.fit_transform(captions)
uni_sim = cosine_similarity(uni_matrix)

def recommend_post(x):
  return ", ".join(data["Caption"].loc[x.argsort()[-7:-1]])

data["Recommended Post"] = [recommend_post(x) for x in uni_sim]

class InstaPost:

    def Post(number):
      count = 0
      wordy = (data["Recommended Post"][number])
      sentence = wordy.split(',')

      for i in sentence:
        count=count+1
        print(count," ",i)

obj = InstaPost

obj.Post(1)

pickle_out = open("modelREC", "wb")
pickle.dump(obj, pickle_out)
pickle_out.close()

pickle_in = open("modelREC", "rb")
exe = pickle.load(pickle_in)

print(exe.Post(10))

NOTE: on a different file

print(exe.Post)

works

and give output

<function InstaPost.Post at 0x7efc0b4c3f70>

if I need to give the reference of the data than please guide me how should I do it. It will be a great help to me

Thanks in advance


问:
Dimensionality reduction using UMAP in batches
I'm using the javascript implementation of UMAP (https://github.com/PAIR-code/umap-js#readme) to do dimensionality reduction for 10,000 embeddings (each with 1558 dimensions). I don't want to have to load all this data into memory at once obviously.

Is there any way I can fit the data in batches?


问:
How to remove the default "left" position of node. d3.js
I have a problem where the node always move left. Here is my code:

```<code><div id="tree-container"></div>

<script src="<?php echo base_url('d3js-nettree/js/d3.js');?>" type="text/javascript"></script>
<script>
<?php if(isset($params['user_code'])){ ?>
treeJSON = d3.json("<?php echo base_url('d3js-parse/'.$params['user_code'].'.json');?>", function(error, treeData) {
    // Calculate total nodes, max label length
    var totalNodes = 0;
    var maxLabelLength = 0;
    // Misc. variables
    var zoomFactor = 1;
    var i = 0;
    var duration = 750;
    var root;
    var rectWidth = 160, rectHeight = 125;

    // size of the diagram
    var viewerWidth = $("#tree-container").width();
    var viewerHeight = 500;

    var tree = d3.layout.tree()
        .size([viewerWidth, viewerHeight]);

    // define a d3 diagonal projection for use by the node paths later on.
    var diagonal = d3.svg.diagonal()
        .projection(function(d) {
            return [d.x, d.y];
        });

    // A recursive helper function for performing some setup by walking through all nodes
    function visit(parent, visitFn, childrenFn) {
        if (!parent) return;

        visitFn(parent);

        var children = childrenFn(parent);
        if (children) {
            var count = children.length;
            for (var i = 0; i < count; i++) {
                visit(children[i], visitFn, childrenFn);
            }
        }
    }

    // Define the zoom function for the zoomable tree
    function zoom() {
        svgGroup.attr("transform", "translate(" + d3.event.translate + ")scale(" + d3.event.scale + ")");
    }

    // define the zoomListener which calls the zoom function on the "zoom" event constrained within the scaleExtents
    var zoomListener = d3.behavior.zoom().scaleExtent([0.1, 3]).on("zoom", zoom);

    d3.selectAll('button').on('click', function(){
        if(this.id === 'zoom_in') {
            zoomFactor = zoomFactor + 0.2;
            zoomListener.scale(zoomFactor).event(d3.select("#tree-container"));
        }
        else if(this.id === 'zoom_out') {
            zoomFactor = zoomFactor - 0.2;
            zoomListener.scale(zoomFactor).event(d3.select("#tree-container"));
        }
        else if(this.id === 'up_level') {
            updateNewTree("ID04838614");
        }
    });

    // define the baseSvg, attaching a class for styling and the zoomListener
    var baseSvg = d3.select("#tree-container").append("svg")
        .attr("width", viewerWidth)
        .attr("height", viewerHeight)
        .attr("class", "overlay")
        .call(zoomListener);

    // Function to center node when clicked/dropped so node doesn't get lost when collapsing/moving with large amount of children.
    function centerNode(source) {
        scale = zoomListener.scale();
        x = -source.x0;
        y = -source.y0;
        x = x * scale + viewerWidth / 2;
        y = y * scale + viewerHeight / 2;
        d3.select('g').transition()
            .duration(duration)
            .attr("transform", "translate(" + x + "," + y + ")scale(" + scale + ")");
        zoomListener.scale(scale);
        zoomListener.translate([x, y]);
    }
    // Call visit function to establish maxLabelLength
    visit(treeData, function(d) {
        totalNodes++;
        maxLabelLength = Math.max(d.distributor_code.length, maxLabelLength);

    }, function(d) {
        return d.children && d.children.length > 0 ? d.children : null;
    });

    // define click event
    function click(d) {
        console.log("clicked");
        // if (d3.event.defaultPrevented) return; // click suppressed
        //d = toggleChildren(d);
        if(d.url !== "") {
            window.open(d.url, "_self");
        } else {
            updateNewTree(d.distributor_code);
        }
        update(d);
        centerNode(d);
    }

    function update(source) {
        // Compute the new height, function counts total children of root node and sets tree height accordingly.
        // This prevents the layout looking squashed when new nodes are made visible or looking sparse when nodes are removed
        // This makes the layout more consistent.
        var levelWidth = [1];
        var childCount = function(level, n) {

            if (n.children && n.children.length > 0) {
                if (levelWidth.length <= level + 1) levelWidth.push(0);

                levelWidth[level + 1] += n.children.length;
                n.children.forEach(function(d) {
                    childCount(level + 1, d);
                });
            }
        };
        childCount(0, root);
        var newWidth = d3.max(levelWidth) * 300; // 300 pixels per line
        tree = tree.size([newWidth, viewerHeight]);

        // Compute the new tree layout.
        var nodes = tree.nodes(root).reverse(),
            links = tree.links(nodes);

        // Set widths between levels based on maxLabelLength.
        nodes.forEach(function(d) {
            //d.y = (d.depth * (maxLabelLength * 10)); //maxLabelLength * 10px
            // alternatively to keep a fixed scale one can set a fixed depth per level
            // Normalize for fixed-depth by commenting out below line
             d.y = (d.depth * 200); //200px per level.
        });

        // Update the nodes…
        node = svgGroup.selectAll("g.node")
            .data(nodes, function(d) {
                return d.id || (d.id = ++i);
            });

        // Enter any new nodes at the parent's previous position.
        var nodeEnter = node.enter().append("g")
            .attr("class", "node")
            .attr("transform", function(d) {
                return "translate(" + source.x0 + "," + source.y0 + ")";
            })
            .on('click', click);

        nodeEnter.append("image")
            .attr("href", "<?php echo base_url('assets/images/people.png');?>")
            .attr("x", -rectWidth/4)
            .attr("y", -rectHeight-75)
            .attr("width", 75)
            .attr("height", 75);

        nodeEnter.append("rect")
            .attr('class', 'nodeRect')
            .attr("x", -rectWidth/2)
            .attr("y", -rectHeight)
            .attr("rx", 10)
            .attr("ry", 10)
            .attr("width", rectWidth)
            .attr("height", rectHeight)
            .style("fill", function(d) {
                //return d._children ? "lightsteelblue" : "#fff";
            });

        nodeEnter.append("text")
            .attr('class', 'txt1')
            .attr("x", 0)
            .attr("y", -rectHeight+15)
            .attr('class', 'textBold')
            .attr("text-anchor", "middle")
            .text(function(d) {
                if(d.distributor_code === "") return "";
                else return d.user_code;
            });
        nodeEnter.append("text")
            .attr('class', 'txt2')
            .attr("x", 0)
            .attr("y", -rectHeight+25)
            .attr("text-anchor", "middle")
            .text(function(d) {
                if(d.distributor_code === "") return "";
                else return d.fullname;
            });

        //IT GOES ON FOR SEVERAL MORE

        // Transition nodes to their new position.
        var nodeUpdate = node.transition()
            .duration(duration)
            .attr("transform", function(d) {
                return "translate(" + d.x + "," + d.y + ")";
            });

        // Fade the text in
        nodeUpdate.select("text")
            .style("fill-opacity", 1);

        // Transition exiting nodes to the parent's new position.
        var nodeExit = node.exit().transition()
            .duration(duration)
            .attr("transform", function(d) {
                return "translate(" + source.x + "," + source.y + ")";
            })
            .remove();

        nodeExit.select("rect")
            .attr("width", 0)
            .attr("height", 0);

        nodeExit.select("text")
            .style("fill-opacity", 0);

        nodeExit.select("image")
            .style("display", "none");

        // Update the links…
        var link = svgGroup.selectAll("path.link")
            .data(links, function(d) {
                return d.target.id;
            });

        // Enter any new links at the parent's previous position.
        link.enter().insert("path", "g")
            .attr("class", "link")
            .attr("d", function(d) {
                var o = {
                    x: source.x0,
                    y: source.y0
                };
                return diagonal({
                    source: o,
                    target: o
                });
            });

        // Transition links to their new position.
        link.transition()
            .duration(duration)
            .attr("d", diagonal);

        // Transition exiting nodes to the parent's new position.
        link.exit().transition()
            .duration(duration)
            .attr("d", function(d) {
                var o = {
                    x: source.x,
                    y: source.y
                };
                return diagonal({
                    source: o,
                    target: o
                });
            })
            .remove();

        // Stash the old positions for transition.
        nodes.forEach(function(d) {
            d.x0 = d.x;
            d.y0 = d.y;
        });
    }

    function updateNewTree($base_id) {
        // Get the data again
        d3.json("nettree-alt.json", function(error, treeData) {
            // Call visit function to establish maxLabelLength
            visit(treeData, function(d) {
                totalNodes++;
                maxLabelLength = Math.max(d.distributor_code.length, maxLabelLength);

            }, function(d) {
                return d.children && d.children.length > 0 ? d.children : null;
            });

            root = treeData;
            root.x0 = viewerHeight / 2;
            root.y0 = 0;

            // Layout the tree initially and center on the root node.
            update(root);
            centerNode(root);

        });
    }

    // Append a group which holds all nodes and which the zoom Listener can act upon.
    var svgGroup = baseSvg.append("g");

    // Define the root
    root = treeData;
    root.x0 = viewerHeight / 2;
    root.y0 = -100;

    // Layout the tree initially and center on the root node.
    update(root);
    centerNode(root);
});
<?php } ?>
function EnableTreeMode(){
    $('.tree').treegrid({
    expanderExpandedClass: 'glyphicon glyphicon-minus',
    expanderCollapsedClass: 'glyphicon glyphicon-plus'
  });
  $('.tree').treegrid('collapseAll');
}

EnableTreeMode();
function collapse(){
  $('.tree').treegrid('collapseAll');
}
function expand(){
    $('.tree').treegrid('expandAll');
}

</script>
</code>```

The problem is like this, i have a "tree" that consist of users which pulls data from a json file:

```<code>                      USER 1
                        /\
                  USER 2  USER 3
</code>```

What i was expecting when i remove a user, say user 2, the "tree" should be like this:

```<code>                      USER 1
                        /\
                   NONE   USER 3
</code>```

But instead the result i got were like this:

```<code>                      USER 1
                        /\
                   USER 3   NONE
</code>```

After i deleted USER 2 the USER 3, which is on the right node, moved on the left node. I have tried debugging my code line by line but still no result.

TIA.

Body:
I have a problem where the node always move left. Here is my code:

The problem is like this, i have a "tree" that consist of users which pulls data from a json file:

                      USER 1
                        /\
                  USER 2  USER 3

What i was expecting when i remove a user, say user 2, the "tree" should be like this:

                      USER 1
                        /\
                   NONE   USER 3

But instead the result i got were like this:

                      USER 1
                        /\
                   USER 3   NONE

After i deleted USER 2 the USER 3, which is on the right node, moved on the left node. I have tried debugging my code line by line but still no result.

TIA.


问:
can't change embedding dimension to pass it through gpt2
I'm practicing image captioning and have some problems with different dimensions of tensors. So I have image embedding aka size [1, 512], but GPT2, which I use for caption generation, needs size [n, 768], where n is number of tokens of the caption's beginning. I don't know how I should change the dimension of my image embedding to pass it through GPT2.
I thought it would be a good idea to fill image embedding with zeros so in will be size [1, 768] but I think it will negatively affect on the result caption.
Thank you for your help!

I've tried to fill image embeddings with zeros to be size [1, 768] but I think it won't help a lot


问:
How can we access fragment manager in component activity
i want to show BottomSheetDialog in component activity but in that im not able to find supportFragmentManager.</p>
```<code>class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MyApplicationTheme {
                Column(
                    horizontalAlignment = Alignment.CenterHorizontally,
                    modifier = Modifier.fillMaxWidth()
                ) {
                    Text(
                        "Hello World",
                        fontSize = 30.sp,
                        modifier =
                            modifier.clickable {
                                val bottomSheet = BottomSheetDialog()
                                bottomSheet.show(supportFragmentManager, "ModalBottomSheet")
                            }
                    )
                }
            }
        }
    }
}
</code>```

Body:
i want to show BottomSheetDialog in component activity but in that im not able to find supportFragmentManager.

class MainActivity : ComponentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {
            MyApplicationTheme {
                Column(
                    horizontalAlignment = Alignment.CenterHorizontally,
                    modifier = Modifier.fillMaxWidth()
                ) {
                    Text(
                        "Hello World",
                        fontSize = 30.sp,
                        modifier =
                            modifier.clickable {
                                val bottomSheet = BottomSheetDialog()
                                bottomSheet.show(supportFragmentManager, "ModalBottomSheet")
                            }
                    )
                }
            }
        }
    }
}


问:
Working with TabularData in Swift - How to create table with means, min and max columns?
I'm trying to use the TabularData framework in swift to process data contained in CSV file to create a table also containing the average, the minimum and the maximum.
I haven't found any examples on the net that can help me.
The code I managed to write is the one below.

```<code>let dataFrame = try DataFrame(contentsOfCSVFile: nomefile_input_URL!)
let dataFrame_Media = dataFrame.grouped(by: "model_variable_code").means("value", Double.self, order: .descending)
print(dataFrame_Media)
</code>```

I get:

How can I modify the code to get a table that contains min(value) and max(value), as well as mean(value)?

Body:
I'm trying to use the TabularData framework in swift to process data contained in CSV file to create a table also containing the average, the minimum and the maximum.
I haven't found any examples on the net that can help me.
The code I managed to write is the one below.

let dataFrame = try DataFrame(contentsOfCSVFile: nomefile_input_URL!)
let dataFrame_Media = dataFrame.grouped(by: "model_variable_code").means("value", Double.self, order: .descending)
print(dataFrame_Media)

I get:

How can I modify the code to get a table that contains min(value) and max(value), as well as mean(value)?


问:
Xamarin Android app splash screen not working
I am learning the android development in visual studio 2022.

when i creating a splash screen, it splashes default Xamarin logo. can some have a look at the code and guide me with resolving this issue.

(https://i.stack.imgur.com/M3BKe.png)](https://i.stack.imgur.com/LHIuV.png)](https://i.stack.imgur.com/CV6O6.png)](https://i.stack.imgur.com/hMaA7.png)

i have tried lots of combinations available online like adding image path in splash.cs. it works but it was not full screen image, rather a very small image.


问:
When I change the input, it doesn't send the variables
When I try to change any input value, it doesn't send the variables information.

Ex:
When I just send it with the fields already filled in from the input, it works.

But when I change any field, everything goes empty.

LOG

OK:

```<code>{ id: '63aca9adeb91db1c46f32b23' }
{ period: 'teste', startId: '321' }
</code>```

WITH PROBLEM:

```<code>{ id: 'undefined' }
{}
</code>```

REACT

const { admin_users_token } = parseCookies();
const [loading, setLoading] = useState(false);
const [turma, setClassroom] = useState();

const handleChange = (f) => {
  setClassroom(f.target.value);
};

const handleSubmit = async (f) => {
  f.preventDefault();
  try {
    setLoading(true);
    const url = `${baseUrl}/api/novotec/classroom/edit/${turma._id}`;
    const { period, startId } = turma;
    const data = {
      period,
      startId,
    };
    const payload = {
      headers: { Authorization: admin_users_token },
    };
    const response = await axios.put(url, data, payload);
    toast.success(response.data.message, {
      style: {
        border: "1px solid #4BB543",
        padding: "16px",
        color: "#4BB543",
      },
      iconTheme: {
        primary: "#4BB543",
        secondary: "#FFFAEE",
      },
    });
  } catch (err) {
    let {
      response: {
        data: { message },
      },
    } = err;
    toast.error(message, {
      style: {
        border: "1px solid #ff0033",
        padding: "16px",
        color: "#ff0033",
      },
      iconTheme: {
        primary: "#ff0033",
        secondary: "#FFFAEE",
      },
    });
  } finally {
    setLoading(false);
  }
};
```
<h1>FORM</h1>
```{
  turma && (
    <form onSubmit={handleSubmit}>

        <input
          type="text"
          name="period"
          value={turma.period}
          onChange={handleChange}
        />

          <input
            type="text"
            name="startId"
            value={turma.startId}
            onChange={handleChange}
          />

        <button type="submit">Salvar</button>{" "}

    </form>
```
<h1>API</h1>
<pre class="lang-js prettyprint-override"><code>const handlePut = async (req, res) => {
  const { id } = req.query;
  const { period, startId } = req.body;

  try {
    const classe = await NovotecClassrooms.updateOne(
      {
        _id: id,
      },
      {
        period,
        startId,
      }
    );

    res.status(200).json({ message: "Turma atualizada com sucesso" });
  } catch (e) {
    res.status(400).json({
      error_code: "update_classrooms",
      message: e.message,
    });
  }
};
</code>```

I need to understand what I'm doing wrong, why it's not passing the changed input values.

Body:
When I try to change any input value, it doesn't send the variables information.

Ex:
When I just send it with the fields already filled in from the input, it works.

But when I change any field, everything goes empty.

LOG

OK:

{ id: '63aca9adeb91db1c46f32b23' }
{ period: 'teste', startId: '321' }

WITH PROBLEM:

{ id: 'undefined' }
{}

REACT

const { admin_users_token } = parseCookies();
const [loading, setLoading] = useState(false);
const [turma, setClassroom] = useState();

const handleChange = (f) => {
  setClassroom(f.target.value);
};

const handleSubmit = async (f) => {
  f.preventDefault();
  try {
    setLoading(true);
    const url = `${baseUrl}/api/novotec/classroom/edit/${turma._id}`;
    const { period, startId } = turma;
    const data = {
      period,
      startId,
    };
    const payload = {
      headers: { Authorization: admin_users_token },
    };
    const response = await axios.put(url, data, payload);
    toast.success(response.data.message, {
      style: {
        border: "1px solid #4BB543",
        padding: "16px",
        color: "#4BB543",
      },
      iconTheme: {
        primary: "#4BB543",
        secondary: "#FFFAEE",
      },
    });
  } catch (err) {
    let {
      response: {
        data: { message },
      },
    } = err;
    toast.error(message, {
      style: {
        border: "1px solid #ff0033",
        padding: "16px",
        color: "#ff0033",
      },
      iconTheme: {
        primary: "#ff0033",
        secondary: "#FFFAEE",
      },
    });
  } finally {
    setLoading(false);
  }
};

FORM

{
  turma && (
    <form onSubmit={handleSubmit}>

        <input
          type="text"
          name="period"
          value={turma.period}
          onChange={handleChange}
        />

          <input
            type="text"
            name="startId"
            value={turma.startId}
            onChange={handleChange}
          />

        <button type="submit">Salvar</button>{" "}

    </form>

API

const handlePut = async (req, res) => {
  const { id } = req.query;
  const { period, startId } = req.body;

  try {
    const classe = await NovotecClassrooms.updateOne(
      {
        _id: id,
      },
      {
        period,
        startId,
      }
    );

    res.status(200).json({ message: "Turma atualizada com sucesso" });
  } catch (e) {
    res.status(400).json({
      error_code: "update_classrooms",
      message: e.message,
    });
  }
};

I need to understand what I'm doing wrong, why it's not passing the changed input values.


问:
iqy file - selection section
I have the following iqy file:

```<code>https://foo.bar.com?sid=["sid"]

Selection=1
Formatting=None
</code>```

when I try to import it it asks for the sid parameter which is stored in another sheet. so far so good.

But I don't understand which parameter I have to enter on the Selection part. I tried 0, 1, "Table 1"... it does not seem to work. Selection=1 seems to pull the whole page

when I import the data manually using "get data from the web" I get the following tables:

the one that I am interested in is "Table 1"

Title: iqy file - selection section

Body:
I have the following iqy file:

https://foo.bar.com?sid=["sid"]

Selection=1
Formatting=None

when I try to import it it asks for the sid parameter which is stored in another sheet. so far so good.

But I don't understand which parameter I have to enter on the Selection part. I tried 0, 1, "Table 1"... it does not seem to work. Selection=1 seems to pull the whole page

when I import the data manually using "get data from the web" I get the following tables:

the one that I am interested in is "Table 1"


问:
ModuleNotFoundError when calling package script, but not when source module file is directly executed
I am new to Python, and I am practising with Poetry. This is the structure of my project:

```<code>.
├── README.md
├── package1
│   ├── __init__.py
│   ├── __main__.py
│   ├── module1.py
│   └── module2.py
├── poetry.lock
├── pyproject.toml
└── tests
    └── __init__.py
</code>```

and here are the files:

module1.py

""" module1 module. """

class Module1():
    def func1(self):
        print("module1.func1")
```
<p><code>module2.py</code></p>
<pre class="lang-py prettyprint-override"><code>""" module2 module. """
from module1 import Module1

class Module2(Module1):
    def func1(self):
        print("module2.func1")
</code>```

__main__.py

""" __main__ module """
from module1 import Module1
from module2 import Module2

def main():
    print("main!")
    module1 = Module1()
    module1.func1()
    module2 = Module2()
    module2.func1()

if __name__ == "__main__":
    main()
```
<p>Moreover, in file <code>pyproject.toml</code> I have the following section:</p>
<pre class="lang-ini prettyprint-override"><code>[tool.poetry.scripts]
package1 = "package1.__main__:__main__"
</code>```

After having called poetry shell (it actually just activates the virtual environment):

If I execute python package1/__main__.py, it works as expected:

```<code>main!
module1.func1
module2.func1
</code>```

If I execute poetry build, then pip install . and finally package1 I have the following error:

```<code>Traceback (most recent call last):
  File "/home/user/repos/package1/.venv/bin/package1", line 5, in <module>
    from package1.__main__ import __main__
  File "/home/user/repos/package1/package1/__main__.py", line 2, in <module>
    from module1 import Module1
ModuleNotFoundError: No module named 'module1'
</code>```

What is the correct way to import my modules in main file, in order to make it work in both cases? I already tried

from .module1 import Module1
from .module2 import Module2
```
<p>and</p>
<pre class="lang-py prettyprint-override"><code>from package1.module1 import Module1
from package1.module2 import Module2
</code>```

but no luck.

Body:
I am new to Python, and I am practising with Poetry. This is the structure of my project:

.
├── README.md
├── package1
│   ├── __init__.py
│   ├── __main__.py
│   ├── module1.py
│   └── module2.py
├── poetry.lock
├── pyproject.toml
└── tests
    └── __init__.py

and here are the files:

module1.py

""" module1 module. """

class Module1():
    def func1(self):
        print("module1.func1")

module2.py

""" module2 module. """
from module1 import Module1

class Module2(Module1):
    def func1(self):
        print("module2.func1")

__main__.py

""" __main__ module """
from module1 import Module1
from module2 import Module2

def main():
    print("main!")
    module1 = Module1()
    module1.func1()
    module2 = Module2()
    module2.func1()

if __name__ == "__main__":
    main()

Moreover, in file pyproject.toml I have the following section:

[tool.poetry.scripts]
package1 = "package1.__main__:__main__"

After having called poetry shell (it actually just activates the virtual environment):

If I execute python package1/__main__.py, it works as expected:

main!
module1.func1
module2.func1

If I execute poetry build, then pip install . and finally package1 I have the following error:

Traceback (most recent call last):
  File "/home/user/repos/package1/.venv/bin/package1", line 5, in <module>
    from package1.__main__ import __main__
  File "/home/user/repos/package1/package1/__main__.py", line 2, in <module>
    from module1 import Module1
ModuleNotFoundError: No module named 'module1'

What is the correct way to import my modules in main file, in order to make it work in both cases? I already tried

from .module1 import Module1
from .module2 import Module2

and

from package1.module1 import Module1
from package1.module2 import Module2

but no luck.


问:
Function does not work in MainActivity, but works in TextRecognizerActivity
I have a recogniseText() function which does text recognition using google ML Kit, placed in TextRecognizerActivity. Initially, I received an image from gallery in MainActivity.kt, and passed it with an intent to TextRecognizerActivity. Everything was working fine.

Then I deleted TextRecognizerActivity and placed the recogniseText() function in MainActivity itself. Now it always executes the addOnFailureListener block. The only thing that changed was the context that was passed to it. Before, the context was this@TextRecognizerActivity, and now the context is this@MainActivity.

```<code>public fun recognizeText(uri:Uri, context: Context): ArrayList<String>{
        var itemsPurchased = ArrayList<String>()

        val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
        val image = InputImage.fromFilePath(context,uri);
        val result = recognizer.process(image)
            .addOnSuccessListener { visionText ->
                itemsPurchased = receiptProcessor(BasicReceipt(),visionText)
            }
            .addOnFailureListener { e ->

            }
        return itemsPurchased
    }
</code>```

I debugged it. the image variable is populated, the uri is also populated correctly. The variable itemsPurchased is returned as an empty ArrayList.

Body:
I have a recogniseText() function which does text recognition using google ML Kit, placed in TextRecognizerActivity. Initially, I received an image from gallery in MainActivity.kt, and passed it with an intent to TextRecognizerActivity. Everything was working fine.

Then I deleted TextRecognizerActivity and placed the recogniseText() function in MainActivity itself. Now it always executes the addOnFailureListener block. The only thing that changed was the context that was passed to it. Before, the context was this@TextRecognizerActivity, and now the context is this@MainActivity.

public fun recognizeText(uri:Uri, context: Context): ArrayList<String>{
        var itemsPurchased = ArrayList<String>()

        val recognizer = TextRecognition.getClient(TextRecognizerOptions.DEFAULT_OPTIONS)
        val image = InputImage.fromFilePath(context,uri);
        val result = recognizer.process(image)
            .addOnSuccessListener { visionText ->
                itemsPurchased = receiptProcessor(BasicReceipt(),visionText)
            }
            .addOnFailureListener { e ->

            }
        return itemsPurchased
    }

I debugged it. the image variable is populated, the uri is also populated correctly. The variable itemsPurchased is returned as an empty ArrayList.


问:
React native fetch response bad characters
So i need to communicate with server. Here is my code

```<code>fetch('http://localhost:444/xml', {
    method: 'POST',
    headers: {
      'STW-Authorization': 'Basic YmFybmk6YmFybmkxNTY=',
      'Content-Type': 'text/xml',
    },
  })
  .then(response => {
    console.log(response.status)
    return response.text()
  })
  .then(data => {
    console.log(data)
  })
</code>```

And this prints badly encoded characters like �

Here is the result.

```<code><?xml version="1.0" encoding="Windows-1250"?>
<rsp:responsePack version="2.0" id="" state="error" programVersion="12003.3 (21.11.2018)" ico="" note="Nebol n�jden� �iadny s�bor pre spracovanie." xmlns:rsp="http://www.stormware.cz/schema/version_2/response.xsd" xmlns:rdc="http://www.stormware.cz/schema/version_2/documentresponse.xsd" xmlns:typ="http://www.stormware.cz/schema/version_2/type.xsd" xmlns:lst="http://www.stormware.cz/schema/version_2/list.xsd" xmlns:lStk="http://www.stormware.cz/schema/version_2/list_stock.xsd" xmlns:lAdb="http://www.stormware.cz/schema/version_2/list_addBook.xsd" xmlns:acu="http://www.stormware.cz/schema/version_2/accountingunit.xsd" xmlns:inv="http://www.stormware.cz/schema/version_2/invoice.xsd" xmlns:vch="http://www.stormware.cz/schema/version_2/voucher.xsd" xmlns:int="http://www.stormware.cz/schema/version_2/intDoc.xsd" xmlns:stk="http://www.stormware.cz/schema/version_2/stock.xsd" xmlns:ord="http://www.stormware.cz/schema/version_2/order.xsd" xmlns:ofr="http://www.stormware.cz/schema/version_2/offer.xsd" xmlns:enq="http://www.stormware.cz/schema/version_2/enquiry.xsd" xmlns:vyd="http://www.stormware.cz/schema/version_2/vydejka.xsd" xmlns:pri="http://www.stormware.cz/schema/version_2/prijemka.xsd" xmlns:bal="http://www.stormware.cz/schema/version_2/balance.xsd" xmlns:pre="http://www.stormware.cz/schema/version_2/prevodka.xsd" xmlns:vyr="http://www.stormware.cz/schema/version_2/vyroba.xsd" xmlns:pro="http://www.stormware.cz/schema/version_2/prodejka.xsd" xmlns:con="http://www.stormware.cz/schema/version_2/contract.xsd" xmlns:adb="http://www.stormware.cz/schema/version_2/addressbook.xsd" xmlns:prm="http://www.stormware.cz/schema/version_2/parameter.xsd" xmlns:lCon="http://www.stormware.cz/schema/version_2/list_contract.xsd" xmlns:ctg="http://www.stormware.cz/schema/version_2/category.xsd" xmlns:ipm="http://www.stormware.cz/schema/version_2/intParam.xsd" xmlns:str="http://www.stormware.cz/schema/version_2/storage.xsd" xmlns:idp="http://www.stormware.cz/schema/version_2/individualPrice.xsd" xmlns:sup="http://www.stormware.cz/schema/version_2/supplier.xsd" xmlns:prn="http://www.stormware.cz/schema/version_2/print.xsd" xmlns:sEET="http://www.stormware.cz/schema/version_2/sendEET.xsd" xmlns:act="http://www.stormware.cz/schema/version_2/accountancy.xsd" xmlns:bnk="http://www.stormware.cz/schema/version_2/bank.xsd" xmlns:sto="http://www.stormware.cz/schema/version_2/store.xsd" xmlns:grs="http://www.stormware.cz/schema/version_2/groupStocks.xsd" xmlns:acp="http://www.stormware.cz/schema/version_2/actionPrice.xsd" xmlns:csh="http://www.stormware.cz/schema/version_2/cashRegister.xsd" xmlns:bka="http://www.stormware.cz/schema/version_2/bankAccount.xsd" xmlns:ilt="http://www.stormware.cz/schema/version_2/inventoryLists.xsd" xmlns:nms="http://www.stormware.cz/schema/version_2/numericalSeries.xsd" xmlns:pay="http://www.stormware.cz/schema/version_2/payment.xsd" xmlns:mKasa="http://www.stormware.cz/schema/version_2/mKasa.xsd" xmlns:gdp="http://www.stormware.cz/schema/version_2/GDPR.xsd" xmlns:ftr="http://www.stormware.cz/schema/version_2/filter.xsd"></rsp:responsePack>
</code>```

The note text should be

```<code>Nebol nájdené žiadny súbor pre spracovanie.
</code>```

Please help me found out the answer.

Body:
So i need to communicate with server. Here is my code

fetch('http://localhost:444/xml', {
    method: 'POST',
    headers: {
      'STW-Authorization': 'Basic YmFybmk6YmFybmkxNTY=',
      'Content-Type': 'text/xml',
    },
  })
  .then(response => {
    console.log(response.status)
    return response.text()
  })
  .then(data => {
    console.log(data)
  })

And this prints badly encoded characters like �

Here is the result.

<?xml version="1.0" encoding="Windows-1250"?>
<rsp:responsePack version="2.0" id="" state="error" programVersion="12003.3 (21.11.2018)" ico="" note="Nebol n�jden� �iadny s�bor pre spracovanie." xmlns:rsp="http://www.stormware.cz/schema/version_2/response.xsd" xmlns:rdc="http://www.stormware.cz/schema/version_2/documentresponse.xsd" xmlns:typ="http://www.stormware.cz/schema/version_2/type.xsd" xmlns:lst="http://www.stormware.cz/schema/version_2/list.xsd" xmlns:lStk="http://www.stormware.cz/schema/version_2/list_stock.xsd" xmlns:lAdb="http://www.stormware.cz/schema/version_2/list_addBook.xsd" xmlns:acu="http://www.stormware.cz/schema/version_2/accountingunit.xsd" xmlns:inv="http://www.stormware.cz/schema/version_2/invoice.xsd" xmlns:vch="http://www.stormware.cz/schema/version_2/voucher.xsd" xmlns:int="http://www.stormware.cz/schema/version_2/intDoc.xsd" xmlns:stk="http://www.stormware.cz/schema/version_2/stock.xsd" xmlns:ord="http://www.stormware.cz/schema/version_2/order.xsd" xmlns:ofr="http://www.stormware.cz/schema/version_2/offer.xsd" xmlns:enq="http://www.stormware.cz/schema/version_2/enquiry.xsd" xmlns:vyd="http://www.stormware.cz/schema/version_2/vydejka.xsd" xmlns:pri="http://www.stormware.cz/schema/version_2/prijemka.xsd" xmlns:bal="http://www.stormware.cz/schema/version_2/balance.xsd" xmlns:pre="http://www.stormware.cz/schema/version_2/prevodka.xsd" xmlns:vyr="http://www.stormware.cz/schema/version_2/vyroba.xsd" xmlns:pro="http://www.stormware.cz/schema/version_2/prodejka.xsd" xmlns:con="http://www.stormware.cz/schema/version_2/contract.xsd" xmlns:adb="http://www.stormware.cz/schema/version_2/addressbook.xsd" xmlns:prm="http://www.stormware.cz/schema/version_2/parameter.xsd" xmlns:lCon="http://www.stormware.cz/schema/version_2/list_contract.xsd" xmlns:ctg="http://www.stormware.cz/schema/version_2/category.xsd" xmlns:ipm="http://www.stormware.cz/schema/version_2/intParam.xsd" xmlns:str="http://www.stormware.cz/schema/version_2/storage.xsd" xmlns:idp="http://www.stormware.cz/schema/version_2/individualPrice.xsd" xmlns:sup="http://www.stormware.cz/schema/version_2/supplier.xsd" xmlns:prn="http://www.stormware.cz/schema/version_2/print.xsd" xmlns:sEET="http://www.stormware.cz/schema/version_2/sendEET.xsd" xmlns:act="http://www.stormware.cz/schema/version_2/accountancy.xsd" xmlns:bnk="http://www.stormware.cz/schema/version_2/bank.xsd" xmlns:sto="http://www.stormware.cz/schema/version_2/store.xsd" xmlns:grs="http://www.stormware.cz/schema/version_2/groupStocks.xsd" xmlns:acp="http://www.stormware.cz/schema/version_2/actionPrice.xsd" xmlns:csh="http://www.stormware.cz/schema/version_2/cashRegister.xsd" xmlns:bka="http://www.stormware.cz/schema/version_2/bankAccount.xsd" xmlns:ilt="http://www.stormware.cz/schema/version_2/inventoryLists.xsd" xmlns:nms="http://www.stormware.cz/schema/version_2/numericalSeries.xsd" xmlns:pay="http://www.stormware.cz/schema/version_2/payment.xsd" xmlns:mKasa="http://www.stormware.cz/schema/version_2/mKasa.xsd" xmlns:gdp="http://www.stormware.cz/schema/version_2/GDPR.xsd" xmlns:ftr="http://www.stormware.cz/schema/version_2/filter.xsd"></rsp:responsePack>

The note text should be

Nebol nájdené žiadny súbor pre spracovanie.

Please help me found out the answer.


问:
Alphabetical order in czech language
Is there any way how to sort by alphabetic order in certain language? For example, in Czech there are letters like "č" or "š" etc. and these characters are in end of the list, even in the alphabet they are at other place. I think that jetpack compose sorting it by ASCII code, but I don't know...

I have idea that I can create such a list with every letter from alphabet with correct order and then sort list of words by this list, but I don't think that is a best idea..

Title: Alphabetical order in czech language


问:
How do create a Erase/Restore brush feature in React.js Canvas
My React website has a tool which allows users to upload an image and remove the background.

How do I create a canvas which allows users to touch up the image by erasing and restoring parts of the image like (https://www.remove.bg/upload allows) until they have a perfectly removed background.


问:
setdiff() showing no data in r
Trying to use a decision tree to predict drug classes, when I set a seed and then set the sample_frac() for my training data & then use setdiff() for my test data im seeing my data within the training data but when i view my training data its showing no data? even tho its showing my decision tree.[[[enter image description here](https://i.stack.imgur.com/wkzA7.png)](https://i.stack.imgur.com/Ltn4v.png)](https://i.stack.imgur.com/nsTcM.png)</p>
```<code>data <- data %>% select(BP, Cholesterol, Drug)
view(data)
str(data)

data <- lapply(data, as.factor)
data <- lapply(data, as.numeric)
view(data)

data <- as.data.frame(data)
view(data)

set.seed(111)
data_training <- data %>% sample_frac(0.80)
data_test <- data %>% setdiff(data_training)

view(data_training)
view(data_test)

data_tree <- rpart(Drug ~ BP + Cholesterol, data=data_training, method = 'class')
plot(data_tree, uniform=TRUE, margin=0.5)
text(data_tree, use.n = TRUE)

data_test['Predicted'] <- predict(data_tree, data_test, type = 'class')
view(data_test)
</code>```

Title: setdiff() showing no data in r

Body:
Trying to use a decision tree to predict drug classes, when I set a seed and then set the sample_frac() for my training data & then use setdiff() for my test data im seeing my data within the training data but when i view my training data its showing no data? even tho its showing my decision tree.[[[enter image description here](https://i.stack.imgur.com/wkzA7.png)](https://i.stack.imgur.com/Ltn4v.png)](https://i.stack.imgur.com/nsTcM.png)

data <- data %>% select(BP, Cholesterol, Drug)
view(data)
str(data)

data <- lapply(data, as.factor)
data <- lapply(data, as.numeric)
view(data)

data <- as.data.frame(data)
view(data)

set.seed(111)
data_training <- data %>% sample_frac(0.80)
data_test <- data %>% setdiff(data_training)

view(data_training)
view(data_test)

data_tree <- rpart(Drug ~ BP + Cholesterol, data=data_training, method = 'class')
plot(data_tree, uniform=TRUE, margin=0.5)
text(data_tree, use.n = TRUE)

data_test['Predicted'] <- predict(data_tree, data_test, type = 'class')
view(data_test)


问:
getting unauthorized error creating ssl on nginx using certbot on AWS
I am trying to create a ssl for my nginx using certbot but I am getting this error.

I am using aws EC2 instance.

I created A record and pointed it to the ec2 instance

nginx

```<code>server {
        listen 80;
        listen [::]:80;

        root /var/www/html;

        server_name www.xxxxxx.ng xxxxxxx.name.ng;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                proxy_pass http://localhost:7500;    # or which other port your app runs on
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
    }
}
</code>```

Body:
I am trying to create a ssl for my nginx using certbot but I am getting this error.

I am using aws EC2 instance.

I created A record and pointed it to the ec2 instance

nginx

server {
        listen 80;
        listen [::]:80;

        root /var/www/html;

        server_name www.xxxxxx.ng xxxxxxx.name.ng;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                proxy_pass http://localhost:7500;    # or which other port your app runs on
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;
    }
}


问:
Creating a folder on android device internal storage does not working
For some reason i canot create a folder with a file on the internal storage. Even with the latest avaiable permission manager where i granted permission, it does not working.
I read an articel (Android 13 - READ_EXTERNAL_STORAGE_PERMISSION still usable) that there is no need for asking permission if targetSdkVersion 33 is set?

compileSdkVersion 33
minSdkVersion 20
targetSdkVersion 33

Ive set the permission in Android Manifest:

android:requestLegacyExternalStorage="true"

This is my code:

```<code>Future saveQrCode({String? qrCode})async{
  if(Platform.isIOS){
     final Directory appDocDir = await getApplicationDocumentsDirectory();
     final Directory appDocDirFolder =  Directory('${appDocDir.path}/account/');
    if ((!await appDocDirFolder.exists())) {
      appDocDirFolder.create();
      final File file = File('${appDocDirFolder.path}/qrCodeGenerated.txt');
      await file.writeAsString(qrCode!);
    }
  }else{
     final Directory? appDocDir = await getExternalStorageDirectory();
     final Directory appDocDirFolder =  Directory('${appDocDir?.path}/account/');
    if ((!await appDocDirFolder.exists())) {
      appDocDirFolder.create();
      final File file = File('${appDocDirFolder.path}/qrCodeGenerated.txt');
      await file.writeAsString(qrCode!);
    }
  }

}
</code>```

On Ios everything works fine, only android shows no effect at all
Does anyone have an idea?
If you need more information, let me know!
Thank you

Body:
For some reason i canot create a folder with a file on the internal storage. Even with the latest avaiable permission manager where i granted permission, it does not working.
I read an articel (Android 13 - READ_EXTERNAL_STORAGE_PERMISSION still usable) that there is no need for asking permission if targetSdkVersion 33 is set?

compileSdkVersion 33
minSdkVersion 20
targetSdkVersion 33

Ive set the permission in Android Manifest:

android:requestLegacyExternalStorage="true"

This is my code:

Future saveQrCode({String? qrCode})async{
  if(Platform.isIOS){
     final Directory appDocDir = await getApplicationDocumentsDirectory();
     final Directory appDocDirFolder =  Directory('${appDocDir.path}/account/');
    if ((!await appDocDirFolder.exists())) {
      appDocDirFolder.create();
      final File file = File('${appDocDirFolder.path}/qrCodeGenerated.txt');
      await file.writeAsString(qrCode!);
    }
  }else{
     final Directory? appDocDir = await getExternalStorageDirectory();
     final Directory appDocDirFolder =  Directory('${appDocDir?.path}/account/');
    if ((!await appDocDirFolder.exists())) {
      appDocDirFolder.create();
      final File file = File('${appDocDirFolder.path}/qrCodeGenerated.txt');
      await file.writeAsString(qrCode!);
    }
  }

}

On Ios everything works fine, only android shows no effect at all
Does anyone have an idea?
If you need more information, let me know!
Thank you


问:
TypeError: axios is not a function - By running test Nodejs
I am facing an error when I am trying to use post request using axios in nodejs.
It keep giving me error when I run test: TypeError: axios is not a function
It refers to line "const axios = require('axios');" in requestToken function.

service.js

```<code>    const axios = require('axios');
    const qs = require('qs');

    const requestToken = async (apiURL, reqBody) => {
      const postBody = qs.stringify({
        client_id: reqBody.client_id,
        client_secret: reqBody.client_secret,
        grant_type: reqBody.grant_type,
        'content-type': reqBody.content_type,
      });
      const postHeaders = {
        'Content-Type': 'application/json',
        'Content-Length': JSON.stringify(postBody).length,
        Host: new URL(apiURL).hostname,
        Connection: 'keep-alive',
      };
      const config = {
        method: 'POST',
        url: apiURL,
        headers: postHeaders,
        data: postBody,
      };
      const response = await axios(config); //it refers to the error here
      return response;
    };
</code>```

Here is my test file:
service.test.js

```<code>const qs = require('qs');
const axios = require('axios');
const {requestToken } = require('../../libs/service');

const apiConfig = {
  TOKEN_REQ_BODY: {
    client_id: 'client_id',
    client_secret: 'client_secret',
    grant_type: 'grant_type',
    content_type: 'content_type',
  },
  AUTH_BASE_URL: 'uri',
  TOKEN_HEADER: {
    appkey: 'appkey',
  },
  API_BASE_URL: 'API_BASE_URL',
};
const tokenAxiosCalledWith = {
  method: 'POST',
  url: apiConfig.AUTH_BASE_URL,
  headers: apiConfig.TOKEN_HEADER,
  data: qs.stringify({
    client_id: apiConfig.TOKEN_REQ_BODY.client_id,
    client_secret: apiConfig.TOKEN_REQ_BODY.client_secret,
    grant_type: apiConfig.TOKEN_REQ_BODY.grant_type,
    'content-type': apiConfig.TOKEN_REQ_BODY.content_type,
  }),
};
const accessToken = {
  data: {
    access_token: 'access_token',
  },
};
const eventData = {
  metadata: {
    method: 'POST',
    uri: 'uri',
  },
  uriparams: 'uriparams',
  payload: tokenAxiosCalledWith.data,
};
const requestHeaders = {
  Authorization: accessToken.data.access_token,
  appkey: apiConfig.TOKEN_HEADER.appkey,
  'content-type': 'application/json',
};
const reqBody = {
  method: eventData.metadata.method,
  baseURL: apiConfig.API_BASE_URL,
  url: eventData.metadata.uri,
  responseType: 'json',
  headers: requestHeaders,
  params: eventData.uriparams,
  data: eventData.payload,
};
jest.mock('axios', () => jest.fn(() => accessToken));

describe('API service', () => {
it('is called with requestToken', (done) => {
    /* eslint-disable no-unused-vars */
    requestToken('https://token', reqBody).then((response) => {
      expect(axios).toHaveBeenCalledTimes(1);
      done();})
      .catch((e) => {
        done(e);
        });
    });
}
</code>```

Can you help to fix this error?

Body:
I am facing an error when I am trying to use post request using axios in nodejs.
It keep giving me error when I run test: TypeError: axios is not a function
It refers to line "const axios = require('axios');" in requestToken function.

service.js

    const axios = require('axios');
    const qs = require('qs');

    const requestToken = async (apiURL, reqBody) => {
      const postBody = qs.stringify({
        client_id: reqBody.client_id,
        client_secret: reqBody.client_secret,
        grant_type: reqBody.grant_type,
        'content-type': reqBody.content_type,
      });
      const postHeaders = {
        'Content-Type': 'application/json',
        'Content-Length': JSON.stringify(postBody).length,
        Host: new URL(apiURL).hostname,
        Connection: 'keep-alive',
      };
      const config = {
        method: 'POST',
        url: apiURL,
        headers: postHeaders,
        data: postBody,
      };
      const response = await axios(config); //it refers to the error here
      return response;
    };

Here is my test file:
service.test.js

const qs = require('qs');
const axios = require('axios');
const {requestToken } = require('../../libs/service');

const apiConfig = {
  TOKEN_REQ_BODY: {
    client_id: 'client_id',
    client_secret: 'client_secret',
    grant_type: 'grant_type',
    content_type: 'content_type',
  },
  AUTH_BASE_URL: 'uri',
  TOKEN_HEADER: {
    appkey: 'appkey',
  },
  API_BASE_URL: 'API_BASE_URL',
};
const tokenAxiosCalledWith = {
  method: 'POST',
  url: apiConfig.AUTH_BASE_URL,
  headers: apiConfig.TOKEN_HEADER,
  data: qs.stringify({
    client_id: apiConfig.TOKEN_REQ_BODY.client_id,
    client_secret: apiConfig.TOKEN_REQ_BODY.client_secret,
    grant_type: apiConfig.TOKEN_REQ_BODY.grant_type,
    'content-type': apiConfig.TOKEN_REQ_BODY.content_type,
  }),
};
const accessToken = {
  data: {
    access_token: 'access_token',
  },
};
const eventData = {
  metadata: {
    method: 'POST',
    uri: 'uri',
  },
  uriparams: 'uriparams',
  payload: tokenAxiosCalledWith.data,
};
const requestHeaders = {
  Authorization: accessToken.data.access_token,
  appkey: apiConfig.TOKEN_HEADER.appkey,
  'content-type': 'application/json',
};
const reqBody = {
  method: eventData.metadata.method,
  baseURL: apiConfig.API_BASE_URL,
  url: eventData.metadata.uri,
  responseType: 'json',
  headers: requestHeaders,
  params: eventData.uriparams,
  data: eventData.payload,
};
jest.mock('axios', () => jest.fn(() => accessToken));

describe('API service', () => {
it('is called with requestToken', (done) => {
    /* eslint-disable no-unused-vars */
    requestToken('https://token', reqBody).then((response) => {
      expect(axios).toHaveBeenCalledTimes(1);
      done();})
      .catch((e) => {
        done(e);
        });
    });
}

Can you help to fix this error?