问:
Javascript / Node JS : "object is not extensible"
I'm trying to write unit test with Mocha and Mongoose using the Mockgoose library to avoid modifying my real database.
I use the code coming from the documentation https://www.npmjs.com/package/mockgoose under ES6 Example, but I get this error when running the test :

```<code>TypeError: Cannot add property mocked, object is not extensible
    at new Mockgoose (...mycodefolder\node_modules\mockgoose\built\mockgoose.js:18:33)
    at file:path-to-the-line-below-causing-the-error
</code>```

Here is my code in the test.js file :

```<code>import * as mongoose from 'mongoose';
import {Mockgoose} from 'mockgoose';
import connectDB from '../Database.js'; // A custom module to connect to my MongoDB database

let mockgoose = new Mockgoose(mongoose); // This line generates an error

// In the documentation, it is written :
// let mockgoose: Mockgoose = new Mockgoose(mongoose)
// but I'm not using Typescript so I deleted the ': Mockgoose' part

mockgoose.prepareStorage().then(() => {
    connectDB()
});
</code>```

Thanks for your help :)

Body:
I'm trying to write unit test with Mocha and Mongoose using the Mockgoose library to avoid modifying my real database.
I use the code coming from the documentation https://www.npmjs.com/package/mockgoose under ES6 Example, but I get this error when running the test :

TypeError: Cannot add property mocked, object is not extensible
    at new Mockgoose (...mycodefolder\node_modules\mockgoose\built\mockgoose.js:18:33)
    at file:path-to-the-line-below-causing-the-error

Here is my code in the test.js file :

import * as mongoose from 'mongoose';
import {Mockgoose} from 'mockgoose';
import connectDB from '../Database.js'; // A custom module to connect to my MongoDB database

let mockgoose = new Mockgoose(mongoose); // This line generates an error

// In the documentation, it is written :
// let mockgoose: Mockgoose = new Mockgoose(mongoose)
// but I'm not using Typescript so I deleted the ': Mockgoose' part

mockgoose.prepareStorage().then(() => {
    connectDB()
});

Thanks for your help :)


来源: stackexchange

问:
How to write SVR loss fuction?
Recently I am studying SVM models. And I have understood the mathematics of SVC and SVR.
But I have some confusions on the issue of loss functions.
For example SVCLoss:

SVC Loss function is here

SVCLoss = \sum_{i} a_i - 0.5 \sum_{i,j} a_i a_j y_{i} y_{j} K_(x_i, x_j)

```<code># Train a quantum support vector classifier
svc = SVC()
svc.fit(samples, labels)

# Get dual coefficients
dual_coefs = svc.dual_coef_[0]

# Get support vectors
support_vecs = svc.support_

# Prune kernel matrix of non-support-vector entries
kmatrix = kmatrix[support_vecs, :][:, support_vecs]

# Calculate loss
loss = np.sum(np.abs(dual_coefs)) - (0.5 * (dual_coefs.T @ kmatrix @ dual_coefs))
</code>```

And I am working to write out the loss function code for SVR in python, but I met some unsolved problem.

SVR Loss fuction

```<code># Train a quantum support vector regressor
svr = SVR(kernel="rbf")
svr.fit(samples, labels)
# Get dual coefficients
dual_coefs = svr.dual_coef_[0]
# Get support vectors
support_vecs = svr.support_
# Prune kernel matrix of non-support-vector entries
kmatrix = kmatrix[support_vecs, :][:, support_vecs]
# Calculate loss
loss = ???
</code>```

I wonder how to represent dual_coefs and support_vecs in SVR_Loss?

How to write SVR_Loss in Python according to advanced code?

I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.

Thanks in advance.

I have tired to work out the following problems for a long time.

I wonder how to represent dual_coefs and support_vecs in SVR_Loss?

How to write SVR_Loss in Python according to advanced code?

ContentLicense: CC BY-SA 4.0

Title: How to write SVR loss fuction?

Body:
Recently I am studying SVM models. And I have understood the mathematics of SVC and SVR.
But I have some confusions on the issue of loss functions.
For example SVCLoss:

SVC Loss function is here

SVCLoss = \sum_{i} a_i - 0.5 \sum_{i,j} a_i a_j y_{i} y_{j} K_(x_i, x_j)

# Train a quantum support vector classifier
svc = SVC()
svc.fit(samples, labels)

# Get dual coefficients
dual_coefs = svc.dual_coef_[0]

# Get support vectors
support_vecs = svc.support_

# Prune kernel matrix of non-support-vector entries
kmatrix = kmatrix[support_vecs, :][:, support_vecs]

# Calculate loss
loss = np.sum(np.abs(dual_coefs)) - (0.5 * (dual_coefs.T @ kmatrix @ dual_coefs))

And I am working to write out the loss function code for SVR in python, but I met some unsolved problem.

SVR Loss fuction

# Train a quantum support vector regressor
svr = SVR(kernel="rbf")
svr.fit(samples, labels)
# Get dual coefficients
dual_coefs = svr.dual_coef_[0]
# Get support vectors
support_vecs = svr.support_
# Prune kernel matrix of non-support-vector entries
kmatrix = kmatrix[support_vecs, :][:, support_vecs]
# Calculate loss
loss = ???

I wonder how to represent dual_coefs and support_vecs in SVR_Loss?

How to write SVR_Loss in Python according to advanced code?

I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.

Thanks in advance.

I have tired to work out the following problems for a long time.

I wonder how to represent dual_coefs and support_vecs in SVR_Loss?

How to write SVR_Loss in Python according to advanced code?


问:
After upgrade PHP to 7.4 to 8.1 version the sites are not up
We have one application that is hosted in AWS Ec2 instance and the operating system is centos 7.

The application is based on drupal framework. previously our server has PHP 7.4 installed. Last week we upgrade PHP version to 7.4 to 8.1.13.

We follow the below mention steps to upgrade the php.

```<code>sudo yum-config-manager --disable 'remi-php*'
sudo yum-config-manager --enable remi-php81
sudo yum -y install php php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json,opcache,redis,memcache}
</code>```

After that from server when we run php -v command we see the updated version 8.1.13 but from browser it show

```<code>handle($request);$response->send();$Kernel->terminate($request,$response);
</code>```

My observation :

During the upgrade I find below warning massages.

PHP Warning:  Failed loading Zend extension 'opcache' (tried: /usr/lib64/php/modules/opcache (/usr/lib64/php/modules/opcache: cannot open shared object file: No such file or directory)

PHP Warning:  PHP Startup: bcmath: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930

PHP Warning:  PHP Startup: Unable to load dynamic library 'dom' (tried: /usr/lib64/php/modules/dom (/usr/lib64/php/modules/dom: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/dom.so (/usr/lib64/php/modules/dom.so: undefined symbol: zend_wrong_parameters_none_exception)) in Unknown on line 0

PHP Warning:  PHP Startup: gd: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930

PHP Warning:  PHP Startup: Unable to load dynamic library 'json' (tried: /usr/lib64/php/modules/json (/usr/lib64/php/modules/json: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/json.so (/usr/lib64/php/modules/json.so: undefined symbol: _call_user_function_ex)) in Unknown on line 0

PHP Warning:  PHP Startup: mbstring: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930

PHP Warning:  PHP Startup: mysqlnd: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930
These options need to match

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo' (tried: /usr/lib64/php/modules/pdo (/usr/lib64/php/modules/pdo: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/pdo.so (/usr/lib64/php/modules/pdo.so: undefined symbol: zend_wrong_parameters_count_exception)) in Unknown on line 0

PHP Warning:  PHP Startup: posix: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930

PHP Warning:  PHP Startup: Unable to load dynamic library 'simplexml' (tried: /usr/lib64/php/modules/simplexml (/usr/lib64/php/modules/simplexml: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/simplexml.so (/usr/lib64/php/modules/simplexml.so: undefined symbol: zend_parse_parameters_throw)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'sodium' (tried: /usr/lib64/php/modules/sodium (/usr/lib64/php/modules/sodium: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/sodium.so (/usr/lib64/php/modules/sodium.so: undefined symbol: zend_parse_parameters_throw)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlite3' (tried: /usr/lib64/php/modules/sqlite3 (/usr/lib64/php/modules/sqlite3: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/sqlite3.so (/usr/lib64/php/modules/sqlite3.so: undefined symbol: zend_parse_parameters_throw)) in Unknown on line 0

PHP Warning:  PHP Startup: sysvmsg: Unable to initialize module

Module compiled with module API=20190902

PHP    compiled with module API=20200930
These options need to match
in Unknown on line 0

PHP Warning:  PHP Startup: sysvsem: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930
These options need to match
in Unknown on line 0

PHP Warning:  PHP Startup: sysvshm: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930
These options need to match
in Unknown on line 0

PHP Warning:  PHP Startup: xml: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930
These options need to match

PHP Warning:  PHP Startup: Unable to load dynamic library 'xsl' (tried: /usr/lib64/php/modules/xsl (/usr/lib64/php/modules/xsl: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/xsl.so (/usr/lib64/php/modules/xsl.so: undefined symbol: dom_node_class_entry)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli' (tried: /usr/lib64/php/modules/mysqli (/usr/lib64/php/modules/mysqli: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/mysqli.so (/usr/lib64/php/modules/mysqli.so: undefined symbol: mysqlnd_global_stats)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/lib64/php/modules/pdo_mysql (/usr/lib64/php/modules/pdo_mysql: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/pdo_mysql.so (/usr/lib64/php/modules/pdo_mysql.so: undefined symbol: mysqlnd_allocator)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: /usr/lib64/php/modules/pdo_sqlite (/usr/lib64/php/modules/pdo_sqlite: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/pdo_sqlite.so (/usr/lib64/php/modules/pdo_sqlite.so: undefined symbol: php_pdo_unregister_driver)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'xmlreader' (tried: /usr/lib64/php/modules/xmlreader (/usr/lib64/php/modules/xmlreader: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/xmlreader.so (/usr/lib64/php/modules/xmlreader.so: undefined symbol: dom_node_class_entry)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/lib64/php/modules/zip.so (/usr/lib64/php/modules/zip.so: undefined symbol: _call_user_function_ex), /usr/lib64/php/modules/zip.so.so (/usr/lib64/php/modules/zip.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'igbinary.so' (tried: /usr/lib64/php/modules/igbinary.so (/usr/lib64/php/modules/igbinary.so: undefined symbol: _call_user_function_ex), /usr/lib64/php/modules/igbinary.so.so (/usr/lib64/php/modules/igbinary.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'memcache.so' (tried: /usr/lib64/php/modules/memcache.so (/usr/lib64/php/modules/memcache.so: undefined symbol: _call_user_function_ex), /usr/lib64/php/modules/memcache.so.so (/usr/lib64/php/modules/memcache.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib64/php/modules/redis.so (/usr/lib64/php/modules/redis.so: undefined symbol: igbinary_serialize), /usr/lib64/php/modules/redis.so.so (/usr/lib64/php/modules/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP Warning:  foreach() argument must be of type array|object, null given in /usr/share/pear/PEAR/Command.php on line 249

PHP Warning:  Trying to access array offset on value of type null in /usr/share/pear/PEAR/Installer/Role.php on line 250

PHP Warning:  Undefined array key "honorsbaseinstall" in /usr/share/pear/PEAR/Installer/Role.php on line 173

PHP Warning:  Undefined array key "installable" in /usr/share/pear/PEAR/Installer/Role.php on line 139

PHP Warning:  Undefined array key "phpfile" in /usr/share/pear/PEAR/Installer/Role.php on line 204

PHP Warning:  Undefined array key "config_vars" in /usr/share/pear/PEAR/Installer/Role.php on line 46

PHP Warning:  foreach() argument must be of type array|object, null given in /usr/share/pear/PEAR/Command.php on line 249

and when I check /usr/lib64/php/modules path I find these PHP modules.

```<code>bcmath.so    curl.so      ftp.so      igbinary.so  mysqli.so     pdo.so         redis.so      sodium.so   sysvshm.so    xmlwriter.so
bz2.so       dom.so       gd.so       mbstring.so  mysqlnd.so    pdo_sqlite.so  shmop.so      sqlite3.so  tokenizer.so  xsl.so
calendar.so  exif.so      gettext.so  memcache.so  opcache.so    phar.so        simplexml.so  sysvmsg.so  xmlreader.so  zip.so
ctype.so     fileinfo.so  iconv.so    msgpack.so   pdo_mysql.so  posix.so       sockets.so    sysvsem.so  xml.so
</code>```

Please help me to solve the issue why from browser I see this error

```<code>handle($request);$response->send();$Kernel->terminate($request,$response);
</code>```

Body:
We have one application that is hosted in AWS Ec2 instance and the operating system is centos 7.

The application is based on drupal framework. previously our server has PHP 7.4 installed. Last week we upgrade PHP version to 7.4 to 8.1.13.

We follow the below mention steps to upgrade the php.

sudo yum-config-manager --disable 'remi-php*'
sudo yum-config-manager --enable remi-php81
sudo yum -y install php php-{cli,fpm,mysqlnd,zip,devel,gd,mbstring,curl,xml,pear,bcmath,json,opcache,redis,memcache}

After that from server when we run php -v command we see the updated version 8.1.13 but from browser it show

handle($request);$response->send();$Kernel->terminate($request,$response);

My observation :

During the upgrade I find below warning massages.

PHP Warning:  Failed loading Zend extension 'opcache' (tried: /usr/lib64/php/modules/opcache (/usr/lib64/php/modules/opcache: cannot open shared object file: No such file or directory)

PHP Warning:  PHP Startup: bcmath: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930

PHP Warning:  PHP Startup: Unable to load dynamic library 'dom' (tried: /usr/lib64/php/modules/dom (/usr/lib64/php/modules/dom: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/dom.so (/usr/lib64/php/modules/dom.so: undefined symbol: zend_wrong_parameters_none_exception)) in Unknown on line 0

PHP Warning:  PHP Startup: gd: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930

PHP Warning:  PHP Startup: Unable to load dynamic library 'json' (tried: /usr/lib64/php/modules/json (/usr/lib64/php/modules/json: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/json.so (/usr/lib64/php/modules/json.so: undefined symbol: _call_user_function_ex)) in Unknown on line 0

PHP Warning:  PHP Startup: mbstring: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930

PHP Warning:  PHP Startup: mysqlnd: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930
These options need to match

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo' (tried: /usr/lib64/php/modules/pdo (/usr/lib64/php/modules/pdo: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/pdo.so (/usr/lib64/php/modules/pdo.so: undefined symbol: zend_wrong_parameters_count_exception)) in Unknown on line 0

PHP Warning:  PHP Startup: posix: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930

PHP Warning:  PHP Startup: Unable to load dynamic library 'simplexml' (tried: /usr/lib64/php/modules/simplexml (/usr/lib64/php/modules/simplexml: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/simplexml.so (/usr/lib64/php/modules/simplexml.so: undefined symbol: zend_parse_parameters_throw)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'sodium' (tried: /usr/lib64/php/modules/sodium (/usr/lib64/php/modules/sodium: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/sodium.so (/usr/lib64/php/modules/sodium.so: undefined symbol: zend_parse_parameters_throw)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlite3' (tried: /usr/lib64/php/modules/sqlite3 (/usr/lib64/php/modules/sqlite3: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/sqlite3.so (/usr/lib64/php/modules/sqlite3.so: undefined symbol: zend_parse_parameters_throw)) in Unknown on line 0

PHP Warning:  PHP Startup: sysvmsg: Unable to initialize module

Module compiled with module API=20190902

PHP    compiled with module API=20200930
These options need to match
in Unknown on line 0

PHP Warning:  PHP Startup: sysvsem: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930
These options need to match
in Unknown on line 0

PHP Warning:  PHP Startup: sysvshm: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930
These options need to match
in Unknown on line 0

PHP Warning:  PHP Startup: xml: Unable to initialize module
Module compiled with module API=20190902
PHP    compiled with module API=20200930
These options need to match

PHP Warning:  PHP Startup: Unable to load dynamic library 'xsl' (tried: /usr/lib64/php/modules/xsl (/usr/lib64/php/modules/xsl: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/xsl.so (/usr/lib64/php/modules/xsl.so: undefined symbol: dom_node_class_entry)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'mysqli' (tried: /usr/lib64/php/modules/mysqli (/usr/lib64/php/modules/mysqli: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/mysqli.so (/usr/lib64/php/modules/mysqli.so: undefined symbol: mysqlnd_global_stats)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/lib64/php/modules/pdo_mysql (/usr/lib64/php/modules/pdo_mysql: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/pdo_mysql.so (/usr/lib64/php/modules/pdo_mysql.so: undefined symbol: mysqlnd_allocator)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_sqlite' (tried: /usr/lib64/php/modules/pdo_sqlite (/usr/lib64/php/modules/pdo_sqlite: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/pdo_sqlite.so (/usr/lib64/php/modules/pdo_sqlite.so: undefined symbol: php_pdo_unregister_driver)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'xmlreader' (tried: /usr/lib64/php/modules/xmlreader (/usr/lib64/php/modules/xmlreader: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/xmlreader.so (/usr/lib64/php/modules/xmlreader.so: undefined symbol: dom_node_class_entry)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/lib64/php/modules/zip.so (/usr/lib64/php/modules/zip.so: undefined symbol: _call_user_function_ex), /usr/lib64/php/modules/zip.so.so (/usr/lib64/php/modules/zip.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'igbinary.so' (tried: /usr/lib64/php/modules/igbinary.so (/usr/lib64/php/modules/igbinary.so: undefined symbol: _call_user_function_ex), /usr/lib64/php/modules/igbinary.so.so (/usr/lib64/php/modules/igbinary.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'memcache.so' (tried: /usr/lib64/php/modules/memcache.so (/usr/lib64/php/modules/memcache.so: undefined symbol: _call_user_function_ex), /usr/lib64/php/modules/memcache.so.so (/usr/lib64/php/modules/memcache.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP Warning:  PHP Startup: Unable to load dynamic library 'redis.so' (tried: /usr/lib64/php/modules/redis.so (/usr/lib64/php/modules/redis.so: undefined symbol: igbinary_serialize), /usr/lib64/php/modules/redis.so.so (/usr/lib64/php/modules/redis.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

PHP Warning:  foreach() argument must be of type array|object, null given in /usr/share/pear/PEAR/Command.php on line 249

PHP Warning:  Trying to access array offset on value of type null in /usr/share/pear/PEAR/Installer/Role.php on line 250

PHP Warning:  Undefined array key "honorsbaseinstall" in /usr/share/pear/PEAR/Installer/Role.php on line 173

PHP Warning:  Undefined array key "installable" in /usr/share/pear/PEAR/Installer/Role.php on line 139

PHP Warning:  Undefined array key "phpfile" in /usr/share/pear/PEAR/Installer/Role.php on line 204

PHP Warning:  Undefined array key "config_vars" in /usr/share/pear/PEAR/Installer/Role.php on line 46

PHP Warning:  foreach() argument must be of type array|object, null given in /usr/share/pear/PEAR/Command.php on line 249

and when I check /usr/lib64/php/modules path I find these PHP modules.

bcmath.so    curl.so      ftp.so      igbinary.so  mysqli.so     pdo.so         redis.so      sodium.so   sysvshm.so    xmlwriter.so
bz2.so       dom.so       gd.so       mbstring.so  mysqlnd.so    pdo_sqlite.so  shmop.so      sqlite3.so  tokenizer.so  xsl.so
calendar.so  exif.so      gettext.so  memcache.so  opcache.so    phar.so        simplexml.so  sysvmsg.so  xmlreader.so  zip.so
ctype.so     fileinfo.so  iconv.so    msgpack.so   pdo_mysql.so  posix.so       sockets.so    sysvsem.so  xml.so

Please help me to solve the issue why from browser I see this error

handle($request);$response->send();$Kernel->terminate($request,$response);


问:
chrome extensions : The difference in the number of headers on "onBeforeSendHeaders" at the manifest 3 and 2
I listen to the headers of the requests and there is a difference in the number of headers in the same address, which has disturbed my work.

manifest 2

```<code>manifest.json
</code>```
```<code>  "manifest_version": 2,
  "name": "my-exteintion",
  "permissions": [
    "cookies",
    "storage",
    "tabs",
    "webRequest",
    "webRequestBlocking",
    "*://*.linkedin.com/*"
  ],
</code>```

manifest 3

```<code>manifest.json
</code>```
```<code>  "manifest_version": 3,
    "name": "mv3",
    "options_page": "/src/html/popup.html",
    "action": {
        "browser_style": true,
        "default_icon": {
            "16": "/src/assets/icon.png",
            "32": "/src/assets/icon.png"
        },
        "default_title": "Send your selected CVs in your account"
    },
    "permissions": [
        "cookies",
        "storage",
        "tabs",
        "webRequest"
    ],
    "host_permissions": [
        "*://*/*"
    ],
    "background": {
        "service_worker": "service-worker.js"
    },
    "content_scripts": [
        {
            "js": [
                "/src/js2/foreground.js"
            ],
            "matches": [
                "*://*/*"

            ]
        }
    ]
}
</code>```
```<code>httpTrackerConstants.js
</code>```
```<code>const httpTracker = {
  browser: chrome,
  isFF: chrome ? true : false,
  PAGE_PATH: "/src/html/popup.html",
  STORAGE_KEY_EXCLUDE_PATTERN: "httpTrackerGlobalExcludePatterns",
  STORAGE_KEY_INCLUDE_PATTERN: "httpTracker_GlobalIncludePatterns",
  STORAGE_KEY_BLOCK_PATTERN: "httpTracker_GlobalBlockPatterns",
  STORAGE_KEY_MASK_PATTERN: "httpTracker_GlobalMaskPatterns",
  STORAGE_KEY_OPEN_ADDON_IN_TAB: "httpTracker_OpenAddonInTab"
};
</code>```
```<code>load on popup.html
httpTrackerDomEvents.js
</code>```
```<code>const reqHeadersBlocking = httpTracker.isFF ? ["requestHeaders"] : ["requestHeaders", "extraHeaders"];//
const r = chrome.browser.webRequest;

r.onBeforeSendHeaders.addListener(
  function (details) {

    console.log("requestHeaders:", details.requestHeaders)

    return { requestHeaders: details.requestHeaders };
  }, trackUrls, reqHeadersBlocking
);
</code>```

Result

result in maifest 2

result in maifest 3

manifest 2 result

```<code>{name: 'sec-ch-ua', value: '"Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"'}
{name: 'Accept', value: 'application/json, text/javascript, */*; q=0.01'}
{name: 'Content-Type', value: 'application/x-www-form-urlencoded; charset=UTF-8'}
{name: 'X-Requested-With', value: 'XMLHttpRequest'}
{name: 'sec-ch-ua-mobile', value: '?0'}
{name: 'User-Agent', value: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWeb…KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'}
{name: 'sec-ch-ua-platform', value: '"Windows"'}
{name: 'Origin', value: '*********'}
{name: 'Sec-Fetch-Site', value: 'same-origin'}
{name: 'Sec-Fetch-Mode', value: 'cors'}
{name: 'Sec-Fetch-Dest', value: 'empty'}
{name: 'Referer', value: '*********'}
{name: 'Accept-Encoding', value: 'gzip, deflate, br'}
{name: 'Accept-Language', value: 'en-US,en;q=0.9,fa-IR;q=0.8,fa;q=0.7'}
{name: 'Cookie', value: '_ga=GA1.2.275275000.1655266027; xcrf=8013511655703….1529841326.1670228884; _gat_gtag_UA_33059988_5=1'}
</code>```

manifest 3 result

```<code>{name: 'sec-ch-ua', value: '"Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"'}
{name: 'Accept', value: 'application/json, text/javascript, */*; q=0.01'}
{name: 'Content-Type', value: 'application/x-www-form-urlencoded; charset=UTF-8'}
{name: 'X-Requested-With', value: 'XMLHttpRequest'}
{name: 'sec-ch-ua-mobile', value: '?0'}
{name: 'User-Agent', value: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWeb…KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'}
{name: 'sec-ch-ua-platform', value: '"Windows"'}
</code>```

Some headers are missing

i want more header like Cookie form request

tnx a lot

Body:
I listen to the headers of the requests and there is a difference in the number of headers in the same address, which has disturbed my work.

manifest 2

manifest.json

  "manifest_version": 2,
  "name": "my-exteintion",
  "permissions": [
    "cookies",
    "storage",
    "tabs",
    "webRequest",
    "webRequestBlocking",
    "*://*.linkedin.com/*"
  ],

manifest 3

manifest.json

  "manifest_version": 3,
    "name": "mv3",
    "options_page": "/src/html/popup.html",
    "action": {
        "browser_style": true,
        "default_icon": {
            "16": "/src/assets/icon.png",
            "32": "/src/assets/icon.png"
        },
        "default_title": "Send your selected CVs in your account"
    },
    "permissions": [
        "cookies",
        "storage",
        "tabs",
        "webRequest"
    ],
    "host_permissions": [
        "*://*/*"
    ],
    "background": {
        "service_worker": "service-worker.js"
    },
    "content_scripts": [
        {
            "js": [
                "/src/js2/foreground.js"
            ],
            "matches": [
                "*://*/*"

            ]
        }
    ]
}

httpTrackerConstants.js

const httpTracker = {
  browser: chrome,
  isFF: chrome ? true : false,
  PAGE_PATH: "/src/html/popup.html",
  STORAGE_KEY_EXCLUDE_PATTERN: "httpTrackerGlobalExcludePatterns",
  STORAGE_KEY_INCLUDE_PATTERN: "httpTracker_GlobalIncludePatterns",
  STORAGE_KEY_BLOCK_PATTERN: "httpTracker_GlobalBlockPatterns",
  STORAGE_KEY_MASK_PATTERN: "httpTracker_GlobalMaskPatterns",
  STORAGE_KEY_OPEN_ADDON_IN_TAB: "httpTracker_OpenAddonInTab"
};

load on popup.html
httpTrackerDomEvents.js

const reqHeadersBlocking = httpTracker.isFF ? ["requestHeaders"] : ["requestHeaders", "extraHeaders"];//
const r = chrome.browser.webRequest;

r.onBeforeSendHeaders.addListener(
  function (details) {

    console.log("requestHeaders:", details.requestHeaders)

    return { requestHeaders: details.requestHeaders };
  }, trackUrls, reqHeadersBlocking
);

Result

result in maifest 2

result in maifest 3

manifest 2 result

{name: 'sec-ch-ua', value: '"Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"'}
{name: 'Accept', value: 'application/json, text/javascript, */*; q=0.01'}
{name: 'Content-Type', value: 'application/x-www-form-urlencoded; charset=UTF-8'}
{name: 'X-Requested-With', value: 'XMLHttpRequest'}
{name: 'sec-ch-ua-mobile', value: '?0'}
{name: 'User-Agent', value: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWeb…KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'}
{name: 'sec-ch-ua-platform', value: '"Windows"'}
{name: 'Origin', value: '*********'}
{name: 'Sec-Fetch-Site', value: 'same-origin'}
{name: 'Sec-Fetch-Mode', value: 'cors'}
{name: 'Sec-Fetch-Dest', value: 'empty'}
{name: 'Referer', value: '*********'}
{name: 'Accept-Encoding', value: 'gzip, deflate, br'}
{name: 'Accept-Language', value: 'en-US,en;q=0.9,fa-IR;q=0.8,fa;q=0.7'}
{name: 'Cookie', value: '_ga=GA1.2.275275000.1655266027; xcrf=8013511655703….1529841326.1670228884; _gat_gtag_UA_33059988_5=1'}

manifest 3 result

{name: 'sec-ch-ua', value: '"Not?A_Brand";v="8", "Chromium";v="108", "Google Chrome";v="108"'}
{name: 'Accept', value: 'application/json, text/javascript, */*; q=0.01'}
{name: 'Content-Type', value: 'application/x-www-form-urlencoded; charset=UTF-8'}
{name: 'X-Requested-With', value: 'XMLHttpRequest'}
{name: 'sec-ch-ua-mobile', value: '?0'}
{name: 'User-Agent', value: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWeb…KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36'}
{name: 'sec-ch-ua-platform', value: '"Windows"'}

Some headers are missing

i want more header like Cookie form request

tnx a lot


问:
If i backspace textfieldwidget or textaheadfield till nothing was left, it gets an error flutter

just simple question, its the error like that is normal? or not?
that error is given when i backspace till the textfield have nothing left. i don't know what the cause of it

```<code>Padding(
          padding:
              const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10),
          child: Container(
            decoration: BoxDecoration(
                color: Colors.grey[200],
                border: Border.all(color: Colors.white),
                borderRadius: BorderRadius.circular(10)),
            child: Padding(
              padding: const EdgeInsets.only(left: 8.0),
              child: TextField(
                controller: emailController,
                cursorColor: Colors.white,
                textInputAction: TextInputAction.next,
                decoration: const InputDecoration(
                    labelText: 'Email', border: InputBorder.none),
              ),
            ),
          ),
        ),
        Padding(
          padding:
              const EdgeInsets.symmetric(horizontal: 15.0, vertical: 2),
          child: Container(
            decoration: BoxDecoration(
                color: Colors.grey[200],
                border: Border.all(color: Colors.white),
                borderRadius: BorderRadius.circular(10)),
            child: Padding(
              padding: const EdgeInsets.only(left: 8.0),
              child: TextField(
                controller: passwordController,
                cursorColor: Colors.white,
                textInputAction: TextInputAction.next,
                decoration: const InputDecoration(
                    labelText: 'Password', border: InputBorder.none),
              ),
            ),
          ),
        ),

        const SizedBox(
          height: 20,
        ),
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 100),
          child: ElevatedButton.icon(
            style: ElevatedButton.styleFrom(
              minimumSize: const Size.fromHeight(50),
            ),
            icon: const Icon(
              Icons.lock_open,
              size: 20,
            ),
            label: const Text(
              'Sign in',
              style: TextStyle(fontSize: 20),
            ),
            onPressed: signIn,
          ),
        ),
</code>```

truthfully all my textfield is acting like that, i don't know how to fix it. it should be looks like any normal textfield.

Body:
just simple question, its the error like that is normal? or not?
that error is given when i backspace till the textfield have nothing left. i don't know what the cause of it

Padding(
          padding:
              const EdgeInsets.symmetric(horizontal: 15.0, vertical: 10),
          child: Container(
            decoration: BoxDecoration(
                color: Colors.grey[200],
                border: Border.all(color: Colors.white),
                borderRadius: BorderRadius.circular(10)),
            child: Padding(
              padding: const EdgeInsets.only(left: 8.0),
              child: TextField(
                controller: emailController,
                cursorColor: Colors.white,
                textInputAction: TextInputAction.next,
                decoration: const InputDecoration(
                    labelText: 'Email', border: InputBorder.none),
              ),
            ),
          ),
        ),
        Padding(
          padding:
              const EdgeInsets.symmetric(horizontal: 15.0, vertical: 2),
          child: Container(
            decoration: BoxDecoration(
                color: Colors.grey[200],
                border: Border.all(color: Colors.white),
                borderRadius: BorderRadius.circular(10)),
            child: Padding(
              padding: const EdgeInsets.only(left: 8.0),
              child: TextField(
                controller: passwordController,
                cursorColor: Colors.white,
                textInputAction: TextInputAction.next,
                decoration: const InputDecoration(
                    labelText: 'Password', border: InputBorder.none),
              ),
            ),
          ),
        ),

        const SizedBox(
          height: 20,
        ),
        Padding(
          padding: const EdgeInsets.symmetric(horizontal: 100),
          child: ElevatedButton.icon(
            style: ElevatedButton.styleFrom(
              minimumSize: const Size.fromHeight(50),
            ),
            icon: const Icon(
              Icons.lock_open,
              size: 20,
            ),
            label: const Text(
              'Sign in',
              style: TextStyle(fontSize: 20),
            ),
            onPressed: signIn,
          ),
        ),

truthfully all my textfield is acting like that, i don't know how to fix it. it should be looks like any normal textfield.


问:
Why is object not getting saved to HazelCast IMap?

Background

I am new to Hazelcast. I'm currently working on an internal tool that uses Hazelcast to cache our data.

Problem

The HazelCast IMap has a String key & HashMap<K, V> value.

We are having an issue with this tool, where inputting an updated HashMap object with put() into the IMap does not update the HashMap object, refer to sample code below. The V in HashMap<K, V> is what gets updated.

Code Structure

In our main code, we have the following:

main() {
    updateTableStatus(...);
    // other business logic
    updateTableStatus(...);
}
```
<p>The <code>updateTableStatus</code> code updates the <code>IMap</code>:</p>
<pre class="lang-java prettyprint-override"><code>updateTableStatus(...) {
    hazelcastInstance.getMap("String").put(K, V);
}
</code>```

After running the app in debug mode, it seems that the first updateTableStatus does not update the HashMap object, only the second updateTableStatus.

The tool is a SpringBoot application, where the HazelcastInstance object is defined as follows:

@Autowired
HazelcastInstance hazelcastInstance;
```

I understand that objects saved to the Hazelcast IMap need to be serializable, but it seems that Hazelcast already has optimized the serialization for HashMap objects as per link.

My Research/Effort To Debug The Problem

I'm not quite sure what other avenues to explore with regards to updating objects in a Hazelcast IMap, these were the StackOverflow articles I referred to:

SO Article #1

SO Article #2

SO Article #3

I think Article #3 is the closest to what I'm asking, but his post had no answers, so I'm not sure how else to proceed.

If there is any other missing pieces of information I could provide about the project / Hazelcast setup, please let me know! I'm still new & learning :)

I appreciate any responses & other people's understanding :)

Body:
Background

I am new to Hazelcast. I'm currently working on an internal tool that uses Hazelcast to cache our data.

Problem

The HazelCast IMap has a String key & HashMap<K, V> value.

We are having an issue with this tool, where inputting an updated HashMap object with put() into the IMap does not update the HashMap object, refer to sample code below. The V in HashMap<K, V> is what gets updated.

Code Structure

In our main code, we have the following:

main() {
    updateTableStatus(...);
    // other business logic
    updateTableStatus(...);
}

The updateTableStatus code updates the IMap:

updateTableStatus(...) {
    hazelcastInstance.getMap("String").put(K, V);
}

After running the app in debug mode, it seems that the first updateTableStatus does not update the HashMap object, only the second updateTableStatus.

The tool is a SpringBoot application, where the HazelcastInstance object is defined as follows:

@Autowired
HazelcastInstance hazelcastInstance;

I understand that objects saved to the Hazelcast IMap need to be serializable, but it seems that Hazelcast already has optimized the serialization for HashMap objects as per link.

My Research/Effort To Debug The Problem

I'm not quite sure what other avenues to explore with regards to updating objects in a Hazelcast IMap, these were the StackOverflow articles I referred to:

SO Article #1

SO Article #2

SO Article #3

I think Article #3 is the closest to what I'm asking, but his post had no answers, so I'm not sure how else to proceed.

If there is any other missing pieces of information I could provide about the project / Hazelcast setup, please let me know! I'm still new & learning :)

I appreciate any responses & other people's understanding :)


问:
Optimize levenshtein find similarity of string in list of strings
We have the given problem:

a list of 1M rows, each row is a sentence.

we have a list of valid strings. The list length is ~1000.

We need to know if, for all the strings in a given sentence (from (1)), there is a candidate in the list of valid strings with a normalized similarity larger than 0.9.

I understand this problem has been tackled many times beforehand, but we have found references only to the naive implementation (attached below).

Is there a way to optimize the process?

```<code># valid_names = [...] 1k of valid strings
import textdistance
def is_valid(name_lst):
    for name in name_lst:
        similarities = []
        for valid_name in valid_names:
            similarities.append(textdistance.levenshtein.normalized_similarity(name, valid_name))
        if(max(similarities) < 0.9):
            return False
    return True

tqdm.pandas(desc=f"get_valid_names")
all_sentences['is_valid'] = False
all_sentences['is_valid'].iloc[:100] = all_sentences.iloc[:100].progress_apply(lambda row: is_valid(row['customer_sentence'].split(' ')),axis=1)

</code>```

Body:
We have the given problem:

a list of 1M rows, each row is a sentence.

we have a list of valid strings. The list length is ~1000.

We need to know if, for all the strings in a given sentence (from (1)), there is a candidate in the list of valid strings with a normalized similarity larger than 0.9.

I understand this problem has been tackled many times beforehand, but we have found references only to the naive implementation (attached below).

Is there a way to optimize the process?

# valid_names = [...] 1k of valid strings
import textdistance
def is_valid(name_lst):
    for name in name_lst:
        similarities = []
        for valid_name in valid_names:
            similarities.append(textdistance.levenshtein.normalized_similarity(name, valid_name))
        if(max(similarities) < 0.9):
            return False
    return True

tqdm.pandas(desc=f"get_valid_names")
all_sentences['is_valid'] = False
all_sentences['is_valid'].iloc[:100] = all_sentences.iloc[:100].progress_apply(lambda row: is_valid(row['customer_sentence'].split(' ')),axis=1)


问:
Vuejs component consuming lot of memory
I have a page in my application which is built in vuejs and does an api call every second using setTimeout in mount method.

When I do about:memory in Firefox (ver 78.11) on Linux it displays around 1 GB memory and energy impact as medium after I kept the tab open for about 5 hours.
It started from like 30MB and have reached after 5 hrs to 1.54 GB.

We are restricted to only use firefox and I cant figure out what's causing the issue.
This vue component is embedded in laravel blade.

I am calling the loadData function on mounted which then calls setTimeout and I am cleaning intervals too.

Though I believe beforeDestroy would never be triggered as the component is displayed forever and not conditionally.

```<code><script>
    Vue.component('alertbody', {
        data: function () {
            return {
                alerts: [],
                loadInterval: null
            }
        },
        template: `
                    <div class="box-body" style="min-height: 510px; overflow:hidden;">
                    <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                      <div v-for="(alert, index ) in alerts"  v-bind:key="alert.eventid" class="panel panel-default" style="word-break:break-all;">
                          <div class="panel-heading" v-bind:style="'background-color:'+alert.color" role="tab"  v-bind:id="'heading'+index">
                                <div class="ml-5">
                                  <a role="button" data-toggle="collapse" data-parent="#accordion"
                                           v-bind:href="'#collapse'+index" aria-expanded="true">
                                               <h4 class="panel-title text-dark">
                                                  <div class="text-bold">@{{ alert.host }}</div>
                                                  <div class="text-sm">@{{ alert.description }}</div>
                                              </h4>
                                    </a>
                                </div>
                            </div>
                        </div>
                        </div>
                    </div>`,

          mounted: function () {
            this.loadData();
          },
        methods: {
            loadData: function () {
                $.get('{{ route('
                getAlertsPersistent
                ') }}', function (response) {
                    this.alerts = response['alerts'];
                }.bind(this)
            )
                ;

                if (this.loadInterval) {
                    clearInterval(this.loadInterval);
                }

                this.loadInterval = setTimeout(this.loadData, 1000);
            },
        },
        beforeDestroy: function () {
            this.alerts = [];
            delete this.alerts;
            clearInterval(this.loadInterval);
        }

    });
    new Vue({el: '#alertbody'});

</script>
</code>```

As in the below picture CMS displays around 500MB memory.

I am not sure if occupying that much memory as its making calls every second is ok.
FYI, After few mins 500MB reduced to 300 MB.

Can anyone suggest if there's any memory leaks?

TIA

Title: Vuejs component consuming lot of memory

Body:
I have a page in my application which is built in vuejs and does an api call every second using setTimeout in mount method.

When I do about:memory in Firefox (ver 78.11) on Linux it displays around 1 GB memory and energy impact as medium after I kept the tab open for about 5 hours.
It started from like 30MB and have reached after 5 hrs to 1.54 GB.

We are restricted to only use firefox and I cant figure out what's causing the issue.
This vue component is embedded in laravel blade.

I am calling the loadData function on mounted which then calls setTimeout and I am cleaning intervals too.

Though I believe beforeDestroy would never be triggered as the component is displayed forever and not conditionally.

As in the below picture CMS displays around 500MB memory.

I am not sure if occupying that much memory as its making calls every second is ok.
FYI, After few mins 500MB reduced to 300 MB.

Can anyone suggest if there's any memory leaks?

TIA


问:
Do solana programs created using Anchor only have IDL?
I am learning about IDL. By following this answers .

I want to know wheather programs deployed using anchor framework only have IDL ? If not how can I fetch the IDL from a cluster not created using anchor.

For eg:

I have deploy a simple helloworld program here on testnet . ( Program ID : 7SKPHGcFDHqK3wbLxiGudZWwajs8ApyHiPiEgD2TYXTq ) . I deploy it following this tutorial

Can someone please show me how can I fetch its IDL ?


问:
installing specific nodejs version 14.17.6 in RHEL server
As per requirement from customer, I would need to install specific nodejs version:14.17.6 in Rhel 8 version.
I have used this "curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash -" and further  "yum install nodejs 14" however the version I get is "14.21.1". Please help with solution to install this specific version</p>


问:
I have a Python program Traceback (Most Recent Calls Error). How do I fix this? I'm new to Python
**This is the error I have: **

```<code>Traceback (most recent call last):
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\main.py", line 3, in <module>
    import pywhatkit
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\venv\Lib\site-packages\pywhatkit\__init__.py", line 12, in <module>
    from pywhatkit.handwriting import text_to_handwriting
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\venv\Lib\site-packages\pywhatkit\handwriting.py", line 1, in <module>
    import requests
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\venv\Lib\site-packages\requests\__init__.py", line 63, in <module>
    from . import utils
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\venv\Lib\site-packages\requests\utils.py", line 27, in <module>
    from .cookies import RequestsCookieJar, cookiejar_from_dict
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\venv\Lib\site-packages\requests\cookies.py", line 172, in <module>
    class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'MutableMapping'

</code>```

This is my program source code. I'm trying to do virtual assistant.

```<code>import speech_recognition as sr
import pyttsx3
import pywhatkit
import datetime
import wikipedia
import pyjokes

listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)

def say(text):
    engine.say(text)
    engine.runAndWait()

# noinspection PyBroadException
def get_command():
    try:
        with sr.Microphone() as source:
            print('Say something please.')
            voice = listener.listen(source)
            command = listener.recognize_google(voice)
            command = command.lower()
            if 'amy' in command:
                command = command.replace('amy', '')
                say(command)
    except:
        pass
    return command

def get_amy():
    command = get_command()
    print(command)
    if 'play' in command:
        song = command.replace('play', '')
        say('Okay bro Im playing' + song)
        pywhatkit.playonyt(song)
    elif 'time' in command:
        time = datetime.datetime.now().strftime('%I %M %p')
        print('bro its ' + time)
        say('bro its' + time)
    elif 'who is' in command:
        person = command.replace('who is', '')
        information = wikipedia.summary(person, 2)
        print(information)
        say(information)
    elif 'what is' in command:
        question = command.replace('what is', '')
        information = wikipedia.summary(question, 2)
        print(information)
        say(information)
    elif 'who are you' in command:
        say('Who do you think I am Amy you idiot')
    elif 'I love you' in command:
        say('Sorry Im in relationship with this Nitro five laptop')
    elif 'joke' in command:
        joke = pyjokes.get_joke()
        print(joke)
        say(joke)
    else:
        say('please tell me something again.I dont understand')

while True:
    get_amy()

</code>```

I tried to install flask as someone suggested but I still have error. And also I tried to check pip paths are correct. I'm currently using Python 3.8. I'm also importing those pip's:

Pywhatkit

Pyttsxt3

Python Speech recognition

Pywikipedia

Pyaudio

Body:
**This is the error I have: **

Traceback (most recent call last):
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\main.py", line 3, in <module>
    import pywhatkit
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\venv\Lib\site-packages\pywhatkit\__init__.py", line 12, in <module>
    from pywhatkit.handwriting import text_to_handwriting
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\venv\Lib\site-packages\pywhatkit\handwriting.py", line 1, in <module>
    import requests
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\venv\Lib\site-packages\requests\__init__.py", line 63, in <module>
    from . import utils
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\venv\Lib\site-packages\requests\utils.py", line 27, in <module>
    from .cookies import RequestsCookieJar, cookiejar_from_dict
  File "C:\Users\Khuslensaikhan\PycharmProjects\MyVirtualAssistant\venv\Lib\site-packages\requests\cookies.py", line 172, in <module>
    class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'collections' has no attribute 'MutableMapping'

This is my program source code. I'm trying to do virtual assistant.

import speech_recognition as sr
import pyttsx3
import pywhatkit
import datetime
import wikipedia
import pyjokes

listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)

def say(text):
    engine.say(text)
    engine.runAndWait()

# noinspection PyBroadException
def get_command():
    try:
        with sr.Microphone() as source:
            print('Say something please.')
            voice = listener.listen(source)
            command = listener.recognize_google(voice)
            command = command.lower()
            if 'amy' in command:
                command = command.replace('amy', '')
                say(command)
    except:
        pass
    return command

def get_amy():
    command = get_command()
    print(command)
    if 'play' in command:
        song = command.replace('play', '')
        say('Okay bro Im playing' + song)
        pywhatkit.playonyt(song)
    elif 'time' in command:
        time = datetime.datetime.now().strftime('%I %M %p')
        print('bro its ' + time)
        say('bro its' + time)
    elif 'who is' in command:
        person = command.replace('who is', '')
        information = wikipedia.summary(person, 2)
        print(information)
        say(information)
    elif 'what is' in command:
        question = command.replace('what is', '')
        information = wikipedia.summary(question, 2)
        print(information)
        say(information)
    elif 'who are you' in command:
        say('Who do you think I am Amy you idiot')
    elif 'I love you' in command:
        say('Sorry Im in relationship with this Nitro five laptop')
    elif 'joke' in command:
        joke = pyjokes.get_joke()
        print(joke)
        say(joke)
    else:
        say('please tell me something again.I dont understand')

while True:
    get_amy()

I tried to install flask as someone suggested but I still have error. And also I tried to check pip paths are correct. I'm currently using Python 3.8. I'm also importing those pip's:

Pywhatkit

Pyttsxt3

Python Speech recognition

Pywikipedia

Pyaudio


问:
Cannot read properties of undefined (reading 'findOne') in nextauth
Hi I building login form and doing authentication with using nextjs , nextauthjs and mysql

these are my codes .

```<code>import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials"
import { query } from "../getdata";
import axios from "axios";
import { Users } from "../../../../server/models/Users";
import mysql from 'mysql2';

    export default NextAuth({
    session: {
        strategy: 'jwt',
    },
    callbacks: {
        async jwt({ token, user }) {
            if (user?.id) token.id = user.id;
            return token;
        },
        async session({ session, token }) {
            if (token?.id) session.user.id = token.id;
            return session;
        },
    },
    providers: [
        CredentialsProvider({
            name: "credentials",
            credentials: {
                username: {
                    label: "username",
                    type: "text",
                    placeholder: "johndoe@test.com",
                },
                password: { label: "Password", type: "password" },
            },
            authorize: async (credentials) => {
                const user = await Users.findOne({ where: { username: credentials.username } });
                console.log()
                // database look up
                if (
                    credentials.username === user.username &&
                    credentials.password === user.password
                ) {
                    return {
                        name: "John",
                        email: "johndoe@test.com",
                    };
                } else {
                    throw new Error(errorMessage);
                }
            },
        }),
    ],
});
</code>```

I am getting this error when I am logging in

Cannot read properties of undefined (reading 'findOne')

Here are data for /models/Users i used this in next auth js.
once i used these code in express there its worked fine same thing i am doing in nextauth but it gives me error

```<code> module.exports = (sequelize, DataTypes) => {
    const Users = sequelize.define("Users", {
        username: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        email: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        password: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        role: {
            type: DataTypes.STRING,
            allowNull: false,
        },
    });
    return Users;
};
</code>```

Body:
Hi I building login form and doing authentication with using nextjs , nextauthjs and mysql

these are my codes .

import NextAuth from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials"
import { query } from "../getdata";
import axios from "axios";
import { Users } from "../../../../server/models/Users";
import mysql from 'mysql2';

    export default NextAuth({
    session: {
        strategy: 'jwt',
    },
    callbacks: {
        async jwt({ token, user }) {
            if (user?.id) token.id = user.id;
            return token;
        },
        async session({ session, token }) {
            if (token?.id) session.user.id = token.id;
            return session;
        },
    },
    providers: [
        CredentialsProvider({
            name: "credentials",
            credentials: {
                username: {
                    label: "username",
                    type: "text",
                    placeholder: "johndoe@test.com",
                },
                password: { label: "Password", type: "password" },
            },
            authorize: async (credentials) => {
                const user = await Users.findOne({ where: { username: credentials.username } });
                console.log()
                // database look up
                if (
                    credentials.username === user.username &&
                    credentials.password === user.password
                ) {
                    return {
                        name: "John",
                        email: "johndoe@test.com",
                    };
                } else {
                    throw new Error(errorMessage);
                }
            },
        }),
    ],
});

I am getting this error when I am logging in

Cannot read properties of undefined (reading 'findOne')

Here are data for /models/Users i used this in next auth js.
once i used these code in express there its worked fine same thing i am doing in nextauth but it gives me error

 module.exports = (sequelize, DataTypes) => {
    const Users = sequelize.define("Users", {
        username: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        email: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        password: {
            type: DataTypes.STRING,
            allowNull: false,
        },
        role: {
            type: DataTypes.STRING,
            allowNull: false,
        },
    });
    return Users;
};


问:
Blocking auth triggers in cloud functions for firebase second generation

I am referring this https://firebase.google.com/docs/functions/beta/auth-blocking-events documentation to implement Blocking auth triggers using 2nd generation cloud function for firebase,
I have created and deployed functions but the problem is that, while registering the triggers under the Blocking functions tab in the Firebase Authentication console, It does not shows that deployed triggers (beforeUserSignedIn, beforeUserCreated) for registering.

Below is my code,

```<code>import functions from 'firebase-functions/v2'
import admin from 'firebase-admin'
import { beforeUserCreated, beforeUserSignedIn } from 'firebase-functions/v2/identity'

import serviceKey from './serviceKey.json' assert {type: 'json'}

admin.initializeApp(serviceKey)

export const beforecreated = beforeUserCreated((event) => {
    console.log("EVENT DATA FOR AUTH beforecreated....", event.data)
    return;
});

export const beforesignedin = beforeUserSignedIn((event) => {
    console.log("EVENT DATA FOR AUTH beforesignedin....",event.data)
});

</code>```

I have tried Blocking auth triggers for first-generation cloud functions for firebase and it's working fine, and also I can register that blocking auth triggers. But this is not working for the second generation cloud function for firebase.

Body:
I am referring this https://firebase.google.com/docs/functions/beta/auth-blocking-events documentation to implement Blocking auth triggers using 2nd generation cloud function for firebase,
I have created and deployed functions but the problem is that, while registering the triggers under the Blocking functions tab in the Firebase Authentication console, It does not shows that deployed triggers (beforeUserSignedIn, beforeUserCreated) for registering.

Below is my code,

import functions from 'firebase-functions/v2'
import admin from 'firebase-admin'
import { beforeUserCreated, beforeUserSignedIn } from 'firebase-functions/v2/identity'

import serviceKey from './serviceKey.json' assert {type: 'json'}

admin.initializeApp(serviceKey)

export const beforecreated = beforeUserCreated((event) => {
    console.log("EVENT DATA FOR AUTH beforecreated....", event.data)
    return;
});

export const beforesignedin = beforeUserSignedIn((event) => {
    console.log("EVENT DATA FOR AUTH beforesignedin....",event.data)
});

I have tried Blocking auth triggers for first-generation cloud functions for firebase and it's working fine, and also I can register that blocking auth triggers. But this is not working for the second generation cloud function for firebase.


问:
Overloay is not visible in fullscreen mode
I have Map page which includes the Overloay after click on Setting button
And another button which display the complete map in fullscreen mode

Below is my code :

```<code>    const [show, setShow] = useState(false);
    const [target, setTarget] = useState(null);
    const ref = useRef(null);

    const handleClick = (event) => {
        setShow(!show);
        setTarget(event.target);
      };

<div ref={ref}>
    <Button onClick={handleClick}>
        <MdSettings size={props.iconSize} data-toggle="tooltip" data-placement="left" title="Settings"></MdSettings>
    </Button>
    <Overlay show={show} target={target} placement="bottom" container={ref} containerPadding={20}>
        <Popover id="popover-contained" className='popup-content'>
            <Popover.Header as="h3">Settings</Popover.Header>
            <Popover.Body>
                <Form>
                    <Form.Check reverse={true} type="switch" label="Capacity Mode"/>
                </Form>
            </Popover.Body>
        </Popover>
    </Overlay>
</div>
</code>```

The fullscreen code is :

```<code>const fullScreen = () => {
        try {
            if (mapLayer)
                mapLayer.addControl(new (L.Control as any).Fullscreen({
                    position: 'bottomright',
                    title: {
                        'false': 'View Fullscreen',
                        'true': 'Exit Fullscreen'
                    },

                }));
        } catch (error) {
            console.log(error);
        }
    };
</code>```

The above code called into the map component to show fullscreen

Its working totally fine with normal screen but not showing overlay after fullscreen mode is enable

Using leaflet-fullscreen

Body:
I have Map page which includes the Overloay after click on Setting button
And another button which display the complete map in fullscreen mode

Below is my code :

    const [show, setShow] = useState(false);
    const [target, setTarget] = useState(null);
    const ref = useRef(null);

    const handleClick = (event) => {
        setShow(!show);
        setTarget(event.target);
      };

    <Button onClick={handleClick}>
        <MdSettings size={props.iconSize} data-toggle="tooltip" data-placement="left" title="Settings"></MdSettings>
    </Button>
    <Overlay show={show} target={target} placement="bottom" container={ref} containerPadding={20}>
        <Popover id="popover-contained" className='popup-content'>
            <Popover.Header as="h3">Settings</Popover.Header>
            <Popover.Body>
                <Form>
                    <Form.Check reverse={true} type="switch" label="Capacity Mode"/>
                </Form>
            </Popover.Body>
        </Popover>
    </Overlay>

The fullscreen code is :

const fullScreen = () => {
        try {
            if (mapLayer)
                mapLayer.addControl(new (L.Control as any).Fullscreen({
                    position: 'bottomright',
                    title: {
                        'false': 'View Fullscreen',
                        'true': 'Exit Fullscreen'
                    },

                }));
        } catch (error) {
            console.log(error);
        }
    };

The above code called into the map component to show fullscreen

Its working totally fine with normal screen but not showing overlay after fullscreen mode is enable

Using leaflet-fullscreen


问:
The 'Make Transition' function is not show in the Unity animator
For use in my Game  I was using the animator function in Unity,
Suddenly, the "Make Transition" function was not shown.

What I knew from trying many different methods was
If I do Make Transition, "Make Transition" function was not shown.
How to fix this problem? I can't find the way.


问:
Bias derivative in backpropagation
I am building a 4 - 5 - 2 layout neural network with m data points, and each data point has 4 independent variables. So for forward propagation my network shape is is:
L1: mx4 * 4x5 + 1x5 = Z1 -> A1 = ReLu(Z1).
L2: mx5 * 5x2 + 1x2 = Z2 -> A2 = softmax(Z2)

For this I get A1 = mx5 and A2 = mx2, respectively, and when finding dweight, I can get two matrices of size 4x5 and 5x2 for dweight1 and dweight2, which means I can perform matrix subtraction for gradient descent.

However, for biases, I am stuck. dL/db2 = dL/dZ2 * dZ2/db2 = (A2 - Y) * 1, which gives me a 2xm matrix, and Im stuck. Is my matrices shape wrong somewhere?

Title: Bias derivative in backpropagation


问:
Decryption error with golang using RSA crypto package
I am using dart/flutter package encrypt to encrypt a string like this:

Future<String> encryptPIN({required String pin}) async {
    final RSAPublicKey publicKey;
    final publicPem =
        await rootBundle.loadString('assets/keys/private-key.pem');
    publicKey = RSAKeyParser().parse(publicPem) as RSAPublicKey;

    final encrypter =
        Encrypter(RSA(publicKey: publicKey, encoding: RSAEncoding.OAEP));
    final encryptedPIN = encrypter.encrypt(pin).base64;
    return encryptedPIN;
  }
}
```
<p>And trying to decrypt using golang</p>
<pre class="lang-golang prettyprint-override"><code>func Decrypt(rsaPrivateKey *rsa.PrivateKey, cipherText []byte) []byte {
    hash := sha256.New()
    r := rand.Reader
    label := []byte(nil)
    decryptedSum, err := rsa.DecryptOAEP(hash, r, rsaPrivateKey, cipherText, label)

    if err != nil {
        panic(err)
    }
    return decryptedSum

}
</code>```

The dart side works, the encryption happens but the golang side fails with an error crypto/rsa: decryption error.

What could i be doing wrong?

Body:
I am using dart/flutter package encrypt to encrypt a string like this:

Future<String> encryptPIN({required String pin}) async {
    final RSAPublicKey publicKey;
    final publicPem =
        await rootBundle.loadString('assets/keys/private-key.pem');
    publicKey = RSAKeyParser().parse(publicPem) as RSAPublicKey;

    final encrypter =
        Encrypter(RSA(publicKey: publicKey, encoding: RSAEncoding.OAEP));
    final encryptedPIN = encrypter.encrypt(pin).base64;
    return encryptedPIN;
  }
}

And trying to decrypt using golang

func Decrypt(rsaPrivateKey *rsa.PrivateKey, cipherText []byte) []byte {
    hash := sha256.New()
    r := rand.Reader
    label := []byte(nil)
    decryptedSum, err := rsa.DecryptOAEP(hash, r, rsaPrivateKey, cipherText, label)

    if err != nil {
        panic(err)
    }
    return decryptedSum

}

The dart side works, the encryption happens but the golang side fails with an error crypto/rsa: decryption error.

What could i be doing wrong?


问:
Set folders in R without hard coding
In R, is there a way to set folders without hard coding. Like,
I have a folder structure as shown below

```<code>> getwd()
[1] "D:/Windows/Analytics/R Programming/GitHub/App/pacakge1"
</code>```

In this folder(App), I have a subfolder called "Lib/R-4.1/New". Now I want to set the .libPaths() to Lib

```<code>.libPaths("Lib")
</code>```

But since I have changed to "Lib", the actually path should be

```<code>.libPaths()
"Lib/R-4.1/New"
</code>```

Meaning It should dynamically take sub-folders inside "Lib".
Is this possible?

Title: Set folders in R without hard coding

Body:
In R, is there a way to set folders without hard coding. Like,
I have a folder structure as shown below

> getwd()
[1] "D:/Windows/Analytics/R Programming/GitHub/App/pacakge1"

In this folder(App), I have a subfolder called "Lib/R-4.1/New". Now I want to set the .libPaths() to Lib

.libPaths("Lib")

But since I have changed to "Lib", the actually path should be

.libPaths()
"Lib/R-4.1/New"

Meaning It should dynamically take sub-folders inside "Lib".
Is this possible?


问:
Is there a way to use the value of a cell in R in subsequent functions?
I have a dataframe of timestamps, and want to edit multiple CSVs according to the timestamp listed in the dataframe (cutting out irrelevant data)
Is there a way for me to use the value of a cell in a dataframe in subsequent functions? I have about 1200 files to edit.

Most answers recommend using coordinates to extract a specific cell value but I feel there must be a more efficient way of doing this.


问:
Importing file with split lines Azure Data Factory pipeline
I have a pipe delimited text file with a header row that I need to import into an SQL Server table (obtained via SFTP). That should be easy enough, however, the input file has input rows split over several lines if the data for the row exceeds 80 chars in length. EOL character is a newline character, which ADF can cope with just fine.

So, we have something like:

```<code>Col1Name|Col2Name|Col3Name|Col4Name
aaaa|bbbbbb|cccc|ddddd
eeeeeee|fffff|gggggg|this is some data that pushes the row over the 80 character li\
mit
hhhhhh|iiiiiii|jjjjjjjj|kk
</code>```

If some of the rows of data weren't split in this manner it would be straightforward to shunt the data into the destination table but I can't work out how to merge the split lines prior to mapping the data to output columns.

Things I have tried/looked at doing:

Using a text file source with pipes as delimiters and newlines as row terminators, replacing the backslash and newline combination with an empty string. Unfortunately, the data is already processed into separate rows at this point so this achieves nothing.

Mucking around with the column/row delimiters to read the file into one big blob and replacing the backslash/newline combos in the blob with an empty string. This doesn't work as the file gets truncated doing this.

Some combination of aggregate transformation with a collect() expression to merge the lines. Again, can't seem to manage this because there aren't any grouping columns in common between the lines the row has been split into to be able to perform this sort of aggregation.

Do I need to write an Azure function to pre-process the file and merge the split lines, or is there something I'm missing that would help?

Body:
I have a pipe delimited text file with a header row that I need to import into an SQL Server table (obtained via SFTP). That should be easy enough, however, the input file has input rows split over several lines if the data for the row exceeds 80 chars in length. EOL character is a newline character, which ADF can cope with just fine.

So, we have something like:

Col1Name|Col2Name|Col3Name|Col4Name
aaaa|bbbbbb|cccc|ddddd
eeeeeee|fffff|gggggg|this is some data that pushes the row over the 80 character li\
mit
hhhhhh|iiiiiii|jjjjjjjj|kk

If some of the rows of data weren't split in this manner it would be straightforward to shunt the data into the destination table but I can't work out how to merge the split lines prior to mapping the data to output columns.

Things I have tried/looked at doing:

Using a text file source with pipes as delimiters and newlines as row terminators, replacing the backslash and newline combination with an empty string. Unfortunately, the data is already processed into separate rows at this point so this achieves nothing.

Mucking around with the column/row delimiters to read the file into one big blob and replacing the backslash/newline combos in the blob with an empty string. This doesn't work as the file gets truncated doing this.

Some combination of aggregate transformation with a collect() expression to merge the lines. Again, can't seem to manage this because there aren't any grouping columns in common between the lines the row has been split into to be able to perform this sort of aggregation.

Do I need to write an Azure function to pre-process the file and merge the split lines, or is there something I'm missing that would help?


问:
Is Hive is supported as IBM CDC Data source
I need to capture data changes in Hive and replicate it to oracle DB using IBM CDC 11.4
Is it supported?
If it is supported, Where can I download the agent?
Any tutorials or guides?</p>


问:
Create X509 based certificate programmatically
Golang provides https://pkg.go.dev/crypto/x509 library for processing certificate and also Rust provides similar library https://docs.rs/x509-certificate/latest/x509_certificate/.

According to https://docs.rs/x509-certificate/latest/x509_certificate/#security-disclaimer it seems not to be production ready.

How should I create a certificate programmatically in Rust, in a production-ready fashion?

There is also https://github.com/sfackler/rust-openssl but not sure should I use it or not.


问:
problem related to deployment of my application as a root app in tomcat
i deployed my application as a root app in tomcat ,i did this by renaming my webapp.war file to ROOT.war . but the thing is when i make any changes to my source code with the help of CI/CD pipeline those changes doesn't reflect on my application ,i think the problem is when i make changes on my source code  it creates another webapp.war file which i previouslly renamed as ROOT.war file , so now there are 2 war file one is ROOT.war file and another is webapp.war(whose changes didn'nt reflect on my app)....i think if the war file which is created as webapp.war file can be deployed as ROOT.war file via CI/CD pipeline the problem can be resolved .... can anyone help me how to do that ??????and if there is any other method please do tell me

i have tried changing pom.xml file but didn't work for me ... i am stuck in this prob in since last 10 days


问:
Google Play Console Data Sefty Form
I have made an app for audio recording, for this I have taken "storage read, write" & "record audio" permissions from the user. how do i fill data safety form in play console??

Help me for filling Play Console Data Sefty Form.

thanks

Title: Google Play Console Data Sefty Form


问:
Flutter audioplayers 1.1.1 version, no sound at all on android imulator but works only on web browser
I have used a last version  of audio player 1.1.1
and i faced this problem that i cann’t play sound at all on android imulator but i works well only on web browser I’ve put this line in manifest

```<code>android:usesCleartextTraffic="true">
</code>```

and this is my code that I’m useing to play sound :

```<code> final player = AudioPlayer();
                  player.play(DeviceFileSource("assets/assets_music-2.mp3"));
</code>```

i used an player.play(AssetSource("assets/assets_music-2.mp3")); Method but it did’t help me

Body:
I have used a last version  of audio player 1.1.1
and i faced this problem that i cann’t play sound at all on android imulator but i works well only on web browser I’ve put this line in manifest

android:usesCleartextTraffic="true">

and this is my code that I’m useing to play sound :

 final player = AudioPlayer();
                  player.play(DeviceFileSource("assets/assets_music-2.mp3"));

i used an player.play(AssetSource("assets/assets_music-2.mp3")); Method but it did’t help me


问:
Simplifying expression in Dirac notation
I'm completely new to Sympy and was just playing with it this morning, but I've already run into a problem that I don't know how to handle.

I wrote a simple operator in Dirac notation, |0><0| - |1><1| that flips the sign of |1> components of a vector.

from sympy.physics.quantum import Dagger, OrthogonalKet
from sympy import *

b0, b1 = OrthogonalKet(0), OrthogonalKet(1)
A = b0 * Dagger(b0) - b1 * Dagger(b1)   # |0><0| - |1><1|
```
<p>When I apply it to a vector, it works fine</p>
<pre class="lang-py prettyprint-override"><code>a, b = symbols("a b")
v = a * b0 + b * b1                     # a|0> + b|1>

(A * v).expand() # a|0><0||0> - a|1><1||0> + b|0><0||1> - b|1><1||1>
</code>```

but I would like to simplify the result to a|0> - b|1>.

With OrthogonalKet, it Sympy can work out the inner products if I set the parentheses correctly

((a*b0) * (Dagger(b0) * b0)).doit() # a|0>
((b*b0) * (Dagger(b0) * b1)).doit() # 0
```
<p>etc. but the expanded expression seems to have set the parentheses around the outer products</p>
```a*|0><0|*|0> - a*|1><1|*|0> + b*|0><0|*|1> - b*|1><1|*|1>
```

and then the inner products are not simplified. Is there a way to tell it that (|i><j|)|x> = |i>(<j|x>)?

Body:
I'm completely new to Sympy and was just playing with it this morning, but I've already run into a problem that I don't know how to handle.

I wrote a simple operator in Dirac notation, |0><0| - |1><1| that flips the sign of |1> components of a vector.

from sympy.physics.quantum import Dagger, OrthogonalKet
from sympy import *

b0, b1 = OrthogonalKet(0), OrthogonalKet(1)
A = b0 * Dagger(b0) - b1 * Dagger(b1)   # |0><0| - |1><1|

When I apply it to a vector, it works fine

a, b = symbols("a b")
v = a * b0 + b * b1                     # a|0> + b|1>

(A * v).expand() # a|0><0||0> - a|1><1||0> + b|0><0||1> - b|1><1||1>

but I would like to simplify the result to a|0> - b|1>.

With OrthogonalKet, it Sympy can work out the inner products if I set the parentheses correctly

((a*b0) * (Dagger(b0) * b0)).doit() # a|0>
((b*b0) * (Dagger(b0) * b1)).doit() # 0

etc. but the expanded expression seems to have set the parentheses around the outer products

a*|0><0|*|0> - a*|1><1|*|0> + b*|0><0|*|1> - b*|1><1|*|1>

and then the inner products are not simplified. Is there a way to tell it that (|i><j|)|x> = |i>(<j|x>)?


问:
COM object that has been separated from its underlying RCW cannot be used. [Word Application] Interop
I am trying to automate word app. With Marshal.GetActiveObject("Word.Application") I can get object of word from ROT Table. But problem is when i call the wordApp.Name application throws  "COM object that has been separated from its underlying RCW cannot be used."

```<code>protected override void OnInit()
{
    // Word Application STA Thread
    _wordApp = (Application)Marshal.GetActiveObject("Word.Application");
    Debug.WriteLine("Output : " + _wordApp?.Application.Name + " , Thread Id : " + Thread.CurrentThread.ManagedThreadId);
}
</code>```
```<code>// Call From Another Thread On Event
private void HandleKeyEventOnFocus(KeyEventArgs e)
{
    try
    {
        Debug.WriteLine("Thread ID : " + Thread.CurrentThread.ManagedThreadId); // STA Thread
        if (_userInputManager.IsHotKeyPressed(Properties.Settings.Default.MS_WORD_READ_SENTENCE, e))
        {
            Thread.Sleep(300);
            // Problem
            Debug.WriteLine(_wordApp?.Name); // COM object that has been separated from its underlying RCW cannot be used.
        }
    }
    catch (Exception exception)
    {
        Debug.WriteLine(exception);
    }
}
</code>```

I have failed multiple times. Is there anyone who has worked on this?

Body:
I am trying to automate word app. With Marshal.GetActiveObject("Word.Application") I can get object of word from ROT Table. But problem is when i call the wordApp.Name application throws  "COM object that has been separated from its underlying RCW cannot be used."

protected override void OnInit()
{
    // Word Application STA Thread
    _wordApp = (Application)Marshal.GetActiveObject("Word.Application");
    Debug.WriteLine("Output : " + _wordApp?.Application.Name + " , Thread Id : " + Thread.CurrentThread.ManagedThreadId);
}

// Call From Another Thread On Event
private void HandleKeyEventOnFocus(KeyEventArgs e)
{
    try
    {
        Debug.WriteLine("Thread ID : " + Thread.CurrentThread.ManagedThreadId); // STA Thread
        if (_userInputManager.IsHotKeyPressed(Properties.Settings.Default.MS_WORD_READ_SENTENCE, e))
        {
            Thread.Sleep(300);
            // Problem
            Debug.WriteLine(_wordApp?.Name); // COM object that has been separated from its underlying RCW cannot be used.
        }
    }
    catch (Exception exception)
    {
        Debug.WriteLine(exception);
    }
}

I have failed multiple times. Is there anyone who has worked on this?


问:
Making one table in R
I am learning programming languages for the first time. I am trying to combine tables in R using:

Trip_data <- bind_rows(oct_td, sep_td, aug_td,jul_td, jun_td,may_td)

and I get the following error:

Error in bind_rows():
! Value of SET_STRING_ELT() must be a 'CHARSXP' not a 'symbol'
Run rlang::last_error() to see where the error occurred.

What does that means? and how do I solve it?

I have another set of tables and I managed to combine them just fine, I also ran that yesterday and I did not get an error.

Title: Making one table in R


问:
cannot find reference of "keras" and "to_categorical": from tensorflow.keras.utils import to_categorical
Im using pycharm version: 17.0.4.1+7-b469.62 amd64 and python 3.9, the tensorflow version is 2.11.0. anyone here can help me with this problem

enter image description here

Is there anyone can help me..
OS:Windows 10 btw


问:
Cypress - getState() function always returning initialState when invoked from cypress test
I am testing my react-redux app using cypress following this blog:

The issue is that when I am invoking getState from window.store it is always returning the initial state.

```<code>cy.window()
        .its("store")
        .invoke("getState")
        .then((state) => {
            expect(state.requiredKey).to.have.length(1)
        })
</code>```

Expected behaviour is that the getState() should return me my current redux store. I am following all the steps as mentioned in blog.

Can anyone help me out. Let me know if more details are required.

I am using redux-toolkit and redux-saga.

This is cypress.config.ts

```<code>import { defineConfig } from "cypress";

export default defineConfig({
  component: {

    supportFile : "cypress/support/**/*.cy.{jsx,tsx,js,ts}",
    devServer: {
      framework: "create-react-app",
      bundler: "webpack",
    },
  },

  e2e: {
    baseUrl:"http://localhost:3000",
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
});
</code>```

Body:
I am testing my react-redux app using cypress following this blog:

The issue is that when I am invoking getState from window.store it is always returning the initial state.

cy.window()
        .its("store")
        .invoke("getState")
        .then((state) => {
            expect(state.requiredKey).to.have.length(1)
        })

Expected behaviour is that the getState() should return me my current redux store. I am following all the steps as mentioned in blog.

Can anyone help me out. Let me know if more details are required.

I am using redux-toolkit and redux-saga.

This is cypress.config.ts

import { defineConfig } from "cypress";

export default defineConfig({
  component: {

    supportFile : "cypress/support/**/*.cy.{jsx,tsx,js,ts}",
    devServer: {
      framework: "create-react-app",
      bundler: "webpack",
    },
  },

  e2e: {
    baseUrl:"http://localhost:3000",
    setupNodeEvents(on, config) {
      // implement node event listeners here
    },
  },
});


问:
SELENIUUM WEB DRIVER
```<code>from telethon import TelegramClient, events, sync,types
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
import time
import asyncio

email="****@gmail.com"
Password="*****"
driver=webdriver.Chrome()
driver.get("https://qxbroker.com/en/sign-in/")
username_textbox = driver.find_element_by_name("email").send_keys(email)
password_textbox= driver.find_element_by_name('password').send_keys(Password)
login_button = driver.find_element_by_xpath('//*[@id="tab-1"]/form/button/div').click()

api_id=123456
api_hash='DFDGGGGGGGDGBGFBGFBFGB'
client = TelegramClient('anon', api_id, api_hash)
@client.on(events.NewMessage)
async def handler(event):
  if "EUR/USD" in event.raw_text:
    if "UP" in event.raw_text:
        print("UP")
        Up_button = driver.find_element_by_xpath('// *[ @ id = "root"] / div / div[1] / main / div[2] / div[1] / div / div[6] / div[1] / button').click()
    elif 'DOWN' in event.raw_text:
        down_button = driver.find_element_by_xpath('//*[@id="root"]/div/div[1]/main/div[2]/div[1]/div/div[6]/div[4]/button').click()
        print("DOWN")

client.start()
client.run_until_disconnected()

</code>```

This is my code i want to select the time from that website but i don't know how if i am using click command it shows error of use await command.The time option was like dropdown menu. please help me. i want to set a trade for five to ten minutes duration. but this code just press what i set in that website.but i want that code select the time itslef automatically

Title: SELENIUUM WEB DRIVER

Body:
from telethon import TelegramClient, events, sync,types
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
import time
import asyncio

email="****@gmail.com"
Password="*****"
driver=webdriver.Chrome()
driver.get("https://qxbroker.com/en/sign-in/")
username_textbox = driver.find_element_by_name("email").send_keys(email)
password_textbox= driver.find_element_by_name('password').send_keys(Password)
login_button = driver.find_element_by_xpath('//*[@id="tab-1"]/form/button/div').click()

api_id=123456
api_hash='DFDGGGGGGGDGBGFBGFBFGB'
client = TelegramClient('anon', api_id, api_hash)
@client.on(events.NewMessage)
async def handler(event):
  if "EUR/USD" in event.raw_text:
    if "UP" in event.raw_text:
        print("UP")
        Up_button = driver.find_element_by_xpath('// *[ @ id = "root"] / div / div[1] / main / div[2] / div[1] / div / div[6] / div[1] / button').click()
    elif 'DOWN' in event.raw_text:
        down_button = driver.find_element_by_xpath('//*[@id="root"]/div/div[1]/main/div[2]/div[1]/div/div[6]/div[4]/button').click()
        print("DOWN")

client.start()
client.run_until_disconnected()

This is my code i want to select the time from that website but i don't know how if i am using click command it shows error of use await command.The time option was like dropdown menu. please help me. i want to set a trade for five to ten minutes duration. but this code just press what i set in that website.but i want that code select the time itslef automatically


问:
Libconfig++ for windows
I have a project which was created under linux, it uses libconfig++. I need to port this project to windows, but I couldn’t find a way to install libconfig++ on windows. Is there any way to do it? Thanks in advance.

P.s. i’m not into c++ that much yet, just started learning and already have this task.

Title: Libconfig++ for windows


问:
typescript is searching for types of packages that aren't installed
I've been working on a typescript project, specifically, I've been working in a firebase functions project, using typescript.

Whenever I run firebase deploy --only functions to deploy the functions I get these three cryptic errors:

```<code>error TS2688: Cannot find type definition file for 'linkify-it'.
  The file is in the program because:
    Entry point for implicit type library 'linkify-it'

error TS2688: Cannot find type definition file for 'markdown-it'.
  The file is in the program because:
    Entry point for implicit type library 'markdown-it'

error TS2688: Cannot find type definition file for 'mdurl'.
  The file is in the program because:
</code>```

I get the same error if I run npm run build or tsc directly.

Here is the weird thing tho: Before today I had never in my life heard of the packages linkify-it,  markdown-it or mdurl, they are not, nor have ever been, dependencies in my project.
In fact, my project only has a handful of dependencies, most of which were added by firebase itself, here is my package.json file:

```<code>{
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "tsc",
    "build:watch": "tsc --watch",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^10.0.2",
    "firebase-functions": "^4.1.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.25.4",
    "firebase-functions-test": "^0.2.0",
    "typescript": "^4.5.4"
  },
  "private": true
}

</code>```

Here is my .tsconfig in case it's useful:

```<code>{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017"
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}

</code>```

Interestingly, I managed to fix the problem by adding the types packages to my project

```<code>npm install @types/markdown-it @types/mdurl @types/linkify-it
</code>```

But of course, that now means I have weird dependencies in my project, so I've been searching for a way to get rid of these dependencies.

I tried:

uninstalling mdurl,  linkify-it and markdown-it, to no avail, my project does not depend on them.

Deleting the node_modules folder and running npm install again, the problem is still there.

Removing other dependencies. I was able to remove pretty much every dev dependency, but the errors would not change, so I reinstalled them all.

I assume something I'm using depends on them, but it seems so weird that my project doesn't tell me why it needs these three packages, I also don't know what could my project possibly use these packages for, I mean the project has absolutely nothing to do with markdown.

I found a number of people with similar problems, namely this gentleman, but all of the examples seemed to be solved by removing some weird dependency from their package.json, I can't find my weird dependency

Body:
I've been working on a typescript project, specifically, I've been working in a firebase functions project, using typescript.

Whenever I run firebase deploy --only functions to deploy the functions I get these three cryptic errors:

error TS2688: Cannot find type definition file for 'linkify-it'.
  The file is in the program because:
    Entry point for implicit type library 'linkify-it'

error TS2688: Cannot find type definition file for 'markdown-it'.
  The file is in the program because:
    Entry point for implicit type library 'markdown-it'

error TS2688: Cannot find type definition file for 'mdurl'.
  The file is in the program because:

I get the same error if I run npm run build or tsc directly.

Here is the weird thing tho: Before today I had never in my life heard of the packages linkify-it,  markdown-it or mdurl, they are not, nor have ever been, dependencies in my project.
In fact, my project only has a handful of dependencies, most of which were added by firebase itself, here is my package.json file:

{
  "name": "functions",
  "scripts": {
    "lint": "eslint --ext .js,.ts .",
    "build": "tsc",
    "build:watch": "tsc --watch",
    "serve": "npm run build && firebase emulators:start --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "16"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "^10.0.2",
    "firebase-functions": "^4.1.0"
  },
  "devDependencies": {
    "@typescript-eslint/eslint-plugin": "^5.12.0",
    "@typescript-eslint/parser": "^5.12.0",
    "eslint": "^8.9.0",
    "eslint-config-google": "^0.14.0",
    "eslint-plugin-import": "^2.25.4",
    "firebase-functions-test": "^0.2.0",
    "typescript": "^4.5.4"
  },
  "private": true
}

Here is my .tsconfig in case it's useful:

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017"
  },
  "compileOnSave": true,
  "include": [
    "src"
  ]
}

Interestingly, I managed to fix the problem by adding the types packages to my project

npm install @types/markdown-it @types/mdurl @types/linkify-it

But of course, that now means I have weird dependencies in my project, so I've been searching for a way to get rid of these dependencies.

I tried:

uninstalling mdurl,  linkify-it and markdown-it, to no avail, my project does not depend on them.

Deleting the node_modules folder and running npm install again, the problem is still there.

Removing other dependencies. I was able to remove pretty much every dev dependency, but the errors would not change, so I reinstalled them all.

I assume something I'm using depends on them, but it seems so weird that my project doesn't tell me why it needs these three packages, I also don't know what could my project possibly use these packages for, I mean the project has absolutely nothing to do with markdown.

I found a number of people with similar problems, namely this gentleman, but all of the examples seemed to be solved by removing some weird dependency from their package.json, I can't find my weird dependency


问:
Django executing different url
urls.py

```<code>from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include("dashboardapp.urls")),
]
</code>```

template

```<code><!DOCTYPE html>
<html>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<body>
<style>
h2 {text-align: center;}

.center {
  margin-left: auto;
  margin-right: auto;
}

table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}
th, td {
  padding-top: 10px;
  padding-bottom: 20px;
  padding-left: 30px;
  padding-right: 40px;
}
tr:nth-child(even) {background-color: #f2f2f2;}
</style>

  <h2>Summary Details</h2>
  <table class="center">
    <thead>
    <tr>
      <th>scrapper_id</th>
      <th>scrapper_jobs_log_id</th>
      <th>external_job_source_id</th>
    </tr>
    </thead>
    <tbody>
    {% for stud in scrappers %}
    {% csrf_token %}
      <tr>
        <td>{{stud.scrapper_id}}</td>
        <td>{{stud.scrapper_jobs_log_id}}</td>
        <td>{{stud.external_job_source_id}}</td>

      </tr>
    {% endfor %}
    </tbody>
  </table>
</body>
</html>
</code>```

My terminal is showing

Starting development server at http://127.0.0.1:8000/.

But when I click the url its changing to different url http://127.0.0.1:8000/sales. But my url has no sales/. but my other project has sales/. Can anybody help with the solution for this

Title: Django executing different url

Body:
urls.py

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include("dashboardapp.urls")),
]

template

<!DOCTYPE html>

  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">

Summary Details

      scrapper_id
      scrapper_jobs_log_id
      external_job_source_id

    {% for stud in scrappers %}
    {% csrf_token %}

        {{stud.scrapper_id}}
        {{stud.scrapper_jobs_log_id}}
        {{stud.external_job_source_id}}

    {% endfor %}

My terminal is showing

Starting development server at http://127.0.0.1:8000/.

But when I click the url its changing to different url http://127.0.0.1:8000/sales. But my url has no sales/. but my other project has sales/. Can anybody help with the solution for this


问:
Python Pandas: Encountered Error with interpolate cubic
I am testing out the interpolate by cubic, but I get below error:

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

```<code>import pandas as pd
q = pd.Series([1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10], index=pd.period_range('2018-01-01',freq='Q', periods=20))

m2 = q.resample('M').interpolate(method='cubic')
</code>```

Body:
I am testing out the interpolate by cubic, but I get below error:

TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

import pandas as pd
q = pd.Series([1,2,3,4,5,6,7,8,9,10,1,2,3,4,5,6,7,8,9,10], index=pd.period_range('2018-01-01',freq='Q', periods=20))

m2 = q.resample('M').interpolate(method='cubic')