问:
Jenkins LDAP integration issues
I have been trying to integrate Jenkins with LDAP manage Jenkins --> Configure Global Security --> Security Realm --> and choosing the LDAP option. Under the advanced configuration tab I specified the enterprise LDAP server details i.e. Server, root DN, User Search Base, etc. I saved the LDAP config, signed out and tried signing back in which was disallowed. Checked the Jenkins system logs and no errors were recorded. Any pointers to debug this would be great.

Jenkins version: 2.375.1 LTS

LDAP plugin: 2.9

Title: Jenkins LDAP integration issues


来源: stackexchange

问:
PYODBC: Passing multiple WHERE conditions as variables
pyodbc (technically pypyodbc) on SQL SERVER (windows) where I have a SELECT statement that has a join and two WHERE conditions. Each parameterized WHERE condition works when in a query by itself:

```<code> bhfc_cursor.execute("""\
    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH
     INNER JOIN INC_MAIN ON inc_auth.inci_id = inc_main.inci_id
      where inc_main.inci_id = (?) """ ,this_incid)
    mutual_aid_fdid = bhfc_cursor.fetchone()

    bhfc_cursor.execute("""\
    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH
     INNER JOIN INC_MAIN ON inc_auth.inci_id = inc_main.inci_id
      where inc_auth.auth_type = (?) """,auth_type)
    mutual_aid_fdid = bhfc_cursor.fetchone()
</code>```

But if I try to make it into a compound where with AND, it bombs:

```<code>   bhfc_cursor.execute("""\
    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH
     INNER JOIN INC_MAIN ON inc_auth.inci_id = inc_main.inci_id
      where inc_auth.auth_type = (?) and inc_main.inci_id = (?) """,auth_type, this_incid)
    mutual_aid_fdid = bhfc_cursor.fetchone()
</code>```

error:

```<code>  File "C:\Users\bucky\OneDrive\Python_Installs\PycharmProjects\ReadSQLWireNFIRS\ReadSQQLWriteNFIRS.py", line 228, in <module>
    bhfc_cursor.execute("""\
  File "C:\Users\bucky\OneDrive\Python_Installs\PycharmProjects\ReadSQLWireNFIRS\Lib\site-packages\pypyodbc.py", line 1617, in execute
    check_success(self, ret)
  File "C:\Users\bucky\OneDrive\Python_Installs\PycharmProjects\ReadSQLWireNFIRS\Lib\site-packages\pypyodbc.py", line 1007, in check_success
    ctrl_err(SQL_HANDLE_STMT, ODBC_obj.stmt_h, ret, ODBC_obj.ansi)
  File "C:\Users\bucky\OneDrive\Python_Installs\PycharmProjects\ReadSQLWireNFIRS\Lib\site-packages\pypyodbc.py", line 987, in ctrl_err
    raise DatabaseError(state,err_text)
pypyodbc.DatabaseError: ('07002', '[07002] [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error')
</code>```

I know one of the princple points in asking a question is "what have you tried"?  Well, I've tried a couple dozen things.  Making it into a different passing format with %s instead of (?).  Making the two variables into a list.  Or tuple.  I've been plugging at this for three hours now and I've tried everything I can think of and everything I've found while searching.  As you can probably infer, this is sort of greek to me- I see many answers where people much smarter than me know the mechanics of where things get interpreted- in the driver or the DB or wherever- so I'm not really sure what the difference is in the "?", "(?)", the %s, %d, %b, %f formats, but I can find anything that works.

The type of inci_id is <class 'pypyodbc.TupleRow..Row'> while auth_type is <class 'list'>.  Thanks.

p.s. this is an internal ETL type program that will never be exposed to the outside world, so SQL injection concerns are minimal, although I know I should get into the habit of writing code that prevents them regardless...

EDIT: while looking at this again, I realized the 2nd table isn't even necessary.  The table that has the columns I want also has the other INCI_ID column.  But even that one fails with the same "count field incorrect.." error.

```<code>    bhfc_cursor.execute("""\
    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH
      where inc_auth.auth_type = (?) and inc_auth.inci_id = (?) """,auth_type, this_incid)
    mutual_aid_fdid = bhfc_cursor.fetchone()```

ANOTHER EDIT:  I replaced one of the variables with a constant and the query works. Although it was somewhat obvious, this proves that the problem is with the variable substitution and not the query itself:

```
```bhfc_cursor.execute("""\
select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH
  where (inc_auth.auth_type = 'OC' ) AND (inc_auth.inci_id = (?) ) """ , this_incid)
oic_details = bhfc_cursor.fetchone()
```
<p>And here's some seemingly relevant stuff from an ODBC trace.  I really don't know what much of this means however.</p>
```ReadSQQLWriteNF fb68-77d0   ENTER SQLPrepareW
        HSTMT               0x000001CEFFC70470
        WCHAR *             0x000001CEFF370570 [     164] "    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH\ a      where (inc_auth.auth_type = (?) ) AND (inc_auth.inci_id = (?) ) "
        SDWORD                   164

ReadSQQLWriteNF fb68-77d0   EXIT  SQLPrepareW  with return code 0 (SQL_SUCCESS)
        HSTMT               0x000001CEFFC70470
        WCHAR *             0x000001CEFF370570 [     164] "    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH\ a      where (inc_auth.auth_type = (?) ) AND (inc_auth.inci_id = (?) ) "
        SDWORD                   164

ReadSQQLWriteNF fb68-77d0   ENTER SQLNumParams
        HSTMT               0x000001CEFFC70470
        SWORD *             0x000001CEFF3B3C98

ReadSQQLWriteNF fb68-77d0   EXIT  SQLNumParams  with return code 0 (SQL_SUCCESS)
        HSTMT               0x000001CEFFC70470
        SWORD *             0x000001CEFF3B3C98 (2)

ReadSQQLWriteNF fb68-77d0   ENTER SQLDescribeParam
        HSTMT               0x000001CEFFC70470
        UWORD                        1
        SWORD *             0x000001CEFF3B3398
        SQLULEN *           0x000001CEFF3B3918
        SWORD *             0x000001CEFF3B3518
        SWORD *             0x000001CEFF3B3718

ReadSQQLWriteNF fb68-77d0   EXIT  SQLDescribeParam  with return code 0 (SQL_SUCCESS)
        HSTMT               0x000001CEFFC70470
        UWORD                        1
        SWORD *             0x000001CEFF3B3398 (-9)
        SQLULEN *           0x000001CEFF3B3918 (255)
        SWORD *             0x000001CEFF3B3518 (0)
        SWORD *             0x000001CEFF3B3718 (1)

ReadSQQLWriteNF fb68-77d0   ENTER SQLDescribeParam
        HSTMT               0x000001CEFFC70470
        UWORD                        2
        SWORD *             0x000001CEFF3B3798
        SQLULEN *           0x000001CEFF3B3398
        SWORD *             0x000001CEFF3B3918
        SWORD *             0x000001CEFF3B3518

ReadSQQLWriteNF fb68-77d0   EXIT  SQLDescribeParam  with return code -1 (SQL_ERROR)
        HSTMT               0x000001CEFFC70470
        UWORD                        2
        SWORD *             0x000001CEFF3B3798
        SQLULEN *           0x000001CEFF3B3398
        SWORD *             0x000001CEFF3B3918
        SWORD *             0x000001CEFF3B3518

        DIAG [07009] [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index (0)

ReadSQQLWriteNF fb68-77d0   ENTER SQLGetDiagRecW
        SQLSMALLINT                  3 <SQL_HANDLE_STMT>
        SQLHANDLE           0x000001CEFFC70470
        SQLSMALLINT                  1
        SQLWCHAR *          0x000001CEFF31A070
        SQLINTEGER *        0x000001CEFF3B2818
        SQLWCHAR *          0x000001CEFF2704E0
        SQLSMALLINT               1024
        SQLSMALLINT *       0x000001CEFF3B2618

ReadSQQLWriteNF fb68-77d0   EXIT  SQLGetDiagRecW  with return code 0 (SQL_SUCCESS)
        SQLSMALLINT                  3 <SQL_HANDLE_STMT>
        SQLHANDLE           0x000001CEFFC70470
        SQLSMALLINT                  1
        SQLWCHAR *          0x000001CEFF31A070 [       5] "07009"
        SQLINTEGER *        0x000001CEFF3B2818 (0)
        SQLWCHAR *          0x000001CEFF2704E0 [      59] "[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index"
        SQLSMALLINT               1024
        SQLSMALLINT *       0x000001CEFF3B2618 (59)
```

ContentLicense: CC BY-SA 4.0

Body:
pyodbc (technically pypyodbc) on SQL SERVER (windows) where I have a SELECT statement that has a join and two WHERE conditions. Each parameterized WHERE condition works when in a query by itself:

 bhfc_cursor.execute("""\
    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH
     INNER JOIN INC_MAIN ON inc_auth.inci_id = inc_main.inci_id
      where inc_main.inci_id = (?) """ ,this_incid)
    mutual_aid_fdid = bhfc_cursor.fetchone()

    bhfc_cursor.execute("""\
    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH
     INNER JOIN INC_MAIN ON inc_auth.inci_id = inc_main.inci_id
      where inc_auth.auth_type = (?) """,auth_type)
    mutual_aid_fdid = bhfc_cursor.fetchone()

But if I try to make it into a compound where with AND, it bombs:

   bhfc_cursor.execute("""\
    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH
     INNER JOIN INC_MAIN ON inc_auth.inci_id = inc_main.inci_id
      where inc_auth.auth_type = (?) and inc_main.inci_id = (?) """,auth_type, this_incid)
    mutual_aid_fdid = bhfc_cursor.fetchone()

error:

  File "C:\Users\bucky\OneDrive\Python_Installs\PycharmProjects\ReadSQLWireNFIRS\ReadSQQLWriteNFIRS.py", line 228, in <module>
    bhfc_cursor.execute("""\
  File "C:\Users\bucky\OneDrive\Python_Installs\PycharmProjects\ReadSQLWireNFIRS\Lib\site-packages\pypyodbc.py", line 1617, in execute
    check_success(self, ret)
  File "C:\Users\bucky\OneDrive\Python_Installs\PycharmProjects\ReadSQLWireNFIRS\Lib\site-packages\pypyodbc.py", line 1007, in check_success
    ctrl_err(SQL_HANDLE_STMT, ODBC_obj.stmt_h, ret, ODBC_obj.ansi)
  File "C:\Users\bucky\OneDrive\Python_Installs\PycharmProjects\ReadSQLWireNFIRS\Lib\site-packages\pypyodbc.py", line 987, in ctrl_err
    raise DatabaseError(state,err_text)
pypyodbc.DatabaseError: ('07002', '[07002] [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error')

I know one of the princple points in asking a question is "what have you tried"?  Well, I've tried a couple dozen things.  Making it into a different passing format with %s instead of (?).  Making the two variables into a list.  Or tuple.  I've been plugging at this for three hours now and I've tried everything I can think of and everything I've found while searching.  As you can probably infer, this is sort of greek to me- I see many answers where people much smarter than me know the mechanics of where things get interpreted- in the driver or the DB or wherever- so I'm not really sure what the difference is in the "?", "(?)", the %s, %d, %b, %f formats, but I can find anything that works.

The type of inci_id is <class 'pypyodbc.TupleRow..Row'> while auth_type is <class 'list'>.  Thanks.

p.s. this is an internal ETL type program that will never be exposed to the outside world, so SQL injection concerns are minimal, although I know I should get into the habit of writing code that prevents them regardless...

EDIT: while looking at this again, I realized the 2nd table isn't even necessary.  The table that has the columns I want also has the other INCI_ID column.  But even that one fails with the same "count field incorrect.." error.

    bhfc_cursor.execute("""\
    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH
      where inc_auth.auth_type = (?) and inc_auth.inci_id = (?) """,auth_type, this_incid)
    mutual_aid_fdid = bhfc_cursor.fetchone()```

ANOTHER EDIT:  I replaced one of the variables with a constant and the query works. Although it was somewhat obvious, this proves that the problem is with the variable substitution and not the query itself:

bhfc_cursor.execute("""\
select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH
  where (inc_auth.auth_type = 'OC' ) AND (inc_auth.inci_id = (?) ) """ , this_incid)
oic_details = bhfc_cursor.fetchone()

And here's some seemingly relevant stuff from an ODBC trace.  I really don't know what much of this means however.

ReadSQQLWriteNF fb68-77d0   ENTER SQLPrepareW
        HSTMT               0x000001CEFFC70470
        WCHAR *             0x000001CEFF370570 [     164] "    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH\ a      where (inc_auth.auth_type = (?) ) AND (inc_auth.inci_id = (?) ) "
        SDWORD                   164

ReadSQQLWriteNF fb68-77d0   EXIT  SQLPrepareW  with return code 0 (SQL_SUCCESS)
        HSTMT               0x000001CEFFC70470
        WCHAR *             0x000001CEFF370570 [     164] "    select inc_auth.staff_id, inc_auth.rank, inc_auth.assignment, inc_auth.dttm from INC_AUTH\ a      where (inc_auth.auth_type = (?) ) AND (inc_auth.inci_id = (?) ) "
        SDWORD                   164

ReadSQQLWriteNF fb68-77d0   ENTER SQLNumParams
        HSTMT               0x000001CEFFC70470
        SWORD *             0x000001CEFF3B3C98

ReadSQQLWriteNF fb68-77d0   EXIT  SQLNumParams  with return code 0 (SQL_SUCCESS)
        HSTMT               0x000001CEFFC70470
        SWORD *             0x000001CEFF3B3C98 (2)

ReadSQQLWriteNF fb68-77d0   ENTER SQLDescribeParam
        HSTMT               0x000001CEFFC70470
        UWORD                        1
        SWORD *             0x000001CEFF3B3398
        SQLULEN *           0x000001CEFF3B3918
        SWORD *             0x000001CEFF3B3518
        SWORD *             0x000001CEFF3B3718

ReadSQQLWriteNF fb68-77d0   EXIT  SQLDescribeParam  with return code 0 (SQL_SUCCESS)
        HSTMT               0x000001CEFFC70470
        UWORD                        1
        SWORD *             0x000001CEFF3B3398 (-9)
        SQLULEN *           0x000001CEFF3B3918 (255)
        SWORD *             0x000001CEFF3B3518 (0)
        SWORD *             0x000001CEFF3B3718 (1)

ReadSQQLWriteNF fb68-77d0   ENTER SQLDescribeParam
        HSTMT               0x000001CEFFC70470
        UWORD                        2
        SWORD *             0x000001CEFF3B3798
        SQLULEN *           0x000001CEFF3B3398
        SWORD *             0x000001CEFF3B3918
        SWORD *             0x000001CEFF3B3518

ReadSQQLWriteNF fb68-77d0   EXIT  SQLDescribeParam  with return code -1 (SQL_ERROR)
        HSTMT               0x000001CEFFC70470
        UWORD                        2
        SWORD *             0x000001CEFF3B3798
        SQLULEN *           0x000001CEFF3B3398
        SWORD *             0x000001CEFF3B3918
        SWORD *             0x000001CEFF3B3518

        DIAG [07009] [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index (0)

ReadSQQLWriteNF fb68-77d0   ENTER SQLGetDiagRecW
        SQLSMALLINT                  3 <SQL_HANDLE_STMT>
        SQLHANDLE           0x000001CEFFC70470
        SQLSMALLINT                  1
        SQLWCHAR *          0x000001CEFF31A070
        SQLINTEGER *        0x000001CEFF3B2818
        SQLWCHAR *          0x000001CEFF2704E0
        SQLSMALLINT               1024
        SQLSMALLINT *       0x000001CEFF3B2618

ReadSQQLWriteNF fb68-77d0   EXIT  SQLGetDiagRecW  with return code 0 (SQL_SUCCESS)
        SQLSMALLINT                  3 <SQL_HANDLE_STMT>
        SQLHANDLE           0x000001CEFFC70470
        SQLSMALLINT                  1
        SQLWCHAR *          0x000001CEFF31A070 [       5] "07009"
        SQLINTEGER *        0x000001CEFF3B2818 (0)
        SQLWCHAR *          0x000001CEFF2704E0 [      59] "[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index"
        SQLSMALLINT               1024
        SQLSMALLINT *       0x000001CEFF3B2618 (59)


问:
Custom C++ Decimal class, how to reduce chances of overflow generated by divide result
I've implemented a fixed Decimal class but I have an overflow problem caused by a propagation of precision when dividing.

At a high level the decimal is represented by:

```<code>template<class MANTISSA>
struct Decimal
{
                        //  Example
                        //  7.14
    MANTISSA mantissa_; //   714
    uint8_t exponent_;  //     2
};
</code>```

However, I have a fundamental design flaw. My divide operator keeps calculating the remainder until it's zero or we run out of digits. The latter scenario occurs more-frequently than I realized.

I then multiply the output of divide by another decimal:

```<code>Decimal operator*(const Decimal& rhs) const
{
    Decimal result = *this;
    result.mantissa_ *= rhs.mantissa_;
    result.exponent_ += rhs.exponent_;
    return result;
}
</code>```

There will most-likely be an overflow here because the mantissa from the divide output already has max digits (18 for int64_t).

To solve this I thought I could detect the overflow and reduce the multiplicands. I changed operator*() to check whether the exponents sum beyond 18. However, this is a bug. The exponents might be less than 18 but the mantissas can still be large enough to overflow.

To solve this properly I would need to count the number of mantissa digits prior to multiplying. And this requires a while loop, divide the mantissa by 10 until you reach zero and do this for both multiplicands- very expensive! Surely this cannot be the best approach??

At this point I have taken a step back because things seem complicated, How should I handle this? Do I fix the problem at source, don't let divide result in so many digits? Assuming so, do I require the user configure how many digits divides should output? Should the precision of divide output depend on the magnitude/exponent of the two input arguments?

Can anyone advise?

Body:
I've implemented a fixed Decimal class but I have an overflow problem caused by a propagation of precision when dividing.

At a high level the decimal is represented by:

template<class MANTISSA>
struct Decimal
{
                        //  Example
                        //  7.14
    MANTISSA mantissa_; //   714
    uint8_t exponent_;  //     2
};

However, I have a fundamental design flaw. My divide operator keeps calculating the remainder until it's zero or we run out of digits. The latter scenario occurs more-frequently than I realized.

I then multiply the output of divide by another decimal:

Decimal operator*(const Decimal& rhs) const
{
    Decimal result = *this;
    result.mantissa_ *= rhs.mantissa_;
    result.exponent_ += rhs.exponent_;
    return result;
}

There will most-likely be an overflow here because the mantissa from the divide output already has max digits (18 for int64_t).

To solve this I thought I could detect the overflow and reduce the multiplicands. I changed operator*() to check whether the exponents sum beyond 18. However, this is a bug. The exponents might be less than 18 but the mantissas can still be large enough to overflow.

To solve this properly I would need to count the number of mantissa digits prior to multiplying. And this requires a while loop, divide the mantissa by 10 until you reach zero and do this for both multiplicands- very expensive! Surely this cannot be the best approach??

At this point I have taken a step back because things seem complicated, How should I handle this? Do I fix the problem at source, don't let divide result in so many digits? Assuming so, do I require the user configure how many digits divides should output? Should the precision of divide output depend on the magnitude/exponent of the two input arguments?

Can anyone advise?


问:
Why are GA4 Conversions not appearing when using utm tags to track them?
I'm having trouble getting purchase conversions to record correctly on GA4 for a LinkedIn Ads campaign. I'm tracking traffic for the Ad using a utm url and the users, sessions, etc are all being recorded correctly, it's just the purchase conversions from the ad that aren't showing up. All other conversions from the website are being recorded correctly. This is part of the utm url we used: utm_source=Articles&utm_medium=Blog&utm_campaign=ISO_ads&utm_id=iso_campaign+&utm_content=dekra

I did a test purchase by clicking on the LinkedIn Ad to see if maybe we just had 0 conversions, but GA4 recorded that purchase. However, it did not assign it to the LinkedIn Ad campaign, it listed the purchase as "Unassigned". I was hoping someone might have an idea on why this is happening? I spoke with GA4 support and they checked the tags on the site and said everything looked good and said that since we were using utm, then they couldn't really help further. Thank you!


问:
custom font using @font-face in css not working
I was trying to add a custom font in my website but it doesn't work.

I have a css file like this:

```<code>@font-face {
    font-family: 'SFProDisplayLight';
    src: url("./SF-Pro-Display-Light.otf") format ("opentype");
    font-weight: normal;
    font-style: normal;
}

body {
    font-family: 'SFProDisplayLight';
}
</code>```

and an html file like this

```<code><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="index.css">
    <title>Document</title>
</head>
<body>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Provident cupiditate,
iste qui dicta corporis sit, harum architecto, illo nobis quidem modi ullam enim
blanditiis odio porro facere. Consectetur, officia repellat!
</body>
</html>
</code>```

My problem is that the custom font isn't applied

Body:
I was trying to add a custom font in my website but it doesn't work.

I have a css file like this:

@font-face {
    font-family: 'SFProDisplayLight';
    src: url("./SF-Pro-Display-Light.otf") format ("opentype");
    font-weight: normal;
    font-style: normal;
}

body {
    font-family: 'SFProDisplayLight';
}

and an html file like this

<!DOCTYPE html>

    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="index.css">
    <title>Document</title>

Lorem ipsum dolor sit amet consectetur adipisicing elit. Provident cupiditate,
iste qui dicta corporis sit, harum architecto, illo nobis quidem modi ullam enim
blanditiis odio porro facere. Consectetur, officia repellat!

My problem is that the custom font isn't applied


问:
How can you maintain the order of an array but not have terraform replace when a new item is added
I have a terraform module that accepts an array of objects as a variable in dependency order. I used the count function to create a resource for each item in the array referencing the prior item, however when a new item is added in the middle, all items are destroyed and recreated.

I processed the array into a map and switch to a for_each to solve the recreate issue. This created a new issue in that order is not preserved in the map (as expected) and items are created out of order causing it to fail when they are not created. I tried using depends_on but you can only use items with constant keys for this to work.

I have made this generic as I have a few places this is used in different providers. The main one is aws.

```<code>Variable ex:
  groups = {
    "corp" = [
      {
        name = "test"
        foo = []
        bar = 124
      },
      {
        name = "test2"
        foo = ["bar"]
        bar = 567
      }
    ]
  }

variable "groups" {
  type = map(list(object({
    name = string,
    foo = list(string)
    bar = number
  }))
}

locals {
  items = flatten([
    for group_key, group_value in var.groups : [
      for i, item_value in groups_value : {
        group_name = group_key
        name     = "${group_key}-${item_value.name}"
        item     = item_value
        dep      = i == 0 ? null : "${group_key}-${var.groups[group_key][(i - 1)].name}"
      }
    ]
  ])
}

resource "group" "this" {
  for_each = { for r in local.items : r.name => r }

  group = each.value.group_name
  name = each.value.name
  dep = each.value.dep

  depends_on = [
    group.this["${each.value.dep}"]
  ]
}

resource "group" "this" {
  count = local.items
  group = local.items[${count.index}].group_name
  name = local.items[${count.index}].name
  dep = local.items[${count.index}].dep
}
</code>```

Body:
I have a terraform module that accepts an array of objects as a variable in dependency order. I used the count function to create a resource for each item in the array referencing the prior item, however when a new item is added in the middle, all items are destroyed and recreated.

I processed the array into a map and switch to a for_each to solve the recreate issue. This created a new issue in that order is not preserved in the map (as expected) and items are created out of order causing it to fail when they are not created. I tried using depends_on but you can only use items with constant keys for this to work.

I have made this generic as I have a few places this is used in different providers. The main one is aws.

Variable ex:
  groups = {
    "corp" = [
      {
        name = "test"
        foo = []
        bar = 124
      },
      {
        name = "test2"
        foo = ["bar"]
        bar = 567
      }
    ]
  }

variable "groups" {
  type = map(list(object({
    name = string,
    foo = list(string)
    bar = number
  }))
}

locals {
  items = flatten([
    for group_key, group_value in var.groups : [
      for i, item_value in groups_value : {
        group_name = group_key
        name     = "${group_key}-${item_value.name}"
        item     = item_value
        dep      = i == 0 ? null : "${group_key}-${var.groups[group_key][(i - 1)].name}"
      }
    ]
  ])
}

resource "group" "this" {
  for_each = { for r in local.items : r.name => r }

  group = each.value.group_name
  name = each.value.name
  dep = each.value.dep

  depends_on = [
    group.this["${each.value.dep}"]
  ]
}

resource "group" "this" {
  count = local.items
  group = local.items[${count.index}].group_name
  name = local.items[${count.index}].name
  dep = local.items[${count.index}].dep
}


问:
expand() function: Wildcards in input files/params cannot be determined from output files
I have been using Snakemake for a considerable amount of time and I still get the same errors regarding the expand function which I am not able to solve or either to find a clear explanation. In the Snakemake documentation it is neither explained.

Snakemake version
I am using version 7.18.2.

In my Snakemake code I usually put the expand function in the rule all so all the variables are full-filled there. This usually works, but sometime I just receive the following error: Wildcards in input files cannot be determined from output files.

This was my code last time that I got that error:

```<code>rule all:
    input:
        snp =  expand(project_dir + plink_output_dir + "target_data/{target_name}.valid.snp", target_name = TARGET_files),
        snp_ex =  expand(project_dir + plink_output_dir + "external_data/{ext_name}.valid.snp", ext_name = EXTERNAL_file),
        pvalue = project_dir + plink_output_dir + "target_data/SNP.pvalue",

rule plink_score_ex:
    input:
        ...
        valid_snps =  project_dir + plink_output_dir + "external_data/{ext_name}.valid.snp",
    params:
        ...
        bfile_dir = project_dir + "data/{ext_name}"
    output:
        status_ex =  project_dir  + plink_output_dir + "external_data/{ext_name}_prs_status",
    shell: ...

</code>```

I got the following error: once for the wildcards placed in the input and another for the wildcards in the params. Here are both logs:

```<code>WildcardError in line 251 of <path>/xxx_snakefile:
Wildcards in input files cannot be determined from output files:
'ext_name'

WildcardError in line 251 of <path>/xxx_snakefile:
Wildcards in params cannot be determined from output files. Note that you have to use a function to deactivate automatic wildcard expansion in params strings, e.g., `lambda wildcards: '{test}'`. Also see https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#non-file-parameters-for-rules:
'ext_name'
</code>```

And this is the code with which I solved the error:

```<code>rule plink_score_ex:
    input:
        valid_snps =  expand(project_dir + plink_output_dir + "external_data/{ext_name}.valid.snp", ext_name = EXTERNAL_file),
    params:
        bfile_dir = expand(project_dir + "data/{ext_name}", ext_name = EXTERNAL_file),
    output:
        plink_status =  expand(project_dir  + plink_output_dir + "external_data/plink_status_ext.txt", ext_name = EXTERNAL_file),
    shell: ...
</code>```

With this, I solved the error corresponding to this specific rule. However, I needed to add the expand function in all the input files and params and in all the different rules.

My question is: once that I have placed the corresponding expand function in the rule all, where do I necessary have to put it again? In case I place it in some specific rule, as it is rule plink_score_ex, do I need to put it in the input? in the output? In both places?

Thank you very much!

Body:
I have been using Snakemake for a considerable amount of time and I still get the same errors regarding the expand function which I am not able to solve or either to find a clear explanation. In the Snakemake documentation it is neither explained.

Snakemake version
I am using version 7.18.2.

In my Snakemake code I usually put the expand function in the rule all so all the variables are full-filled there. This usually works, but sometime I just receive the following error: Wildcards in input files cannot be determined from output files.

This was my code last time that I got that error:

rule all:
    input:
        snp =  expand(project_dir + plink_output_dir + "target_data/{target_name}.valid.snp", target_name = TARGET_files),
        snp_ex =  expand(project_dir + plink_output_dir + "external_data/{ext_name}.valid.snp", ext_name = EXTERNAL_file),
        pvalue = project_dir + plink_output_dir + "target_data/SNP.pvalue",

rule plink_score_ex:
    input:
        ...
        valid_snps =  project_dir + plink_output_dir + "external_data/{ext_name}.valid.snp",
    params:
        ...
        bfile_dir = project_dir + "data/{ext_name}"
    output:
        status_ex =  project_dir  + plink_output_dir + "external_data/{ext_name}_prs_status",
    shell: ...

I got the following error: once for the wildcards placed in the input and another for the wildcards in the params. Here are both logs:

WildcardError in line 251 of <path>/xxx_snakefile:
Wildcards in input files cannot be determined from output files:
'ext_name'

WildcardError in line 251 of <path>/xxx_snakefile:
Wildcards in params cannot be determined from output files. Note that you have to use a function to deactivate automatic wildcard expansion in params strings, e.g., `lambda wildcards: '{test}'`. Also see https://snakemake.readthedocs.io/en/stable/snakefiles/rules.html#non-file-parameters-for-rules:
'ext_name'

And this is the code with which I solved the error:

rule plink_score_ex:
    input:
        valid_snps =  expand(project_dir + plink_output_dir + "external_data/{ext_name}.valid.snp", ext_name = EXTERNAL_file),
    params:
        bfile_dir = expand(project_dir + "data/{ext_name}", ext_name = EXTERNAL_file),
    output:
        plink_status =  expand(project_dir  + plink_output_dir + "external_data/plink_status_ext.txt", ext_name = EXTERNAL_file),
    shell: ...

With this, I solved the error corresponding to this specific rule. However, I needed to add the expand function in all the input files and params and in all the different rules.

My question is: once that I have placed the corresponding expand function in the rule all, where do I necessary have to put it again? In case I place it in some specific rule, as it is rule plink_score_ex, do I need to put it in the input? in the output? In both places?

Thank you very much!


问:
Debugging cursor issue in Steam game on Linux - cursor only moves in upper left quadrant of screen during game
When I launch certain games, on SteamDeck (Arch Desktop Mode Linux) - The cursor is restricted by the upper left quadrant of the screen. Making it impossible to click menu buttons to start the game.

There's GOT to be a reason for this, maybe it's a resolution issue, something else... The games in question (This one is Project Playtime), does not have proper settings. I can't use the launch options field for this, nor can I access the windows settings file because this is linux.

Any help would be appreciated.

Launch game -> mouse locked into top left quad.


问:
How can I navigation to other screens in Jetpack Compose?
My code is below.

RootNavGraph.kt

```<code>@Composable
fun RootNavGraph(navController: NavHostController = rememberNavController()) {
    NavHost(
        navController = navController,
        route = rootRoute,
        startDestination = authGraphRoutePattern
    ) {
        authGraph(
            navigateToHome = {
                navController.popBackStack()
                navController.navigateToAppBarGraph()
            }
            authOtherScreen { navController.popBackStack() }
        }
        appBarGraph()
        supplementSearchScreen()
    }
}
</code>```

SupplementSearch.kt

```<code>const val supplementSearchRoute = "supplement_search_route"

fun NavController.navigateToSupplementSearch(navOptions: NavOptions? = null) {
    this.navigate(supplementSearchRoute, navOptions)
}

fun NavGraphBuilder.supplementSearchScreen() {
    composable(route = supplementSearchRoute) {
        SupplementSearchRoute()
    }
}
</code>```

authGraph() is for different login.
appBarGraph() is for bottom navigation menus.

As far as I read this Navigation document, I can place screens in NavHost like this

```<code>SomeAScreen()
AGraph()
BGraph()
SomeBScreen()
SomeCScreen()
SomeDScreen()
CGraph()
</code>```

But I get NPE when I call like this:

```<code>@Composable
fun AddSupplementItem(
    addSupplement: Vitamin.AddSupplement
) {
    val isClicked = remember { mutableStateOf(false) }

    Column(
        modifier = Modifier
            .width(97.dp)
            .clickable {
                isClicked.value = !isClicked.value
            },
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        AsyncImage(
            model = addSupplement.imageUrl,
            modifier = Modifier
                .fillMaxWidth()
                .padding(5.dp)
                .aspectRatio(1.46f)
                .clip(RoundedCornerShape(16.dp)),
            contentDescription = addSupplement.name,
            contentScale = ContentScale.Crop
        )
        Text(
            text = addSupplement.name,
            fontSize = 13.sp,
            color = Color.Gray
        )
    }

    if (isClicked.value) {
        val navController = rememberNavController()
        navController.navigateToSupplementSearch() // NullPointException
    }
}
</code>```

It seems like SupplementSearchScreen is not registered to the graph.

Should I keep passing navcontroller from NavHost to that Screen?

```<code>NavHost(...){
    // otherGraphs()
    supplementSearchScreen(navController)
}
</code>```

But it didn't work.

And also,

```<code>// the parent composable function is
fun SupplementGrid(vitaminList: List<Vitamin>) {
     // list of vitamin item. and also use AddSupplement()
}
// And also it has parent composable function
@Composable
fun SupplementLayout(feedType: FeedType, supplements: List<Vitamin>) {
    // call SupplementGrid()
}

// and finally,
@Composable
fun NutritionScreen(
    // it uses LazyColumn and one of item is SupplementLayout()
)
</code>```

How can I solve this issue??

Body:
My code is below.

RootNavGraph.kt

@Composable
fun RootNavGraph(navController: NavHostController = rememberNavController()) {
    NavHost(
        navController = navController,
        route = rootRoute,
        startDestination = authGraphRoutePattern
    ) {
        authGraph(
            navigateToHome = {
                navController.popBackStack()
                navController.navigateToAppBarGraph()
            }
            authOtherScreen { navController.popBackStack() }
        }
        appBarGraph()
        supplementSearchScreen()
    }
}

SupplementSearch.kt

const val supplementSearchRoute = "supplement_search_route"

fun NavController.navigateToSupplementSearch(navOptions: NavOptions? = null) {
    this.navigate(supplementSearchRoute, navOptions)
}

fun NavGraphBuilder.supplementSearchScreen() {
    composable(route = supplementSearchRoute) {
        SupplementSearchRoute()
    }
}

authGraph() is for different login.
appBarGraph() is for bottom navigation menus.

As far as I read this Navigation document, I can place screens in NavHost like this

SomeAScreen()
AGraph()
BGraph()
SomeBScreen()
SomeCScreen()
SomeDScreen()
CGraph()

But I get NPE when I call like this:

@Composable
fun AddSupplementItem(
    addSupplement: Vitamin.AddSupplement
) {
    val isClicked = remember { mutableStateOf(false) }

    Column(
        modifier = Modifier
            .width(97.dp)
            .clickable {
                isClicked.value = !isClicked.value
            },
        horizontalAlignment = Alignment.CenterHorizontally
    ) {
        AsyncImage(
            model = addSupplement.imageUrl,
            modifier = Modifier
                .fillMaxWidth()
                .padding(5.dp)
                .aspectRatio(1.46f)
                .clip(RoundedCornerShape(16.dp)),
            contentDescription = addSupplement.name,
            contentScale = ContentScale.Crop
        )
        Text(
            text = addSupplement.name,
            fontSize = 13.sp,
            color = Color.Gray
        )
    }

    if (isClicked.value) {
        val navController = rememberNavController()
        navController.navigateToSupplementSearch() // NullPointException
    }
}

It seems like SupplementSearchScreen is not registered to the graph.

Should I keep passing navcontroller from NavHost to that Screen?

NavHost(...){
    // otherGraphs()
    supplementSearchScreen(navController)
}

But it didn't work.

And also,

// the parent composable function is
fun SupplementGrid(vitaminList: List<Vitamin>) {
     // list of vitamin item. and also use AddSupplement()
}
// And also it has parent composable function
@Composable
fun SupplementLayout(feedType: FeedType, supplements: List<Vitamin>) {
    // call SupplementGrid()
}

// and finally,
@Composable
fun NutritionScreen(
    // it uses LazyColumn and one of item is SupplementLayout()
)

How can I solve this issue??


问:
Why QWORD seems to use 12 byte memory
I am new to assembly language, and looking at GCC's unoptimized code-gen for a function that initializes int, long, and char variables.

```<code>int main()
{
    int intVariable {};
    long longVariable {};
    char charVariable{};

    return 0;
}
</code>```

you can check the code on Godbolt

```<code>        push    rbp
        mov     rbp, rsp
        mov     DWORD PTR [rbp-4], 0
        mov     QWORD PTR [rbp-16], 0
        mov     BYTE PTR [rbp-17], 0
        mov     eax, 0
        pop     rbp
        ret
</code>```

I create an integer and it takes 4 bytes [rbp-4]  :  0 -> 4

Create a long seems to use 12 bytes [rbp-16] 4 -> 16

Create a char takes 1 byte [rbp-17] : 16 -> 17

Can somebody explain me why long data type seems to use 12 byte?

Title: Why QWORD seems to use 12 byte memory

Body:
I am new to assembly language, and looking at GCC's unoptimized code-gen for a function that initializes int, long, and char variables.

int main()
{
    int intVariable {};
    long longVariable {};
    char charVariable{};

    return 0;
}

you can check the code on Godbolt

        push    rbp
        mov     rbp, rsp
        mov     DWORD PTR [rbp-4], 0
        mov     QWORD PTR [rbp-16], 0
        mov     BYTE PTR [rbp-17], 0
        mov     eax, 0
        pop     rbp
        ret

I create an integer and it takes 4 bytes [rbp-4]  :  0 -> 4

Create a long seems to use 12 bytes [rbp-16] 4 -> 16

Create a char takes 1 byte [rbp-17] : 16 -> 17

Can somebody explain me why long data type seems to use 12 byte?


问:
Cannot connect Socket.io Node (AWS EC2) from React Application ( AWS Amplify) polling (400) bad request
Note: ALL is WORKING FINE in Local ENV

HI, i have deployed my backend on AWS EC2 port 80 with SSL certificate and everything. It is currently working fine with React application except socket connection. which gives following errors

here is my client code:
"socket.io-client": "^4.5.3",

```<code>import { io } from "socket.io-client";
socket.current = io(`ws://${process.env.REACT_APP_SOCKET_URL}`);
</code>```

Server side code:
"socket.io": "^4.5.3",

```<code>const io = require("socket.io")(server, {
  autoConnect: false,
  cors: {
    origin: [
 process.env.FrontEnd_URL,
    ],
    credentials: true,
  },
});
</code>```

Any Help will be Appreciated. Thanks

Body:
Note: ALL is WORKING FINE in Local ENV

HI, i have deployed my backend on AWS EC2 port 80 with SSL certificate and everything. It is currently working fine with React application except socket connection. which gives following errors

here is my client code:
"socket.io-client": "^4.5.3",

import { io } from "socket.io-client";
socket.current = io(`ws://${process.env.REACT_APP_SOCKET_URL}`);

Server side code:
"socket.io": "^4.5.3",

const io = require("socket.io")(server, {
  autoConnect: false,
  cors: {
    origin: [
 process.env.FrontEnd_URL,
    ],
    credentials: true,
  },
});

Any Help will be Appreciated. Thanks


问:
How to add more than 3 conditional formatting rules using Apache POI?
My Java application generates Excel spreadsheets using Apache POI.  (I'm not sure the version.)  I'm upgrading our code from the "HSSF" classes, which are used to produce ".xls" (pre-2007) spreadsheets, to the "XSSF" classes which are used to produce ".xlsx" (Excel 2007) spreadsheets.

One of the limitations on the older file format was you couldn't have more than 3 conditional formatting rules on a cell or cell range.  See this Javadoc for example:

```<code>public void addRule(ConditionalFormattingRule cfRule)
</code>```

Add a Conditional Formatting rule. Excel pre-2007 allows to create up to 3
Conditional Formatting rules.

By upgrading to the new classes (e.g. from HSSFWorkbook to XSSFWorkbook) I think my exports are now in the Excel 2007 format.  At least I'm naming them ".xlsx" and Excel isn't giving me any error about the file type not matching the extension.  Yet, when I try to add more than three rules (using XSSFSheetConditionalFormatting.applyConditionalFormatting()), I'm getting an IllegalArgumentException with the message "Number of rules must not exceed 3".

How can I add more than three rules in this case?

Body:
My Java application generates Excel spreadsheets using Apache POI.  (I'm not sure the version.)  I'm upgrading our code from the "HSSF" classes, which are used to produce ".xls" (pre-2007) spreadsheets, to the "XSSF" classes which are used to produce ".xlsx" (Excel 2007) spreadsheets.

One of the limitations on the older file format was you couldn't have more than 3 conditional formatting rules on a cell or cell range.  See this Javadoc for example:

public void addRule(ConditionalFormattingRule cfRule)

Add a Conditional Formatting rule. Excel pre-2007 allows to create up to 3
Conditional Formatting rules.

By upgrading to the new classes (e.g. from HSSFWorkbook to XSSFWorkbook) I think my exports are now in the Excel 2007 format.  At least I'm naming them ".xlsx" and Excel isn't giving me any error about the file type not matching the extension.  Yet, when I try to add more than three rules (using XSSFSheetConditionalFormatting.applyConditionalFormatting()), I'm getting an IllegalArgumentException with the message "Number of rules must not exceed 3".

How can I add more than three rules in this case?


问:
How to create a JFrog Artifactory remote repository for amazon linux yum packages
I would like my EC2 in an isolated private subnet to access my JFrog Artifactory for amazon linux yum packages. Towards that, is it possible to create a remote repository in JFrog Artifactory to access amazonlinux yum package repo mirror site.

I cannot access amazon's yum package repos directly as I am in a private subnet with no internet access and firewall does not allow s3 endpoint access on purpose. We are required to use JFrog Artifactory repositories (either local or remote repositories). Would like to have instructions on how to setup a remote repository in JFrog Artifactory to point to amazon linux 2 yum package repo. Identity issues may not be allowing this to happen.


问:
Create my own name servers to inject code?
Does anybody know how I can create my own DNS name servers that inject JS code if you visit a specific webpage on the device that has their Custom Name Servers changed? I am new to this whole topic, so I would love some guidance :)

Help would be much much appreciated!!

I didn't try anything, as I am new to this topic.


问:
How to reference a DLL from a nuget package being restored as part of another project in the solution
Let's say I have a project A that restores a nuget package which includes a specific DLL named D. Another project B in that solution needs to use/reference the D dll that is being restored as part of the nuget pack when project A is compiled. If I simply reference project A from my project B, then the classes in D are not visible within my project B. How I can achieve that, so I use functionality buried in D within my project B (the limitation is I cannot reference that same nuget package from project B)?</p>


问:
Why isn't pytesseract recognizing this image?
It can read other images fine, it just can not read this one

enter image description here

```<code>import numpy as np
from pytesseract import pytesseract
import cv2
import numpy as np
from PIL import Image
import os

path_to_tesseract = r'C:\Program Files\Tesseract-OCR\tesseract.exe'

pytesseract.tesseract_cmd = path_to_tesseract

img = cv2.imread(r'C:\Users\Owner\Desktop\Coding\PNGs\tugteam project\tugteam2.png')

grayImage = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
(thresh, img) = cv2.threshold(grayImage, 127, 255, cv2.THRESH_BINARY)

img = cv2.bitwise_not(img)

img = cv2.resize(img, (600, 400))

cv2.imshow('asd',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

text = pytesseract.image_to_string(img)
print(text)

</code>```

I tried resizing the image, converting it to grayscale b/w w/b nothing will work.

Body:
It can read other images fine, it just can not read this one

enter image description here

import numpy as np
from pytesseract import pytesseract
import cv2
import numpy as np
from PIL import Image
import os

path_to_tesseract = r'C:\Program Files\Tesseract-OCR\tesseract.exe'

pytesseract.tesseract_cmd = path_to_tesseract

img = cv2.imread(r'C:\Users\Owner\Desktop\Coding\PNGs\tugteam project\tugteam2.png')

grayImage = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
(thresh, img) = cv2.threshold(grayImage, 127, 255, cv2.THRESH_BINARY)

img = cv2.bitwise_not(img)

img = cv2.resize(img, (600, 400))

cv2.imshow('asd',img)
cv2.waitKey(0)
cv2.destroyAllWindows()

text = pytesseract.image_to_string(img)
print(text)

I tried resizing the image, converting it to grayscale b/w w/b nothing will work.


问:
How to make same actions on Multiple links using selenium with c#
I am automating our portal where I want the same actions to happen on multiple sim pages. I want to write a method that will import and open these URLs, that I can obtain in a CSV and perform the same actions on them all. Locators of these pages are the same so trigger actions are not a problem. the problem is creating a method that will import the links from CSV and perform actions on them in each iteration.

driver.Url = TestContext.DataRow[0.ToString()]; but DataRow returned error

Error   CS0012  The type 'DataRow' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.


问:
How to load assets from a framework on iOS 16?
I have a private library which contains image assets for many of my apps. I include this library using CocoaPods in my app, using a local path and use_frameworks!.

I use the following code for opening an image from the bundle included in the library:

```<code>NSBundle *podBundle = [NSBundle bundleForClass:[self classForCoder]];
NSBundle *imagesBundle = [NSBundle bundleWithURL:[podBundle URLForResource:@"LibKwindoo" withExtension:@"bundle"]];
self.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"ImageName"] inBundle:imagesBundle compatibleWithTraitCollection:nil];
</code>```

This worked fine until iOS 16, and works still fine under iOS 15 when I compile using iOS 16 SDK, but on iOS 16, the image gets just nil. The bundles seem to be correct. I also checked and the files are present in the compiled .car asset bundle which is included in the .app.

UPDATE: Even stranger: I experience this only when running the app from Xcode on the device or in the Simulator. When I run the same app independently on the device, it works!

What changed on iOS 16 which prevents me to load images from this asset bundle?

Body:
I have a private library which contains image assets for many of my apps. I include this library using CocoaPods in my app, using a local path and use_frameworks!.

I use the following code for opening an image from the bundle included in the library:

NSBundle *podBundle = [NSBundle bundleForClass:[self classForCoder]];
NSBundle *imagesBundle = [NSBundle bundleWithURL:[podBundle URLForResource:@"LibKwindoo" withExtension:@"bundle"]];
self.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"ImageName"] inBundle:imagesBundle compatibleWithTraitCollection:nil];

This worked fine until iOS 16, and works still fine under iOS 15 when I compile using iOS 16 SDK, but on iOS 16, the image gets just nil. The bundles seem to be correct. I also checked and the files are present in the compiled .car asset bundle which is included in the .app.

UPDATE: Even stranger: I experience this only when running the app from Xcode on the device or in the Simulator. When I run the same app independently on the device, it works!

What changed on iOS 16 which prevents me to load images from this asset bundle?


问:
How to Realtime Crud Firestore using Getx flultter
I am not able to fetch data with realtime firestore. I am using firebase as a cart to store data of cart. but I am able to add the data to firebase but it is not working as realtime. Please help me resolve it. I tried to find out many way but I am not able to do that.

// this is my controller
import 'dart:async';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:e_commerce/code%20editing%20folder/cartModel.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:get/get.dart';

class CartController extends GetxController {
  @override
  void onInit() async {
    // TODO: implement onInit
    getCartData();
    await getcartDataModel;
    super.onInit();
  }

  void addtoCart({
    required String cartId,
    required String cartName,
    required String cartImage,
    required int cartPrice,
    required int cartQuantity,
  }) async {
    await FirebaseFirestore.instance
        .collection('Users')
        .doc(FirebaseAuth.instance.currentUser!.uid)
        .collection('yourCart')
        .doc(cartId)
        .set({
      "cartId": cartId,
      "cartName": cartName,
      "cartImage": cartImage,
      "cartPrice": cartPrice,
      "cartQuantity": cartQuantity
    });
  }

  RxList cartDataModel = [].obs;
  void getCartData() async {
    RxList newList = [].obs;
    QuerySnapshot cartStream = await FirebaseFirestore.instance
        .collection("Users")
        .doc(FirebaseAuth.instance.currentUser!.uid)
        .collection("yourCart")
        .get();
    cartStream.docs.forEach((element) {
      ReviewCartModel reviewCartModel = ReviewCartModel(
        cartId: element.get("cartId"),
        cartImage: element.get("cartImage"),
        cartName: element.get("cartName"),
        cartPrice: element.get("cartPrice"),
        cartQuantity: element.get("cartQuantity"),
      );
      newList.add(reviewCartModel);
    });

    cartDataModel = newList;
    update();
  }

  RxList get getcartDataModel {
    return cartDataModel;
    update();
  }
}

```
<p>Below I also added the screen where I want to implement the crud operation, but I am not able to do that. I can only get the data one time only when the application start</p>
<pre class="lang-dart prettyprint-override"><code>// this is my cartScreen
import 'package:e_commerce/code%20editing%20folder/cartModel.dart';
import 'package:e_commerce/code%20editing%20folder/firebaseCartController.dart';
import 'package:e_commerce/core/viewmodel/home_viewmodel.dart';
import 'package:e_commerce/view/widgets/counterstate.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class CartScreemn extends StatelessWidget {
  CartScreemn({super.key});
  final HomeViewModel homeViewModel = Get.put(HomeViewModel());
  @override
  Widget build(BuildContext context) {
    return GetX<CartController>(
      init: Get.put<CartController>(CartController()),
      builder: (CartController cartController) => SafeArea(
        top: true,
        bottom: true,
        child: Scaffold(
            body: Column(children: [
          Expanded(
            child: ListView.builder(
                padding: EdgeInsets.all(10),
                itemCount: cartController.getcartDataModel.length,
                itemBuilder: (BuildContext, int index) {
                  ReviewCartModel data = cartController.getcartDataModel[index];
                  return Padding(
                    padding: const EdgeInsets.all(10.0),
                    child: Row(
                      children: [
                        Container(
                          height: 100,
                          width: 100,
                          decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(40),
                              image: DecorationImage(
                                  image: NetworkImage(data.cartImage),
                                  fit: BoxFit.fill)),
                        ),
                        Column(
                          children: [
                            Text(data.cartName),
                            Text(data.cartPrice.toString()),
                          ],
                        ),
                        Column(
                          children: [
                            CounterState(
                                productId:
                                    homeViewModel.products[index].productId,
                                itemImage:
                                    homeViewModel.products[index].itemimageUrl,
                                itemName:
                                    homeViewModel.products[index].itemName,
                                itemQuantity: 1,
                                itemprice:
                                    homeViewModel.products[index].itemprice),
                            Text(
                                "${homeViewModel.products[index].itemprice} * ${cartController.cartDataModel[index].cartQuantity}")
                          ],
                        )
                      ],
                    ),
                  );
                }),
          )
        ])),
      ),
    );
  }
}

</code>```

Body:
I am not able to fetch data with realtime firestore. I am using firebase as a cart to store data of cart. but I am able to add the data to firebase but it is not working as realtime. Please help me resolve it. I tried to find out many way but I am not able to do that.

// this is my controller
import 'dart:async';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:e_commerce/code%20editing%20folder/cartModel.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:get/get.dart';

class CartController extends GetxController {
  @override
  void onInit() async {
    // TODO: implement onInit
    getCartData();
    await getcartDataModel;
    super.onInit();
  }

  void addtoCart({
    required String cartId,
    required String cartName,
    required String cartImage,
    required int cartPrice,
    required int cartQuantity,
  }) async {
    await FirebaseFirestore.instance
        .collection('Users')
        .doc(FirebaseAuth.instance.currentUser!.uid)
        .collection('yourCart')
        .doc(cartId)
        .set({
      "cartId": cartId,
      "cartName": cartName,
      "cartImage": cartImage,
      "cartPrice": cartPrice,
      "cartQuantity": cartQuantity
    });
  }

  RxList cartDataModel = [].obs;
  void getCartData() async {
    RxList newList = [].obs;
    QuerySnapshot cartStream = await FirebaseFirestore.instance
        .collection("Users")
        .doc(FirebaseAuth.instance.currentUser!.uid)
        .collection("yourCart")
        .get();
    cartStream.docs.forEach((element) {
      ReviewCartModel reviewCartModel = ReviewCartModel(
        cartId: element.get("cartId"),
        cartImage: element.get("cartImage"),
        cartName: element.get("cartName"),
        cartPrice: element.get("cartPrice"),
        cartQuantity: element.get("cartQuantity"),
      );
      newList.add(reviewCartModel);
    });

    cartDataModel = newList;
    update();
  }

  RxList get getcartDataModel {
    return cartDataModel;
    update();
  }
}

Below I also added the screen where I want to implement the crud operation, but I am not able to do that. I can only get the data one time only when the application start

// this is my cartScreen
import 'package:e_commerce/code%20editing%20folder/cartModel.dart';
import 'package:e_commerce/code%20editing%20folder/firebaseCartController.dart';
import 'package:e_commerce/core/viewmodel/home_viewmodel.dart';
import 'package:e_commerce/view/widgets/counterstate.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class CartScreemn extends StatelessWidget {
  CartScreemn({super.key});
  final HomeViewModel homeViewModel = Get.put(HomeViewModel());
  @override
  Widget build(BuildContext context) {
    return GetX<CartController>(
      init: Get.put<CartController>(CartController()),
      builder: (CartController cartController) => SafeArea(
        top: true,
        bottom: true,
        child: Scaffold(
            body: Column(children: [
          Expanded(
            child: ListView.builder(
                padding: EdgeInsets.all(10),
                itemCount: cartController.getcartDataModel.length,
                itemBuilder: (BuildContext, int index) {
                  ReviewCartModel data = cartController.getcartDataModel[index];
                  return Padding(
                    padding: const EdgeInsets.all(10.0),
                    child: Row(
                      children: [
                        Container(
                          height: 100,
                          width: 100,
                          decoration: BoxDecoration(
                              borderRadius: BorderRadius.circular(40),
                              image: DecorationImage(
                                  image: NetworkImage(data.cartImage),
                                  fit: BoxFit.fill)),
                        ),
                        Column(
                          children: [
                            Text(data.cartName),
                            Text(data.cartPrice.toString()),
                          ],
                        ),
                        Column(
                          children: [
                            CounterState(
                                productId:
                                    homeViewModel.products[index].productId,
                                itemImage:
                                    homeViewModel.products[index].itemimageUrl,
                                itemName:
                                    homeViewModel.products[index].itemName,
                                itemQuantity: 1,
                                itemprice:
                                    homeViewModel.products[index].itemprice),
                            Text(
                                "${homeViewModel.products[index].itemprice} * ${cartController.cartDataModel[index].cartQuantity}")
                          ],
                        )
                      ],
                    ),
                  );
                }),
          )
        ])),
      ),
    );
  }
}


问:
Getting point coordinates onclick to Python API (Google Earth Engine plugin in QGIS)
I am working with Google Earth Engine plugin in QGIS and trying to get a point geomtry from QGIS to use in the python API code.

I wrote some code that needs point coordinates to start the process. I can do that by generating the point inside the script (point = ee.Geometry.Point([Xcoord, Ycoord])), but I actually need to generate that point interctively, that means I click on the map and point coordinates are passed to the code.

Only string I could find that seems related to what I'm seeking is map.onclick(callback), but I'm not sure that's what I need and anyway that throws the error AttributeError: type object 'map' has no attribute 'onclick'.

Does anyone have any suggestion about that?

Many thanks


问:
Issue with android permissions related to Android Studio TargetSdk = 33 and CompileSdk = 33
So... i was implementing runtime permissions on my app and i cudnt figure out why when I tap on the feature that needs that permission, it just wont show the system dialog so the user can grant or deny it. After a lot of reading and literally playing with the app gradle settings I realized that changing CompileSdk from 33 to 32 and also tragetSdk from 33 to 32, that solved the issue,
So my question is Its this a problem that only i am facing or ist a bug on AStudio.

Note: I have the latest version of AStudio and dependencies installed. Also when i create a new Project the default values for CompileSdk / tragetSdk are 32 on gradle file, then i get a warning that i have to change to 33 because i not trageting the lattest version and when i do... i get that issue when requesting any permission.
Any help or advice please. Thanks in advance.


问:
Instagram app occasionally sets Origin header to "null" when browsing to another site via link in profile
People sometimes link to our website in their instagram profile. If a user is using the instagram app and browses to our site via that link, and later POSTs a form on our site, very occasionally (maybe 1 in 10,000 users) the Origin Header is set to the string "null" in the POST request.

We have not been able to repro.

(Note: We separately integrate with instagram to provide a "book now" button and also see this behavior occasionally (also not reproducible) in the OAUTH flow.)

Here is a sample agent string:
Mozilla/5.0 (iPhone; CPU iPhone OS 16_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 Instagram 262.0.0.15.327 (iPhone14,5; iOS 16_1_2; en_IQ; ar-IQ; scale=3.00; 1170x2532; 425379641)

So far, we've only seen this happen on iOS/instagram browser.

Note: I'm wondering if perhaps instagram occasionally inserts an HTTP redirect (hidden from us) which triggers this?


问:
Requests from referer are blocked for accessing Google API
We used the third-party web app and tried to integrate this Google API for Translation.

Currently, it's working OK. We can call the API to do the translation.

However, when we started to restrict this by using the HTTP REFERRER. We keep getting: Requests from referer are blocked.

On the URL, we tried the combination below and no luck:

```<code>*.ourdomainname.com/*
ourdomainname.com/*
</code>```

The developer helped us to identify this and come up with this error detail:

```<code>Requests from referer <empty> are blocked.
</code>```

Any ideas? Currently, it's working OK if we are not putting any restrictions, which is not good :) We prefer to restrict this.

I'm appreciated your feedback.

Thanks

Body:
We used the third-party web app and tried to integrate this Google API for Translation.

Currently, it's working OK. We can call the API to do the translation.

However, when we started to restrict this by using the HTTP REFERRER. We keep getting: Requests from referer are blocked.

On the URL, we tried the combination below and no luck:

*.ourdomainname.com/*
ourdomainname.com/*

The developer helped us to identify this and come up with this error detail:

Requests from referer <empty> are blocked.

Any ideas? Currently, it's working OK if we are not putting any restrictions, which is not good :) We prefer to restrict this.

I'm appreciated your feedback.

Thanks


问:
How to restore submodule from github?
is there option to dowload these nested repositories? Unfortunetly I deleted one of repos locacly and want to retrieve it. But when i try to clone repository these nested repos are empty even with --recursion option. When I clink into lab7 it shows this so i think it should clone soemthing.

Title: How to restore submodule from github?


问:
Php CURLFile equivalent in Node js
I'm trying to send a post request to an external api where one of the parameters needs to be of 'multipart/form-data' encoding, specifically with type image/jpeg. In php this works with CURLFile

new CURLFile($file, 'image/jpeg');

Is there an equivalent to this in Node JS?

Title: Php CURLFile equivalent in Node js


问:
How can I access to folders files outside of wwwroot with IIS?
I am using windows server 2019 and I have a domain given by azure. The webapp works great but I am wondering if there is a possibility to configure the IIS so I can access to any folder inside the server. For example I have a text file in the server's desktop called testing.txt and I want to access to that file through the server name and Uri like:

http://test.eastus.cloudapp.azure.com/Users/Fredy/Desktop/testing.txt

but gives me the following error:

I am asking if there is a documentation for configuring IIS for such scenarios? I know this is dangerous but maybe if there is a possibility I can configure which folders can be seen. Files that are being accessed can be images, texts, connectionStrings, etc.

Is it possible? How do I do this?


问:
How do i override scaffold backGround or default text size locally in flutter?
using the technique described in https://docs.flutter.dev/cookbook/design/themes#creating-unique-themedata I can modify accentColor, splashColor but not scaffoldColor or text size

https://github.com/neiljaywarner/local_theme_test

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

const smallDefault = const TextTheme(bodyText2: TextStyle(fontSize: 15.0));
const bigDefault = const TextTheme(bodyText2: TextStyle(fontSize: 54.0));
var orangeBrown = ThemeData(
  scaffoldBackgroundColor: Colors.brown,
  textTheme: smallDefault,
  accentColor: Colors.orange,
);
var bluePink = ThemeData(
  scaffoldBackgroundColor: Colors.blue,
  textTheme: bigDefault,
  accentColor: Colors.pink,
);

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Primary Text theme override',
      theme: orangeBrown,
      home: Scaffold(
        body: Center(
          child: Theme(
            data: bluePink,
            child: Text('?why small??'),
          ),
        ),
        floatingActionButton: Theme(
          data: bluePink,
          child: FloatingActionButton(
            onPressed: () {},
            child: const Icon(Icons.add),
          ),
        ),
      ),
    );
  }
}
```


问:
zookeeper stopped logging after log4j 2.17.1 patch
As you see the log dir, log info level are all in class path; however there is no /var/log/zookeeper/zookeeper.log . I restarted the  zookeeper.service , ensured LOG dir has the write permission etc., but still no clue.

ps -ef | grep zookeeper

zookeep+ 14134     1  0 Dec12 ?        00:00:37 java -Dzookeeper.log.dir=/var/log/zookeeper -Dzookeeper.root.logger=INFO,ROLLINGFILE -cp /opt/zookeeper/bin/../build/classes:/opt/zookeeper/bin/../build/lib/.jar:/opt/zookeeper/bin/../share/zookeeper/zookeeper-3.4.13-1.hardtop.0.9.1.jar:/opt/zookeeper/bin/../share/zookeeper/slf4j-api-1.7.25.jar:/opt/zookeeper/bin/../share/zookeeper/netty-all-4.1.30.Final.jar:/opt/zookeeper/bin/../share/zookeeper/log4j-slf4j-impl-2.17.1.jar:/opt/zookeeper/bin/../share/zookeeper/log4j-core-2.17.1.jar:/opt/zookeeper/bin/../share/zookeeper/log4j-api-2.17.1.jar:/opt/zookeeper/bin/../share/zookeeper/jline-0.9.94.jar:/opt/zookeeper/bin/../share/zookeeper/audience-annotations-0.5.0.jar:/opt/zookeeper/bin/../src/java/lib/.jar:/opt/zookeeper/bin/../conf: -Xmx1024m -Dzookeeper.allowSaslFailedClients=false -Djava.security.krb5.realm=MYHOST.MYORG.COM -Djava.security.krb5.kdc=MYKDC.MYORG.com -Djava.security.auth.login.config=/opt/zookeeper/conf/zookeeper_jaas.conf -Xmx2048m -Xms512m -Dzookeeper.allowSaslFailedClients=false -Dzookeeper.jmx.log4j.disable=true org.apache.zookeeper.server.quorum.QuorumPeerMain /opt/zookeeper/bin/../conf/zoo.cfg

This worked before log4j upgrade. Recently I updated it to 2.17.1


问:
How to only drag object in JFrame when clicking on it, not around it
The goal here is to only be able to drag the circle (rock) around when the mouse clicks on it and I can't seem to figure it out. Right now, I can click anywhere in the frame and be able to move the circle. Any suggestions appreciated!

Here's my main class that has the Jframe, label and my object called rock

```<code>import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Runner {
    public static void main(String[] args) {

        JFrame myFrame = new JFrame();

        rock = new Rock(0,0, SIZE);

        final MyIcon myIcon = new MyIcon(rock, ICON_W, ICON_H);
        final JLabel myLabel = new JLabel(myIcon);

        myLabel.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e){

                rock.mousePoint = e.getPoint();
                if (! myLabel.contains(rock.mousePoint)) {
                    rock.mousePoint = null;
                }
            }
        });

        myLabel.addMouseMotionListener(new MouseMotionAdapter() {
            public void mouseDragged(MouseEvent e){

                if (rock.mousePoint != null) {
                    Point lastMousePoint = rock.mousePoint;
                    rock.mousePoint = e.getPoint();
                    double dx = rock.mousePoint.getX() - lastMousePoint.getX();
                    double dy = rock.mousePoint.getY() - lastMousePoint.getY();
                    rock.translate((int) dx, (int) dy);
                    myFrame.repaint();
                    myFrame.pack();
                }
            }
        });

        myFrame.repaint();
        myFrame.add(myLabel);
        myFrame.setLayout(new FlowLayout());
        myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        myFrame.pack();
        myFrame.setVisible(true);

    }
    static Rock rock;
    //private static Point mousePoint;
    private static final int SIZE = 40;
    private static final int ICON_W = 800;
    private static final int ICON_H = 550;

}
</code>```

This is the rock object class

```<code>public class Rock implements MovingObject{

    public Rock(int x, int y, int size) {
        this.x = x;
        this.y = x;
        this.size = size;
        mousePoint = new Point();
        //rock = new Ellipse2D.Double(x, y, size, size);
    }

    public void translate(int xChange, int yChange) {
        x += xChange;
        y += yChange;
    }

    public void draw(Graphics2D g2D) {

        Ellipse2D.Double rock = new Ellipse2D.Double(x, y, size, size);
        g2D.fill(rock);
        g2D.draw(rock);
    }

   // Ellipse2D.Double rock;
    protected Point mousePoint;
    int x;
    int y;
    int size;
}
</code>```

Body:
The goal here is to only be able to drag the circle (rock) around when the mouse clicks on it and I can't seem to figure it out. Right now, I can click anywhere in the frame and be able to move the circle. Any suggestions appreciated!

Here's my main class that has the Jframe, label and my object called rock

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Runner {
    public static void main(String[] args) {

        JFrame myFrame = new JFrame();

        rock = new Rock(0,0, SIZE);

        final MyIcon myIcon = new MyIcon(rock, ICON_W, ICON_H);
        final JLabel myLabel = new JLabel(myIcon);

        myLabel.addMouseListener(new MouseAdapter() {
            public void mousePressed(MouseEvent e){

                rock.mousePoint = e.getPoint();
                if (! myLabel.contains(rock.mousePoint)) {
                    rock.mousePoint = null;
                }
            }
        });

        myLabel.addMouseMotionListener(new MouseMotionAdapter() {
            public void mouseDragged(MouseEvent e){

                if (rock.mousePoint != null) {
                    Point lastMousePoint = rock.mousePoint;
                    rock.mousePoint = e.getPoint();
                    double dx = rock.mousePoint.getX() - lastMousePoint.getX();
                    double dy = rock.mousePoint.getY() - lastMousePoint.getY();
                    rock.translate((int) dx, (int) dy);
                    myFrame.repaint();
                    myFrame.pack();
                }
            }
        });

        myFrame.repaint();
        myFrame.add(myLabel);
        myFrame.setLayout(new FlowLayout());
        myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        myFrame.pack();
        myFrame.setVisible(true);

    }
    static Rock rock;
    //private static Point mousePoint;
    private static final int SIZE = 40;
    private static final int ICON_W = 800;
    private static final int ICON_H = 550;

}

This is the rock object class

public class Rock implements MovingObject{

    public Rock(int x, int y, int size) {
        this.x = x;
        this.y = x;
        this.size = size;
        mousePoint = new Point();
        //rock = new Ellipse2D.Double(x, y, size, size);
    }

    public void translate(int xChange, int yChange) {
        x += xChange;
        y += yChange;
    }

    public void draw(Graphics2D g2D) {

        Ellipse2D.Double rock = new Ellipse2D.Double(x, y, size, size);
        g2D.fill(rock);
        g2D.draw(rock);
    }

   // Ellipse2D.Double rock;
    protected Point mousePoint;
    int x;
    int y;
    int size;
}


问:
Swap two keyboard Keys
I want to create a program in "C#", which when I type the "Enter" key, it will act as if "Tab" was typed, and the program will run in the state where the window is Minimized.
Sorry for typos, I wrote this text with a translator

I used the following code:

```<code>private void treeView1_KeyDown(object sender, KeyEventArgs e)
{
  /* If the 'Alt' and 'E' keys are pressed,
   * allow the user to edit the TreeNode label. */
  if (e.KeyCode == Keys.Enter)
  {
    MessageBox.Show("Thanks!");
  }
}
</code>```

And the result I wanted was not achieved

Title: Swap two keyboard Keys

Body:
I want to create a program in "C#", which when I type the "Enter" key, it will act as if "Tab" was typed, and the program will run in the state where the window is Minimized.
Sorry for typos, I wrote this text with a translator

I used the following code:

private void treeView1_KeyDown(object sender, KeyEventArgs e)
{
  /* If the 'Alt' and 'E' keys are pressed,
   * allow the user to edit the TreeNode label. */
  if (e.KeyCode == Keys.Enter)
  {
    MessageBox.Show("Thanks!");
  }
}

And the result I wanted was not achieved


问:
Spring Boot, Make File Reference Case Sensitive
We are using a Spring Boot project. On Windows, the actual filename is getproduct.sql (all lower case).

However in the code reference, which reads it, has Capitalization. This creates No issue when testing locally on Windows (which is Not case sensitive). However, when deploying to Linux server, it cannot read the file (since Linux is case sensitive), and has deployment issue. How do we ensure Spring Boot File Reads are Case Sensitive on the filename text, regardless of environment? Is there a Spring Boot Setting?

```<code>public class ProductRepository {

    private static final Path GET_PRODUCT = Paths.get("sql", "GetProduct.sql");

    private final String getProduct;

    public ProductRepository() {
        this.getProduct = FileResourceUtil.readFileAsString(getClass(), GET_PRODUCT.toString());
</code>```

Note: We are reluctant to change all our Legacy code, is there a setting, parameter fix in Spring Boot Settings which will resolve this?

Body:
We are using a Spring Boot project. On Windows, the actual filename is getproduct.sql (all lower case).

However in the code reference, which reads it, has Capitalization. This creates No issue when testing locally on Windows (which is Not case sensitive). However, when deploying to Linux server, it cannot read the file (since Linux is case sensitive), and has deployment issue. How do we ensure Spring Boot File Reads are Case Sensitive on the filename text, regardless of environment? Is there a Spring Boot Setting?

public class ProductRepository {

    private static final Path GET_PRODUCT = Paths.get("sql", "GetProduct.sql");

    private final String getProduct;

    public ProductRepository() {
        this.getProduct = FileResourceUtil.readFileAsString(getClass(), GET_PRODUCT.toString());

Note: We are reluctant to change all our Legacy code, is there a setting, parameter fix in Spring Boot Settings which will resolve this?


问:
Use android camera on edge website, just working on edge
I have a library that reads QR and I am trying to set the camera on a all devices, pc, laptop, table and phone, I already did that, but for phone is just working on chrome, I cannot figure out why this is happening, before I found a code that solved this issue, but it just worked for chrome

```<code>navigator.mediaDevices.getUserMedia({ audio: true, video: { facingMode: "environment" }}).then(() => {
                this.qrScannerComponent.chooseCamera.next(choosenDev);})
</code>```

this is my ts code that is run in the after init

```<code>  qrReader(){

    this.qrScannerComponent.getMediaDevices().then(devices => {
      console.log(devices);
      const videoDevices: MediaDeviceInfo[] = [];
      for (const device of devices) {
          if (device.kind.toString() === 'videoinput') {
              videoDevices.push(device);
            }
          }

      if (videoDevices.length > 1){
          let choosenDev;
          for (const dev of videoDevices){
              if (dev.label.includes('back')){
                  choosenDev = dev;

                  break;
              }
          }
          if (choosenDev) {
            alert(JSON.stringify( choosenDev))
              this.qrScannerComponent.chooseCamera.next(choosenDev);
              navigator.mediaDevices.getUserMedia({ audio: true, video: { facingMode: "environment" }}).then(() => {
                this.qrScannerComponent.chooseCamera.next(choosenDev);})
          }
          else {
              this.qrScannerComponent.chooseCamera.next(videoDevices[0]);
          }
      }
      else if (videoDevices.length == 1){
          let choosenDev;
          for (const dev of videoDevices){
              if (dev.label.includes('front')){
                  choosenDev = dev;
                  break;
              }
          }
          if (choosenDev) {
              this.qrScannerComponent.chooseCamera.next(choosenDev);

          } else {
              this.qrScannerComponent.chooseCamera.next(videoDevices[0]);
          }

      }
  });

  this.qrScannerComponent.capturedQr.subscribe(result => {
      alert(result);
  });

  }
</code>```

The library that I am using is angular2-qrscanner

result on edge

Result on chrome

Body:
I have a library that reads QR and I am trying to set the camera on a all devices, pc, laptop, table and phone, I already did that, but for phone is just working on chrome, I cannot figure out why this is happening, before I found a code that solved this issue, but it just worked for chrome

navigator.mediaDevices.getUserMedia({ audio: true, video: { facingMode: "environment" }}).then(() => {
                this.qrScannerComponent.chooseCamera.next(choosenDev);})

this is my ts code that is run in the after init

  qrReader(){

    this.qrScannerComponent.getMediaDevices().then(devices => {
      console.log(devices);
      const videoDevices: MediaDeviceInfo[] = [];
      for (const device of devices) {
          if (device.kind.toString() === 'videoinput') {
              videoDevices.push(device);
            }
          }

      if (videoDevices.length > 1){
          let choosenDev;
          for (const dev of videoDevices){
              if (dev.label.includes('back')){
                  choosenDev = dev;

                  break;
              }
          }
          if (choosenDev) {
            alert(JSON.stringify( choosenDev))
              this.qrScannerComponent.chooseCamera.next(choosenDev);
              navigator.mediaDevices.getUserMedia({ audio: true, video: { facingMode: "environment" }}).then(() => {
                this.qrScannerComponent.chooseCamera.next(choosenDev);})
          }
          else {
              this.qrScannerComponent.chooseCamera.next(videoDevices[0]);
          }
      }
      else if (videoDevices.length == 1){
          let choosenDev;
          for (const dev of videoDevices){
              if (dev.label.includes('front')){
                  choosenDev = dev;
                  break;
              }
          }
          if (choosenDev) {
              this.qrScannerComponent.chooseCamera.next(choosenDev);

          } else {
              this.qrScannerComponent.chooseCamera.next(videoDevices[0]);
          }

      }
  });

  this.qrScannerComponent.capturedQr.subscribe(result => {
      alert(result);
  });

  }

The library that I am using is angular2-qrscanner

result on edge

Result on chrome