问:
How to create an entity representing a shopping cart in TypeORM
I have created a REST API using node and express. My CRUD operations are performed via SQL in combination with the node module "pg", which allows for interacting with a PostgreSQL database. Now, I am thinking about refactoring my code to make use of TypeORM.

I have created the following three tables:

orders:

```<code>CREATE TABLE orders
(
    id      SERIAL PRIMARY KEY,
    status  VARCHAR(8),
    user_id INTEGER REFERENCES users (id)
);
</code>```

products:

```<code>CREATE TABLE products
(
    id       SERIAL PRIMARY KEY,
    name     VARCHAR(100),
    price    DECIMAL(4, 2),
    category VARCHAR(50)
);
</code>```

order_products:

```<code>CREATE TABLE order_products
(
    id         SERIAL PRIMARY KEY,
    order_id   INTEGER REFERENCES orders (id),
    product_id INTEGER REFERENCES products (id),
    quantity   INTEGER
);
</code>```

I am trying to create the entities, which represent these three tables. I tried to do this, but I am pretty sure something is off. Can you help me with this?

These are the entities I have created:

User:

```<code>@Entity('users')
export class User extends BaseEntity {

  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  firstname: string;

  @Column()
  lastname: string;

  @Column()
  username: string;

  @Column()
  password: string;
}
</code>```

Product:

```<code>@Entity('products')
export class Product extends BaseEntity {

  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column()
  price: number;

  @Column()
  category: string;
}
</code>```

OrderProduct:

```<code>@Entity('order_products')
export class OrderProduct extends BaseEntity {

  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  quantity: number;

  @OneToOne(
    () => Order
  )
  @JoinColumn({
    name: 'order_id'
  })
  order: Order;

  @OneToMany(
    () => Product,
    product => product.id
  )
  @JoinColumn({
    name: 'product_id'
  })
  products: Product[];
}
</code>```

I think the OrderProduct-entity is wrong: The OneToMany relationship will probably create a column "product_id" at the many-side of the relationship, which is the products-table. I want to have this column on my order_products table, however.

Body:
I have created a REST API using node and express. My CRUD operations are performed via SQL in combination with the node module "pg", which allows for interacting with a PostgreSQL database. Now, I am thinking about refactoring my code to make use of TypeORM.

I have created the following three tables:

orders:

CREATE TABLE orders
(
    id      SERIAL PRIMARY KEY,
    status  VARCHAR(8),
    user_id INTEGER REFERENCES users (id)
);

products:

CREATE TABLE products
(
    id       SERIAL PRIMARY KEY,
    name     VARCHAR(100),
    price    DECIMAL(4, 2),
    category VARCHAR(50)
);

order_products:

CREATE TABLE order_products
(
    id         SERIAL PRIMARY KEY,
    order_id   INTEGER REFERENCES orders (id),
    product_id INTEGER REFERENCES products (id),
    quantity   INTEGER
);

I am trying to create the entities, which represent these three tables. I tried to do this, but I am pretty sure something is off. Can you help me with this?

These are the entities I have created:

User:

@Entity('users')
export class User extends BaseEntity {

  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  firstname: string;

  @Column()
  lastname: string;

  @Column()
  username: string;

  @Column()
  password: string;
}

Product:

@Entity('products')
export class Product extends BaseEntity {

  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  name: string;

  @Column()
  price: number;

  @Column()
  category: string;
}

OrderProduct:

@Entity('order_products')
export class OrderProduct extends BaseEntity {

  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  quantity: number;

  @OneToOne(
    () => Order
  )
  @JoinColumn({
    name: 'order_id'
  })
  order: Order;

  @OneToMany(
    () => Product,
    product => product.id
  )
  @JoinColumn({
    name: 'product_id'
  })
  products: Product[];
}

I think the OrderProduct-entity is wrong: The OneToMany relationship will probably create a column "product_id" at the many-side of the relationship, which is the products-table. I want to have this column on my order_products table, however.


来源: stackexchange

问:
vscode terminal showing weird character in mac's terminal names
vscode
here in this picture is showing weird characters between terminal's name in my macbook

I tried quitting vscode multiple times and tried various option. But none matches to this problem

ContentLicense: CC BY-SA 4.0


问:
Code Coverage with Django 4.1 Raising OSError on run
i am using python 3.10.8, django 4.1.4, and coverage 6.5.0. I tried adding the coverage library to my django project to measure the test coverage, I followed the setup process as shown on the Official Django Documentation on testing.

Whenever I run the command below, its raises an error.

```<code>    coverage run --source='.' manage.py test myapp
</code>```

myapp name is a dummy name instead of my custom app name

Error:

```<code>    OSError: [WinError 127] The specified procedure could not be found
</code>```

Full Traceback is provided here

```<code>    Traceback (most recent call last):
  File "C:\Users\DUDO\Desktop\projects\salespace inc\app\web\manage.py", line 28, in <module>
    main()
  File "C:\Users\DUDO\Desktop\projects\salespace inc\app\web\manage.py", line 24, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\core\management\__init__.py", line 420, in execute
    django.setup()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\apps\registry.py", line 116, in populate
    app_config.import_models()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\apps\config.py", line 269, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\DUDO\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\auth\models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\auth\base_user.py", line 49, in <module>
    class AbstractBaseUser(models.Model):
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\base.py", line 141, in __new__
    new_class.add_to_class("_meta", Options(meta, app_label))
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\base.py", line 369, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\options.py", line 231, in contribute_to_class
    self.db_table, connection.ops.max_name_length()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\utils\connection.py", line 15, in __getattr__
    return getattr(self._connections[self._alias], item)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\utils\connection.py", line 62, in __getitem__
    conn = self.create_connection(alias)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\utils.py", line 193, in create_connection
    backend = load_backend(db["ENGINE"])
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\utils.py", line 113, in load_backend
    return import_module("%s.base" % backend_name)
  File "C:\Users\DUDO\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 6, in <module>
    from .features import DatabaseFeatures
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\postgis\features.py", line 1, in <module>
    from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\base\features.py", line 3, in <module>
    from django.contrib.gis.db import models
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\__init__.py", line 3, in <module>
    import django.contrib.gis.db.models.functions  # NOQA
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\functions.py", line 3, in <module>
    from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\fields.py", line 3, in <module>
    from django.contrib.gis import forms, gdal
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\forms\__init__.py", line 3, in <module>
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 40, in <module>
    from django.contrib.gis.gdal.driver import Driver
PS C:\Users\DUDO\Desktop\projects\salespace inc\app\web> coverage run manage.py test accounts
Traceback (most recent call last):
  File "C:\Users\DUDO\Desktop\projects\salespace inc\app\web\manage.py", line 28, in <module>
    main()
  File "C:\Users\DUDO\Desktop\projects\salespace inc\app\web\manage.py", line 24, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\core\management\__init__.py", line 420, in execute
    django.setup()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\apps\registry.py", line 116, in populate
    app_config.import_models()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\apps\config.py", line 269, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\DUDO\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\auth\models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\auth\base_user.py", line 49, in <module>
    class AbstractBaseUser(models.Model):
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\base.py", line 141, in __new__
    new_class.add_to_class("_meta", Options(meta, app_label))
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\base.py", line 369, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\options.py", line 231, in contribute_to_class
    self.db_table, connection.ops.max_name_length()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\utils\connection.py", line 15, in __getattr__
    return getattr(self._connections[self._alias], item)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\utils\connection.py", line 62, in __getitem__
    conn = self.create_connection(alias)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\utils.py", line 193, in create_connection
    backend = load_backend(db["ENGINE"])
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\utils.py", line 113, in load_backend
    return import_module("%s.base" % backend_name)
  File "C:\Users\DUDO\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 6, in <module>
    from .features import DatabaseFeatures
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\postgis\features.py", line 1, in <module>
    from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\base\features.py", line 3, in <module>
    from django.contrib.gis.db import models
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\__init__.py", line 3, in <module>
    import django.contrib.gis.db.models.functions  # NOQA
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\functions.py", line 3, in <module>
    from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\fields.py", line 3, in <module>
    from django.contrib.gis import forms, gdal
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\forms\__init__.py", line 3, in <module>
    from .fields import (  # NOQA
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\forms\fields.py", line 2, in <module>
    from django.contrib.gis.gdal import GDALException
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\gdal\__init__.py", line 28, in <module>
    from django.contrib.gis.gdal.datasource import DataSource
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 40, in <module>
    from django.contrib.gis.gdal.driver import Driver
    from django.contrib.gis.gdal.prototypes import ds as vcapi
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in <module>
    from django.contrib.gis.gdal.libgdal import lgdal
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 67, in <module>
    lgdal = CDLL(lib_path)
  File "C:\Users\DUDO\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 127] The specified procedure could not be found

</code>```

Body:
i am using python 3.10.8, django 4.1.4, and coverage 6.5.0. I tried adding the coverage library to my django project to measure the test coverage, I followed the setup process as shown on the Official Django Documentation on testing.

Whenever I run the command below, its raises an error.

    coverage run --source='.' manage.py test myapp

myapp name is a dummy name instead of my custom app name

Error:

    OSError: [WinError 127] The specified procedure could not be found

Full Traceback is provided here

    Traceback (most recent call last):
  File "C:\Users\DUDO\Desktop\projects\salespace inc\app\web\manage.py", line 28, in <module>
    main()
  File "C:\Users\DUDO\Desktop\projects\salespace inc\app\web\manage.py", line 24, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\core\management\__init__.py", line 420, in execute
    django.setup()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\apps\registry.py", line 116, in populate
    app_config.import_models()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\apps\config.py", line 269, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\DUDO\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\auth\models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\auth\base_user.py", line 49, in <module>
    class AbstractBaseUser(models.Model):
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\base.py", line 141, in __new__
    new_class.add_to_class("_meta", Options(meta, app_label))
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\base.py", line 369, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\options.py", line 231, in contribute_to_class
    self.db_table, connection.ops.max_name_length()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\utils\connection.py", line 15, in __getattr__
    return getattr(self._connections[self._alias], item)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\utils\connection.py", line 62, in __getitem__
    conn = self.create_connection(alias)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\utils.py", line 193, in create_connection
    backend = load_backend(db["ENGINE"])
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\utils.py", line 113, in load_backend
    return import_module("%s.base" % backend_name)
  File "C:\Users\DUDO\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 6, in <module>
    from .features import DatabaseFeatures
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\postgis\features.py", line 1, in <module>
    from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\base\features.py", line 3, in <module>
    from django.contrib.gis.db import models
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\__init__.py", line 3, in <module>
    import django.contrib.gis.db.models.functions  # NOQA
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\functions.py", line 3, in <module>
    from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\fields.py", line 3, in <module>
    from django.contrib.gis import forms, gdal
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\forms\__init__.py", line 3, in <module>
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 40, in <module>
    from django.contrib.gis.gdal.driver import Driver
PS C:\Users\DUDO\Desktop\projects\salespace inc\app\web> coverage run manage.py test accounts
Traceback (most recent call last):
  File "C:\Users\DUDO\Desktop\projects\salespace inc\app\web\manage.py", line 28, in <module>
    main()
  File "C:\Users\DUDO\Desktop\projects\salespace inc\app\web\manage.py", line 24, in main
    execute_from_command_line(sys.argv)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
    utility.execute()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\core\management\__init__.py", line 420, in execute
    django.setup()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\apps\registry.py", line 116, in populate
    app_config.import_models()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\apps\config.py", line 269, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\DUDO\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\auth\models.py", line 3, in <module>
    from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\auth\base_user.py", line 49, in <module>
    class AbstractBaseUser(models.Model):
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\base.py", line 141, in __new__
    new_class.add_to_class("_meta", Options(meta, app_label))
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\base.py", line 369, in add_to_class
    value.contribute_to_class(cls, name)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\models\options.py", line 231, in contribute_to_class
    self.db_table, connection.ops.max_name_length()
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\utils\connection.py", line 15, in __getattr__
    return getattr(self._connections[self._alias], item)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\utils\connection.py", line 62, in __getitem__
    conn = self.create_connection(alias)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\utils.py", line 193, in create_connection
    backend = load_backend(db["ENGINE"])
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\db\utils.py", line 113, in load_backend
    return import_module("%s.base" % backend_name)
  File "C:\Users\DUDO\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 6, in <module>
    from .features import DatabaseFeatures
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\postgis\features.py", line 1, in <module>
    from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\backends\base\features.py", line 3, in <module>
    from django.contrib.gis.db import models
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\__init__.py", line 3, in <module>
    import django.contrib.gis.db.models.functions  # NOQA
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\functions.py", line 3, in <module>
    from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\db\models\fields.py", line 3, in <module>
    from django.contrib.gis import forms, gdal
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\forms\__init__.py", line 3, in <module>
    from .fields import (  # NOQA
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\forms\fields.py", line 2, in <module>
    from django.contrib.gis.gdal import GDALException
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\gdal\__init__.py", line 28, in <module>
    from django.contrib.gis.gdal.datasource import DataSource
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 40, in <module>
    from django.contrib.gis.gdal.driver import Driver
    from django.contrib.gis.gdal.prototypes import ds as vcapi
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in <module>
    from django.contrib.gis.gdal.libgdal import lgdal
  File "C:\Users\DUDO\.virtualenvs\web-15Kcga0E\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 67, in <module>
    lgdal = CDLL(lib_path)
  File "C:\Users\DUDO\AppData\Local\Programs\Python\Python310\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 127] The specified procedure could not be found


问:
c#, build lambda expression dynamically
I don't have to much experience using expression tree's or building expressions dynamically. However, can somebody help point me in the correct direction following the examples below:

Both use TestTable class

EXAMPLE 1

```<code>public class TestTable
    {
        public int KeyID { get; set; }
        public int KeyID2 { get; set; }
        public string KeyName { get; set; }
    }
</code>```
```<code>Expression<Func<TestTable, object>> TableKeys = e => new { KeyID = e.KeyID, KeyID2 = e.KeyID2};
</code>```

The value of TableKeys ends up being  = {new <>f__AnonymousType0`2(KeyID = e.KeyID, KeyID2 = e.KeyID2)}

EXAMPLE 2

```<code>IList<string> FieldList = new List<string>();
            FieldList.Add("KeyID");
            FieldList.Add("KeyID2");
</code>```
```<code>var Result = DynamicFields<TestTable>(FieldList);

</code>```
```<code> public static Expression<Func<T, object>> DynamicFields<T>(IList<string> fields)
        {
            var source = Expression.Parameter(typeof(T), "e");
            var properties = fields
                .Select(f => typeof(T).GetProperty(f))
                .Select(p => new DynamicProperty(p.Name, p.PropertyType))
                .ToList();
            var resultType = DynamicClassFactory.CreateType(properties, false);
            var bindings = properties.Select(p => Expression.Bind(resultType.GetProperty(p.Name), Expression.Property(source, p.Name)));
            var result = Expression.MemberInit(Expression.New(resultType), bindings);

            return Expression.Lambda<Func<T, object>>(result, source);
        }
</code>```

The value of Result above ends up being =  {e => new {KeyID = e.KeyID, KeyID2 = e.KeyID2}}

How can I get the code in example 2 above to produce the same output of example 1?

Thanks
Again

Expecting the output of example 2 to produce the output of example 1

Title: c#, build lambda expression dynamically

Body:
I don't have to much experience using expression tree's or building expressions dynamically. However, can somebody help point me in the correct direction following the examples below:

Both use TestTable class

EXAMPLE 1

public class TestTable
    {
        public int KeyID { get; set; }
        public int KeyID2 { get; set; }
        public string KeyName { get; set; }
    }

Expression<Func<TestTable, object>> TableKeys = e => new { KeyID = e.KeyID, KeyID2 = e.KeyID2};

The value of TableKeys ends up being  = {new <>f__AnonymousType0`2(KeyID = e.KeyID, KeyID2 = e.KeyID2)}

EXAMPLE 2

IList<string> FieldList = new List<string>();
            FieldList.Add("KeyID");
            FieldList.Add("KeyID2");

var Result = DynamicFields<TestTable>(FieldList);

 public static Expression<Func<T, object>> DynamicFields<T>(IList<string> fields)
        {
            var source = Expression.Parameter(typeof(T), "e");
            var properties = fields
                .Select(f => typeof(T).GetProperty(f))
                .Select(p => new DynamicProperty(p.Name, p.PropertyType))
                .ToList();
            var resultType = DynamicClassFactory.CreateType(properties, false);
            var bindings = properties.Select(p => Expression.Bind(resultType.GetProperty(p.Name), Expression.Property(source, p.Name)));
            var result = Expression.MemberInit(Expression.New(resultType), bindings);

            return Expression.Lambda<Func<T, object>>(result, source);
        }

The value of Result above ends up being =  {e => new {KeyID = e.KeyID, KeyID2 = e.KeyID2}}

How can I get the code in example 2 above to produce the same output of example 1?

Thanks
Again

Expecting the output of example 2 to produce the output of example 1


问:
Wrapping component with Animated.View makes touch events propagate to component behind it
I have two sibling components

<MapContainer/>

<BottomUi>

the <BottomUi> overlays the map by using absolute positioning:

```<code>    bottomUi: {
      position: 'absolute',
      bottom: 0,
      width: '100%',
      alignItems: 'center',
    },
</code>```

Everything was fine until I decided to animate <BottomUi> using react's Animated api. It seems that wrapping the component with Animated.View causes any touches on the overlay (<BottomUi>) to reach the background (<MapContainer/>). Is there fix for this?

I tried the following with no success:

using onResponderStart={() => true} on the <BottomUi>

using pointerEvents which resulted in disabling touch events on <BottomUi> but the touch still reached the background component.

wrapping the component with TouchableWithoutFeedback

Here is my app.js:

```<code>/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow strict-local
 */

import React, {useContext, useEffect, useState} from 'react';
import {
  ActivityIndicator,
  Appearance,
  StyleSheet,
  Text,
  TextInput,
  View,
} from 'react-native';
import BottomUi from './src/components/bottomUi.component';
import Busy from './src/components/busy.component';
import Card from './src/components/card.component';
import InfoCard from './src/components/infoCard.component';
import MapContainer from './src/components/mapContainer.component';
import TopUi from './src/components/topUi.component';
import {PathProvider} from './src/context/path.context';
import {PointProvider} from './src/context/points.context';
import useToggle from './src/hooks/toggle.hook';
import useStorage from './src/hooks/useStorage.hook';
import {getStyles} from './src/utils/getStyles';

const App = () => {
  const colorScheme = Appearance.getColorScheme();
  const isDark = colorScheme === 'light' ? 'false' : 'true';
  const [coords, setcoords] = React.useState({
    latitude: 52.3727598,
    longitude: 4.8936041,
  });
  const [darkTheme, toggleTheme] = useToggle(isDark);
  const [cardVisible, toggleCard] = useToggle(true);
  const [gettingData, setgettingData] = useState(false);
  const [hightlightPoint, sethightlightPoint] = useState();
  const styles = getStyles(darkTheme);
  const {getObject} = useStorage();

  useEffect(() => {
    async function getStoredLocation() {
      try {
        const location = await getObject('@coords');
        console.log('location:::', location);
        if (!location || !location.latitude || !location.longitude) {
          return;
        }
        setcoords(location);
      } catch (error) {
        console.log(error);
      }
    }

    getStoredLocation();
  }, []);

  return (
    <View style={styles.home}>
      <PointProvider>
        <PathProvider>
          <MapContainer
            coords={coords}
            styles={styles}
            setgettingData={setgettingData}
            hightlightPoint={hightlightPoint}
          />
          <TopUi
            styles={styles}
            setcoords={setcoords}
            useDarkTheme={darkTheme}
            setuseDarkTheme={toggleTheme}
          />
          <BottomUi styles={styles} cardVisible={cardVisible}>
            {
              <Card
                styles={styles}
                toggleCard={toggleCard}
                sethightlightPoint={sethightlightPoint}
                gettingData={gettingData}
                cardVisible={cardVisible}
              />
            }
            <InfoCard
              isVisible={gettingData}
              styles={styles}
              message={<Busy styles={styles} />}
            />
          </BottomUi>
        </PathProvider>
      </PointProvider>
    </View>
  );
};

export default App;
</code>```

<BottomUi>:

```<code>import {
  View,
  Animated,
  TouchableWithoutFeedback,
  TouchableHighlight,
} from 'react-native';
import React, {useEffect, useState} from 'react';
export default function BottomUi({styles, cardVisible, children}) {
  const [yPosition] = useState(new Animated.Value(10));

  useEffect(() => {
    Animated.timing(yPosition, {
      toValue: cardVisible ? 0 : 200,
      duration: 250,
      useNativeDriver: true,
    }).start();
  }, [cardVisible]);

  return (
    <Animated.View style={{transform: [{translateY: yPosition}]}}>
      <View style={styles.bottomUi}>{children}</View>
    </Animated.View>
  );
}

</code>```

I have opened an issue for this: https://github.com/facebook/react-native/issues/35612

Body:
I have two sibling components

<MapContainer/>

<BottomUi>

the <BottomUi> overlays the map by using absolute positioning:

    bottomUi: {
      position: 'absolute',
      bottom: 0,
      width: '100%',
      alignItems: 'center',
    },

Everything was fine until I decided to animate <BottomUi> using react's Animated api. It seems that wrapping the component with Animated.View causes any touches on the overlay (<BottomUi>) to reach the background (<MapContainer/>). Is there fix for this?

I tried the following with no success:

using onResponderStart={() => true} on the <BottomUi>

using pointerEvents which resulted in disabling touch events on <BottomUi> but the touch still reached the background component.

wrapping the component with TouchableWithoutFeedback

Here is my app.js:

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow strict-local
 */

import React, {useContext, useEffect, useState} from 'react';
import {
  ActivityIndicator,
  Appearance,
  StyleSheet,
  Text,
  TextInput,
  View,
} from 'react-native';
import BottomUi from './src/components/bottomUi.component';
import Busy from './src/components/busy.component';
import Card from './src/components/card.component';
import InfoCard from './src/components/infoCard.component';
import MapContainer from './src/components/mapContainer.component';
import TopUi from './src/components/topUi.component';
import {PathProvider} from './src/context/path.context';
import {PointProvider} from './src/context/points.context';
import useToggle from './src/hooks/toggle.hook';
import useStorage from './src/hooks/useStorage.hook';
import {getStyles} from './src/utils/getStyles';

const App = () => {
  const colorScheme = Appearance.getColorScheme();
  const isDark = colorScheme === 'light' ? 'false' : 'true';
  const [coords, setcoords] = React.useState({
    latitude: 52.3727598,
    longitude: 4.8936041,
  });
  const [darkTheme, toggleTheme] = useToggle(isDark);
  const [cardVisible, toggleCard] = useToggle(true);
  const [gettingData, setgettingData] = useState(false);
  const [hightlightPoint, sethightlightPoint] = useState();
  const styles = getStyles(darkTheme);
  const {getObject} = useStorage();

  useEffect(() => {
    async function getStoredLocation() {
      try {
        const location = await getObject('@coords');
        console.log('location:::', location);
        if (!location || !location.latitude || !location.longitude) {
          return;
        }
        setcoords(location);
      } catch (error) {
        console.log(error);
      }
    }

    getStoredLocation();
  }, []);

  return (
    <View style={styles.home}>
      <PointProvider>
        <PathProvider>
          <MapContainer
            coords={coords}
            styles={styles}
            setgettingData={setgettingData}
            hightlightPoint={hightlightPoint}
          />
          <TopUi
            styles={styles}
            setcoords={setcoords}
            useDarkTheme={darkTheme}
            setuseDarkTheme={toggleTheme}
          />
          <BottomUi styles={styles} cardVisible={cardVisible}>
            {
              <Card
                styles={styles}
                toggleCard={toggleCard}
                sethightlightPoint={sethightlightPoint}
                gettingData={gettingData}
                cardVisible={cardVisible}
              />
            }
            <InfoCard
              isVisible={gettingData}
              styles={styles}
              message={<Busy styles={styles} />}
            />
          </BottomUi>
        </PathProvider>
      </PointProvider>
    </View>
  );
};

export default App;

<BottomUi>:

import {
  View,
  Animated,
  TouchableWithoutFeedback,
  TouchableHighlight,
} from 'react-native';
import React, {useEffect, useState} from 'react';
export default function BottomUi({styles, cardVisible, children}) {
  const [yPosition] = useState(new Animated.Value(10));

  useEffect(() => {
    Animated.timing(yPosition, {
      toValue: cardVisible ? 0 : 200,
      duration: 250,
      useNativeDriver: true,
    }).start();
  }, [cardVisible]);

  return (
    <Animated.View style={{transform: [{translateY: yPosition}]}}>
      <View style={styles.bottomUi}>{children}</View>
    </Animated.View>
  );
}

I have opened an issue for this: https://github.com/facebook/react-native/issues/35612


问:
Why does my code say "TypeError: 'int' object is not callable" in my text based fighter code?
```<code>import random

class Character:
    def __init__(self, name, hp, attack, dodge):
        self.name = name
        self.hp = hp
        self.attack = attack
        self.dodge = dodge

    def take_damage(self, damage):
        self.hp -= damage

    def attack(self, target):
        damage = self.attack
        target.take_damage(damage)
        print(f"{self.name} attacks {target.name} for {damage} damage!")

class Player(Character):
    def __init__(self, name, hp, attack, dodge):
        super().__init__(name, hp, attack, dodge)

class Enemy(Character):
    def __init__(self, name, hp, attack, dodge):
        super().__init__(name, hp, attack, dodge)

    fighter = Player("Fighter", 5, 3, 2)
    mage = Player("Mage" ,1, 5, 4)
    thief = Player("Thief" ,4, 3, 4)

    print("Welcome to Fighter Arena")
    x = input("Enter Your Name: ")
    print("Choose Your Character (fighter = 1 | mage = 2 | thief = 3)")
    choice = input()

    if choice == '1':
      player = fighter

    if choice == '2':
      player = mage

    if choice == '3':
      player = thief

    while True:
      enemy = random.randint(1,3)
      if enemy == 1:
        enemy = fighter
        print("\nYou are fighting a fighter!")
        break
      if enemy == 2:
        enemy = mage
        print("\nYou are fighting a mage!")
        break
      if enemy == 3:
        enemy = thief
        print("\nYou are fighting a thief!")
        break

    while player.hp > 0 and enemy.hp > 0:
        player.attack(enemy)
        if enemy.hp <= 0:
            break
        enemy.attack(player)
        if player.hp <= 0:
            break

        if player.hp > 0:
            print("You win!")
        else:
            print("You lose!")
</code>```

Traceback (most recent call last):
File "main.py", line 1, in
from player import Player, Character, Enemy
File "/home/runner/ClassesAssessment/player.py", line 23, in
class Enemy(Character):
File "/home/runner/ClassesAssessment/player.py", line 61, in Enemy
int(player.attack(enemy))
TypeError: 'int' object is not callable

I tried changing any other objects, classes, etc also named player or changing the syntax but none of it worked. I believe there is something wrong when I am assigning the different fighter classes (mage, fighter, thief) and all that I've searched has not helped me.

Body:
import random

class Character:
    def __init__(self, name, hp, attack, dodge):
        self.name = name
        self.hp = hp
        self.attack = attack
        self.dodge = dodge

    def take_damage(self, damage):
        self.hp -= damage

    def attack(self, target):
        damage = self.attack
        target.take_damage(damage)
        print(f"{self.name} attacks {target.name} for {damage} damage!")

class Player(Character):
    def __init__(self, name, hp, attack, dodge):
        super().__init__(name, hp, attack, dodge)

class Enemy(Character):
    def __init__(self, name, hp, attack, dodge):
        super().__init__(name, hp, attack, dodge)

    fighter = Player("Fighter", 5, 3, 2)
    mage = Player("Mage" ,1, 5, 4)
    thief = Player("Thief" ,4, 3, 4)

    print("Welcome to Fighter Arena")
    x = input("Enter Your Name: ")
    print("Choose Your Character (fighter = 1 | mage = 2 | thief = 3)")
    choice = input()

    if choice == '1':
      player = fighter

    if choice == '2':
      player = mage

    if choice == '3':
      player = thief

    while True:
      enemy = random.randint(1,3)
      if enemy == 1:
        enemy = fighter
        print("\nYou are fighting a fighter!")
        break
      if enemy == 2:
        enemy = mage
        print("\nYou are fighting a mage!")
        break
      if enemy == 3:
        enemy = thief
        print("\nYou are fighting a thief!")
        break

    while player.hp > 0 and enemy.hp > 0:
        player.attack(enemy)
        if enemy.hp <= 0:
            break
        enemy.attack(player)
        if player.hp <= 0:
            break

        if player.hp > 0:
            print("You win!")
        else:
            print("You lose!")

Traceback (most recent call last):
File "main.py", line 1, in
from player import Player, Character, Enemy
File "/home/runner/ClassesAssessment/player.py", line 23, in
class Enemy(Character):
File "/home/runner/ClassesAssessment/player.py", line 61, in Enemy
int(player.attack(enemy))
TypeError: 'int' object is not callable

I tried changing any other objects, classes, etc also named player or changing the syntax but none of it worked. I believe there is something wrong when I am assigning the different fighter classes (mage, fighter, thief) and all that I've searched has not helped me.


问:
Drive runs at different speeds with different programs
I have a python script that checks the speed of the selected drive.

It's 103 lines so I won't paste the whole thing, but the important parts are here:

```<code># Write
start_time_w = time.time()
with open (location, "w") as f:
    try:
        f.write("0" * 1000 * 1000 * size) # We want size in MiB // size is int(64)
        f.close()
        finish_time_w = time.time()
    except Exception as e:
        # try removing the file if it was created
        try: f.close(), os.remove(location)
        except OSError: pass
        print(f"Something went wrong...\n{e}")
        input()
        return
time_taken = round(finish_time_w-start_time_w, 1)
print(f"Wrote {size}MiB in {time_taken} ({round(size/time_taken, 2)}MiB/s)")
</code>```

and

```<code># Read
start_time_r = time.time()
with open (location, "r") as f:
    try:
        f.read()
        f.close()
        finish_time_r = time.time()
    except Exception as e:
        # try removing the file
        try: f.close(), os.remove(location)
        except OSError: pass
        print(f"Something went wrong...\n{e}")
        input()
        return
time_taken = finish_time_r-start_time_r
print(f"Read {round(size, 1)}MiB in {time_taken}s ({round(size/time_taken, 2)}MiB/s)")
</code>```

To test the accuracy of my program I ran a program called CrystalDiskInfo which shows the speed of a selected drive.

All tests were ran without any background usage and writing/reading 64MiB
I tested my removable USB drive X: (a patriot drive model 1633 PHMPH) and got these results with my program:

I tested the same drive with CrystalDiskMark and got these results

Why are the wright results not matching with any of the 4 types of tests provided by CDM?

Why is my read speed plentifold higher than CDM?

How do I fix these issues?

(edit: I do realize that CDM has size in MiB and speed in MB/s, while my program has both in MiB, However the difference should not be this drastic, as 1 MB is 1.048576 MiB)

Body:
I have a python script that checks the speed of the selected drive.

It's 103 lines so I won't paste the whole thing, but the important parts are here:

# Write
start_time_w = time.time()
with open (location, "w") as f:
    try:
        f.write("0" * 1000 * 1000 * size) # We want size in MiB // size is int(64)
        f.close()
        finish_time_w = time.time()
    except Exception as e:
        # try removing the file if it was created
        try: f.close(), os.remove(location)
        except OSError: pass
        print(f"Something went wrong...\n{e}")
        input()
        return
time_taken = round(finish_time_w-start_time_w, 1)
print(f"Wrote {size}MiB in {time_taken} ({round(size/time_taken, 2)}MiB/s)")

and

# Read
start_time_r = time.time()
with open (location, "r") as f:
    try:
        f.read()
        f.close()
        finish_time_r = time.time()
    except Exception as e:
        # try removing the file
        try: f.close(), os.remove(location)
        except OSError: pass
        print(f"Something went wrong...\n{e}")
        input()
        return
time_taken = finish_time_r-start_time_r
print(f"Read {round(size, 1)}MiB in {time_taken}s ({round(size/time_taken, 2)}MiB/s)")

To test the accuracy of my program I ran a program called CrystalDiskInfo which shows the speed of a selected drive.

All tests were ran without any background usage and writing/reading 64MiB
I tested my removable USB drive X: (a patriot drive model 1633 PHMPH) and got these results with my program:

I tested the same drive with CrystalDiskMark and got these results

Why are the wright results not matching with any of the 4 types of tests provided by CDM?

Why is my read speed plentifold higher than CDM?

How do I fix these issues?

(edit: I do realize that CDM has size in MiB and speed in MB/s, while my program has both in MiB, However the difference should not be this drastic, as 1 MB is 1.048576 MiB)


问:
GGplot2 plots and dataTables having conditionalPanel suddenly disappeared in shiny dashboard
I am new to shiny dashboard.  I was making few data tables and plots in shiny session. It was working fine two days ago. All the output was working perfectly for last 2 days.
I had used global functions to for the  the plot and tables and called them from within the shiny server with appropriate reactive elements. It worked fine.

But when suddenly something went wrong when revisited my work  for final checks and the plots and data tables now show up as just blank , the select menu options do not display any more. I am in sort of panic now as this was an assigned task to me and I have a deadline.

All the conditional panel related work has mostly disappeared and syntax wise everything looks fine. I am using 2 files system for the dashboard with some conditionalPanels , Tabitems and tabPanels.

Please help!! And guide me what possibly could have gone wrongs so that I can do the checks.

Thanks.


问:
Vite TypeScript with Qwik (SSR)
I need your help on understanding, I'm contributing to an open-source and feature that is needed is "As a user I want to click on SOMEKEY so that I can focus on the search input so I don't have to do that manually", and I'm having some troubles adding the useRef to the input.

I have basic typescript understanding, and this is the error I get:

"Cannot read properties of null (reading 'useRef')"

My code (that triggers the error):

```<code>const textInputRef = useRef<HTMLInputElement>(null)
</code>```

&&:

```<code><input
      ref={textInputRef} <== this one
      window:onKeyDown$={(e) => console.log(e.key)}
      onKeyUp$={props.onKeyUp$}
      onInput$={props.onInput$}
      value={state.inputValue}
      type="text"
      id="urlInput"
      class="input input-bordered focus:outline-0 bg-base-200
flex-auto w-full sm:w-auto mb-2"
      placeholder="Very long url..."
      aria-label="url"
      aria-describedby="shortenerBtn"
    />
</code>```

full code:

```<code>import { component$, useContext } from '@builder.io/qwik';
import { useRef } from 'react';
import { InputContext, Store } from '~/routes';
import { ShortenerInputBtn } from './shortener-input-btn';

export interface ShortenerInputProps {
  onKeyUp$: (event: KeyboardEvent) => void;
  onInput$: (event: InputEvent) => void;
  onSubmit$: () => void;
}

export const ShortenerInput = component$((props:
ShortenerInputProps) => {
  const state: Store = useContext(InputContext) as Store;
  const textInputRef = useRef<HTMLInputElement>(null)

  return (
    <div className="form-control">
      <div class="sm:input-group mb-3 flex-col sm:flex-row gap-2
sm:gap-0">
        <input
          ref={textInputRef}
          window:onKeyDown$={(e) => console.log(e.key)}
          onKeyUp$={props.onKeyUp$}
          onInput$={props.onInput$}
          value={state.inputValue}
          type="text"
          id="urlInput"
          class="input input-bordered focus:outline-0 bg-base-200
flex-auto w-full sm:w-auto mb-2"
          placeholder="Very long url..."
          aria-label="url"
          aria-describedby="shortenerBtn"
        />
        <ShortenerInputBtn disabled={state.inputValue.length ===
0} onClick$={props.onSubmit$} />
      </div>
    </div>
  );
});
</code>```

any suggestion how to bypass that "useRef is null" error?

Title: Vite TypeScript with Qwik (SSR)

Body:
I need your help on understanding, I'm contributing to an open-source and feature that is needed is "As a user I want to click on SOMEKEY so that I can focus on the search input so I don't have to do that manually", and I'm having some troubles adding the useRef to the input.

I have basic typescript understanding, and this is the error I get:

"Cannot read properties of null (reading 'useRef')"

My code (that triggers the error):

const textInputRef = useRef<HTMLInputElement>(null)

&&:

<input
      ref={textInputRef} <== this one
      window:onKeyDown$={(e) => console.log(e.key)}
      onKeyUp$={props.onKeyUp$}
      onInput$={props.onInput$}
      value={state.inputValue}
      type="text"
      id="urlInput"
      class="input input-bordered focus:outline-0 bg-base-200
flex-auto w-full sm:w-auto mb-2"
      placeholder="Very long url..."
      aria-label="url"
      aria-describedby="shortenerBtn"
    />

full code:

import { component$, useContext } from '@builder.io/qwik';
import { useRef } from 'react';
import { InputContext, Store } from '~/routes';
import { ShortenerInputBtn } from './shortener-input-btn';

export interface ShortenerInputProps {
  onKeyUp$: (event: KeyboardEvent) => void;
  onInput$: (event: InputEvent) => void;
  onSubmit$: () => void;
}

export const ShortenerInput = component$((props:
ShortenerInputProps) => {
  const state: Store = useContext(InputContext) as Store;
  const textInputRef = useRef<HTMLInputElement>(null)

  return (

        <input
          ref={textInputRef}
          window:onKeyDown$={(e) => console.log(e.key)}
          onKeyUp$={props.onKeyUp$}
          onInput$={props.onInput$}
          value={state.inputValue}
          type="text"
          id="urlInput"
          class="input input-bordered focus:outline-0 bg-base-200
flex-auto w-full sm:w-auto mb-2"
          placeholder="Very long url..."
          aria-label="url"
          aria-describedby="shortenerBtn"
        />
        <ShortenerInputBtn disabled={state.inputValue.length ===
0} onClick$={props.onSubmit$} />

  );
});

any suggestion how to bypass that "useRef is null" error?


问:
How can I build a VBA web scraper to extract dynamically generated links/table entries?
I am trying to build a web scraper to extract the links/table entries from the following page:

https://www.adr.db.com/drwebrebrand/dr-universe/corporate_actions_type_e.html

I then want to import these all into an excel sheet. I want to repeat this each day and import the new entries, so I'm thinking a VBA macro that I just have to click once per day might be best to keep it all in the sheet. Another option I've explored is using Apify, but I'm less familiar with how to use it.

However, my web scraping knowledge is limited and all I've been able to do so far is extract the html source code. The relevant part of that looks like this:

 View full details

Which means the URLs are dynamically generated with Javascript, so I'm not actually able to see the generated links for each entry. How would I go about extracting the actual links?

If it helps, this is my VBA code for extracting the HTML:

```<code>Sub Oval1_Click()
Dim result As String
Dim myURL As String
Dim winHttpReq As Object
Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")

myURL = "https://www.adr.db.com/drwebrebrand/dr-universe/corporate_actions_type_e.html"

winHttpReq.Open "GET", myURL, False
winHttpReq.send

result = winHttpReq.responseText
Range("A1").Value = result

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
Set oFile = fso.CreateTextFile("DB_source.txt")
oFile.WriteLine result
oFile.Close
Set fso = Nothing
Set oFile = Nothing

End Sub
</code>```

Body:
I am trying to build a web scraper to extract the links/table entries from the following page:

https://www.adr.db.com/drwebrebrand/dr-universe/corporate_actions_type_e.html

I then want to import these all into an excel sheet. I want to repeat this each day and import the new entries, so I'm thinking a VBA macro that I just have to click once per day might be best to keep it all in the sheet. Another option I've explored is using Apify, but I'm less familiar with how to use it.

However, my web scraping knowledge is limited and all I've been able to do so far is extract the html source code. The relevant part of that looks like this:

 View full details

Which means the URLs are dynamically generated with Javascript, so I'm not actually able to see the generated links for each entry. How would I go about extracting the actual links?

If it helps, this is my VBA code for extracting the HTML:

Sub Oval1_Click()
Dim result As String
Dim myURL As String
Dim winHttpReq As Object
Set winHttpReq = CreateObject("WinHttp.WinHttpRequest.5.1")

myURL = "https://www.adr.db.com/drwebrebrand/dr-universe/corporate_actions_type_e.html"

winHttpReq.Open "GET", myURL, False
winHttpReq.send

result = winHttpReq.responseText
Range("A1").Value = result

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
Set oFile = fso.CreateTextFile("DB_source.txt")
oFile.WriteLine result
oFile.Close
Set fso = Nothing
Set oFile = Nothing

End Sub


问:
My cursor fetch throws null in every variable
So I have this procedure:

```<code>BEGIN
DECLARE noRow int(5);
DECLARE codmensc int(5);
DECLARE titulosc varchar(30);
DECLARE emisorsc varchar(30);
DECLARE nombmedsc varchar(30);
DECLARE cantsc int(5);
DECLARE codmedsc int(5);
DECLARE totsc double(8,2);
DECLARE calo CURSOR FOR
    SELECT m.codmen, m.titulo, m.emisor, me.nombmed, m.cant, m.codmed, m.cant*me.precunit as tot
    FROM mensaje m
    JOIN medicina me on m.codmed=me.codmed
    JOIN cliente c on c.codcli = m.codcli
    WHERE c.usuario = usuarioactual;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET noRow = 0;

OPEN calo;

LOOPROWS: LOOP
        IF noRow = 0 THEN
            CLOSE calo;
            LEAVE LOOPROWS;
        END IF;

        FETCH calo INTO codmensc, titulosc, emisorsc, nombmedsc, cantsc, codmedsc, totsc;

        SELECT codmensc , titulosc , emisorsc , nombmedsc , cantsc , totsc;

    END LOOP;
END
</code>```

It was created with no exceptions, but when I call it, it gives me this result:
result

At first, my variables where named like the select attributes in the cursor. I changed them, expecting for that to be the problem, but it kept throwing null.

P.S: Every table has data.

Body:
So I have this procedure:

BEGIN
DECLARE noRow int(5);
DECLARE codmensc int(5);
DECLARE titulosc varchar(30);
DECLARE emisorsc varchar(30);
DECLARE nombmedsc varchar(30);
DECLARE cantsc int(5);
DECLARE codmedsc int(5);
DECLARE totsc double(8,2);
DECLARE calo CURSOR FOR
    SELECT m.codmen, m.titulo, m.emisor, me.nombmed, m.cant, m.codmed, m.cant*me.precunit as tot
    FROM mensaje m
    JOIN medicina me on m.codmed=me.codmed
    JOIN cliente c on c.codcli = m.codcli
    WHERE c.usuario = usuarioactual;

DECLARE CONTINUE HANDLER FOR NOT FOUND SET noRow = 0;

OPEN calo;

LOOPROWS: LOOP
        IF noRow = 0 THEN
            CLOSE calo;
            LEAVE LOOPROWS;
        END IF;

        FETCH calo INTO codmensc, titulosc, emisorsc, nombmedsc, cantsc, codmedsc, totsc;

        SELECT codmensc , titulosc , emisorsc , nombmedsc , cantsc , totsc;

    END LOOP;
END

It was created with no exceptions, but when I call it, it gives me this result:
result

At first, my variables where named like the select attributes in the cursor. I changed them, expecting for that to be the problem, but it kept throwing null.

P.S: Every table has data.


问:
Handle inputs from a gamepad with Processing for Android
I’m trying to use Processing for Android to get inputs from a physical game controller (with buttons and joysticks).

I am using the Android documentation on controller actions as a guide.

Tl;dr: I'm struggling to find how to override the necessary callbacks (onGenericMotionEvent(), onKeyDown(), onKeyUp()) in the context of Processing since it instantiates the Activity and View itself.

Here's what I have managed so far:

Compile Processing examples to the device (specifically the RG353V, an Android-based handheld gaming console from Anbernic)

Use android.view.InputDevice to make a list of input devices and output their names to the console

Filter the input devices that are game controllers

Register an input device listener to receive notifications about when input devices are added, removed or changed using inputManager.registerInputDeviceListener()

Get the main activity with Activity activity = getActivity()

Get the root view with ViewGroup rootView = activity.findViewById(android.R.id.content);

I now want to capture button/joystick events but this is where my trouble starts.

All the examples I found involve implementing a custom view and overriding onGenericMotionEvent() for joystick events, and onKeyDown()/onKeyUp() for button events.

Only Processing instantiates the main Activity and View on its own, so I don't know to override those callbacks. Is it even possible to override a method on an instance of a class?

I was hoping to find something similar to registerInputDeviceListener() in the InputManager class or registerListener() in the SensorManager class, but I haven't found a method that would allow to register callbacks for button and joystick input in the InputDevice class in the same way.

I'll be grateful for any pointers.

PS: I posted a feature request on the Processing for Android repo.


问:
How to make a listview work in Xamarin (VS 2022)
Here's this code. It sort of runs but then abends. How do I make the choice work? And additionally, I wrote (copied) this code about 18 months ago, so I am vague as to why it seems so backward:

```<code>void SwitchNumber()
{

    var dialogView = LayoutInflater.Inflate(Resource.Layout.list_view, null);
    Android.App.AlertDialog alertDialog;

    listview = dialogView.FindViewById<ListView>(Resource.Id.listview);
    textview = dialogView.FindViewById<TextView>(Resource.Id.textview);

    var items = new string[] { "1","2","3" };
    var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, items);
    using (var dialog = new Android.App.AlertDialog.Builder(this))
    {
        listview.Adapter = adapter;
        listview.ItemClick += Listview_ItemClick;

        dialog.SetTitle("Switch Number");
        dialog.SetMessage("Click on the number you want to switch to");
        dialog.SetView(dialogView);
        string newNumber = string.Empty;
        dialog.SetNegativeButton("Cancel", (s, a) => { });
        dialog.SetPositiveButton("OK", (s, a) =>
        {

            switch (prefs.GetInt("selectitemforAlert", 0))
            {
                case 0:
                    newNumber = "1";
                    break;
                case 1:
                    newNumber = "2";
                    break;
                case 2:
                    newNumber = "3";
                    break;

                default:
                    currentNumber = "1";
                    break;
            }
        }//switch
            );
        if (newNumber == currentNumber) return;

        ChangeNumber(newNumber);

        alertDialog = dialog.Create();
        //   }
    }
    //using
    dialogView.FindViewById<ListView>(Resource.Id.listview).Adapter = adapter;
    alertDialog.Show();
    listview.Adapter = adapter;
    listview.ItemClick += Listview_ItemClick;
}
</code>```

The list does appear but I get a null object reference.

Body:
Here's this code. It sort of runs but then abends. How do I make the choice work? And additionally, I wrote (copied) this code about 18 months ago, so I am vague as to why it seems so backward:

void SwitchNumber()
{

    var dialogView = LayoutInflater.Inflate(Resource.Layout.list_view, null);
    Android.App.AlertDialog alertDialog;

    listview = dialogView.FindViewById<ListView>(Resource.Id.listview);
    textview = dialogView.FindViewById<TextView>(Resource.Id.textview);

    var items = new string[] { "1","2","3" };
    var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, items);
    using (var dialog = new Android.App.AlertDialog.Builder(this))
    {
        listview.Adapter = adapter;
        listview.ItemClick += Listview_ItemClick;

        dialog.SetTitle("Switch Number");
        dialog.SetMessage("Click on the number you want to switch to");
        dialog.SetView(dialogView);
        string newNumber = string.Empty;
        dialog.SetNegativeButton("Cancel", (s, a) => { });
        dialog.SetPositiveButton("OK", (s, a) =>
        {

            switch (prefs.GetInt("selectitemforAlert", 0))
            {
                case 0:
                    newNumber = "1";
                    break;
                case 1:
                    newNumber = "2";
                    break;
                case 2:
                    newNumber = "3";
                    break;

                default:
                    currentNumber = "1";
                    break;
            }
        }//switch
            );
        if (newNumber == currentNumber) return;

        ChangeNumber(newNumber);

        alertDialog = dialog.Create();
        //   }
    }
    //using
    dialogView.FindViewById<ListView>(Resource.Id.listview).Adapter = adapter;
    alertDialog.Show();
    listview.Adapter = adapter;
    listview.ItemClick += Listview_ItemClick;
}

The list does appear but I get a null object reference.


问:
Local Storage not persisting on refresh
I am going back and working on a previous project in my bootcamp, because I would like to add it to my personal portfolio. I have an issue with local storage not persisting on refresh. It stores the values and saves them in local storage, on refresh though it will not display the values I stored until I choose to store another value, then it will display all previous values along with the new one I added. Any thoughts?

```<code>//Save to local storage function
$("#saveButton").on("click", function() {

    savedMovieObj = {
        Title: tmdbMovieData.results[currentMovieIndex].title,
        Release: tmdbMovieData.results[currentMovieIndex].release_date,
        Overview: tmdbMovieData.results[currentMovieIndex].overview,
        Stars: tmdbMovieData.results[currentMovieIndex].vote_average / 2,
        Poster: tmdbMovieData.results[currentMovieIndex].poster_path,
        VideoID: globalVideoId,
    };

    var movieHistArr = JSON.parse(localStorage.getItem("savedMovieObj"));
    if (!movieHistArr) {
        movieHistArr = [];
    }

    var hasMovie = movieHistArr.find(function(movie) {
        return movie.Title === savedMovieObj.Title;
    });

    if (!hasMovie) {
        movieHistArr.push(savedMovieObj);
    }

    localStorage.setItem("savedMovieObj", JSON.stringify(movieHistArr));
    //console.log(movieHistArr);

    $("#myList").empty()
    for (var i = 0; i < movieHistArr.length; i++) {
        var storedMovieEl = $(
            '<li class=  text-slate-400 ">'
        );
        var storedMovie = storedMovieEl
            .text(movieHistArr[i].Title)

        $("#myList").append(storedMovie);
    }
});
</code>```

I have tried using replace as opposed to empty, but did not produce the effect I thought it would.

Title: Local Storage not persisting on refresh

Body:
I am going back and working on a previous project in my bootcamp, because I would like to add it to my personal portfolio. I have an issue with local storage not persisting on refresh. It stores the values and saves them in local storage, on refresh though it will not display the values I stored until I choose to store another value, then it will display all previous values along with the new one I added. Any thoughts?

//Save to local storage function
$("#saveButton").on("click", function() {

    savedMovieObj = {
        Title: tmdbMovieData.results[currentMovieIndex].title,
        Release: tmdbMovieData.results[currentMovieIndex].release_date,
        Overview: tmdbMovieData.results[currentMovieIndex].overview,
        Stars: tmdbMovieData.results[currentMovieIndex].vote_average / 2,
        Poster: tmdbMovieData.results[currentMovieIndex].poster_path,
        VideoID: globalVideoId,
    };

    var movieHistArr = JSON.parse(localStorage.getItem("savedMovieObj"));
    if (!movieHistArr) {
        movieHistArr = [];
    }

    var hasMovie = movieHistArr.find(function(movie) {
        return movie.Title === savedMovieObj.Title;
    });

    if (!hasMovie) {
        movieHistArr.push(savedMovieObj);
    }

    localStorage.setItem("savedMovieObj", JSON.stringify(movieHistArr));
    //console.log(movieHistArr);

    $("#myList").empty()
    for (var i = 0; i < movieHistArr.length; i++) {
        var storedMovieEl = $(
            '
'
        );
        var storedMovie = storedMovieEl
            .text(movieHistArr[i].Title)

        $("#myList").append(storedMovie);
    }
});

I have tried using replace as opposed to empty, but did not produce the effect I thought it would.


问:
SSH connection made through VS Code bypassing the bash files in /etc/profile.d
I need to make a reservation website, this website lets users book a certain server, further the users will be allowed to make ssh to the server only in the time it is booked by them. I am storing the bookings info in MuSQL. In each server I have added a bash file in the directory /etc/profile.d that runs whenever there is a request for making an ssh connection. This bash file manages if the user can be allowed to make the ssh connection or not.

The bash file checks the MySQL database and finds if there is a reservation made by the user. When I make a ssh through the terminal in my windows computer, everything works as expected(I can make a connection when I have booked the server, otherwise I am kicked out). However when I try to make the SSH connection with VS code, it connects to the server regardless of the booking status. One interesting thing is that "who" command in the vs code terminal after the ssh connection does not list the current username(with with the ssh is made to the server through vs code).


问:
How to access a Sprite that is created in another module
I am using pixi with typescript and I am required to create a number of sprites in a separate module(class based) and access them one by one from the main module.

The module is imported in the main module. First i load all the images in the loader, after that i generate textures and sprites for each of them. But I can't find a way to access them from the main module to put them in the stage.
I have tried setting all flags to public and still no result.


问:
Heroku Build keeps failing, node issue?
Heroku asks that I specify version in package.json, which I have done:

```<code>"engines": {
    "node": "16.16.0",
    "npm": "8.11.0"
  }
</code>```

I would normally have put the x after version, but read that specifying the exact version may help.

Below are the errors I get with the build:

```<code>-----> Build
remote:        Detected both "build" and "heroku-postbuild" scripts
remote:        Running heroku-postbuild
remote:
remote:        > wino@1.0.0 heroku-postbuild
remote:        > npm run build
remote:
remote:
remote:        > wino@1.0.0 build
remote:        > cd client && npm run build
remote:
remote:
remote:        > wino@0.1.0 build
remote:        > react-scripts build
remote:
remote:        Creating an optimized production build...
remote: Error: error:0308010C:digital envelope routines::unsupported
remote:     at new Hash (node:internal/crypto/hash:71:19)
remote:     at Object.createHash (node:crypto:140:10)
remote:     at module.exports (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/util/createHash.js:90:53)
remote:     at NormalModule._initBuildHash (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:401:16)
remote:     at handleParseError (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:449:10)
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:481:5
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:342:12
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:373:3
remote:     at iterateNormalLoaders (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
remote:     at iterateNormalLoaders (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:236:3
remote:     at runSyncOrAsync (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
remote:     at iterateNormalLoaders (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
remote:     at Array.<anonymous> (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
remote:     at Storage.finished (/tmp/build_25ff6fd3/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
remote:     at /tmp/build_25ff6fd3/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9
remote: /tmp/build_25ff6fd3/client/node_modules/react-scripts/scripts/build.js:19
remote:   throw err;
remote:   ^
remote:
remote: Error: error:0308010C:digital envelope routines::unsupported
remote:     at new Hash (node:internal/crypto/hash:71:19)
remote:     at Object.createHash (node:crypto:140:10)
remote:     at module.exports (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/util/createHash.js:90:53)
remote:     at NormalModule._initBuildHash (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:401:16)
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:433:10
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:308:13
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:367:11
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:233:18
remote:     at context.callback (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
remote:     at /tmp/build_25ff6fd3/client/node_modules/babel-loader/lib/index.js:51:103 {
remote:   opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
remote:   library: 'digital envelope routines',
remote:   reason: 'unsupported',
remote:   code: 'ERR_OSSL_EVP_UNSUPPORTED'
remote: }
remote:
remote: Node.js v19.2.0
remote:
remote: -----> Build failed
</code>```

Also, I have been getting errors about upgrading the stack to Heroku-22. I was working on that, but it seems to be trying to build to that stack anyway so I don't think that's the issue.
Thanks in advance for the help!

Title: Heroku Build keeps failing, node issue?

Body:
Heroku asks that I specify version in package.json, which I have done:

"engines": {
    "node": "16.16.0",
    "npm": "8.11.0"
  }

I would normally have put the x after version, but read that specifying the exact version may help.

Below are the errors I get with the build:

-----> Build
remote:        Detected both "build" and "heroku-postbuild" scripts
remote:        Running heroku-postbuild
remote:
remote:        > wino@1.0.0 heroku-postbuild
remote:        > npm run build
remote:
remote:
remote:        > wino@1.0.0 build
remote:        > cd client && npm run build
remote:
remote:
remote:        > wino@0.1.0 build
remote:        > react-scripts build
remote:
remote:        Creating an optimized production build...
remote: Error: error:0308010C:digital envelope routines::unsupported
remote:     at new Hash (node:internal/crypto/hash:71:19)
remote:     at Object.createHash (node:crypto:140:10)
remote:     at module.exports (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/util/createHash.js:90:53)
remote:     at NormalModule._initBuildHash (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:401:16)
remote:     at handleParseError (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:449:10)
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:481:5
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:342:12
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:373:3
remote:     at iterateNormalLoaders (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:214:10)
remote:     at iterateNormalLoaders (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:221:10)
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:236:3
remote:     at runSyncOrAsync (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
remote:     at iterateNormalLoaders (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:232:2)
remote:     at Array.<anonymous> (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:205:4)
remote:     at Storage.finished (/tmp/build_25ff6fd3/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:43:16)
remote:     at /tmp/build_25ff6fd3/client/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:79:9
remote: /tmp/build_25ff6fd3/client/node_modules/react-scripts/scripts/build.js:19
remote:   throw err;
remote:   ^
remote:
remote: Error: error:0308010C:digital envelope routines::unsupported
remote:     at new Hash (node:internal/crypto/hash:71:19)
remote:     at Object.createHash (node:crypto:140:10)
remote:     at module.exports (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/util/createHash.js:90:53)
remote:     at NormalModule._initBuildHash (/tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:401:16)
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:433:10
remote:     at /tmp/build_25ff6fd3/client/node_modules/webpack/lib/NormalModule.js:308:13
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:367:11
remote:     at /tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:233:18
remote:     at context.callback (/tmp/build_25ff6fd3/client/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
remote:     at /tmp/build_25ff6fd3/client/node_modules/babel-loader/lib/index.js:51:103 {
remote:   opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
remote:   library: 'digital envelope routines',
remote:   reason: 'unsupported',
remote:   code: 'ERR_OSSL_EVP_UNSUPPORTED'
remote: }
remote:
remote: Node.js v19.2.0
remote:
remote: -----> Build failed

Also, I have been getting errors about upgrading the stack to Heroku-22. I was working on that, but it seems to be trying to build to that stack anyway so I don't think that's the issue.
Thanks in advance for the help!


问:
I want to embed the Vuejs Sidebar inside the page
I want to add the sidebar to the profile page under the Navbar, but I couldn't manage it.

I am using Vue JS Interna talwindcss.

Code library I use for sidebar : https://github.com/akahon/vue-sidebar-menu-akahon

Click for current image, you will understand better.

I tried to adjust the CSS settings, but somehow I could not place the sidebar under the navbar.


问:
How to extract specific value in a dictionary column with multiple lists
I'm trying to extract specific value inside a column in a dataframe as you can see in the next image without any success, referring back to similar question still didn't work for my code.

If there is any way to extract the values as [Culture, Climate change, technology, ...]

Data

First Try
I have tried split() function however I reached a dead end as still I need the exact value after the word "name", and this new dataframe contains 75 columns. If I can only get a for loop to extract the value after the word "name" that's my latest vision to solve my problem.


问:
How to implement a WebSocket in Android with multiple fragments
Hi there I am working on an app for a school project that communicates with a multiplayer game server I've written myself. The server uses a WebSocket to allow instantaneous communication. I checked out some tutorials on how to implement a WebSocketClient in Android and decided to use okhttp3. This is my implementation:

class GameServerWebSocket() : WebSocketListener() {

    override fun onMessage(webSocket: WebSocket, text: String) {
        val response = Gson().fromJson(text, GameServerResponse::class.java)
    }

}
```
<p>I start the connection by doing this:</p>
<pre class="lang-kotlin prettyprint-override"><code>private val client = OkHttpClient()
private val request = Request
    .Builder()
    .url("ws://10.0.2.2:8080")
    .build()

private val listener = GameServerWebSocket()
private val webSocket = client.newWebSocket(request, listener)
</code>```

I then realized that this is not going to work. There are going to be several fragments like a CreateGame, JoinGame or Game Fragment. These all need to use the same socket though since otherwise I would just join the server with a different client. What I've done till now is to use Dagger Hilt to create a singleton instance using SingletonComponent. That way I can access the same socket in every fragment. Now comes the problem. How do I get the responses from the socket to the appropriate fragment. E.g. when I connect to the server I want to store the uuid the server provides. But when I join a game session the message should go to the JoinSession Fragment. I am currently writing all the server messages to a room db and observing specific identifiers in the appropriate fragments but that doesn't feel like it's a good solution. Is there any straight forward way?

In case the implementation is unclear this is my repo. It's still work in progress:

https://github.com/lela2011/FranticMultiplayer/blob/master/app/src/main/java/jakob/mostert/frantic/di/AppModule.kt

https://github.com/lela2011/FranticMultiplayer/blob/master/app/src/main/java/jakob/mostert/frantic/di/AppModule.kt

https://github.com/lela2011/FranticMultiplayer

Body:
Hi there I am working on an app for a school project that communicates with a multiplayer game server I've written myself. The server uses a WebSocket to allow instantaneous communication. I checked out some tutorials on how to implement a WebSocketClient in Android and decided to use okhttp3. This is my implementation:

class GameServerWebSocket() : WebSocketListener() {

    override fun onMessage(webSocket: WebSocket, text: String) {
        val response = Gson().fromJson(text, GameServerResponse::class.java)
    }

}

I start the connection by doing this:

private val client = OkHttpClient()
private val request = Request
    .Builder()
    .url("ws://10.0.2.2:8080")
    .build()

private val listener = GameServerWebSocket()
private val webSocket = client.newWebSocket(request, listener)

I then realized that this is not going to work. There are going to be several fragments like a CreateGame, JoinGame or Game Fragment. These all need to use the same socket though since otherwise I would just join the server with a different client. What I've done till now is to use Dagger Hilt to create a singleton instance using SingletonComponent. That way I can access the same socket in every fragment. Now comes the problem. How do I get the responses from the socket to the appropriate fragment. E.g. when I connect to the server I want to store the uuid the server provides. But when I join a game session the message should go to the JoinSession Fragment. I am currently writing all the server messages to a room db and observing specific identifiers in the appropriate fragments but that doesn't feel like it's a good solution. Is there any straight forward way?

In case the implementation is unclear this is my repo. It's still work in progress:

https://github.com/lela2011/FranticMultiplayer/blob/master/app/src/main/java/jakob/mostert/frantic/di/AppModule.kt

https://github.com/lela2011/FranticMultiplayer/blob/master/app/src/main/java/jakob/mostert/frantic/di/AppModule.kt

https://github.com/lela2011/FranticMultiplayer


问:
nDepend - The assembly {assembly name} is not in sync with corresponding coverage data
When importing a VSTS coverage data file to a NDepend project I'm getting an error message "The assembly {assembly name} is not in sync with corresponding coverage data.". This project analyzes 3 assemblies and the coverage data for the 3 assemblies is grouped in the same coverage data file, but the error message only appears for one of these assemblies. For the other two assemblies everything works fine.

I tried searching the web, but couldn't find any information about this error. Have anyone seen this error before?

ContentLicense: CC BY-SA 3.0