问:
Java Stream Corrupted error when iterating through Serialized file to deserialize
I initially created a file containing serialized data, and wanted to iterate through it and add the objects to a text file. However, I keep getting a StreamCorrupted error when I try doing so. Any suggestions on how to fix this? Thanks in advance.
The Method:

```<code>public static ImperialDrone retrieveDrone(String filename) {

        try {
            System.out.println(filename);
            boolean cont = true;
            ArrayList<ImperialDrone> list = new ArrayList<>();
            ObjectInputStream Sin = new ObjectInputStream(new FileInputStream("C:\\Users\\13023\\eclipse-workspace\\Chunduru_HW6\\src\\chunduru\\STORAGE\\DStore"));
            while(cont){
                ImperialDrone I = null;
              try {
                  I = (ImperialDrone) Sin.readObject();
              } catch (EOFException E) {
                  E.printStackTrace();
              }
                if(I != null) {
                     list.add(I);
                     System.out.println("Added 1");
                }

                else {
                    cont = false;
                }

             }

            Sin.close();
            return list.get(0);

        }
        catch (Exception e) {
            e.printStackTrace();
            System.out.println(e);
        }
        return null;

    }
</code>```

The Error:

```<code>java.io.StreamCorruptedException: invalid type code: AC
    at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1764)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:509)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:467)
    at Chunduru_HW6/chunduru.INTERFACES.DroneOperations.retrieveDrone(DroneOperations.java:49)
    at Chunduru_HW6/chunduru.MAIN.Chunduru.main(Chunduru.java:26)
java.io.StreamCorruptedException: invalid type code: AC
</code>```

Body:
I initially created a file containing serialized data, and wanted to iterate through it and add the objects to a text file. However, I keep getting a StreamCorrupted error when I try doing so. Any suggestions on how to fix this? Thanks in advance.
The Method:

public static ImperialDrone retrieveDrone(String filename) {

        try {
            System.out.println(filename);
            boolean cont = true;
            ArrayList<ImperialDrone> list = new ArrayList<>();
            ObjectInputStream Sin = new ObjectInputStream(new FileInputStream("C:\\Users\\13023\\eclipse-workspace\\Chunduru_HW6\\src\\chunduru\\STORAGE\\DStore"));
            while(cont){
                ImperialDrone I = null;
              try {
                  I = (ImperialDrone) Sin.readObject();
              } catch (EOFException E) {
                  E.printStackTrace();
              }
                if(I != null) {
                     list.add(I);
                     System.out.println("Added 1");
                }

                else {
                    cont = false;
                }

             }

            Sin.close();
            return list.get(0);

        }
        catch (Exception e) {
            e.printStackTrace();
            System.out.println(e);
        }
        return null;

    }

The Error:

java.io.StreamCorruptedException: invalid type code: AC
    at java.base/java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1764)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:509)
    at java.base/java.io.ObjectInputStream.readObject(ObjectInputStream.java:467)
    at Chunduru_HW6/chunduru.INTERFACES.DroneOperations.retrieveDrone(DroneOperations.java:49)
    at Chunduru_HW6/chunduru.MAIN.Chunduru.main(Chunduru.java:26)
java.io.StreamCorruptedException: invalid type code: AC


来源: stackexchange

问:
How to update data on firebase realtime database?
In my project i need to update data in firebase. Firstly i write and made the first data:

```<code>set(ref(db, 'users/' + res.data.localId), {
            name: name,
            surname: surname,
            email: email,
            countTrains: 0
          }).then(() => {
             console.log('Made new account');
        })
            .catch((error) => {
                console.log(error);
            });

</code>```

Then i need to update the feeld countTrains:

```<code> update(ref(db, 'users/' + user.localId), {
      countTrains: countTrain,
    }).then(() => {
      alert('data updated!');
  })
      .catch((error) => {
          alert(error);
      });

</code>```

But it doesn't work and takes an exception like: RangeError: Maximum call stack size exceeded, js engine: hermes.
Please, help

UPDATE:
I take the param of count from another Stack Screen by

```<code> const countTrain = route.params.count
</code>```

The source look like:

```<code>  const [count, setCount] = useState(1);
 onPress={() => {
     toResult();
     setCount(count + 1);

const toResult = () => {
    navigation.navigate('Result',  {count})
  }
</code>```

ContentLicense: CC BY-SA 4.0

Body:
In my project i need to update data in firebase. Firstly i write and made the first data:

set(ref(db, 'users/' + res.data.localId), {
            name: name,
            surname: surname,
            email: email,
            countTrains: 0
          }).then(() => {
             console.log('Made new account');
        })
            .catch((error) => {
                console.log(error);
            });

Then i need to update the feeld countTrains:

 update(ref(db, 'users/' + user.localId), {
      countTrains: countTrain,
    }).then(() => {
      alert('data updated!');
  })
      .catch((error) => {
          alert(error);
      });

But it doesn't work and takes an exception like: RangeError: Maximum call stack size exceeded, js engine: hermes.
Please, help

UPDATE:
I take the param of count from another Stack Screen by

 const countTrain = route.params.count

The source look like:

  const [count, setCount] = useState(1);
 onPress={() => {
     toResult();
     setCount(count + 1);

const toResult = () => {
    navigation.navigate('Result',  {count})
  }


问:
SqlAlchemy Parsing Result Object By Columns
In sqlalchemy, the result object returns me the data row by row, I want the query to return the me data column by column.

```<code>query = self.controller.ListAll(query) # returns <class 'sqlalchemy.engine.cursor.LegacyCursorResult'>
</code>```

output ==> (1,Carlson,1000),(2,Jack,2000)

the result i want:

output ==> (1,2),(Carlson,Jack),(1000,2000)

The query is constantly changing. I couldn't find a defined function that returns the result object column by column. Should I write a function to return the value it returns to the output I want or is there another way to do this?

Body:
In sqlalchemy, the result object returns me the data row by row, I want the query to return the me data column by column.

query = self.controller.ListAll(query) # returns <class 'sqlalchemy.engine.cursor.LegacyCursorResult'>

output ==> (1,Carlson,1000),(2,Jack,2000)

the result i want:

output ==> (1,2),(Carlson,Jack),(1000,2000)

The query is constantly changing. I couldn't find a defined function that returns the result object column by column. Should I write a function to return the value it returns to the output I want or is there another way to do this?


问:
What can I change there?
```<code>return stripe.checkout.sessions.create({
       payment_method_types: ['card'],
       line_items: products.map(p => {
           return {
             name: p.productId.title,
             description: p.productId.description,
             price_data: p.productId.price * 100,
             currency: 'usd',
             quantity: p.quantity
           };
    }),
        success_url: req.protocol + '://' + req.get('host') + '/checkout/success', // => http://localhost:3000
        cancel_url: req.protocol + '://' + req.get('host') + '/checkout/cancel'
    });
})
</code>```

Error: You may only specify one of these parameters: name, price_data.

I couldn't find a solution to this

Title: What can I change there?

Body:
return stripe.checkout.sessions.create({
       payment_method_types: ['card'],
       line_items: products.map(p => {
           return {
             name: p.productId.title,
             description: p.productId.description,
             price_data: p.productId.price * 100,
             currency: 'usd',
             quantity: p.quantity
           };
    }),
        success_url: req.protocol + '://' + req.get('host') + '/checkout/success', // => http://localhost:3000
        cancel_url: req.protocol + '://' + req.get('host') + '/checkout/cancel'
    });
})

Error: You may only specify one of these parameters: name, price_data.

I couldn't find a solution to this


问:
Moving file E93: More than one match
The following function works (it opens and moves the desired file to a new or preexisting directory). But, I receive an error message concerning line 11 of the function execute 'bwipeout '.expand(s:oldFileName). The error I receive is E93: More than one match for <the old file name>. I don't understand how this is possible because it has already successfully moved the file to the s:newFileName and the old file has been deleted. The new file's buffer doesn't have the same name as the old buffer. So, how would there be more than one match for the name of the old buffer?

```<code>command! -nargs=0 -bar MoveFile call s:functionMoveFile()
    function s:functionMoveFile() abort
        call dirvish#open("edit", 0)
        let s:oldFileName = expand("%:p")
        call inputsave()
        let s:newFileName = input("Move file here: ",expand(s:oldFileName),"file")
        call inputrestore()
        if s:newFileName != '' && s:newFileName != s:oldFileName
            execute 'sav '.fnameescape(s:newFileName)
            let s:newFileDirectory = expand("%:p:h")
            call delete(s:oldFileName)
            execute 'Dirvish '.expand(s:newFileDirectory)
            execute 'bwipeout '.expand(s:oldFileName)
        endif
    endfunction
</code>```

I can prepend silent! to line 11 to avoid the error message. But, that isn't a proper fix. I don't know what else I should try because I am not asking vim to wipeout the new buffer and the old file's name doesn't match the new one. The command works as desired, but I would like to know what is incorrect about what I'm doing.

Thank you for your help.

Title: Moving file E93: More than one match

Body:
The following function works (it opens and moves the desired file to a new or preexisting directory). But, I receive an error message concerning line 11 of the function execute 'bwipeout '.expand(s:oldFileName). The error I receive is E93: More than one match for <the old file name>. I don't understand how this is possible because it has already successfully moved the file to the s:newFileName and the old file has been deleted. The new file's buffer doesn't have the same name as the old buffer. So, how would there be more than one match for the name of the old buffer?

command! -nargs=0 -bar MoveFile call s:functionMoveFile()
    function s:functionMoveFile() abort
        call dirvish#open("edit", 0)
        let s:oldFileName = expand("%:p")
        call inputsave()
        let s:newFileName = input("Move file here: ",expand(s:oldFileName),"file")
        call inputrestore()
        if s:newFileName != '' && s:newFileName != s:oldFileName
            execute 'sav '.fnameescape(s:newFileName)
            let s:newFileDirectory = expand("%:p:h")
            call delete(s:oldFileName)
            execute 'Dirvish '.expand(s:newFileDirectory)
            execute 'bwipeout '.expand(s:oldFileName)
        endif
    endfunction

I can prepend silent! to line 11 to avoid the error message. But, that isn't a proper fix. I don't know what else I should try because I am not asking vim to wipeout the new buffer and the old file's name doesn't match the new one. The command works as desired, but I would like to know what is incorrect about what I'm doing.

Thank you for your help.


问:
Oracle database slow execution of statement with multiple recursive common table expressions
I have an Oracle 19c database table with "resources" that are organized hierarchically like a nested folder tree. The table contains around 2.5 million rows and the tree is up to 10 levels deep.

```<code>create table RESOURCES (
    ID_       NUMBER(10) not null constraint PK_RESOURCES primary key,
    FOLDERID_ NUMBER(10) constraint FK_PARENTFOLDER references RESOURCES
);

create index FOLDERIDINDEX on RESOURCES (FOLDERID_);
</code>```

I'm using SQL recursive common table expressions (aka recursive subquery factoring) to find all descendants of some given resources.

In general, this works quite nicely, but if I try to get descendants of multiple folders with one query, some queries don't perform at all using Oracle. I'd like to understand why this is the case, and if there's some easy way to speed things up (query hint?, bugfix?, ...?)

For example, this statement does not return within 60 minutes(!):

```<code>WITH cte1 (id_) AS (SELECT id_ FROM Resources where id_ = 11
                    UNION ALL
                    SELECT r.id_ FROM Resources r, cte1 c WHERE r.folderId_ = c.id_),
     cte2 (id_) AS (SELECT id_ FROM Resources where id_ = 808965
                    UNION ALL
                    SELECT r.id_ FROM Resources r, cte2 c WHERE r.folderId_ = c.id_)
SELECT count(*)
FROM Resources r
WHERE (r.folderId_ IN (SELECT * FROM cte1) OR r.folderId_ IN (SELECT * FROM cte2));
</code>```

If I replace the two sub-selects in the last line with a UNION, it just takes a few seconds:

```<code>WITH cte1 (id_) AS (SELECT id_ FROM Resources where id_ = 11
                    UNION ALL
                    SELECT r.id_ FROM Resources r, cte1 c WHERE r.folderId_ = c.id_),
     cte2 (id_) AS (SELECT id_ FROM Resources where id_ = 808965
                    UNION ALL
                    SELECT r.id_ FROM Resources r, cte2 c WHERE r.folderId_ = c.id_)
SELECT count(*)
FROM Resources r
WHERE (r.folderId_ IN (SELECT * FROM cte1 UNION SELECT * FROM cte2));
</code>```

While that could already be the solution, it's a bit hard to change in my project, because SQL is auto-generated by code from application queries, and at that point not so easy to change. Also, application queries could be much more complex and such a replacement might not even be possible. These are just simplified examples. Maybe there's some other way to speed things up?

Interestingly, the slow query works without any performance problems on other databases like MySQL 8, PostgreSQL 13, SQL Server 2016 (with small syntax changes for the databases). It's just Oracle which seems to have a problem here.

This is the query plan for the first query, i.e. the slow one:

```<code>------------------------------------------------------------------------------------------------------------
| Id  | Operation                                   | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                            |              |     1 |     5 |    54G  (1)|591:38:12 |
|   1 |  SORT AGGREGATE                             |              |     1 |     5 |            |          |
|*  2 |   FILTER                                    |              |       |       |            |          |
|   3 |    TABLE ACCESS FULL                        | RESOURCES    |  2410K|    11M|  9389   (1)| 00:00:01 |
|*  4 |    VIEW                                     |              |   239K|  3046K| 23128   (1)| 00:00:01 |
|   5 |     UNION ALL (RECURSIVE WITH) BREADTH FIRST|              |       |       |            |          |
|*  6 |      INDEX UNIQUE SCAN                      | PK_RESOURCES |     1 |     6 |     2   (0)| 00:00:01 |
|*  7 |      HASH JOIN                              |              |   239K|  5623K| 23126   (1)| 00:00:01 |
|   8 |       RECURSIVE WITH PUMP                   |              |       |       |            |          |
|   9 |       BUFFER SORT (REUSE)                   |              |       |       |            |          |
|  10 |        TABLE ACCESS FULL                    | RESOURCES    |  2410K|    25M|  9386   (1)| 00:00:01 |
|* 11 |    VIEW                                     |              |   239K|  3046K| 23128   (1)| 00:00:01 |
|  12 |     UNION ALL (RECURSIVE WITH) BREADTH FIRST|              |       |       |            |          |
|* 13 |      INDEX UNIQUE SCAN                      | PK_RESOURCES |     1 |     6 |     2   (0)| 00:00:01 |
|* 14 |      HASH JOIN                              |              |   239K|  5623K| 23126   (1)| 00:00:01 |
|  15 |       RECURSIVE WITH PUMP                   |              |       |       |            |          |
|  16 |       BUFFER SORT (REUSE)                   |              |       |       |            |          |
|  17 |        TABLE ACCESS FULL                    | RESOURCES    |  2410K|    25M|  9386   (1)| 00:00:01 |
------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

"   2 - filter( EXISTS (SELECT 0 FROM ""CTE1"" ""CTE1"" WHERE ""CTE1"".""ID_""=:B1) OR  EXISTS (SELECT 0 "
"              FROM ""CTE2"" ""CTE2"" WHERE ""CTE2"".""ID_""=:B2))"
"   4 - filter(""CTE1"".""ID_""=:B1)"
"   6 - access(""ID_""=11)"
"   7 - access(""R"".""FOLDERID_""=""C"".""ID_"")"
"  11 - filter(""CTE2"".""ID_""=:B1)"
"  13 - access(""ID_""=808965)"
"  14 - access(""R"".""FOLDERID_""=""C"".""ID_"")"
</code>```

For comparison, the faster query using a UNION seems to use a better plan:

```<code>------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                                      | Name          | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                               |               |     1 |    18 |       | 55733   (1)| 00:00:03 |
|   1 |  SORT AGGREGATE                                |               |     1 |    18 |       |            |          |
|*  2 |   HASH JOIN                                    |               |  2806K|    48M|    11M| 55733   (1)| 00:00:03 |
|   3 |    VIEW                                        | VW_NSO_1      |   479K|  6092K|       | 50820   (1)| 00:00:02 |
|   4 |     SORT UNIQUE                                |               |   479K|  6092K|  9424K| 50820   (1)| 00:00:02 |
|   5 |      UNION-ALL                                 |               |       |       |       |            |          |
|   6 |       VIEW                                     |               |   239K|  3046K|       | 23128   (1)| 00:00:01 |
|   7 |        UNION ALL (RECURSIVE WITH) BREADTH FIRST|               |       |       |       |            |          |
|*  8 |         INDEX UNIQUE SCAN                      | PK_RESOURCES  |     1 |     6 |       |     2   (0)| 00:00:01 |
|*  9 |         HASH JOIN                              |               |   239K|  5623K|       | 23126   (1)| 00:00:01 |
|  10 |          RECURSIVE WITH PUMP                   |               |       |       |       |            |          |
|  11 |          BUFFER SORT (REUSE)                   |               |       |       |       |            |          |
|  12 |           TABLE ACCESS FULL                    | RESOURCES     |  2410K|    25M|       |  9386   (1)| 00:00:01 |
|  13 |       VIEW                                     |               |   239K|  3046K|       | 23128   (1)| 00:00:01 |
|  14 |        UNION ALL (RECURSIVE WITH) BREADTH FIRST|               |       |       |       |            |          |
|* 15 |         INDEX UNIQUE SCAN                      | PK_RESOURCES  |     1 |     6 |       |     2   (0)| 00:00:01 |
|* 16 |         HASH JOIN                              |               |   239K|  5623K|       | 23126   (1)| 00:00:01 |
|  17 |          RECURSIVE WITH PUMP                   |               |       |       |       |            |          |
|  18 |          BUFFER SORT (REUSE)                   |               |       |       |       |            |          |
|  19 |           TABLE ACCESS FULL                    | RESOURCES     |  2410K|    25M|       |  9386   (1)| 00:00:01 |
|  20 |    INDEX FAST FULL SCAN                        | FOLDERIDINDEX |  2410K|    11M|       |  2392   (1)| 00:00:01 |
------------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

"   2 - access(""R"".""FOLDERID_""=""ID_"")"
"   8 - access(""ID_""=11)"
"   9 - access(""R"".""FOLDERID_""=""C"".""ID_"")"
"  15 - access(""ID_""=808965)"
"  16 - access(""R"".""FOLDERID_""=""C"".""ID_"")"
</code>```

Body:
I have an Oracle 19c database table with "resources" that are organized hierarchically like a nested folder tree. The table contains around 2.5 million rows and the tree is up to 10 levels deep.

create table RESOURCES (
    ID_       NUMBER(10) not null constraint PK_RESOURCES primary key,
    FOLDERID_ NUMBER(10) constraint FK_PARENTFOLDER references RESOURCES
);

create index FOLDERIDINDEX on RESOURCES (FOLDERID_);

I'm using SQL recursive common table expressions (aka recursive subquery factoring) to find all descendants of some given resources.

In general, this works quite nicely, but if I try to get descendants of multiple folders with one query, some queries don't perform at all using Oracle. I'd like to understand why this is the case, and if there's some easy way to speed things up (query hint?, bugfix?, ...?)

For example, this statement does not return within 60 minutes(!):

WITH cte1 (id_) AS (SELECT id_ FROM Resources where id_ = 11
                    UNION ALL
                    SELECT r.id_ FROM Resources r, cte1 c WHERE r.folderId_ = c.id_),
     cte2 (id_) AS (SELECT id_ FROM Resources where id_ = 808965
                    UNION ALL
                    SELECT r.id_ FROM Resources r, cte2 c WHERE r.folderId_ = c.id_)
SELECT count(*)
FROM Resources r
WHERE (r.folderId_ IN (SELECT * FROM cte1) OR r.folderId_ IN (SELECT * FROM cte2));

If I replace the two sub-selects in the last line with a UNION, it just takes a few seconds:

WITH cte1 (id_) AS (SELECT id_ FROM Resources where id_ = 11
                    UNION ALL
                    SELECT r.id_ FROM Resources r, cte1 c WHERE r.folderId_ = c.id_),
     cte2 (id_) AS (SELECT id_ FROM Resources where id_ = 808965
                    UNION ALL
                    SELECT r.id_ FROM Resources r, cte2 c WHERE r.folderId_ = c.id_)
SELECT count(*)
FROM Resources r
WHERE (r.folderId_ IN (SELECT * FROM cte1 UNION SELECT * FROM cte2));

While that could already be the solution, it's a bit hard to change in my project, because SQL is auto-generated by code from application queries, and at that point not so easy to change. Also, application queries could be much more complex and such a replacement might not even be possible. These are just simplified examples. Maybe there's some other way to speed things up?

Interestingly, the slow query works without any performance problems on other databases like MySQL 8, PostgreSQL 13, SQL Server 2016 (with small syntax changes for the databases). It's just Oracle which seems to have a problem here.

This is the query plan for the first query, i.e. the slow one:

------------------------------------------------------------------------------------------------------------
| Id  | Operation                                   | Name         | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                            |              |     1 |     5 |    54G  (1)|591:38:12 |
|   1 |  SORT AGGREGATE                             |              |     1 |     5 |            |          |
|*  2 |   FILTER                                    |              |       |       |            |          |
|   3 |    TABLE ACCESS FULL                        | RESOURCES    |  2410K|    11M|  9389   (1)| 00:00:01 |
|*  4 |    VIEW                                     |              |   239K|  3046K| 23128   (1)| 00:00:01 |
|   5 |     UNION ALL (RECURSIVE WITH) BREADTH FIRST|              |       |       |            |          |
|*  6 |      INDEX UNIQUE SCAN                      | PK_RESOURCES |     1 |     6 |     2   (0)| 00:00:01 |
|*  7 |      HASH JOIN                              |              |   239K|  5623K| 23126   (1)| 00:00:01 |
|   8 |       RECURSIVE WITH PUMP                   |              |       |       |            |          |
|   9 |       BUFFER SORT (REUSE)                   |              |       |       |            |          |
|  10 |        TABLE ACCESS FULL                    | RESOURCES    |  2410K|    25M|  9386   (1)| 00:00:01 |
|* 11 |    VIEW                                     |              |   239K|  3046K| 23128   (1)| 00:00:01 |
|  12 |     UNION ALL (RECURSIVE WITH) BREADTH FIRST|              |       |       |            |          |
|* 13 |      INDEX UNIQUE SCAN                      | PK_RESOURCES |     1 |     6 |     2   (0)| 00:00:01 |
|* 14 |      HASH JOIN                              |              |   239K|  5623K| 23126   (1)| 00:00:01 |
|  15 |       RECURSIVE WITH PUMP                   |              |       |       |            |          |
|  16 |       BUFFER SORT (REUSE)                   |              |       |       |            |          |
|  17 |        TABLE ACCESS FULL                    | RESOURCES    |  2410K|    25M|  9386   (1)| 00:00:01 |
------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

"   2 - filter( EXISTS (SELECT 0 FROM ""CTE1"" ""CTE1"" WHERE ""CTE1"".""ID_""=:B1) OR  EXISTS (SELECT 0 "
"              FROM ""CTE2"" ""CTE2"" WHERE ""CTE2"".""ID_""=:B2))"
"   4 - filter(""CTE1"".""ID_""=:B1)"
"   6 - access(""ID_""=11)"
"   7 - access(""R"".""FOLDERID_""=""C"".""ID_"")"
"  11 - filter(""CTE2"".""ID_""=:B1)"
"  13 - access(""ID_""=808965)"
"  14 - access(""R"".""FOLDERID_""=""C"".""ID_"")"

For comparison, the faster query using a UNION seems to use a better plan:

------------------------------------------------------------------------------------------------------------------------
| Id  | Operation                                      | Name          | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT                               |               |     1 |    18 |       | 55733   (1)| 00:00:03 |
|   1 |  SORT AGGREGATE                                |               |     1 |    18 |       |            |          |
|*  2 |   HASH JOIN                                    |               |  2806K|    48M|    11M| 55733   (1)| 00:00:03 |
|   3 |    VIEW                                        | VW_NSO_1      |   479K|  6092K|       | 50820   (1)| 00:00:02 |
|   4 |     SORT UNIQUE                                |               |   479K|  6092K|  9424K| 50820   (1)| 00:00:02 |
|   5 |      UNION-ALL                                 |               |       |       |       |            |          |
|   6 |       VIEW                                     |               |   239K|  3046K|       | 23128   (1)| 00:00:01 |
|   7 |        UNION ALL (RECURSIVE WITH) BREADTH FIRST|               |       |       |       |            |          |
|*  8 |         INDEX UNIQUE SCAN                      | PK_RESOURCES  |     1 |     6 |       |     2   (0)| 00:00:01 |
|*  9 |         HASH JOIN                              |               |   239K|  5623K|       | 23126   (1)| 00:00:01 |
|  10 |          RECURSIVE WITH PUMP                   |               |       |       |       |            |          |
|  11 |          BUFFER SORT (REUSE)                   |               |       |       |       |            |          |
|  12 |           TABLE ACCESS FULL                    | RESOURCES     |  2410K|    25M|       |  9386   (1)| 00:00:01 |
|  13 |       VIEW                                     |               |   239K|  3046K|       | 23128   (1)| 00:00:01 |
|  14 |        UNION ALL (RECURSIVE WITH) BREADTH FIRST|               |       |       |       |            |          |
|* 15 |         INDEX UNIQUE SCAN                      | PK_RESOURCES  |     1 |     6 |       |     2   (0)| 00:00:01 |
|* 16 |         HASH JOIN                              |               |   239K|  5623K|       | 23126   (1)| 00:00:01 |
|  17 |          RECURSIVE WITH PUMP                   |               |       |       |       |            |          |
|  18 |          BUFFER SORT (REUSE)                   |               |       |       |       |            |          |
|  19 |           TABLE ACCESS FULL                    | RESOURCES     |  2410K|    25M|       |  9386   (1)| 00:00:01 |
|  20 |    INDEX FAST FULL SCAN                        | FOLDERIDINDEX |  2410K|    11M|       |  2392   (1)| 00:00:01 |
------------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

"   2 - access(""R"".""FOLDERID_""=""ID_"")"
"   8 - access(""ID_""=11)"
"   9 - access(""R"".""FOLDERID_""=""C"".""ID_"")"
"  15 - access(""ID_""=808965)"
"  16 - access(""R"".""FOLDERID_""=""C"".""ID_"")"


问:
Regressions (OLS) on subsets of a dataset
I have the following dataset.

The interesting columns are Primary_sic_code (industry flag) and ABROA (abnormal ROA). My goal is to calculate, for each industry (i.e., each Primary_Sic_code), the regression ABNORMAL_t = b0 + b1 * DP * ABROA_{t-1} + b2 * DL * ABROA_{t-1}, where DP and DL are dummy variables (how can I use latex here?)

My solution is the following:

```<code>    betas = {}
i=0
for id in sym_entity_sector.PRIMARY_SIC_CODE:
    if i%10e4==0:
        print(len(sym_entity_sector)-i)
    i+=1
    X = df4[df4.PRIMARY_SIC_CODE==id].loc[:,["DP*ABROA", "DL*ABROA"]].shift(-1).fillna(0)
    Y = df4[df4.PRIMARY_SIC_CODE==id].loc[:,"ABROA"].fillna(0)
    # with sklearn
    try:
        regr = linear_model.LinearRegression()
        regr.fit(X, Y)
        beta2 = regr.coef_[1]
        betas[id] = beta2
    except ValueError:
        betas[id] = np.nan
</code>```

Problem? The dataset is huge and the loop is very slow. Is there a way of optimising this? Thanks!

Body:
I have the following dataset.

The interesting columns are Primary_sic_code (industry flag) and ABROA (abnormal ROA). My goal is to calculate, for each industry (i.e., each Primary_Sic_code), the regression ABNORMAL_t = b0 + b1 * DP * ABROA_{t-1} + b2 * DL * ABROA_{t-1}, where DP and DL are dummy variables (how can I use latex here?)

My solution is the following:

    betas = {}
i=0
for id in sym_entity_sector.PRIMARY_SIC_CODE:
    if i%10e4==0:
        print(len(sym_entity_sector)-i)
    i+=1
    X = df4[df4.PRIMARY_SIC_CODE==id].loc[:,["DP*ABROA", "DL*ABROA"]].shift(-1).fillna(0)
    Y = df4[df4.PRIMARY_SIC_CODE==id].loc[:,"ABROA"].fillna(0)
    # with sklearn
    try:
        regr = linear_model.LinearRegression()
        regr.fit(X, Y)
        beta2 = regr.coef_[1]
        betas[id] = beta2
    except ValueError:
        betas[id] = np.nan

Problem? The dataset is huge and the loop is very slow. Is there a way of optimising this? Thanks!


问:
Render all artists(several artists) from Spotify in reactjs?
How to render all Spotify artists in react using Spotify API. Here is how to render one artist from spotify:
fetch('https://api.spotify.com/v1/artists/1ZwdS5xdxEREPySFridCfh', authPlaylistParameters) How to get several artists according to this site: https://developer.spotify.com/documentation/web-api/reference/#/operations/get-an-artists-related-artists


问:
Flutter: I am getting errors after downgrading my Flutter version to 2.5.0
So I have decided to downgrade my Flutter version from 3.0.5 to 2.5.0 using git checkout 2.5.0, and have been getting some errors that I cannot fix. I want this project to run on 2.5.0. How can I solve those errors so I can run my project on version 2.5.0?

The errors:

```<code>../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/percent_indicator-4.2.1/lib/linear_percent_indicator.dart:162:5: Warning: The class 'WidgetsBinding' cannot be null.
Try replacing '?.' with '.'
    WidgetsBinding?.instance?.addPostFrameCallback((_) {
    ^^^^^^^^^^^^^^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:13:11: Error: Method not found: 'Error.throwWithStackTrace'.
    Error.throwWithStackTrace(exception, stackTrace);
          ^^^^^^^^^^^^^^^^^^^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:16:9: Error: Method not found: 'Error.throwWithStackTrace'.
  Error.throwWithStackTrace(
        ^^^^^^^^^^^^^^^^^^^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:11:7: Error: A non-null value must be returned since the return type 'Never' doesn't allow null.
Never convertPlatformException(Object exception, StackTrace stackTrace) {
      ^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:14:11: Error: Method not found: 'Error.throwWithStackTrace'.
    Error.throwWithStackTrace(exception, stackTrace);
          ^^^^^^^^^^^^^^^^^^^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:17:9: Error: Method not found: 'Error.throwWithStackTrace'.
  Error.throwWithStackTrace(
        ^^^^^^^^^^^^^^^^^^^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:12:7: Error: A non-null value must be returned since the return type 'Never' doesn't allow null.
Never convertPlatformException(Object exception, StackTrace stackTrace) {
      ^
</code>```

pubspec.yaml file:

```<code>environment:

sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cloud_firestore:
  cupertino_icons: null
  firebase_auth:
  firebase_core:
  firebase_messaging:
  flutter_google_places: null
  flutter_spinkit: ^5.1.0
  geocoder:
  geoflutterfire:
  geolocator:
  google_maps_flutter: null
  google_maps_webservice: null
  http: null
  location: ^4.4.0
  modal_bottom_sheet: ^2.0.1
  percent_indicator: ^4.2.1
  provider: null
  rxdart: any
  shared_preferences: ^2.0.15
  uuid: null
  url_launcher: ^6.0.5
  get_it: ^7.2.0
  plugin_platform_interface:
  geolocator_platform_interface:
  geocoding: ^2.0.4
  google_api_availability:
  google_api_headers: ^1.1.1
  mockito: ^5.2.0

</code>```

Body:
So I have decided to downgrade my Flutter version from 3.0.5 to 2.5.0 using git checkout 2.5.0, and have been getting some errors that I cannot fix. I want this project to run on 2.5.0. How can I solve those errors so I can run my project on version 2.5.0?

The errors:

../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/percent_indicator-4.2.1/lib/linear_percent_indicator.dart:162:5: Warning: The class 'WidgetsBinding' cannot be null.
Try replacing '?.' with '.'
    WidgetsBinding?.instance?.addPostFrameCallback((_) {
    ^^^^^^^^^^^^^^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:13:11: Error: Method not found: 'Error.throwWithStackTrace'.
    Error.throwWithStackTrace(exception, stackTrace);
          ^^^^^^^^^^^^^^^^^^^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:16:9: Error: Method not found: 'Error.throwWithStackTrace'.
  Error.throwWithStackTrace(
        ^^^^^^^^^^^^^^^^^^^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_messaging_platform_interface-3.2.0/lib/src/method_channel/utils/exception.dart:11:7: Error: A non-null value must be returned since the return type 'Never' doesn't allow null.
Never convertPlatformException(Object exception, StackTrace stackTrace) {
      ^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:14:11: Error: Method not found: 'Error.throwWithStackTrace'.
    Error.throwWithStackTrace(exception, stackTrace);
          ^^^^^^^^^^^^^^^^^^^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:17:9: Error: Method not found: 'Error.throwWithStackTrace'.
  Error.throwWithStackTrace(
        ^^^^^^^^^^^^^^^^^^^
../../../Downloads/flutter_windows_2.10.2-stable/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_auth_platform_interface-6.2.0/lib/src/method_channel/utils/exception.dart:12:7: Error: A non-null value must be returned since the return type 'Never' doesn't allow null.
Never convertPlatformException(Object exception, StackTrace stackTrace) {
      ^

pubspec.yaml file:

environment:

sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cloud_firestore:
  cupertino_icons: null
  firebase_auth:
  firebase_core:
  firebase_messaging:
  flutter_google_places: null
  flutter_spinkit: ^5.1.0
  geocoder:
  geoflutterfire:
  geolocator:
  google_maps_flutter: null
  google_maps_webservice: null
  http: null
  location: ^4.4.0
  modal_bottom_sheet: ^2.0.1
  percent_indicator: ^4.2.1
  provider: null
  rxdart: any
  shared_preferences: ^2.0.15
  uuid: null
  url_launcher: ^6.0.5
  get_it: ^7.2.0
  plugin_platform_interface:
  geolocator_platform_interface:
  geocoding: ^2.0.4
  google_api_availability:
  google_api_headers: ^1.1.1
  mockito: ^5.2.0


问:
Flutter resize container Programatically
i have a container where i want change it size programmatically depending on the offset from the scroll controller , i have tried this equation . it gives me a fine solution but it has some mistakes that would change the size randomly.

(12 - (widget.height / d))

```<code>other working function

 height = d.floor() < 5 ? widget.value : max(250, (height! - d) % 30);
      width = d.floor() < 5 ? widget.width : max(150, (width! - d) % 30);
</code>```

it works for some gesture events and none for other events.

is there a better solution to change it and get a smooth animation between two values like 400 and 150.

i was having an equation but i lost it .

Body:
i have a container where i want change it size programmatically depending on the offset from the scroll controller , i have tried this equation . it gives me a fine solution but it has some mistakes that would change the size randomly.

(12 - (widget.height / d))

other working function

 height = d.floor() < 5 ? widget.value : max(250, (height! - d) % 30);
      width = d.floor() < 5 ? widget.width : max(150, (width! - d) % 30);

it works for some gesture events and none for other events.

is there a better solution to change it and get a smooth animation between two values like 400 and 150.

i was having an equation but i lost it .


问:
How to Redirect Dynamic URLS in Wordpress
I have a WordPress website and I installed wordfence plugin which caused duplicate URLs in google, I deleted the plugin but those URLs are still there and working. so I want to redirect them to eliminate duplicate page issues. there are multiple URLs that need to be redirected.

how can I redirect those workforce URLs via htaccess? below are some examples

I want to redirect this

```<code>https://www.example.com/page/2?wordfence_lh=1&hid=10813D53CD849633351F7F5195D75319
</code>```

to this

```<code>https://www.example.com/page/2
</code>```

and

```<code>https://www.example.com/page/22?wordfence_lh=1&hid=10813D53CD849633351F7F5195D75319
</code>```

to

```<code>https://www.example.com/page/22
</code>```

there are multiple URLs but they all have ?wordfence_lh=1&hid=xxxxxxxxxxxxxxxxxxxxxx

I tried multiple solution found on internet but they didn't work

Body:
I have a WordPress website and I installed wordfence plugin which caused duplicate URLs in google, I deleted the plugin but those URLs are still there and working. so I want to redirect them to eliminate duplicate page issues. there are multiple URLs that need to be redirected.

how can I redirect those workforce URLs via htaccess? below are some examples

I want to redirect this

https://www.example.com/page/2?wordfence_lh=1&hid=10813D53CD849633351F7F5195D75319

to this

https://www.example.com/page/2

and

https://www.example.com/page/22?wordfence_lh=1&hid=10813D53CD849633351F7F5195D75319

to

https://www.example.com/page/22

there are multiple URLs but they all have ?wordfence_lh=1&hid=xxxxxxxxxxxxxxxxxxxxxx

I tried multiple solution found on internet but they didn't work


问:
ThreeJS TextureLoader is black in .NET blazor application
When using textureloader from three.js in a blazor application. when trying to get a picture on a cube, it just gets displayed in black. I have tried a lot of things including:

    new THREE.TextureLoader().load('https://images.pexels.com/photos/2422/sky-earth-galaxy-universe.jpg?auto=compress&cs=tinysrgb&dpr=1&w=500', function (texture) {
        var objGeometry = new THREE.SphereBufferGeometry(11, 11, 11);
        var objMaterial = new THREE.MeshPhongMaterial({
            map: texture,
            shading: THREE.FlatShading
        });

        moonMesh = new THREE.Mesh(objGeometry, objMaterial);
        scene.add(moonMesh);
    });
```
<p><img src="https://i.stack.imgur.com/WyAbH.png" alt="black sphere" />
Local images that are preloaded don't work, tried with and without callback. Tried another browser.
The console is empty, if I log the texture, it's always define.
Still the sphere is always displayed in black. Maybe a light is missing, although they don't get used in any example. The js is loaded from a blazor page using the following code:</p>
<pre class="lang-cs prettyprint-override"><code>    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        object[] args = { canvasId };
        await JSRuntime.InvokeVoidAsync("threeExample", args); // NOTE: call JavaScript function
    }
</code>```

And the scene and stuff load fine, I can use orbidcontrols, normal cubes with a color texture are visibe. Any ideas?

EDIT:
When using MeshBasicMaterial It works! So I guess I used the wrong type of material to use the texture.

Kind regards

Body:
When using textureloader from three.js in a blazor application. when trying to get a picture on a cube, it just gets displayed in black. I have tried a lot of things including:

    new THREE.TextureLoader().load('https://images.pexels.com/photos/2422/sky-earth-galaxy-universe.jpg?auto=compress&cs=tinysrgb&dpr=1&w=500', function (texture) {
        var objGeometry = new THREE.SphereBufferGeometry(11, 11, 11);
        var objMaterial = new THREE.MeshPhongMaterial({
            map: texture,
            shading: THREE.FlatShading
        });

        moonMesh = new THREE.Mesh(objGeometry, objMaterial);
        scene.add(moonMesh);
    });

Local images that are preloaded don't work, tried with and without callback. Tried another browser.
The console is empty, if I log the texture, it's always define.
Still the sphere is always displayed in black. Maybe a light is missing, although they don't get used in any example. The js is loaded from a blazor page using the following code:

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        object[] args = { canvasId };
        await JSRuntime.InvokeVoidAsync("threeExample", args); // NOTE: call JavaScript function
    }

And the scene and stuff load fine, I can use orbidcontrols, normal cubes with a color texture are visibe. Any ideas?

EDIT:
When using MeshBasicMaterial It works! So I guess I used the wrong type of material to use the texture.

Kind regards


问:
Make a function loop in js whenever user clicks on an element
I have an array of objects that I want to display in a template. I wrote the function below and its almost working except when I click on an li, the properties of the object remain the same and don't change if I click on a different li; this is the error that I get : // uncaught TypeError: Cannot read properties of null (reading 'content') at HTMLUListElement.

Here is the code I am using :

```<code>function afficherDetailsPokemon() {

  const listPokemons = document.getElementById('list-pokemons');

  listPokemons.addEventListener('click', event => {
    if (event.target.tagName === 'LI') {
      const pokemonId = event.target.dataset.pokemonId;
      const pokemon = pokemons.find(p => p.id === Number(pokemonId));

      if (pokemon) {
        // Clone the template
        const template = document.getElementById('template').content.cloneNode(true);

        // Set the values of the form elements to the properties of the Pokemon object
        template.querySelector('#nom_en').value = pokemon.name.english;
        template.querySelector('#nom_fr').value = pokemon.name.french;
        template.querySelector('#attaque').value = pokemon.base.Attack;
        template.querySelector('#defense').value = pokemon.base.Defense;

        // Create a new span element for each type and append it to the type_p element
        pokemon.type.forEach(type => {
          const span = document.createElement('span');
          span.textContent = type;
          template.querySelector('#type_p').appendChild(span);
        });

        // Replace the info div with the template
        const infoDiv = document.getElementById('info');
        infoDiv.parentNode.replaceChild(template, infoDiv);
      }
    }
  });
}
</code>```

I am pretty new to js and would appreciate your help.

When I click on an li, it does display the properties of the name I select first, but when I try a second time I get the error  // uncaught TypeError: Cannot read properties of null (reading 'content') at HTMLUListElement.

If it helps, this happens on the line where I clone the template.

Body:
I have an array of objects that I want to display in a template. I wrote the function below and its almost working except when I click on an li, the properties of the object remain the same and don't change if I click on a different li; this is the error that I get : // uncaught TypeError: Cannot read properties of null (reading 'content') at HTMLUListElement.

Here is the code I am using :

function afficherDetailsPokemon() {

  const listPokemons = document.getElementById('list-pokemons');

  listPokemons.addEventListener('click', event => {
    if (event.target.tagName === 'LI') {
      const pokemonId = event.target.dataset.pokemonId;
      const pokemon = pokemons.find(p => p.id === Number(pokemonId));

      if (pokemon) {
        // Clone the template
        const template = document.getElementById('template').content.cloneNode(true);

        // Set the values of the form elements to the properties of the Pokemon object
        template.querySelector('#nom_en').value = pokemon.name.english;
        template.querySelector('#nom_fr').value = pokemon.name.french;
        template.querySelector('#attaque').value = pokemon.base.Attack;
        template.querySelector('#defense').value = pokemon.base.Defense;

        // Create a new span element for each type and append it to the type_p element
        pokemon.type.forEach(type => {
          const span = document.createElement('span');
          span.textContent = type;
          template.querySelector('#type_p').appendChild(span);
        });

        // Replace the info div with the template
        const infoDiv = document.getElementById('info');
        infoDiv.parentNode.replaceChild(template, infoDiv);
      }
    }
  });
}

I am pretty new to js and would appreciate your help.

When I click on an li, it does display the properties of the name I select first, but when I try a second time I get the error  // uncaught TypeError: Cannot read properties of null (reading 'content') at HTMLUListElement.

If it helps, this happens on the line where I clone the template.


问:
I need to make a wave system for every player
I have a few islands, where players spawn, and I need to make a wave(round like in TD games) system for every player, and, when a player leaves and then joins the game, everything should start from a wave, where the player finished. I guess I know how to save data but I really don't know how to make a separate wave system for every player, I mean, where I have to save the value of the wave number. I'm a total noob in everything so I really don't understand how starter pack changes work and server storage also. So I would be rlly happy if anyone could help with it.

Also, I know that there are module scripts and they may help here, but I don't know how can I use it here.

I have a spawner of enemies and I need to change it for the wave system

```<code>local marine = rs.Enemies.OnePiece.Marine2:Clone()
local anim = rs.EnemiesScripts:FindFirstChild("Animation"):Clone()
local move = rs.EnemiesScripts:FindFirstChild("Movement"):Clone()
local hpBar = rs.BillboardUi.HpBar:Clone()
hpBar.Parent = marine
move.Parent = marine
anim.Parent = marine

marine.Parent = workspace.Islands:WaitForChild("1").Bodies:WaitForChild("enemies")
marine.HumanoidRootPart.CFrame = marine.Parent.Parent.Parent:FindFirstChild("enemySpawner").CFrame * CFrame.new(0,10,0) * CFrame.Angles(0,3.2,0)````
```

Body:
I have a few islands, where players spawn, and I need to make a wave(round like in TD games) system for every player, and, when a player leaves and then joins the game, everything should start from a wave, where the player finished. I guess I know how to save data but I really don't know how to make a separate wave system for every player, I mean, where I have to save the value of the wave number. I'm a total noob in everything so I really don't understand how starter pack changes work and server storage also. So I would be rlly happy if anyone could help with it.

Also, I know that there are module scripts and they may help here, but I don't know how can I use it here.

I have a spawner of enemies and I need to change it for the wave system

local marine = rs.Enemies.OnePiece.Marine2:Clone()
local anim = rs.EnemiesScripts:FindFirstChild("Animation"):Clone()
local move = rs.EnemiesScripts:FindFirstChild("Movement"):Clone()
local hpBar = rs.BillboardUi.HpBar:Clone()
hpBar.Parent = marine
move.Parent = marine
anim.Parent = marine

marine.Parent = workspace.Islands:WaitForChild("1").Bodies:WaitForChild("enemies")
marine.HumanoidRootPart.CFrame = marine.Parent.Parent.Parent:FindFirstChild("enemySpawner").CFrame * CFrame.new(0,10,0) * CFrame.Angles(0,3.2,0)````


问:
Web service call with a SHA-384 ECDSA certificate
For the project I am working on I have to convert the following legacy code to use a SHA-384 ECDSA certificate, .NET Framework 4.8 as target.

Is it possible natively in C# or do I need some help like BouncyCastle lib and how?

```<code>using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

[...]

// Certificate is in PKCS#12 format and contains a private key, certificate is password protected with the session id
var certificateBytes = Convert.FromBase64String(base64Certificate.ToString());
var certificate = new X509Certificate2();
certificate.Import(certificateBytes, sessionId, X509KeyStorageFlags.DefaultKeySet);

var result = (HttpWebRequest)WebRequest.Create( url );

result.Headers.Add( "x-jwt-authorization", $"Bearer {JSONWebToken}" );

result.ClientCertificates.Add( Certificate );

var response = (HttpWebResponse)request.GetResponse();
</code>```

I tried to find a solution/explanation online but didn't work (keep getting a "Not supported" for the PrivateKey property when trying to import the certificate, and a 403 Forbidden as server response).
Also if I want to keep backward compatibility, how do I distinguish if the Base64 string contains a X509 or a SHA one to support both?

Body:
For the project I am working on I have to convert the following legacy code to use a SHA-384 ECDSA certificate, .NET Framework 4.8 as target.

Is it possible natively in C# or do I need some help like BouncyCastle lib and how?

using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

[...]

// Certificate is in PKCS#12 format and contains a private key, certificate is password protected with the session id
var certificateBytes = Convert.FromBase64String(base64Certificate.ToString());
var certificate = new X509Certificate2();
certificate.Import(certificateBytes, sessionId, X509KeyStorageFlags.DefaultKeySet);

var result = (HttpWebRequest)WebRequest.Create( url );

result.Headers.Add( "x-jwt-authorization", $"Bearer {JSONWebToken}" );

result.ClientCertificates.Add( Certificate );

var response = (HttpWebResponse)request.GetResponse();

I tried to find a solution/explanation online but didn't work (keep getting a "Not supported" for the PrivateKey property when trying to import the certificate, and a 403 Forbidden as server response).
Also if I want to keep backward compatibility, how do I distinguish if the Base64 string contains a X509 or a SHA one to support both?


问:
How to run c program with coderunner in visual studio code?
I'm trying to run my c program in visual studio code without having to do gcc main.c /other c files/ && .\a.out everytime and just use coderunner, but everytime I try and use coderunner I get an unresolved reference error and I'm not sure how to fix that. Coderunner was working fine when it was just one file but now it's not. Any help is appreciated.


Title: Converting SAS Mixed model with spline effect to R

Body:
I am trying to run this SAS PROC MIXED model that has a random intercept and spline effect, however I now need to run the same model but in R, the code for the SAS model is:

proc hpmixed data = eplong  noclprint noitprint ;
    class ID;
    effect spl = spline(GA / details naturalcubic basis=tpf knotmethod=percentiles(3)); *
    model TCA = spl / s;
    random int spl / type=un subject = ID s;
run;

Below is the first 48 rows from the data that I am working with

structure(list(ID = structure(c("8366", "8366", "8366",
"8366", "8367", "8367", "8367", "8367", "8368", "8368", "8368",
"8368", "8369", "8369", "8369", "8369", "8370", "8370", "8370",
"8370", "8371", "8371", "8371", "8371", "8372", "8372", "8372",
"8372", "8374", "8374", "8374", "8374", "8393", "8393", "8393",
"8393", "8394", "8394", "8394", "8394", "8395", "8395", "8395",
"8395", "8396", "8396", "8396", "8396"), format.sas = "$"), TAC = c(79.7,
89.4, 82.6, 93, 79.7, 123.8, 100.4, 83.9, 96.3, 80, 81.8, 87.8,
34.4, 91.2, 80.6, 76.8, 84.8, 94.1, 81.9, 82.4, 49.4, 46.7, 54,
NA, 86.8, 76.6, 77.4, 79.2, 85.4, 93.1, 83.7, 84.3, 100.5, 82.3,
86.5, 81.1, 95.3, 96.5, 98.5, 94.8, 87, 87.8, 82.9, 86.1, NA,
35.8, 43.6, NA), GA = c(11.86, 19.14, 27.86, 38.71, 12.71, 17.86,
25.71, 35.57, 13.29, 23.29, 28.29, 37.29, 11, 17.86, 25.29, 35.14,
12, 15.86, 24.14, 35.86, 13.86, 22.86, 30, 39.43, 13.14, 19.14,
25.14, 34.14, 11.71, 20, 27, 36.29, 13.86, 24.71, 27.29, 35.71,
13.71, 25.57, 28, 36, 13.86, 18.43, 27.14, 35, 12.29, 21.29,
31.29, 38.29), visit = c(0, 1, 2, 4, 0, 1, 2, 4, 0, 1, 2, 4,
0, 1, 2, 4, 0, 1, 2, 4, 0, 1, 2, 4, 0, 1, 2, 4, 0, 1, 2, 4, 0,
1, 2, 4, 0, 1, 2, 4, 0, 1, 2, 4, 0, 1, 2, 4)), row.names = c(NA,
-48L), class = c("tbl_df", "tbl", "data.frame"))

I have tried using the lme4 package with the splines package

lmer(TAC ~ 1 + (bs(GA, df=3) | ID), data = post.df)

Which gives an error stating that there are more random effects (=48) than observations (45) which is odd to me as there are 48 rows, or does it require more IDs?

I have also tried

lmer(TAC ~ 1 + bs(GA) + (1 | ID), data = post.df)

which will run without errors but I am not sure if this is having a random spline effect as it is a random intercept for each ID.
Thanks.

EDIT
the SAS output for the random effects is:

effect      spl   estimate  Std Err DF t-value Pr>|t|
Intercept ID 8366 -6.7274 11.0589 1125 -0.61 0.5431
2 spl 1 ID 8366 -5.5371 12.3271 1125 -0.45 0.6534
3 spl 2 ID 8366 0.06818 0.1409 1125 0.48 0.6287
4 spl 3 ID 8366 -0.00007 0.001157 1125 -0.06 0.9544
5 Intercept ID 8367 -8.3470 11.4438 1125 -0.73 0.4659
6 spl 1 ID 8367 -23.3954 12.9557 1125 -1.81 0.0712
7 spl 2 ID 8367 0.3962 0.1527 1125 2.59 0.0096
8 spl 3 ID 8367 -0.00374 0.001314 1125 -2.85 0.0045
9 Intercept ID 8368 8.3946 11.7727 1125 0.71 0.4760
10 spl 1 ID 8368 10.9419 12.6986 1125 0.86 0.3891
11 spl 2 ID 8368 -0.1611 0.1445 1125 -1.11 0.2652
12 spl 3 ID 8368 0.001065 0.001188 1125 0.90 0.3705
13 Intercept ID 8369 -41.4729 10.6336 1125 -3.90 0.0001
14 spl 1 ID 8369 -42.0124 11.9225 1125 -3.52 0.0004
15 spl 2 ID 8369 0.5689 0.1344 1125 4.23 <.0001
16 spl 3 ID 8369 -0.00368 0.001243 1125 -2.96 0.0032
17 Intercept ID 8370 -0.6361 10.8564 1125 -0.06 0.9533
18 spl 1 ID 8370 -0.3350 12.4578 1125 -0.03 0.9786
19 spl 2 ID 8370 0.002890 0.1455 1125 0.02 0.9842
20 spl 3 ID 8370 -0.00024 0.001273 1125 -0.19 0.8501
21 Intercept ID 8371 -24.6320 12.4400 1125 -1.98 0.0479
22 spl 1 ID 8371 -2.3020 14.2970 1125 -0.16 0.8721
23 spl 2 ID 8371 -0.08930 0.1777 1125 -0.50 0.6153
24 spl 3 ID 8371 0.001215 0.001947 1125 0.62 0.5325
25 Intercept ID 8372 -0.2713 11.7812 1125 -0.02 0.9816
26 spl 1 ID 8372 4.9727 13.1356 1125 0.38 0.7051
27 spl 2 ID 8372 -0.09524 0.1543 1125 -0.62 0.5372
28 spl 3 ID 8372 0.000628 0.001358 1125 0.46 0.6441
29 Intercept ID 8374 -3.2900 11.0061 1125 -0.30 0.7651
30 spl 1 ID 8374 -4.7893 12.1409 1125 -0.39 0.6933
31 spl 2 ID 8374 0.07259 0.1368 1125 0.53 0.5959
32 spl 3 ID 8374 -0.00069 0.001200 1125 -0.58 0.5641
33 Intercept ID 8393 10.7260 12.0891 1125 0.89 0.3751
34 spl 1 ID 8393 9.5581 13.0069 1125 0.73 0.4626
35 spl 2 ID 8393 -0.1225 0.1497 1125 -0.82 0.4133
36 spl 3 ID 8393 0.000234 0.001277 1125 0.18 0.8546
37 Intercept ID 8394 2.2753 12.0000 1125 0.19 0.8497
38 spl 1  8394 -3.6781 13.0104 1125 -0.28 0.7775
39 spl 2 ID 8394 0.08162 0.1508 1125 0.54 0.5883
40 spl 3 ID 8394 -0.00053 0.001300 1125 -0.41 0.6810
41 Intercept ID 8395 -0.3884 12.2819 1125 -0.03 0.9748
42 spl 1 ID 8395 0.5401 14.0418 1125 0.04 0.9693
43 spl 2 ID 8395 -0.01228 0.1717 1125 -0.07 0.9430
44 spl 3 ID 8395 0.000087 0.001455 1125 0.06 0.9522
45 Intercept ID 8396 -16.6502 17.6935 1125 -0.94 0.3469
46 spl 1 ID 8396 10.1673 18.3253 1125 0.55 0.5791
47 spl 2 ID 8396 -0.2815 0.2314 1125 -1.22 0.2240
48 spl 3 ID 8396 0.001955 0.001850 1125 1.06 0.2910

and for the fixed effects:

effect      spl   estimate  Std Err    DF     t-value  Pr>|t|
Intercept           93.99      2.33   1125      40.18   <.0001
spl          1       0          .       .        .        .
spl          2      -0.052     0.0197  1125     -2.64   0.0083
spl          3       0.000304  0.00004  1125    0.62   .5362


问:
Inconsistence when converting time string to timestamp using python in Mac OS
I tried to convert some time strings to timestamp using Python (pkg time & datetime). Unexpected things happened when I converted time strings during 2AM period. It will reconsider timezone in the timestamp value for no reason.

Here are four timestrings around 2 AM, I convert each of them to timestamp using datetime and time, respectively.

```<code>import time
from datetime import datetime
timestrings = ["2008-10-26 02:55:26", "2008-10-26 02:55:31", "2008-10-26 02:59:59", "2008-10-26 03:00:02"]
for i in range(1, len(timestrings)):
    ts00 = datetime.timestamp(datetime.strptime(timestrings[i-1], "%Y-%m-%d %H:%M:%S"))
    ts10 = datetime.timestamp(datetime.strptime(timestrings[i], "%Y-%m-%d %H:%M:%S"))
    print(ts00-ts10)
    ts01 = time.mktime(time.strptime(timestrings[i-1], "%Y-%m-%d %H:%M:%S"))
    ts11 = time.mktime(time.strptime(timestrings[i], "%Y-%m-%d %H:%M:%S"))
    print(ts01-ts11)
</code>```

Considering the local timezone (mine is UTC+1), the values maybe different, but the differences between pairwise values should be consistent, which means the outputs should be

```<code>5.0
5.0
268.0
268.0
3.0
3.0
</code>```

However, my outputs was

```<code>5.0
3605.0
268.0
268.0
3603.0
3.0
</code>```

This inconsistence happened both in time and datetime, but in different time points when I ran it in IOS system. When I tested it in windows & linux system and everything is ok. I also tested a lot of records in string format, this inconsistence occured randomly and rarely. I can only find out a question mentioning "ambiguous 2AM cases"[https://stackoverflow.com/questions/13464009/calculate-tm-isdst-from-date-and-timezone]. Is it some weird curse for IOS system?

Body:
I tried to convert some time strings to timestamp using Python (pkg time & datetime). Unexpected things happened when I converted time strings during 2AM period. It will reconsider timezone in the timestamp value for no reason.

Here are four timestrings around 2 AM, I convert each of them to timestamp using datetime and time, respectively.

import time
from datetime import datetime
timestrings = ["2008-10-26 02:55:26", "2008-10-26 02:55:31", "2008-10-26 02:59:59", "2008-10-26 03:00:02"]
for i in range(1, len(timestrings)):
    ts00 = datetime.timestamp(datetime.strptime(timestrings[i-1], "%Y-%m-%d %H:%M:%S"))
    ts10 = datetime.timestamp(datetime.strptime(timestrings[i], "%Y-%m-%d %H:%M:%S"))
    print(ts00-ts10)
    ts01 = time.mktime(time.strptime(timestrings[i-1], "%Y-%m-%d %H:%M:%S"))
    ts11 = time.mktime(time.strptime(timestrings[i], "%Y-%m-%d %H:%M:%S"))
    print(ts01-ts11)

Considering the local timezone (mine is UTC+1), the values maybe different, but the differences between pairwise values should be consistent, which means the outputs should be

5.0
5.0
268.0
268.0
3.0
3.0

However, my outputs was

5.0
3605.0
268.0
268.0
3603.0
3.0

This inconsistence happened both in time and datetime, but in different time points when I ran it in IOS system. When I tested it in windows & linux system and everything is ok. I also tested a lot of records in string format, this inconsistence occured randomly and rarely. I can only find out a question mentioning "ambiguous 2AM cases"[https://stackoverflow.com/questions/13464009/calculate-tm-isdst-from-date-and-timezone]. Is it some weird curse for IOS system?


问:
Setting Pandas data into Qt's GUI (Python)
I have tried to use several QWidgets, but none gave me a working solution.

Here's an example that works when I run it:

```<code>import sys
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtCore import Qt
import pandas as pd

class TableModel(QtCore.QAbstractTableModel):

    def __init__(self, data):
        super(TableModel, self).__init__()
        self._data = data

    def data(self, index, role):
        if role == Qt.DisplayRole:
            value = self._data.iloc[index.row(), index.column()]
            return str(value)

    def rowCount(self, index):
        return self._data.shape[0]

    def columnCount(self, index):
        return self._data.shape[1]

    def headerData(self, section, orientation, role):
        # section is the index of the column/row.
        if role == Qt.DisplayRole:
            if orientation == Qt.Horizontal:
                return str(self._data.columns[section])

            if orientation == Qt.Vertical:
                return str(self._data.index[section])

class MainWindow(QtWidgets.QMainWindow):

    def __init__(self):
        super().__init__()

        self.table = QtWidgets.QTableView()

        data = pd.DataFrame([
          [1, 9, 2],
          [1, 0, -1],
          [3, 5, 2],
          [3, 3, 2],
          [5, 8, 9],
        ], columns = ['A', 'B', 'C'], index=['Row 1', 'Row 2', 'Row 3', 'Row 4', 'Row 5'])

        self.model = TableModel(data)
        self.table.setModel(self.model)

        self.setCentralWidget(self.table)

if __name__ == "__main__":
    app=QtWidgets.QApplication(sys.argv)
    window=MainWindow()
    window.show()
    app.exec_()
</code>```

But, when I try to use the TableModel class for myself, it fails:

```<code>from PandasModelClass import TableModel
model = TableModel(dataFrame)
self.tableView.setModel(model)
</code>```

It crashes during the .setModel() method. It says:

```<code>line 60, in showData
    self.tableView.setModel(model)
TypeError: setModel(self, QAbstractItemModel): argument 1 has unexpected type 'TableModel'
</code>```

The variable dataFrame is fine, self.tableView is defined in a .ui file:

```<code><?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>593</width>
    <height>664</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <layout class="QHBoxLayout" name="horizontalLayout">
    <item>
     <widget class="QGroupBox" name="fileGroupBox">
      <property name="title">
       <string>File selection</string>
      </property>
      <layout class="QHBoxLayout" name="horizontalLayout_3">
       <item>
        <layout class="QVBoxLayout" name="verticalLayout_2">
         <item>
          <layout class="QVBoxLayout" name="verticalLayout_3">
           <item>
            <widget class="QPushButton" name="browseButton">
             <property name="text">
              <string>Browse directories</string>
             </property>
            </widget>
           </item>
           <item>
            <layout class="QHBoxLayout" name="horizontalLayout_2">
             <item>
              <widget class="QListWidget" name="fileListWidget"/>
             </item>
             <item>
              <widget class="QListWidget" name="tableListWidget"/>
             </item>
            </layout>
           </item>
           <item>
            <spacer name="horizontalSpacer">
             <property name="orientation">
              <enum>Qt::Horizontal</enum>
             </property>
             <property name="sizeHint" stdset="0">
              <size>
               <width>40</width>
               <height>20</height>
              </size>
             </property>
            </spacer>
           </item>
           <item>
            <widget class="QRadioButton" name="radioButton">
             <property name="text">
              <string>RadioButton</string>
             </property>
            </widget>
           </item>
           <item>
            <widget class="QRadioButton" name="radioButton_2">
             <property name="text">
              <string>RadioButton</string>
             </property>
            </widget>
           </item>
          </layout>
         </item>
        </layout>
       </item>
       <item>
        <layout class="QVBoxLayout" name="verticalLayout_4">
         <item>
          <widget class="QTableView" name="tableView"/>
         </item>
         <item>
          <widget class="QPushButton" name="plotButton">
           <property name="text">
            <string>Plot</string>
           </property>
          </widget>
         </item>
        </layout>
       </item>
      </layout>
     </widget>
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>593</width>
     <height>21</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

</code>```

I don't see how is my implementation any different than the one from the example code, yet it crashes. Can anyone explain?

Body:
I have tried to use several QWidgets, but none gave me a working solution.

Here's an example that works when I run it:

import sys
from PySide6 import QtCore, QtGui, QtWidgets
from PySide6.QtCore import Qt
import pandas as pd

class TableModel(QtCore.QAbstractTableModel):

    def __init__(self, data):
        super(TableModel, self).__init__()
        self._data = data

    def data(self, index, role):
        if role == Qt.DisplayRole:
            value = self._data.iloc[index.row(), index.column()]
            return str(value)

    def rowCount(self, index):
        return self._data.shape[0]

    def columnCount(self, index):
        return self._data.shape[1]

    def headerData(self, section, orientation, role):
        # section is the index of the column/row.
        if role == Qt.DisplayRole:
            if orientation == Qt.Horizontal:
                return str(self._data.columns[section])

            if orientation == Qt.Vertical:
                return str(self._data.index[section])

class MainWindow(QtWidgets.QMainWindow):

    def __init__(self):
        super().__init__()

        self.table = QtWidgets.QTableView()

        data = pd.DataFrame([
          [1, 9, 2],
          [1, 0, -1],
          [3, 5, 2],
          [3, 3, 2],
          [5, 8, 9],
        ], columns = ['A', 'B', 'C'], index=['Row 1', 'Row 2', 'Row 3', 'Row 4', 'Row 5'])

        self.model = TableModel(data)
        self.table.setModel(self.model)

        self.setCentralWidget(self.table)

if __name__ == "__main__":
    app=QtWidgets.QApplication(sys.argv)
    window=MainWindow()
    window.show()
    app.exec_()

But, when I try to use the TableModel class for myself, it fails:

from PandasModelClass import TableModel
model = TableModel(dataFrame)
self.tableView.setModel(model)

It crashes during the .setModel() method. It says:

line 60, in showData
    self.tableView.setModel(model)
TypeError: setModel(self, QAbstractItemModel): argument 1 has unexpected type 'TableModel'

The variable dataFrame is fine, self.tableView is defined in a .ui file:

<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>MainWindow</class>
 <widget class="QMainWindow" name="MainWindow">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>593</width>
    <height>664</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>MainWindow</string>
  </property>
  <widget class="QWidget" name="centralwidget">
   <layout class="QHBoxLayout" name="horizontalLayout">
    <item>
     <widget class="QGroupBox" name="fileGroupBox">
      <property name="title">
       <string>File selection</string>
      </property>
      <layout class="QHBoxLayout" name="horizontalLayout_3">
       <item>
        <layout class="QVBoxLayout" name="verticalLayout_2">
         <item>
          <layout class="QVBoxLayout" name="verticalLayout_3">
           <item>
            <widget class="QPushButton" name="browseButton">
             <property name="text">
              <string>Browse directories</string>
             </property>
            </widget>
           </item>
           <item>
            <layout class="QHBoxLayout" name="horizontalLayout_2">
             <item>
              <widget class="QListWidget" name="fileListWidget"/>
             </item>
             <item>
              <widget class="QListWidget" name="tableListWidget"/>
             </item>
            </layout>
           </item>
           <item>
            <spacer name="horizontalSpacer">
             <property name="orientation">
              <enum>Qt::Horizontal</enum>
             </property>
             <property name="sizeHint" stdset="0">
              <size>
               <width>40</width>
               <height>20</height>
              </size>
             </property>
            </spacer>
           </item>
           <item>
            <widget class="QRadioButton" name="radioButton">
             <property name="text">
              <string>RadioButton</string>
             </property>
            </widget>
           </item>
           <item>
            <widget class="QRadioButton" name="radioButton_2">
             <property name="text">
              <string>RadioButton</string>
             </property>
            </widget>
           </item>
          </layout>
         </item>
        </layout>
       </item>
       <item>
        <layout class="QVBoxLayout" name="verticalLayout_4">
         <item>
          <widget class="QTableView" name="tableView"/>
         </item>
         <item>
          <widget class="QPushButton" name="plotButton">
           <property name="text">
            <string>Plot</string>
           </property>
          </widget>
         </item>
        </layout>
       </item>
      </layout>
     </widget>
    </item>
   </layout>
  </widget>
  <widget class="QMenuBar" name="menubar">
   <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
     <width>593</width>
     <height>21</height>
    </rect>
   </property>
  </widget>
  <widget class="QStatusBar" name="statusbar"/>
 </widget>
 <resources/>
 <connections/>
</ui>

I don't see how is my implementation any different than the one from the example code, yet it crashes. Can anyone explain?


问:
Google App Script won't allow saving edits to appsscript.json
I've written a Google App Script in a google sheet that requires access to gmail.
I want to limit that access to read only in gmail so that when I share this with others, to limit the scripts access and reduce the scary warning messages.

When I edit the appsscript.json file, the project never saves and doesn't throw a visible error.
I just see "Saving project..." until I refresh the page and lose the edits.

Below is my appscript.json I'm trying to save.

```<code>{
  "timeZone": "America/New_York",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8"

  "oauthScopes": [
    "https://www.googleapis.com/auth/gmail.readonly",
  ]

}
</code>```

I've also tried without the comma after ...readlonly"

```<code>{
  "timeZone": "America/New_York",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8"

  "oauthScopes": [
    "https://www.googleapis.com/auth/gmail.readonly"
  ]

}
</code>```

If that's not possible, is there a way to do something similar to

```<code>/**
 * @OnlyCurrentDoc
 */
</code>```

at the top of the code.gs to limit gmail to read only?

I followed the edit suggested here
(Won't allow me to save edits to appsscript.json) and it didn't make a difference.

I'm working in a corporate google instance and copied by code in my personal gmail and the first time I tried to save, briefly, saw a red error message about "Invalid changes (?) something..."  I tried to recreate the error message an was unable to.

Body:
I've written a Google App Script in a google sheet that requires access to gmail.
I want to limit that access to read only in gmail so that when I share this with others, to limit the scripts access and reduce the scary warning messages.

When I edit the appsscript.json file, the project never saves and doesn't throw a visible error.
I just see "Saving project..." until I refresh the page and lose the edits.

Below is my appscript.json I'm trying to save.

{
  "timeZone": "America/New_York",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8"

  "oauthScopes": [
    "https://www.googleapis.com/auth/gmail.readonly",
  ]

}

I've also tried without the comma after ...readlonly"

{
  "timeZone": "America/New_York",
  "dependencies": {
  },
  "exceptionLogging": "STACKDRIVER",
  "runtimeVersion": "V8"

  "oauthScopes": [
    "https://www.googleapis.com/auth/gmail.readonly"
  ]

}

If that's not possible, is there a way to do something similar to

/**
 * @OnlyCurrentDoc
 */

at the top of the code.gs to limit gmail to read only?

I followed the edit suggested here
(Won't allow me to save edits to appsscript.json) and it didn't make a difference.

I'm working in a corporate google instance and copied by code in my personal gmail and the first time I tried to save, briefly, saw a red error message about "Invalid changes (?) something..."  I tried to recreate the error message an was unable to.


问:
Firebase Auth Emulator - Golang: Project not found
Recently I started testing my go server, which uses firebase admin sdk, with firebase local emulator suite. It works perfectly with firestore, but with the authentication not so much.

I tried many different approaches, including firebase demo project, my own demo project, and a simple test project. Nothing of those did the job; I kept receive the same error message, project not found.

Firebase Emulator

I use the firebase admin SDK, and I followed the insructions in the
official firebase article.

To configure the emulator, I ran firebase init and firebase init emulators in terminal. Those resulted in the files in the next section. Then the emulator starts with the command firebase emulators:start, and I added --project test to set the project ID.

Simplified Code

firebase.json

```<code>{
  "emulators": {
    "auth": {
      "port": 9099
    }
  }
}
</code>```

Simple JSON which describes the port for auth service.

.firebaserc

```<code>{}
</code>```

This is empty because it doesn't have any project set, but I also tried adding projects here. Anyway, the project ID is set to "test" in both terminals, the one that runs the emulator, and the one that runs the golang app.

main.go

```<code>package main

import (
    "context"

    firebase "firebase.google.com/go"
    "firebase.google.com/go/auth"
)

func main() {
    ctx := context.Background()
    config := &firebase.Config{ProjectID: "test"}
    app, _ := firebase.NewApp(ctx, config)
    Auth, _ := app.Auth(ctx)

    params := (&auth.UserToCreate{}).
        DisplayName("Some Name").
        Email("example@gmail.com").
        Password("password")

    _, err := Auth.CreateUser(ctx, params)
    if err != nil {
        panic(err)
    }
}
</code>```

On the final line it panics with error status 400 Bad Request, and message PROJECT_NOT_FOUND. It looks like the admin SDK is looking at a public project with project ID "test", and I'm trying to emulate a local project.

Firestore emulator works, Auth does not.
I haven't found a single solution for this in golang. In node.js admin SDK the local auth emulator works, but I need the golang admin SDK.

How can I tell the go admin SDK for firebase auth emulator to look for a local project?

Body:
Recently I started testing my go server, which uses firebase admin sdk, with firebase local emulator suite. It works perfectly with firestore, but with the authentication not so much.

I tried many different approaches, including firebase demo project, my own demo project, and a simple test project. Nothing of those did the job; I kept receive the same error message, project not found.

Firebase Emulator

I use the firebase admin SDK, and I followed the insructions in the
official firebase article.

To configure the emulator, I ran firebase init and firebase init emulators in terminal. Those resulted in the files in the next section. Then the emulator starts with the command firebase emulators:start, and I added --project test to set the project ID.

Simplified Code

firebase.json

{
  "emulators": {
    "auth": {
      "port": 9099
    }
  }
}

Simple JSON which describes the port for auth service.

.firebaserc

{}

This is empty because it doesn't have any project set, but I also tried adding projects here. Anyway, the project ID is set to "test" in both terminals, the one that runs the emulator, and the one that runs the golang app.

main.go

package main

import (
    "context"

    firebase "firebase.google.com/go"
    "firebase.google.com/go/auth"
)

func main() {
    ctx := context.Background()
    config := &firebase.Config{ProjectID: "test"}
    app, _ := firebase.NewApp(ctx, config)
    Auth, _ := app.Auth(ctx)

    params := (&auth.UserToCreate{}).
        DisplayName("Some Name").
        Email("example@gmail.com").
        Password("password")

    _, err := Auth.CreateUser(ctx, params)
    if err != nil {
        panic(err)
    }
}

On the final line it panics with error status 400 Bad Request, and message PROJECT_NOT_FOUND. It looks like the admin SDK is looking at a public project with project ID "test", and I'm trying to emulate a local project.

Firestore emulator works, Auth does not.
I haven't found a single solution for this in golang. In node.js admin SDK the local auth emulator works, but I need the golang admin SDK.

How can I tell the go admin SDK for firebase auth emulator to look for a local project?


问:
How to read data in a tfrecords file format?
I have a file in tfrecords format containing images as a dataset. Can anyone suggest a way to get actual images from the tfrecords file.

The above image shows the file properties.


问:
Extract complete URL from a link
I am scrapping amanzon.co.in using scrapy-playwright. I am able to extract description, rating and price of desired item.  However for going to next page I want to extract href for Next Page button at the bottom of the page.

Thru scrapy-playwright python code I am able to extract href of next button as : href="/s?k=Soap+for+men&page=2"

When I extract URL using the browser, it appears like : https://www.amazon.in/s?k=soap+for+men&page=2&crid=1A43B14UY65X0&qid=1671472636&sprefix=soap+for+men%2Caps%2C262&ref=sr_pg_1

How do I get generate complete URL from the link including crid extracted thru code ?

Title: Extract complete URL from a link


问:
how to list dropdown from VIewBag with one to many relation on a partial page?

this is my model.

This is a partial page:

```<code>@model FinalForm.Models.Employee

<div class="container">
    @using (Html.BeginForm("SaveMarks", "Reg", FormMethod.Post))
    {
        <div class="form-group">
            <button type="button" id="Submit" class="btn btn-info col-md-2" onclick="SubmitM()">Add Marks</button>
            <div>
                <label class="form-label col-md-1">Qualification</label>

                @Html.DropDownList("Quallist", null, "Select", htmlAttributes: new { @class = "form-control search-select offerItem Item border border-dark", id = "Item", @Name = "QualificationList.Q_Name" })
                @Html.ValidationMessageFor(model => model.EMP_QUALIFICATION, "", new { @class = "text-danger" })
            </div>
            <div>
                <label class="form-label col-md-1">Marks</label>
                <input type="text" id="Marks" name="Marks" class="form-control col-md-1" placeholder="" />

            </div>

        </div>
    }
    <div class="panel-body">
        <table id="tbl_qlist" class="table table-bordered" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>Q_id</th>
                    <th>Q_Name</th>
                    <th>Marks</th>
                    <th>Del</th>
                </tr>
            </thead>
        </table>
    </div>
</div>
</code>```

this is contoller method:

```<code>  [ChildActionOnly]
        public ActionResult Equalify()
        {
            ViewBag.Quallist = new SelectList(new List<QualificationList>(), "Q_id", "Q_Name");
            return PartialView("Equalify");
        }
</code>```

```

System.InvalidOperationException: 'There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'Quallist'.'

Body:
this is my model.

This is a partial page:

@model FinalForm.Models.Employee

    @using (Html.BeginForm("SaveMarks", "Reg", FormMethod.Post))
    {

            <button type="button" id="Submit" class="btn btn-info col-md-2" onclick="SubmitM()">Add Marks</button>

                Qualification

                @Html.DropDownList("Quallist", null, "Select", htmlAttributes: new { @class = "form-control search-select offerItem Item border border-dark", id = "Item", @Name = "QualificationList.Q_Name" })
                @Html.ValidationMessageFor(model => model.EMP_QUALIFICATION, "", new { @class = "text-danger" })

                Marks
                <input type="text" id="Marks" name="Marks" class="form-control col-md-1" placeholder="" />

    }

                    Q_id
                    Q_Name
                    Marks
                    Del

this is contoller method:

  [ChildActionOnly]
        public ActionResult Equalify()
        {
            ViewBag.Quallist = new SelectList(new List<QualificationList>(), "Q_id", "Q_Name");
            return PartialView("Equalify");
        }

```

System.InvalidOperationException: 'There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'Quallist'.'


问:
Convert tweets.js to pandas dataframe , jupyter notebook
If you download an archive of all your tweets, Twitter sends you a zip file. This zip file, when unzipped contains several .js files.

One, is called tweets.js. tweets.js looks like a JSON file, but it's not exactly a JSON file. It has a strange key value that isn't a string, and the rest of the JSON file is in square brackets. The file also needs to be flattened

How can i, using python, in a jupyter notebook, convert the tweets.js file into a pandas dataframe?

(This is NOT using the API request. The file is loaded locally)

tried using pd.read_json() didn't work

tried removing the key, saving the file as tweets.json, save json.dumps('tweets.json') as a variable, use flatten_json to concert and save it as a new variable. it gives me an error message that it cannot read strings. Obviously because dumps returns a string


问:
Webpack compilation failed: in ./src/index.js 1:0 Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (1:0)
How do you get round this error in webpack?

Answers in similar threads are poorly explained.

I get this error when trying to run the code and have no idea how to solve it - what steps to take, where to look for error etc.

babel.config.js

```<code>    module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current',
        },
      },
    ],
  ],
};
</code>```

webpack.config.js

const path = require('path');

```<code>module.exports = {
    target: 'node',
    output: {
        path: path.join(__dirname, './.webpack'),
        filename: 'handler.js',
        libraryTarget: 'commonjs',
    }
  };
</code>```

package.json

```<code>   {
  "name": "rate-repository-api",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node -r esm ./src/index.js",
    "start:dev": "nodemon -r esm ./src/index.js",
    "bundle": "cpx src/**/* functions/bundle",
    "start:lambda": "netlify-lambda serve ./src/lambda",
    "lint": "eslint ./src",
    "test": "jest .",
    "migrate:make": "knex migrate:make",
    "migrate:latest": "knex migrate:latest",
    "build": "npm run migrate:latest",
    "seed:make": "knex seed:make",
    "seed:run": "knex seed:run"
  },
  "lint-staged": {
    "src/**/*.js": "eslint",
    "*.{js,json,css,md}": "prettier --write"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Kaltsoon/rate-repository-api.git"
  },
  "author": "Kalle Ilves",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/Kaltsoon/rate-repository-api/issues"
  },
  "homepage": "https://github.com/Kaltsoon/rate-repository-api#readme",
  "dependencies": {
    "@apollo/server": "^4.3.0",
    "@as-integrations/aws-lambda": "^1.1.0",
    "@koa/cors": "^3.0.0",
    "apollo-boost": "^0.4.9",
    "apollo-server": "^3.3.0",
    "apollo-server-core": "^3.3.0",
    "apollo-server-koa": "^3.3.0",
    "apollo-server-lambda": "^3.11.1",
    "axios": "^0.24.0",
    "bcrypt": "^5.0.0",
    "dataloader": "^2.0.0",
    "date-fns": "^2.9.0",
    "dotenv": "^11.0.0",
    "es6-error": "^4.1.1",
    "esm": "^3.2.25",
    "graceful-fs": "^4.2.10",
    "graphql": "^16.6.0",
    "jsonwebtoken": "^8.5.1",
    "knex": "^0.95.15",
    "koa": "^2.11.0",
    "koa-bodyparser": "^4.3.0",
    "koa-morgan": "^1.0.1",
    "koa-router": "^10.0.0",
    "lodash": "^4.17.15",
    "lru-cache": "^6.0.0",
    "netlify-lambda": "^2.0.15",
    "objection": "^3.0.1",
    "serverless-plugin-common-excludes": "^4.0.0",
    "serverless-plugin-include-dependencies": "^5.0.0",
    "sqlite3": "^5.0.2",
    "through2": "^4.0.2",
    "uuid": "^8.3.2",
    "watchman": "^1.0.0",
    "winston": "^3.8.2",
    "yup": "^0.32.8"
  },
  "devDependencies": {
    "@babel/core": "^7.16.7",
    "@babel/eslint-parser": "^7.16.5",
    "@babel/preset-env": "^7.8.4",
    "cpx": "^1.5.0",
    "eslint": "^8.6.0",
    "eslint-plugin-jest": "^25.3.4",
    "husky": "^4.2.3",
    "jest": "^27.4.7",
    "lint-staged": "^10.0.7",
    "nodemon": "^2.0.7",
    "prettier": "^2.2.1",
    "serverless-plugin-typescript": "^2.1.4",
    "serverless-webpack": "^5.11.0"
  },
  "type": "commonjs"
}
</code>```

index.js

```<code>import http from 'http';
var fs = require('graceful-fs')
import logger from './utils/logger';
import { API_PORT, APOLLO_PORT } from './config';
import createApolloServer from './apolloServer';
import app from './app';

var gracefulFs = require('graceful-fs')
gracefulFs.gracefulify(fs)

const startServer = async () => {
  const httpServer = http.createServer(app);

  const apolloServer = createApolloServer();

  await apolloServer.listen({ port: APOLLO_PORT });

  httpServer.on('request', app.callback());

  await new Promise((resolve) =>
    httpServer.listen({ port: API_PORT }, resolve),
  );

  logger.info(`Apollo Server ready at http://localhost:${APOLLO_PORT}`);
};

startServer();
</code>```

Body:
How do you get round this error in webpack?

Answers in similar threads are poorly explained.

I get this error when trying to run the code and have no idea how to solve it - what steps to take, where to look for error etc.

babel.config.js

    module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current',
        },
      },
    ],
  ],
};

webpack.config.js

const path = require('path');

module.exports = {
    target: 'node',
    output: {
        path: path.join(__dirname, './.webpack'),
        filename: 'handler.js',
        libraryTarget: 'commonjs',
    }
  };

package.json

   {
  "name": "rate-repository-api",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node -r esm ./src/index.js",
    "start:dev": "nodemon -r esm ./src/index.js",
    "bundle": "cpx src/**/* functions/bundle",
    "start:lambda": "netlify-lambda serve ./src/lambda",
    "lint": "eslint ./src",
    "test": "jest .",
    "migrate:make": "knex migrate:make",
    "migrate:latest": "knex migrate:latest",
    "build": "npm run migrate:latest",
    "seed:make": "knex seed:make",
    "seed:run": "knex seed:run"
  },
  "lint-staged": {
    "src/**/*.js": "eslint",
    "*.{js,json,css,md}": "prettier --write"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Kaltsoon/rate-repository-api.git"
  },
  "author": "Kalle Ilves",
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/Kaltsoon/rate-repository-api/issues"
  },
  "homepage": "https://github.com/Kaltsoon/rate-repository-api#readme",
  "dependencies": {
    "@apollo/server": "^4.3.0",
    "@as-integrations/aws-lambda": "^1.1.0",
    "@koa/cors": "^3.0.0",
    "apollo-boost": "^0.4.9",
    "apollo-server": "^3.3.0",
    "apollo-server-core": "^3.3.0",
    "apollo-server-koa": "^3.3.0",
    "apollo-server-lambda": "^3.11.1",
    "axios": "^0.24.0",
    "bcrypt": "^5.0.0",
    "dataloader": "^2.0.0",
    "date-fns": "^2.9.0",
    "dotenv": "^11.0.0",
    "es6-error": "^4.1.1",
    "esm": "^3.2.25",
    "graceful-fs": "^4.2.10",
    "graphql": "^16.6.0",
    "jsonwebtoken": "^8.5.1",
    "knex": "^0.95.15",
    "koa": "^2.11.0",
    "koa-bodyparser": "^4.3.0",
    "koa-morgan": "^1.0.1",
    "koa-router": "^10.0.0",
    "lodash": "^4.17.15",
    "lru-cache": "^6.0.0",
    "netlify-lambda": "^2.0.15",
    "objection": "^3.0.1",
    "serverless-plugin-common-excludes": "^4.0.0",
    "serverless-plugin-include-dependencies": "^5.0.0",
    "sqlite3": "^5.0.2",
    "through2": "^4.0.2",
    "uuid": "^8.3.2",
    "watchman": "^1.0.0",
    "winston": "^3.8.2",
    "yup": "^0.32.8"
  },
  "devDependencies": {
    "@babel/core": "^7.16.7",
    "@babel/eslint-parser": "^7.16.5",
    "@babel/preset-env": "^7.8.4",
    "cpx": "^1.5.0",
    "eslint": "^8.6.0",
    "eslint-plugin-jest": "^25.3.4",
    "husky": "^4.2.3",
    "jest": "^27.4.7",
    "lint-staged": "^10.0.7",
    "nodemon": "^2.0.7",
    "prettier": "^2.2.1",
    "serverless-plugin-typescript": "^2.1.4",
    "serverless-webpack": "^5.11.0"
  },
  "type": "commonjs"
}

index.js

import http from 'http';
var fs = require('graceful-fs')
import logger from './utils/logger';
import { API_PORT, APOLLO_PORT } from './config';
import createApolloServer from './apolloServer';
import app from './app';

var gracefulFs = require('graceful-fs')
gracefulFs.gracefulify(fs)

const startServer = async () => {
  const httpServer = http.createServer(app);

  const apolloServer = createApolloServer();

  await apolloServer.listen({ port: APOLLO_PORT });

  httpServer.on('request', app.callback());

  await new Promise((resolve) =>
    httpServer.listen({ port: API_PORT }, resolve),
  );

  logger.info(`Apollo Server ready at http://localhost:${APOLLO_PORT}`);
};

startServer();


问:
How to replace all HTML Tags in  wrapped into two html-comments using JavaScript?
In my HTML document's head is a section of tags (meta, link, ...) wrapped into two specific comments (specified by comments text-content). I want to take everything within those comments including the comments, delete it and then paste something else into it.

Example before:

```<code>    <head>
      <title>My Website</title>
      <meta property="test" content="some content" />
      ...
      <!-- This is the first comment -->
      <meta property="hi" content="something" />
      <link rel="canonical" href="http://website.com/test/">
      <!-- This is the second comment -->
      ...
      <link rel="dns-prefetch" href="//use.typekit.net">
    </head>
</code>```

Example after:

```<code>    <head>
      <title>My Website</title>
      <meta property="test" content="some content" />
      ...
      <!-- This is the first NEW comment -->
      <meta property="hi" content="something new" />
      <link rel="canonical" href="http://website.com/hi-im-new/">
      <meta property="hiagain" content="something completely new" />
      <!-- This is the second NEW comment -->
      ...
      <link rel="dns-prefetch" href="//use.typekit.net">
    </head>
</code>```

Title: How to replace all HTML Tags in <head> wrapped into two html-comments using JavaScript?

Body:
In my HTML document's head is a section of tags (meta, link, ...) wrapped into two specific comments (specified by comments text-content). I want to take everything within those comments including the comments, delete it and then paste something else into it.

Example before:

      <title>My Website</title>
      <meta property="test" content="some content" />
      ...

      <meta property="hi" content="something" />
      <link rel="canonical" href="http://website.com/test/">

      ...
      <link rel="dns-prefetch" href="//use.typekit.net">

Example after:

      <title>My Website</title>
      <meta property="test" content="some content" />
      ...

      <meta property="hi" content="something new" />
      <link rel="canonical" href="http://website.com/hi-im-new/">
      <meta property="hiagain" content="something completely new" />

      ...
      <link rel="dns-prefetch" href="//use.typekit.net">