问:
Reassigning C macro to its previous value?
Before including a header file, I want to change a macro, like this:

```<code>#define MY_MACRO STATE_0

...

#undef MY_MACRO
#define MY_MACRO STATE_1
#include "my_header.h"
</code>```

However, I'd like to change the macro back to its previous value after including the header, like this:

```<code>#define MY_MACRO STATE_0

...

#undef MY_MACRO
#define MY_MACRO STATE_1
#include "my_header.h"

#define MY_MACRO [previous value] // reassigns MY_MACRO to STATE_0
</code>```

MY_MACRO can store one of several (so far, just two) states.

I have two possible solutions, but none of them are as simple as I want. The first one is to create a temporary macro storing the previous value of MY_MACRO. However, using #define OLD_MACRO MY_MACRO does not work, since OLD_MACRO will be replaced by MY_MACRO, so it will change when MY_MACRO changes. What I instead did, was to define OLD_MACRO like this:

```<code>#if MY_MACRO == STATE_0
#define OLD_MACRO STATE_0
#elif MY_MACRO == STATE_1
#define OLD_MACRO STATE_1
#else
#error Invalid state
#endif
</code>```

After including the header, I can write this:

```<code>#if OLD_MACRO == STATE_0
#define MY_MACRO STATE_0
#elif OLD_MACRO == STATE_1
#define MY_MACRO STATE_1
#else
#error Invalid state
#endif

#undef OLD_MACRO
</code>```

This approach requires a lot of code, and if I ever need more possible states for MY_MACRO, I have to add code in two additional places. I could use a constant variable rather than a macro to represent OLD_MACRO and redefine MY_MACRO as that variable, but then MY_MACRO would have to be evaluated at run-time since it's an alias for a variable, which I don't want. Another possible better solution was to use another macro in my_header.h if it exists, but use the default macro if it doesn't. In that case, my_header.h would look something like this:

```<code>#ifndef MY_HEADER_MY_MACRO
#define MY_HEADER_MY_MACRO MY_MACRO
#endif
</code>```

In that case, I would use MY_HEADER_MY_MACRO rather than MY_MACRO in my_header.h, and the source file including my_header.h would look like this:

```<code>#define MY_MACRO STATE_0

...

#define MY_HEADER_MY_MACRO STATE_1
#include "my_header.h"
#undef MY_HEADER_MY_MACRO
</code>```

However, MY_MACRO is used in a lot of different files, and I think it's a little weird and inconsistent to use another macro in one specific file because of how it's included somewhere else. Is there a better way?

Body:
Before including a header file, I want to change a macro, like this:

#define MY_MACRO STATE_0

...

#undef MY_MACRO
#define MY_MACRO STATE_1
#include "my_header.h"

However, I'd like to change the macro back to its previous value after including the header, like this:

#define MY_MACRO STATE_0

...

#undef MY_MACRO
#define MY_MACRO STATE_1
#include "my_header.h"

#define MY_MACRO [previous value] // reassigns MY_MACRO to STATE_0

MY_MACRO can store one of several (so far, just two) states.

I have two possible solutions, but none of them are as simple as I want. The first one is to create a temporary macro storing the previous value of MY_MACRO. However, using #define OLD_MACRO MY_MACRO does not work, since OLD_MACRO will be replaced by MY_MACRO, so it will change when MY_MACRO changes. What I instead did, was to define OLD_MACRO like this:

#if MY_MACRO == STATE_0
#define OLD_MACRO STATE_0
#elif MY_MACRO == STATE_1
#define OLD_MACRO STATE_1
#else
#error Invalid state
#endif

After including the header, I can write this:

#if OLD_MACRO == STATE_0
#define MY_MACRO STATE_0
#elif OLD_MACRO == STATE_1
#define MY_MACRO STATE_1
#else
#error Invalid state
#endif

#undef OLD_MACRO

This approach requires a lot of code, and if I ever need more possible states for MY_MACRO, I have to add code in two additional places. I could use a constant variable rather than a macro to represent OLD_MACRO and redefine MY_MACRO as that variable, but then MY_MACRO would have to be evaluated at run-time since it's an alias for a variable, which I don't want. Another possible better solution was to use another macro in my_header.h if it exists, but use the default macro if it doesn't. In that case, my_header.h would look something like this:

#ifndef MY_HEADER_MY_MACRO
#define MY_HEADER_MY_MACRO MY_MACRO
#endif

In that case, I would use MY_HEADER_MY_MACRO rather than MY_MACRO in my_header.h, and the source file including my_header.h would look like this:

#define MY_MACRO STATE_0

...

#define MY_HEADER_MY_MACRO STATE_1
#include "my_header.h"
#undef MY_HEADER_MY_MACRO

However, MY_MACRO is used in a lot of different files, and I think it's a little weird and inconsistent to use another macro in one specific file because of how it's included somewhere else. Is there a better way?


来源: stackexchange

问:
How to find the version of emulator (not the Android version)
Is there any command to find the version of emulator?

For now, I can only see it in the SDK tools.

ContentLicense: CC BY-SA 4.0


问:
Horizontal Progress Bar - How to add label inside indicator?
I'm using the material library's LinearProgressIndicator for a horizontal progress bar.

How would I add a label inside the indicator of the progressbar indicator?

```<code><com.google.android.material.progressindicator.LinearProgressIndicator
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:max="100"
        android:progress="65"
        app:trackColor="@color/background_color"
        app:trackThickness="16dp"
        app:indicatorColor="@color/black"/>
</code>```

Body:
I'm using the material library's LinearProgressIndicator for a horizontal progress bar.

How would I add a label inside the indicator of the progressbar indicator?

<com.google.android.material.progressindicator.LinearProgressIndicator
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:max="100"
        android:progress="65"
        app:trackColor="@color/background_color"
        app:trackThickness="16dp"
        app:indicatorColor="@color/black"/>


问:
rollup-plugin-esbuild resolve .ts file failed
There are a loading module in my monorepo workspace, and it has a loding.ts file.

So i import it like this:

```<code>import 'loading/loading'
</code>```

But when i use rollup-plugin-esbuild, rollup can't resolve loading/loading, when i change the import to import 'loading/loading.ts', rollup-plugin-esbuild works, but type check failed, because typescript don't allow to import **.ts.

When i migrate to @rollup/plugin-typescript, whether load loading/loading or loading/loading.ts can work.

Here's my rollup config:

```<code>export default defineConfig({
    input: packages,
    output: {
        dir: 'dist',
        chunkFileNames: 'chunk/[hash].js',
        compact: true
    },
    plugins: [
        litcssPlugin,
        MinifyHTML.default(),
        typescript(),
        resolve(),
        filesize()
    ]
});
</code>```

I want to make rollup-plugin-esbuild can import 'loading/loading'

Body:
There are a loading module in my monorepo workspace, and it has a loding.ts file.

So i import it like this:

import 'loading/loading'

But when i use rollup-plugin-esbuild, rollup can't resolve loading/loading, when i change the import to import 'loading/loading.ts', rollup-plugin-esbuild works, but type check failed, because typescript don't allow to import **.ts.

When i migrate to @rollup/plugin-typescript, whether load loading/loading or loading/loading.ts can work.

Here's my rollup config:

export default defineConfig({
    input: packages,
    output: {
        dir: 'dist',
        chunkFileNames: 'chunk/[hash].js',
        compact: true
    },
    plugins: [
        litcssPlugin,
        MinifyHTML.default(),
        typescript(),
        resolve(),
        filesize()
    ]
});

I want to make rollup-plugin-esbuild can import 'loading/loading'


问:
On Jenkins, How can I make 'BUILD_ID=dontKillMe' work
I using java, springboot, maven
and Jenkins on AWS EC2 Linux2

For Build.
At 'Build Step',
using invoke top-level Maven targets,
I typed clean package -D maven.test.skip=true.

And then I added Post Build Task
'BUILD SUCCESS' in 'Log text'
then I typed

```<code>#!/bin/bash
fuser -n tcp -k 8080
BUILD_ID=dontKillMe java -jar target/back-0.0.1-SNAPSHOT.jar &
</code>```

in 'script'

And then I click a 'Build now'

they run, but they end up with this log

```<code>2022-12-10 17:28:05.701  INFO 13132 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
Process leaked file descriptors. See https://www.jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors for more information
POST BUILD TASK : SUCCESS
END OF POST BUILD TASK : 0
Finished: SUCCESS
</code>```

But I am not using the "pipeline". Just "Freestyle".
So I think "BUILD_ID" is correct.

But I think it didn't work.

What should I do.
What am I missing?

I had typed 'BUILD_ID' at Execute Shell.
and I had used 'String Parameter'
and I had put -Dhudson.util.ProcessTree.disable=true between scripts.

Body:
I using java, springboot, maven
and Jenkins on AWS EC2 Linux2

For Build.
At 'Build Step',
using invoke top-level Maven targets,
I typed clean package -D maven.test.skip=true.

And then I added Post Build Task
'BUILD SUCCESS' in 'Log text'
then I typed

#!/bin/bash
fuser -n tcp -k 8080
BUILD_ID=dontKillMe java -jar target/back-0.0.1-SNAPSHOT.jar &

in 'script'

And then I click a 'Build now'

they run, but they end up with this log

2022-12-10 17:28:05.701  INFO 13132 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Starting...
Process leaked file descriptors. See https://www.jenkins.io/redirect/troubleshooting/process-leaked-file-descriptors for more information
POST BUILD TASK : SUCCESS
END OF POST BUILD TASK : 0
Finished: SUCCESS

But I am not using the "pipeline". Just "Freestyle".
So I think "BUILD_ID" is correct.

But I think it didn't work.

What should I do.
What am I missing?

I had typed 'BUILD_ID' at Execute Shell.
and I had used 'String Parameter'
and I had put -Dhudson.util.ProcessTree.disable=true between scripts.


问:
How can I improve the response time of this query in Oracle
this query takes 24 seconds and returns 1891 results:

```<code>SELECT p.STATE, p.REFNUM, p.CODE, p.TYPE, i.STATE, pj.NAME, pj.DOCUMENT
        TABLE p
        inner join TABLE2 i on  i.REFNUM = p.REFNUM
        inner join TABLE3 pj on pj.NUMBER = i.NUMBER and p.OFIC_ID = pj.OFIC_ID and p.PUB_ID  = pj.PUB_ID
        inner join OFICE o on t.OFIC_ID = p.OFIC_ID and o.PUB_ID = p.PUB_ID
        inner join GROUP glad on glad.GROUP_CODE=p.GROUP_CODE
    WHERE glad.GROUP_TYPE ='3' AND i.STATE = '1'
        AND p.PUB_ID IN ('05','11','12','09','08','13','04','02','01','06','10','03','07','14')
        AND pj.NAME LIKE 'BANK%'
    ORDER BY o.NAME,p.ID;
</code>```

I have these indexes:

```<code>    CREATE INDEX IND_TABLE1_REFNUM_ZONE ON TABLE1 (PUB_ID, OFIC_ID, REFNUM, ZONE_ID)
    CREATE INDEX IND_TABLE1_REFNUMPUB ON TABLE1 (REFNUM, PUB_ID, OFIC_ID, GROUP_CODE );
    CREATE INDEX IND_TABLE1_GROUP ON TABLE1 (PUB_ID, GROUP_CODE, REFNUM, OFIC_ID)
    CREATE INDEX IND_TABLE2_REF ON TABLE2 (REFNUM, NUMBER, STATE);
    CREATE INDEX IND_TABLE2_QUERY ON TABLE2 (NUMBER, TYPE, STATE, REFNUM, NUM, CODE);
    CREATE INDEX IND_TABLE2_REFNUM ON TABLE2 (REFNUM)
    CREATE INDEX IND_TABLE2_NUMBER ON TABLE2 (NUMBER)
    CREATE INDEX IND_TABLE3_NUM ON TABLE3 (NUMBER, PUB_ID, OFIC_ID, NAME );
    CREATE INDEX IND_TABLE3_NAME ON TABLE3 ( NAME );
    CREATE INDEX IND_GROUP_COD ON GROUP (GROUP_CODE, GROUP_TYPE)
</code>```

I made the following queries to see how many records are in each table:

```<code>    SELECT count(*) FROM TABLE1  --> 18298458 results
    SELECT count(*) FROM TABLE2 --> 60627924 results
    SELECT count(*) FROM TABLE3 --> 18425913 results
    SELECT count(*) FROM OFICE --> 65 results
    SELECT count(*) FROM TABLE1 p INNER JOIN GROUP glad on glad.GROUP_CODE=p.GROUP_CODE where glad.GROUP_TYPE ='3' AND p.PUB_ID IN ('05','11','12','09','08','13','04','02','01','06','10','03','07','14') --> 1314077 results
    SELECT count(*) FROM TABLE1 p INNER JOIN GROUP glad on glad.GROUP_CODE=p.GROUP_CODE where glad.GROUP_TYPE ='3' AND p.PUB_ID IN ('05')  --> 53754 results
    SELECT count(*) FROM TABLE3 WHERE NAME LIKE 'BANK%' --> 1922081 results
</code>```

this is the plan generated by oracle:

```<code>    -----------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                | Name                  | Rows  | Bytes | Cost  | Pstart| Pstop |
    -----------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                         |                       |   291K|    38M|   384K|       |       |
    |   1 |  SORT ORDER BY                           |                       |   291K|    38M|   384K|       |       |
    |   2 |   HASH JOIN                              |                       |   291K|    38M|   375K|       |       |
    |   3 |    TABLE ACCESS FULL                     | OFICE                 |    64 |   960 |     3 |       |       |
    |   4 |    HASH JOIN                             |                       |   291K|    34M|   375K|       |       |
    |   5 |     INDEX SKIP SCAN                      | IND_GROUP_COD         |    47 |   329 |     1 |       |       |
    |   6 |     HASH JOIN                            |                       |   452K|    50M|   375K|       |       |
    |   7 |      PART JOIN FILTER CREATE             | :BF0000               |   452K|    50M|   375K|       |       |
    |   8 |       NESTED LOOPS                       |                       |   452K|    50M|   375K|       |       |
    |   9 |        NESTED LOOPS                      |                       |       |       |       |       |       |
    |  10 |         STATISTICS COLLECTOR             |                       |       |       |       |       |       |
    |  11 |          HASH JOIN                       |                       |  2100K|   166M|   252K|       |       |
    |  12 |           NESTED LOOPS                   |                       |  2100K|   166M|   252K|       |       |
    |  13 |            STATISTICS COLLECTOR          |                       |       |       |       |       |       |
    |  14 |             PARTITION RANGE ALL          |                       |  1681K|    89M| 82582 |     1 |    19 |
    |  15 |              PARTITION HASH ALL          |                       |  1681K|    89M| 82582 |     1 |    32 |
    |  16 |               TABLE ACCESS FULL          | TABLE3                |  1681K|    89M| 82582 |     1 |   608 |
    |  17 |            INDEX RANGE SCAN              | IND_TABLE2_QUERY      |     1 |    27 |   103K|       |       |
    |  18 |           INDEX FAST FULL SCAN           | IND_TABLE2_QUERY      |    32M|   845M|   103K|       |       |
    |  19 |         INDEX RANGE SCAN                 | IND_TABLE1_REFNUM_ZONE|       |       |       |       |       |
    |  20 |        TABLE ACCESS BY GLOBAL INDEX ROWID| TABLE1                |     1 |    35 | 70380 | ROWID | ROWID |
    |  21 |      PARTITION RANGE ALL                 |                       |    19M|   650M| 70380 |     1 |    19 |
    |  22 |       PARTITION HASH JOIN-FILTER         |                       |    19M|   650M| 70380 |:BF0000|:BF0000|
    |  23 |        TABLE ACCESS FULL                 | TABLE1                |    19M|   650M| 70380 |     1 |   608 |
    -----------------------------------------------------------------------------------------------------------------
</code>```

I think it takes time because this one is using TABLE ACCESS FULL for TABLE1 and TABLE3

if I perform the query filtering only PUB_ID='05' instead of all the numbers in the above query, the query returns 181 results and takes 8 seconds and in that case oracle generates this plan:

```<code>    --------------------------------------------------------------------------------------------------------------
    | Id  | Operation                              | Name                | Rows  | Bytes | Cost  | Pstart| Pstop |
    --------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                       |                     |   797 |   108K|   312K|       |       |
    |   1 |  SORT ORDER BY                         |                     |   797 |   108K|   312K|       |       |
    |   2 |   NESTED LOOPS                         |                     |   797 |   108K|   312K|       |       |
    |   3 |    HASH JOIN                           |                     |  1238 |   160K|   312K|       |       |
    |   4 |     TABLE ACCESS BY INDEX ROWID BATCHED| OFICE               |     3 |    45 |     2 |       |       |
    |   5 |      INDEX RANGE SCAN                  | SYS_C0034405        |     3 |       |     1 |       |       |
    |   6 |     HASH JOIN                          |                     |  2091 |   240K|   312K|       |       |
    |   7 |      PART JOIN FILTER CREATE           | :BF0000             | 66316 |  5375K|   241K|       |       |
    |   8 |       NESTED LOOPS                     |                     | 66316 |  5375K|   241K|       |       |
    |   9 |        PARTITION RANGE ALL             |                     | 53085 |  2903K| 82490 |     1 |    19 |
    |  10 |         PARTITION HASH ALL             |                     | 53085 |  2903K| 82490 |     1 |    32 |
    |  11 |          TABLE ACCESS FULL             | TABLE3              | 53085 |  2903K| 82490 |     1 |   608 |
    |  12 |        INDEX RANGE SCAN                | IND_TABLE2_QUERY    |     1 |    27 |     3 |       |       |
    |  13 |      PARTITION RANGE ALL               |                     |   762K|    25M| 68657 |     1 |    19 |
    |  14 |       PARTITION HASH JOIN-FILTER       |                     |   762K|    25M| 68657 |:BF0000|:BF0000|
    |  15 |        TABLE ACCESS FULL               | TABLE1              |   762K|    25M| 68657 |     1 |   608 |
    |  16 |    INDEX RANGE SCAN                    | IND_GROUP_COD       |     1 |     7 |     0 |       |       |
    --------------------------------------------------------------------------------------------------------------
</code>```

SYS_C0034405 is the primary key of OFFICE which contains these fields: (PUB_ID, REG_ID)

if in addition to filtering only PUB_ID='05' I remove the "order by", the query takes only 3.5 seconds but I definitely have to return the ordered data and I would prefer to be able to filter several PUB_IDs

I thought the query could be improved if I removed the "inner join" from GROUP and changed the filter "glad.GROUP_TYPE ='3'" to "p.GROUP_CODE in ('01','07','10','21 ')" (these are all type 3 codes), because now it should use the IND_TABLE1_GROUP index but instead of improving, it gets worse, it takes 13 seconds even filtering only PUB_ID='05'; This is the plan that oracle generates:

```<code>    ------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                          | Name                    | Rows  | Bytes | Cost  | Pstart| Pstop |
    ------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                                   |                         |    47 |  6251 |   172K|       |       |
    |   1 |  SORT ORDER BY                                     |                         |    47 |  6251 |   172K|       |       |
    |   2 |   HASH JOIN                                        |                         |    47 |  6251 |   172K|       |       |
    |   3 |    PARTITION RANGE ALL                             |                         | 47786 |  2613K| 82490 |     1 |    19 |
    |   4 |     PARTITION HASH ALL                             |                         | 47786 |  2613K| 82490 |     1 |    32 |
    |   5 |      TABLE ACCESS FULL                             | TABLE3                  | 47786 |  2613K| 82490 |     1 |   608 |
    |   6 |    HASH JOIN                                       |                         | 41945 |  3154K| 89633 |       |       |
    |   7 |     NESTED LOOPS                                   |                         | 41945 |  3154K| 89633 |       |       |
    |   8 |      NESTED LOOPS                                  |                         | 75740 |  3154K| 89633 |       |       |
    |   9 |       STATISTICS COLLECTOR                         |                         |       |       |       |       |       |
    |  10 |        NESTED LOOPS                                |                         | 18935 |   924K| 15985 |       |       |
    |  11 |         TABLE ACCESS BY INDEX ROWID BATCHED        | OFICE                   |     3 |    45 |     2 |       |       |
    |  12 |          INDEX RANGE SCAN                          | SYS_C0034405            |     3 |       |     1 |       |       |
    |  13 |         INLIST ITERATOR                            |                         |       |       |       |       |       |
    |  14 |          TABLE ACCESS BY GLOBAL INDEX ROWID BATCHED| TABLE1                  |  6312 |   215K|  7039 | ROWID | ROWID |
    |  15 |           INDEX RANGE SCAN                         | IND_TABLE1_GROUP         |  6828 |       |   284 |       |       |
    |  16 |       INDEX RANGE SCAN                             | IND_TABLE2_REFNUM       |     4 |       |     2 |       |       |
    |  17 |      TABLE ACCESS BY INDEX ROWID                   | TABLE2                  |     2 |    54 |     4 |       |       |
    |  18 |     INDEX FAST FULL SCAN                           | IND_TABLE2_QUERY        |     2 |    54 |     2 |       |       |
    ------------------------------------------------------------------------------------------------------------------------------
</code>```

And if I put all the PUB_IDs, Oracle generates this plan (it doesn't even use the IND_TABLE1_GROUP index anymore):

```<code>    -------------------------------------------------------------------------------------------------
    | Id  | Operation                  | Name               | Rows  | Bytes | Cost  | Pstart| Pstop |
    -------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT           |                    | 35661 |  4631K|   345K|       |       |
    |   1 |  SORT ORDER BY             |                    | 35661 |  4631K|   345K|       |       |
    |   2 |   HASH JOIN                |                    | 35661 |  4631K|   344K|       |       |
    |   3 |    TABLE ACCESS FULL       | OFICE              |    64 |   960 |     3 |       |       |
    |   4 |    HASH JOIN               |                    | 35661 |  4109K|   344K|       |       |
    |   5 |     PARTITION RANGE ALL    |                    |  1360K|    45M| 79580 |     1 |    19 |
    |   6 |      PARTITION HASH ALL    |                    |  1360K|    45M| 79580 |     1 |    32 |
    |   7 |       TABLE ACCESS FULL    | TABLE1             |  1360K|    45M| 79580 |     1 |   608 |
    |   8 |     HASH JOIN              |                    |  2100K|   166M|   252K|       |       |
    |   9 |      NESTED LOOPS          |                    |  2100K|   166M|   252K|       |       |
    |  10 |       STATISTICS COLLECTOR |                    |       |       |       |       |       |
    |  11 |        PARTITION RANGE ALL |                    |  1681K|    89M| 82582 |     1 |    19 |
    |  12 |         PARTITION HASH ALL |                    |  1681K|    89M| 82582 |     1 |    32 |
    |  13 |          TABLE ACCESS FULL | TABLE3             |  1681K|    89M| 82582 |     1 |   608 |
    |  14 |       INDEX RANGE SCAN     | IND_TABLE2_QUERY   |     1 |    27 |   103K|       |       |
    |  15 |      INDEX FAST FULL SCAN  | IND_TABLE2_QUERY   |    32M|   845M|   103K|       |       |
    -------------------------------------------------------------------------------------------------
</code>```

Body:
this query takes 24 seconds and returns 1891 results:

SELECT p.STATE, p.REFNUM, p.CODE, p.TYPE, i.STATE, pj.NAME, pj.DOCUMENT
        TABLE p
        inner join TABLE2 i on  i.REFNUM = p.REFNUM
        inner join TABLE3 pj on pj.NUMBER = i.NUMBER and p.OFIC_ID = pj.OFIC_ID and p.PUB_ID  = pj.PUB_ID
        inner join OFICE o on t.OFIC_ID = p.OFIC_ID and o.PUB_ID = p.PUB_ID
        inner join GROUP glad on glad.GROUP_CODE=p.GROUP_CODE
    WHERE glad.GROUP_TYPE ='3' AND i.STATE = '1'
        AND p.PUB_ID IN ('05','11','12','09','08','13','04','02','01','06','10','03','07','14')
        AND pj.NAME LIKE 'BANK%'
    ORDER BY o.NAME,p.ID;

I have these indexes:

    CREATE INDEX IND_TABLE1_REFNUM_ZONE ON TABLE1 (PUB_ID, OFIC_ID, REFNUM, ZONE_ID)
    CREATE INDEX IND_TABLE1_REFNUMPUB ON TABLE1 (REFNUM, PUB_ID, OFIC_ID, GROUP_CODE );
    CREATE INDEX IND_TABLE1_GROUP ON TABLE1 (PUB_ID, GROUP_CODE, REFNUM, OFIC_ID)
    CREATE INDEX IND_TABLE2_REF ON TABLE2 (REFNUM, NUMBER, STATE);
    CREATE INDEX IND_TABLE2_QUERY ON TABLE2 (NUMBER, TYPE, STATE, REFNUM, NUM, CODE);
    CREATE INDEX IND_TABLE2_REFNUM ON TABLE2 (REFNUM)
    CREATE INDEX IND_TABLE2_NUMBER ON TABLE2 (NUMBER)
    CREATE INDEX IND_TABLE3_NUM ON TABLE3 (NUMBER, PUB_ID, OFIC_ID, NAME );
    CREATE INDEX IND_TABLE3_NAME ON TABLE3 ( NAME );
    CREATE INDEX IND_GROUP_COD ON GROUP (GROUP_CODE, GROUP_TYPE)

I made the following queries to see how many records are in each table:

    SELECT count(*) FROM TABLE1  --> 18298458 results
    SELECT count(*) FROM TABLE2 --> 60627924 results
    SELECT count(*) FROM TABLE3 --> 18425913 results
    SELECT count(*) FROM OFICE --> 65 results
    SELECT count(*) FROM TABLE1 p INNER JOIN GROUP glad on glad.GROUP_CODE=p.GROUP_CODE where glad.GROUP_TYPE ='3' AND p.PUB_ID IN ('05','11','12','09','08','13','04','02','01','06','10','03','07','14') --> 1314077 results
    SELECT count(*) FROM TABLE1 p INNER JOIN GROUP glad on glad.GROUP_CODE=p.GROUP_CODE where glad.GROUP_TYPE ='3' AND p.PUB_ID IN ('05')  --> 53754 results
    SELECT count(*) FROM TABLE3 WHERE NAME LIKE 'BANK%' --> 1922081 results

this is the plan generated by oracle:

    -----------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                | Name                  | Rows  | Bytes | Cost  | Pstart| Pstop |
    -----------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                         |                       |   291K|    38M|   384K|       |       |
    |   1 |  SORT ORDER BY                           |                       |   291K|    38M|   384K|       |       |
    |   2 |   HASH JOIN                              |                       |   291K|    38M|   375K|       |       |
    |   3 |    TABLE ACCESS FULL                     | OFICE                 |    64 |   960 |     3 |       |       |
    |   4 |    HASH JOIN                             |                       |   291K|    34M|   375K|       |       |
    |   5 |     INDEX SKIP SCAN                      | IND_GROUP_COD         |    47 |   329 |     1 |       |       |
    |   6 |     HASH JOIN                            |                       |   452K|    50M|   375K|       |       |
    |   7 |      PART JOIN FILTER CREATE             | :BF0000               |   452K|    50M|   375K|       |       |
    |   8 |       NESTED LOOPS                       |                       |   452K|    50M|   375K|       |       |
    |   9 |        NESTED LOOPS                      |                       |       |       |       |       |       |
    |  10 |         STATISTICS COLLECTOR             |                       |       |       |       |       |       |
    |  11 |          HASH JOIN                       |                       |  2100K|   166M|   252K|       |       |
    |  12 |           NESTED LOOPS                   |                       |  2100K|   166M|   252K|       |       |
    |  13 |            STATISTICS COLLECTOR          |                       |       |       |       |       |       |
    |  14 |             PARTITION RANGE ALL          |                       |  1681K|    89M| 82582 |     1 |    19 |
    |  15 |              PARTITION HASH ALL          |                       |  1681K|    89M| 82582 |     1 |    32 |
    |  16 |               TABLE ACCESS FULL          | TABLE3                |  1681K|    89M| 82582 |     1 |   608 |
    |  17 |            INDEX RANGE SCAN              | IND_TABLE2_QUERY      |     1 |    27 |   103K|       |       |
    |  18 |           INDEX FAST FULL SCAN           | IND_TABLE2_QUERY      |    32M|   845M|   103K|       |       |
    |  19 |         INDEX RANGE SCAN                 | IND_TABLE1_REFNUM_ZONE|       |       |       |       |       |
    |  20 |        TABLE ACCESS BY GLOBAL INDEX ROWID| TABLE1                |     1 |    35 | 70380 | ROWID | ROWID |
    |  21 |      PARTITION RANGE ALL                 |                       |    19M|   650M| 70380 |     1 |    19 |
    |  22 |       PARTITION HASH JOIN-FILTER         |                       |    19M|   650M| 70380 |:BF0000|:BF0000|
    |  23 |        TABLE ACCESS FULL                 | TABLE1                |    19M|   650M| 70380 |     1 |   608 |
    -----------------------------------------------------------------------------------------------------------------

I think it takes time because this one is using TABLE ACCESS FULL for TABLE1 and TABLE3

if I perform the query filtering only PUB_ID='05' instead of all the numbers in the above query, the query returns 181 results and takes 8 seconds and in that case oracle generates this plan:

    --------------------------------------------------------------------------------------------------------------
    | Id  | Operation                              | Name                | Rows  | Bytes | Cost  | Pstart| Pstop |
    --------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                       |                     |   797 |   108K|   312K|       |       |
    |   1 |  SORT ORDER BY                         |                     |   797 |   108K|   312K|       |       |
    |   2 |   NESTED LOOPS                         |                     |   797 |   108K|   312K|       |       |
    |   3 |    HASH JOIN                           |                     |  1238 |   160K|   312K|       |       |
    |   4 |     TABLE ACCESS BY INDEX ROWID BATCHED| OFICE               |     3 |    45 |     2 |       |       |
    |   5 |      INDEX RANGE SCAN                  | SYS_C0034405        |     3 |       |     1 |       |       |
    |   6 |     HASH JOIN                          |                     |  2091 |   240K|   312K|       |       |
    |   7 |      PART JOIN FILTER CREATE           | :BF0000             | 66316 |  5375K|   241K|       |       |
    |   8 |       NESTED LOOPS                     |                     | 66316 |  5375K|   241K|       |       |
    |   9 |        PARTITION RANGE ALL             |                     | 53085 |  2903K| 82490 |     1 |    19 |
    |  10 |         PARTITION HASH ALL             |                     | 53085 |  2903K| 82490 |     1 |    32 |
    |  11 |          TABLE ACCESS FULL             | TABLE3              | 53085 |  2903K| 82490 |     1 |   608 |
    |  12 |        INDEX RANGE SCAN                | IND_TABLE2_QUERY    |     1 |    27 |     3 |       |       |
    |  13 |      PARTITION RANGE ALL               |                     |   762K|    25M| 68657 |     1 |    19 |
    |  14 |       PARTITION HASH JOIN-FILTER       |                     |   762K|    25M| 68657 |:BF0000|:BF0000|
    |  15 |        TABLE ACCESS FULL               | TABLE1              |   762K|    25M| 68657 |     1 |   608 |
    |  16 |    INDEX RANGE SCAN                    | IND_GROUP_COD       |     1 |     7 |     0 |       |       |
    --------------------------------------------------------------------------------------------------------------

SYS_C0034405 is the primary key of OFFICE which contains these fields: (PUB_ID, REG_ID)

if in addition to filtering only PUB_ID='05' I remove the "order by", the query takes only 3.5 seconds but I definitely have to return the ordered data and I would prefer to be able to filter several PUB_IDs

I thought the query could be improved if I removed the "inner join" from GROUP and changed the filter "glad.GROUP_TYPE ='3'" to "p.GROUP_CODE in ('01','07','10','21 ')" (these are all type 3 codes), because now it should use the IND_TABLE1_GROUP index but instead of improving, it gets worse, it takes 13 seconds even filtering only PUB_ID='05'; This is the plan that oracle generates:

    ------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                          | Name                    | Rows  | Bytes | Cost  | Pstart| Pstop |
    ------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                                   |                         |    47 |  6251 |   172K|       |       |
    |   1 |  SORT ORDER BY                                     |                         |    47 |  6251 |   172K|       |       |
    |   2 |   HASH JOIN                                        |                         |    47 |  6251 |   172K|       |       |
    |   3 |    PARTITION RANGE ALL                             |                         | 47786 |  2613K| 82490 |     1 |    19 |
    |   4 |     PARTITION HASH ALL                             |                         | 47786 |  2613K| 82490 |     1 |    32 |
    |   5 |      TABLE ACCESS FULL                             | TABLE3                  | 47786 |  2613K| 82490 |     1 |   608 |
    |   6 |    HASH JOIN                                       |                         | 41945 |  3154K| 89633 |       |       |
    |   7 |     NESTED LOOPS                                   |                         | 41945 |  3154K| 89633 |       |       |
    |   8 |      NESTED LOOPS                                  |                         | 75740 |  3154K| 89633 |       |       |
    |   9 |       STATISTICS COLLECTOR                         |                         |       |       |       |       |       |
    |  10 |        NESTED LOOPS                                |                         | 18935 |   924K| 15985 |       |       |
    |  11 |         TABLE ACCESS BY INDEX ROWID BATCHED        | OFICE                   |     3 |    45 |     2 |       |       |
    |  12 |          INDEX RANGE SCAN                          | SYS_C0034405            |     3 |       |     1 |       |       |
    |  13 |         INLIST ITERATOR                            |                         |       |       |       |       |       |
    |  14 |          TABLE ACCESS BY GLOBAL INDEX ROWID BATCHED| TABLE1                  |  6312 |   215K|  7039 | ROWID | ROWID |
    |  15 |           INDEX RANGE SCAN                         | IND_TABLE1_GROUP         |  6828 |       |   284 |       |       |
    |  16 |       INDEX RANGE SCAN                             | IND_TABLE2_REFNUM       |     4 |       |     2 |       |       |
    |  17 |      TABLE ACCESS BY INDEX ROWID                   | TABLE2                  |     2 |    54 |     4 |       |       |
    |  18 |     INDEX FAST FULL SCAN                           | IND_TABLE2_QUERY        |     2 |    54 |     2 |       |       |
    ------------------------------------------------------------------------------------------------------------------------------

And if I put all the PUB_IDs, Oracle generates this plan (it doesn't even use the IND_TABLE1_GROUP index anymore):

    -------------------------------------------------------------------------------------------------
    | Id  | Operation                  | Name               | Rows  | Bytes | Cost  | Pstart| Pstop |
    -------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT           |                    | 35661 |  4631K|   345K|       |       |
    |   1 |  SORT ORDER BY             |                    | 35661 |  4631K|   345K|       |       |
    |   2 |   HASH JOIN                |                    | 35661 |  4631K|   344K|       |       |
    |   3 |    TABLE ACCESS FULL       | OFICE              |    64 |   960 |     3 |       |       |
    |   4 |    HASH JOIN               |                    | 35661 |  4109K|   344K|       |       |
    |   5 |     PARTITION RANGE ALL    |                    |  1360K|    45M| 79580 |     1 |    19 |
    |   6 |      PARTITION HASH ALL    |                    |  1360K|    45M| 79580 |     1 |    32 |
    |   7 |       TABLE ACCESS FULL    | TABLE1             |  1360K|    45M| 79580 |     1 |   608 |
    |   8 |     HASH JOIN              |                    |  2100K|   166M|   252K|       |       |
    |   9 |      NESTED LOOPS          |                    |  2100K|   166M|   252K|       |       |
    |  10 |       STATISTICS COLLECTOR |                    |       |       |       |       |       |
    |  11 |        PARTITION RANGE ALL |                    |  1681K|    89M| 82582 |     1 |    19 |
    |  12 |         PARTITION HASH ALL |                    |  1681K|    89M| 82582 |     1 |    32 |
    |  13 |          TABLE ACCESS FULL | TABLE3             |  1681K|    89M| 82582 |     1 |   608 |
    |  14 |       INDEX RANGE SCAN     | IND_TABLE2_QUERY   |     1 |    27 |   103K|       |       |
    |  15 |      INDEX FAST FULL SCAN  | IND_TABLE2_QUERY   |    32M|   845M|   103K|       |       |
    -------------------------------------------------------------------------------------------------


问:
(in promise) TypeError: Cannot read properties of undefined (reading 'call')
When i try to call CALL Function of thirdweb it shows error "(in promise) TypeError: Cannot read properties of undefined (reading 'call')". Everthing is correct but.</p>
```<code>const getCampaigns = async () => {
        const campaigns = await contract.call('getCampaigns');

        const parsedCampaings = campaigns.map((campaign, i) => ({
            owner: campaign.owner,
            title: campaign.title,
            description: campaign.description,
            target: ethers.utils.formatEther(campaign.target.toString()),
            deadline: campaign.deadline.toNumber(),
            amountCollected: ethers.utils.formatEther(campaign.amountCollected.toString()),
            image: campaign.image,
            pId: i
        }));
        console.log(parsedCampaings);
    }
</code>```

Body:
When i try to call CALL Function of thirdweb it shows error "(in promise) TypeError: Cannot read properties of undefined (reading 'call')". Everthing is correct but.

const getCampaigns = async () => {
        const campaigns = await contract.call('getCampaigns');

        const parsedCampaings = campaigns.map((campaign, i) => ({
            owner: campaign.owner,
            title: campaign.title,
            description: campaign.description,
            target: ethers.utils.formatEther(campaign.target.toString()),
            deadline: campaign.deadline.toNumber(),
            amountCollected: ethers.utils.formatEther(campaign.amountCollected.toString()),
            image: campaign.image,
            pId: i
        }));
        console.log(parsedCampaings);
    }


问:
How to set dynamic height on LazyVerticalGrid inside Column verticalscroll?
My goal is to do something like this:

Currently I make my code like this:

```<code>Column(vertical scroll) {
Image()
Text()
LazyVerticalGrid(
modifier = Modifier.height(200.dp)
)
Text()
LazyRow()
}
</code>```

How can I set the height according to the length of the items contained in it, because currently, if the items exceed 200.dp it will be truncated.

What's the best solution?

do I have to change it to LazyVertivalGrid as the parent, but how do I set the padding for each item in the future?

Body:
My goal is to do something like this:

Currently I make my code like this:

Column(vertical scroll) {
Image()
Text()
LazyVerticalGrid(
modifier = Modifier.height(200.dp)
)
Text()
LazyRow()
}

How can I set the height according to the length of the items contained in it, because currently, if the items exceed 200.dp it will be truncated.

What's the best solution?

do I have to change it to LazyVertivalGrid as the parent, but how do I set the padding for each item in the future?


问:
Error with --enable-display-device in COS Google Compute Engine VM
I'm using Cloud Build to start a Google Cloud Compute Engine VM.

Here's the command I got from Compute Engine by selecting options in the UI and getting the "Equivalent command line", notice the --enable-display-device:

gcloud compute instances create-with-container my-vm
--project=XXX
--zone=us-central1-a
--machine-type=g1-small
--network-interface=network-tier=PREMIUM,subnet=default
--maintenance-policy=MIGRATE
--provisioning-model=STANDARD
--service-account=XXX
--scopes=https://www.googleapis.com/auth/cloud-platform
--enable-display-device
--image=projects/cos-cloud/global/images/cos-stable-97-16919-29-16
--boot-disk-size=10GB
--boot-disk-type=pd-balanced
--boot-disk-device-name=checkmate-dev
--container-image=XXX
--container-restart-policy=always
--no-shielded-secure-boot
--shielded-vtpm
--shielded-integrity-monitoring
--labels=container-vm=cos-stable-97-16919-29-16
```
<p>This command is placed in the <code>args</code> field of the <code>cloudbuild.yaml</code> which seems to run as intended until Cloud Build spits out an error:</p>
```unrecognized arguments: --enable-display-device (did you mean '--boot-disk-device-name'?)
```

I don't understand because this flag came from Compute Engine so I figure it's valid.  The flag is not actually in the docs in https://cloud.google.com/sdk/gcloud/reference/compute/instances/create-with-container.

But if I use the Compute Engine UI to make a "New VM Instance" as opposed to a container VM, then the flag appears in the command line.

Body:
I'm using Cloud Build to start a Google Cloud Compute Engine VM.

Here's the command I got from Compute Engine by selecting options in the UI and getting the "Equivalent command line", notice the --enable-display-device:

gcloud compute instances create-with-container my-vm
--project=XXX
--zone=us-central1-a
--machine-type=g1-small
--network-interface=network-tier=PREMIUM,subnet=default
--maintenance-policy=MIGRATE
--provisioning-model=STANDARD
--service-account=XXX
--scopes=https://www.googleapis.com/auth/cloud-platform
--enable-display-device
--image=projects/cos-cloud/global/images/cos-stable-97-16919-29-16
--boot-disk-size=10GB
--boot-disk-type=pd-balanced
--boot-disk-device-name=checkmate-dev
--container-image=XXX
--container-restart-policy=always
--no-shielded-secure-boot
--shielded-vtpm
--shielded-integrity-monitoring
--labels=container-vm=cos-stable-97-16919-29-16

This command is placed in the args field of the cloudbuild.yaml which seems to run as intended until Cloud Build spits out an error:

unrecognized arguments: --enable-display-device (did you mean '--boot-disk-device-name'?)

I don't understand because this flag came from Compute Engine so I figure it's valid.  The flag is not actually in the docs in https://cloud.google.com/sdk/gcloud/reference/compute/instances/create-with-container.

But if I use the Compute Engine UI to make a "New VM Instance" as opposed to a container VM, then the flag appears in the command line.


问:
fatal: unable to access 'https://github.com/sridhar7411/centralgit.git/': The requested URL returned error: 400
i am new to git hub am trying to push the data to git hub
using it my git
using git push -u origin master command
user: provided the git hub user name
password :pasted token generated from git hub, the personal accesses token. the token itself is not pasting here.
and showing the error like this
fatal: unable to access 'https://github.com/sridhar7411/centralgit.git/': The requested URL returned error: 400

please help me solve the issue

using git push -u origin master command
user: provided the git hub user name
password :pasted token generated from git hub, the personal accesses token. the token itself is not pasting here.
and showing the error like this
fatal: unable to access 'https://github.com/sridhar7411/centralgit.git/': The requested URL returned error: 400


问:
Sync ends with BUILD SUCCESSFUL but Make Project FAILS
All SO post on this subject (except for an unanswered one) describe the exact opposite situation: Build successful but Sync fails.

My situation is that I installed Android Studio for the first time (2021.3.1.17) and successfully imported an old (but working) Eclipse/ADT project of mine: Sync completes successfully, albeit with several warnings:

```<code>> Task :prepareKotlinBuildScriptModel UP-TO-DATE

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 1s
</code>```

It also warns about the Java version:

```<code>Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
 Your current JDK is located in C:\Program Files\Java\jdk1.8.0_341\jre
 You can try some of the following options:
  - changing the IDE settings.
  - changing the JAVA_HOME environment variable.
  - changing `org.gradle.java.home` in `gradle.properties`.
Gradle settings
</code>```

But when I try to Build > Make Project, it surprisingly ends with an ERROR:

```<code>Build file 'C:\Users\WebViewer\StudioProjects\MyApp\billing\build.gradle' line: 1

A problem occurred evaluating project ':billing'.
> Failed to apply plugin 'com.android.internal.library'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
      Your current JDK is located in C:\Program Files\Java\jdk1.8.0_341\jre
      You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
</code>```

I understand the warnings (definitely good ones, prompting to update to current versions, and I eliminated the Java version one via File > Settings > Build Tools > Gradle) but... if Sync ends successfully, why would Make Project fail completely?

As a newcomer to Android Studio (IntelliJ + Gradle), I am confused by this discrepancy. Could someone please shed light on the essential difference between Sync, Make Project and Rebuild Project?

Body:
All SO post on this subject (except for an unanswered one) describe the exact opposite situation: Build successful but Sync fails.

My situation is that I installed Android Studio for the first time (2021.3.1.17) and successfully imported an old (but working) Eclipse/ADT project of mine: Sync completes successfully, albeit with several warnings:

> Task :prepareKotlinBuildScriptModel UP-TO-DATE

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 1s

It also warns about the Java version:

Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
 Your current JDK is located in C:\Program Files\Java\jdk1.8.0_341\jre
 You can try some of the following options:
  - changing the IDE settings.
  - changing the JAVA_HOME environment variable.
  - changing `org.gradle.java.home` in `gradle.properties`.
Gradle settings

But when I try to Build > Make Project, it surprisingly ends with an ERROR:

Build file 'C:\Users\WebViewer\StudioProjects\MyApp\billing\build.gradle' line: 1

A problem occurred evaluating project ':billing'.
> Failed to apply plugin 'com.android.internal.library'.
   > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
      Your current JDK is located in C:\Program Files\Java\jdk1.8.0_341\jre
      You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

I understand the warnings (definitely good ones, prompting to update to current versions, and I eliminated the Java version one via File > Settings > Build Tools > Gradle) but... if Sync ends successfully, why would Make Project fail completely?

As a newcomer to Android Studio (IntelliJ + Gradle), I am confused by this discrepancy. Could someone please shed light on the essential difference between Sync, Make Project and Rebuild Project?


问:
port DropShadow from Qt5 to Qt6
In Qt5, I frequently used DropShadow (from QtGraphicalEffects) like in

```<code>   DropShadow {
        anchors.fill: button_layer
        source: button_layer
        visible: button_layer.visible
        verticalOffset: 3
        radius: 6
        samples: 13
        color: app.colorScheme.dropShadow
    }
</code>```

but QtGraphicalEffects does not seem to exist in Qt6 anymore.

What can I use in Qt6 to replace DropShadow (and FastBlur, ColorOverlay, LinearGradient)?

I understand there is a import Qt5Compat.GraphicalEffects, which works fine, but it doesn't feel like a longterm solution.

Title: port DropShadow from Qt5 to Qt6

Body:
In Qt5, I frequently used DropShadow (from QtGraphicalEffects) like in

   DropShadow {
        anchors.fill: button_layer
        source: button_layer
        visible: button_layer.visible
        verticalOffset: 3
        radius: 6
        samples: 13
        color: app.colorScheme.dropShadow
    }

but QtGraphicalEffects does not seem to exist in Qt6 anymore.

What can I use in Qt6 to replace DropShadow (and FastBlur, ColorOverlay, LinearGradient)?

I understand there is a import Qt5Compat.GraphicalEffects, which works fine, but it doesn't feel like a longterm solution.


问:
on SQLAlchemy sqlalchemy.table() or class extends Base, which do I must use?
I'm using python3.10 and SQLAlchemy 1.4.44.

SQLAlchemy have 2 style of way to express sqlalchemy.table() and class extends Base.
Is this 2 ways can convert each other?
or are the two exclusive?

I created table classes extends Base. But I want to upsert to mysql, it looks like to need table()'s variable.

What shoud I do?


问:
Where to put static fields used in builder pattern?
Using a builder pattern I want to have static fields used in all instances. Do I put them in the Url class or in the UrlBuilder class as static fields or do I extract them into a new class to only hold the static fields?

The expected result is the ability to create a Url instance by using the Builder class and a switch case logic in the UrlBuilder constructor.

Here is a code example:

```<code>public class Url {

  //required parameters
  private String homePage;
  private String boardSuffix;

  public String getHomePage() {
    return homePage;
  }

  public String getBoardSuffix() {
    return boardSuffix;
  }

  private Url(UrlBuilder builder) {
    this.homePage = builder.homePage;
    this.boardSuffix = builder.boardSuffix;
  }

  //Builder class
  public static class UrlBuilder {

    //required parameters
    private String homePage;
    private String boardSuffix;

    public UrlBuilder(String homePage, String boardSuffix) {
      this.homePage = homePage;
      this.boardSuffix = boardSuffix;
    }

    public Url build() {
      return new Url(this);
    }

  }

}
</code>```

I've tried placing the static fields in a "Constants" enum, but got lost in the reflection of enums, while trying to prepare tests.

Body:
Using a builder pattern I want to have static fields used in all instances. Do I put them in the Url class or in the UrlBuilder class as static fields or do I extract them into a new class to only hold the static fields?

The expected result is the ability to create a Url instance by using the Builder class and a switch case logic in the UrlBuilder constructor.

Here is a code example:

public class Url {

  //required parameters
  private String homePage;
  private String boardSuffix;

  public String getHomePage() {
    return homePage;
  }

  public String getBoardSuffix() {
    return boardSuffix;
  }

  private Url(UrlBuilder builder) {
    this.homePage = builder.homePage;
    this.boardSuffix = builder.boardSuffix;
  }

  //Builder class
  public static class UrlBuilder {

    //required parameters
    private String homePage;
    private String boardSuffix;

    public UrlBuilder(String homePage, String boardSuffix) {
      this.homePage = homePage;
      this.boardSuffix = boardSuffix;
    }

    public Url build() {
      return new Url(this);
    }

  }

}

I've tried placing the static fields in a "Constants" enum, but got lost in the reflection of enums, while trying to prepare tests.


问:
Built a project from source, how to link it to a forked repository on Github?
I want to start contributing to an open source project I've been using for a few years. I'm new to Github. I built the project from source on my computer, but I have noticed that I do not actually have the project I've built from source linked to my Github account. I have forked the repository so that I can now make changes on it. How can I now set it up so that the changes I make on my computer (where I built the project from source) are reflected in my forked repository?</p>


问:
Enum Can not be serialized in Asp.net Web API
I am dealing with a reference service in ASP.net Web API , when I call one of its function and fill all the required arguments I face this unusual error. The current .NET Framework of my project is 4.5.2, despite nothing happened when it was downgraded to 3.5.

You can cheer me up, if you can give me some points to tackle the problem.

Here is the error I get:

Enum value '0' is invalid for type
'WebApplication8.ServiceReference1.InsuranceCompanyEnum' and cannot be
serialized. Ensure that the necessary enum values are present and are
marked with EnumMemberAttribute attribute if the type has
DataContractAttribute attribute

Here is the code

```<code>[System.Runtime.Serialization.DataContractAttribute(Name="InsuranceCompanyEnum", Namespace="http://schemas.datacontract.org/2004/07/IGS.TRN.Common.Entities")]
public enum InsuranceCompanyEnum : int {

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Iran = 2,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Asia = 4,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Dana = 5,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Moealem = 6,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Alborz = 7,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_KarAfarin = 8,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Parsian = 9,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Toseeh = 10,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Sina = 11,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Saman = 12,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Rzai = 13,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Novin = 14,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Dey = 15,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Mihan = 16,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Mellat = 17,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Hafez = 18,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Etekayi_Amin = 19,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Iran_Moein = 20,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Omid = 21,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Pasargad = 23,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Etekayi_Iranian = 25,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Kosar = 26,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Teavon = 32,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Ma = 33,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Asmari = 34,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Sarmad = 35,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Arman = 36,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Faghed_Bimeh = 38,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Tejarat_No = 39,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Motaghabel_Etminan_Motahed_Gheshm = 40,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Motaghabel_Kish = 41,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Sherkathaye_Edghami_Dana = 42,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Etekayi_Bimeh_Markazi_IRR = 43,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Hesab_Etekayi_Vijeh = 44,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Hekmat_Saba = 45,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Zendagi_Khavarmiyaneh = 46,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Zendagi_Baran = 47,
}

WebApplication8.ServiceReference1.InquiryResponse InsertBillOfLading(WebApplication8.ServiceReference1.BillOfLading BillOfLading);

public partial class BillOfLading
{
    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private WebApplication13.ServiceReference1.InsuranceCompanyEnum InsuranceCompanyField;
    [System.Runtime.Serialization.DataMemberAttribute()]
    public WebApplication8.ServiceReference1.InsuranceCompanyEnum InsuranceCompany {
        get {
            return this.InsuranceCompanyField;
        }
        set {
            if ((this.InsuranceCompanyField.Equals(value) != true)) {
                this.InsuranceCompanyField = value;
                this.RaisePropertyChanged("InsuranceCompany");
            }
        }
    }
}
</code>```

What I have been sending to the server is:

```<code>ServiceReference1.BillOfLading bill = new ServiceReference1.BillOfLading();
bill.InsuranceCompany = (ServiceReference1.InsuranceCompanyEnum)4;
var result = srv.InsertBillOfLading(bill);
</code>```

Body:
I am dealing with a reference service in ASP.net Web API , when I call one of its function and fill all the required arguments I face this unusual error. The current .NET Framework of my project is 4.5.2, despite nothing happened when it was downgraded to 3.5.

You can cheer me up, if you can give me some points to tackle the problem.

Here is the error I get:

Enum value '0' is invalid for type
'WebApplication8.ServiceReference1.InsuranceCompanyEnum' and cannot be
serialized. Ensure that the necessary enum values are present and are
marked with EnumMemberAttribute attribute if the type has
DataContractAttribute attribute

Here is the code

[System.Runtime.Serialization.DataContractAttribute(Name="InsuranceCompanyEnum", Namespace="http://schemas.datacontract.org/2004/07/IGS.TRN.Common.Entities")]
public enum InsuranceCompanyEnum : int {

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Iran = 2,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Asia = 4,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Dana = 5,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Moealem = 6,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Alborz = 7,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_KarAfarin = 8,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Parsian = 9,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Toseeh = 10,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Sina = 11,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Saman = 12,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Rzai = 13,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Novin = 14,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Dey = 15,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Mihan = 16,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Mellat = 17,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Hafez = 18,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Etekayi_Amin = 19,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Iran_Moein = 20,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Omid = 21,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Pasargad = 23,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Etekayi_Iranian = 25,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Kosar = 26,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Teavon = 32,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Ma = 33,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Asmari = 34,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Sarmad = 35,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Arman = 36,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Faghed_Bimeh = 38,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Tejarat_No = 39,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Motaghabel_Etminan_Motahed_Gheshm = 40,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Motaghabel_Kish = 41,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Sherkathaye_Edghami_Dana = 42,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Etekayi_Bimeh_Markazi_IRR = 43,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Hesab_Etekayi_Vijeh = 44,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Hekmat_Saba = 45,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Zendagi_Khavarmiyaneh = 46,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    Bimeh_Zendagi_Baran = 47,
}

WebApplication8.ServiceReference1.InquiryResponse InsertBillOfLading(WebApplication8.ServiceReference1.BillOfLading BillOfLading);

public partial class BillOfLading
{
    [System.Runtime.Serialization.OptionalFieldAttribute()]
    private WebApplication13.ServiceReference1.InsuranceCompanyEnum InsuranceCompanyField;
    [System.Runtime.Serialization.DataMemberAttribute()]
    public WebApplication8.ServiceReference1.InsuranceCompanyEnum InsuranceCompany {
        get {
            return this.InsuranceCompanyField;
        }
        set {
            if ((this.InsuranceCompanyField.Equals(value) != true)) {
                this.InsuranceCompanyField = value;
                this.RaisePropertyChanged("InsuranceCompany");
            }
        }
    }
}

What I have been sending to the server is:

ServiceReference1.BillOfLading bill = new ServiceReference1.BillOfLading();
bill.InsuranceCompany = (ServiceReference1.InsuranceCompanyEnum)4;
var result = srv.InsertBillOfLading(bill);


问:
How to save multiple data in localStorage with zustand?
I build a stepper and I want save my data in each step and access all my last data`s

```<code>    export const useInformation = create(
  persist(
    (set) => ({
      personInfo: [],
      setPersonInfo: (callBack) => {
        set((state) => ({
          personInfo: callBack,
        }));
      },
    }),
    {
      name: 'Person_setting',
      getStorage: () => localStorage,
    }
  )
);
</code>```

this my store with zustand and it will update in my component with onclick but when i update it, its return just last data steps

but

Body:
I build a stepper and I want save my data in each step and access all my last data`s

    export const useInformation = create(
  persist(
    (set) => ({
      personInfo: [],
      setPersonInfo: (callBack) => {
        set((state) => ({
          personInfo: callBack,
        }));
      },
    }),
    {
      name: 'Person_setting',
      getStorage: () => localStorage,
    }
  )
);

this my store with zustand and it will update in my component with onclick but when i update it, its return just last data steps

but


问:
java controller to html if alert
i have a problem using alert in html.

I have a controller in Java that sends

```<code>model.addAttribute("borrowedAlready",1);
</code>```

and I need to take it from html.

here's code i have but doesn't seem to work.

```<code><div>
    <script type="text/javascript">
        var borrowed = '${borrowedAlready}';
        if(borrowed== 1){
            alert("Borrwed Already.");
        }
    </script>
</div>
</code>```

Need help

Title: java controller to html if alert

Body:
i have a problem using alert in html.

I have a controller in Java that sends

model.addAttribute("borrowedAlready",1);

and I need to take it from html.

here's code i have but doesn't seem to work.

Need help


问:
Getting started with OFX, How to download transaction statements
I would like to upgrade a macOS application I built to allow users to directly download their transaction statements via OFX data direct connect.

So far, my research has found two good sources of info

OfxTools: https://ofxtools.readthedocs.io/en/latest/index.html

OfxHome: https://www.ofxhome.com/index.php/home/ofxget

I've downloaded and installed both (command line from OfxHome and Python from OfxTools). Then tried to download statements from two of my accounts (TD Ameritrade and Fidelity). Both failed.

TD Ameritrade fails with "Signon Invalid"

Fidelity fails with "Access Denied" cannot access from this server

I initially thought the issue is that I am overseas and running from my own computer. So I installed the same two packages on a hosted server running out of San Francisco. Yet, both failed with the same errors.

I happen to be a member of an application (Profit.ly) that allows you to download your transaction statements (they use OFX, just like Quicken, etc). I can enter my TD Ameritrade and Fidelity credentials on Profit.ly, and it can download my transaction data successfully.

So what am I missing?  Below is my request from OfxHome cmd line for fidelity.

```<code>./ofxget -institution 449 -request accounts.txt

OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:20221211035100.000

<OFX>
<SIGNONMSGSRQV1>
<SONRQ>
<DTCLIENT>20221211035100.000
<USERID>MyUserName
<USERPASS>MyPassword
<LANGUAGE>ENG
<FI>
<ORG>fidelity.com
<FID>7776
</FI>
<APPID>QBW
<APPVER>1800
</SONRQ>
</SIGNONMSGSRQV1>
<SIGNUPMSGSRQV1>
<ACCTINFOTRNRQ>
<TRNUID>20221211035100.000
<CLTCOOKIE>1
<ACCTINFORQ>
<DTACCTUP>19691231
</ACCTINFORQ>
</ACCTINFOTRNRQ>
</SIGNUPMSGSRQV1>
</OFX>
</code>```

Fidelity Response

```<code><HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access "http://ofx.fidelity.com/ftgw/OFX/clients/download" on this server.<P>
Reference #18.65f466ab.1670748661.20bf6f3d
</BODY>
</HTML>
</code>```

TD Ameritrade OFX request

```<code>OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:20221211040449.000

<OFX>
<SIGNONMSGSRQV1>
<SONRQ>
<DTCLIENT>20221211040449.000
<USERID>MyUserName
<USERPASS>MyPassword
<LANGUAGE>ENG
<FI>
<ORG>ameritrade.com
<FID>5024
</FI>
<APPID>QBW
<APPVER>1800
</SONRQ>
</SIGNONMSGSRQV1>
<INVSTMTMSGSRQV1>
<INVSTMTTRNRQ>
<TRNUID>20221211040449.000
<CLTCOOKIE>4
<INVSTMTRQ>
<INVACCTFROM>
<BROKERID>ameritrade.com
<ACCTID>MyAcctNumber
</INVACCTFROM>
<INCTRAN>
<DTSTART>19000101
<INCLUDE>Y
</INCTRAN>
<INCOO>Y
<INCPOS>
<DTASOF>20221211040449.000
<INCLUDE>Y
</INCPOS>
<INCBAL>Y
</INVSTMTRQ>
</INVSTMTTRNRQ>
</INVSTMTMSGSRQV1>
</OFX>
</code>```

TD Ameritrade Response

```<code>OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:20221211040449.000

<OFX><SIGNONMSGSRSV1><SONRS><STATUS><CODE>15500</CODE><SEVERITY>ERROR</SEVERITY><MESSAGE>Signon invalid</MESSAGE></STATUS><DTSERVER>20221211040450</DTSERVER><LANGUAGE>ENG</LANGUAGE><FI><ORG>ameritrade.com</ORG><FID>5024</FID></FI></SONRS></SIGNONMSGSRSV1><INVSTMTMSGSRSV1><INVSTMTTRNRS><TRNUID>20221211040449.000</TRNUID><STATUS><CODE>15500</CODE><SEVERITY>ERROR</SEVERITY><MESSAGE>pr-txlvofx-pp02-clientsys Signon invalid</MESSAGE></STATUS><CLTCOOKIE>4</CLTCOOKIE></INVSTMTTRNRS></INVSTMTMSGSRSV1></OFX>
</code>```

Why can I not use my own computer with my own bank and credentials to download my data via command line using ofxtools or ofxget?

Is there some sort of authorization token, SSL cert, or something I am missing?

Is there a list somewhere of servers that banks trust to fetch OFX data?

Am I asking the wrong questions? lol

Possible deprecation: OFX merging with FDX (https://financialdataexchange.org/ofx)

Update

I got TD Ameritrade to response successfully by changing the APPID and APPVER

From

```<code><APPID>QBW
<APPVER>1800
</code>```

To

```<code><APPID>MDNC
<APPVER>2021
</code>```

Using OfxHome commands, I was able to fetch my TD Ameritrade transaction data however, still stuck on Fidelity.

This raises a bigger issue, which is probably core to the whole OFX thing. I'm trying to test OFX data fetching by using two brokers that I have. Straight off the bat I ran into problems and have spent all day just to figure out how to get one broker working. This is not scalable.

I guess the core of the problem is to find a database that contains the most update-to-date data for all the financial institutions. Then, be able to read the database, parse the data into the correct OFX format (w/ correct tags, version #, data), then send the request. This is the most challenging part.

I've reviewed 5 OFX libraries and tested 3 of them. All failed out-of-the-box to format a proper OFX request for TD and Fidelity. After hours of work I was able to piece together what is required by TD.

So the question is

Who has the most updated OFX request data for each financial institution?

Code to compile the OFX data into a proper request for each OFX version

Body:
I would like to upgrade a macOS application I built to allow users to directly download their transaction statements via OFX data direct connect.

So far, my research has found two good sources of info

OfxTools: https://ofxtools.readthedocs.io/en/latest/index.html

OfxHome: https://www.ofxhome.com/index.php/home/ofxget

I've downloaded and installed both (command line from OfxHome and Python from OfxTools). Then tried to download statements from two of my accounts (TD Ameritrade and Fidelity). Both failed.

TD Ameritrade fails with "Signon Invalid"

Fidelity fails with "Access Denied" cannot access from this server

I initially thought the issue is that I am overseas and running from my own computer. So I installed the same two packages on a hosted server running out of San Francisco. Yet, both failed with the same errors.

I happen to be a member of an application (Profit.ly) that allows you to download your transaction statements (they use OFX, just like Quicken, etc). I can enter my TD Ameritrade and Fidelity credentials on Profit.ly, and it can download my transaction data successfully.

So what am I missing?  Below is my request from OfxHome cmd line for fidelity.

./ofxget -institution 449 -request accounts.txt

OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:20221211035100.000

<OFX>
<SIGNONMSGSRQV1>
<SONRQ>
<DTCLIENT>20221211035100.000
<USERID>MyUserName
<USERPASS>MyPassword
<LANGUAGE>ENG
<FI>
<ORG>fidelity.com
<FID>7776
</FI>
<APPID>QBW
<APPVER>1800
</SONRQ>
</SIGNONMSGSRQV1>
<SIGNUPMSGSRQV1>
<ACCTINFOTRNRQ>
<TRNUID>20221211035100.000
<CLTCOOKIE>1
<ACCTINFORQ>
<DTACCTUP>19691231
</ACCTINFORQ>
</ACCTINFOTRNRQ>
</SIGNUPMSGSRQV1>
</OFX>

Fidelity Response

<TITLE>Access Denied</TITLE>

Access Denied

You don't have permission to access "http://ofx.fidelity.com/ftgw/OFX/clients/download" on this server.

Reference #18.65f466ab.1670748661.20bf6f3d

TD Ameritrade OFX request

OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:20221211040449.000

<OFX>
<SIGNONMSGSRQV1>
<SONRQ>
<DTCLIENT>20221211040449.000
<USERID>MyUserName
<USERPASS>MyPassword
<LANGUAGE>ENG
<FI>
<ORG>ameritrade.com
<FID>5024
</FI>
<APPID>QBW
<APPVER>1800
</SONRQ>
</SIGNONMSGSRQV1>
<INVSTMTMSGSRQV1>
<INVSTMTTRNRQ>
<TRNUID>20221211040449.000
<CLTCOOKIE>4
<INVSTMTRQ>
<INVACCTFROM>
<BROKERID>ameritrade.com
<ACCTID>MyAcctNumber
</INVACCTFROM>
<INCTRAN>
<DTSTART>19000101
<INCLUDE>Y
</INCTRAN>
<INCOO>Y
<INCPOS>
<DTASOF>20221211040449.000
<INCLUDE>Y
</INCPOS>
<INCBAL>Y
</INVSTMTRQ>
</INVSTMTTRNRQ>
</INVSTMTMSGSRQV1>
</OFX>

TD Ameritrade Response

OFXHEADER:100
DATA:OFXSGML
VERSION:102
SECURITY:NONE
ENCODING:USASCII
CHARSET:1252
COMPRESSION:NONE
OLDFILEUID:NONE
NEWFILEUID:20221211040449.000

<OFX><SIGNONMSGSRSV1><SONRS><STATUS>15500<SEVERITY>ERROR</SEVERITY><MESSAGE>Signon invalid</MESSAGE></STATUS><DTSERVER>20221211040450</DTSERVER><LANGUAGE>ENG</LANGUAGE><FI><ORG>ameritrade.com</ORG><FID>5024</FID></FI></SONRS></SIGNONMSGSRSV1><INVSTMTMSGSRSV1><INVSTMTTRNRS><TRNUID>20221211040449.000</TRNUID><STATUS>15500<SEVERITY>ERROR</SEVERITY><MESSAGE>pr-txlvofx-pp02-clientsys Signon invalid</MESSAGE></STATUS><CLTCOOKIE>4</CLTCOOKIE></INVSTMTTRNRS></INVSTMTMSGSRSV1></OFX>

Why can I not use my own computer with my own bank and credentials to download my data via command line using ofxtools or ofxget?

Is there some sort of authorization token, SSL cert, or something I am missing?

Is there a list somewhere of servers that banks trust to fetch OFX data?

Am I asking the wrong questions? lol

Possible deprecation: OFX merging with FDX (https://financialdataexchange.org/ofx)

Update

I got TD Ameritrade to response successfully by changing the APPID and APPVER

From

<APPID>QBW
<APPVER>1800

To

<APPID>MDNC
<APPVER>2021

Using OfxHome commands, I was able to fetch my TD Ameritrade transaction data however, still stuck on Fidelity.

This raises a bigger issue, which is probably core to the whole OFX thing. I'm trying to test OFX data fetching by using two brokers that I have. Straight off the bat I ran into problems and have spent all day just to figure out how to get one broker working. This is not scalable.

I guess the core of the problem is to find a database that contains the most update-to-date data for all the financial institutions. Then, be able to read the database, parse the data into the correct OFX format (w/ correct tags, version #, data), then send the request. This is the most challenging part.

I've reviewed 5 OFX libraries and tested 3 of them. All failed out-of-the-box to format a proper OFX request for TD and Fidelity. After hours of work I was able to piece together what is required by TD.

So the question is

Who has the most updated OFX request data for each financial institution?

Code to compile the OFX data into a proper request for each OFX version


问:
Is there a way to cause compilation error when some function is called from async function?
We have a pair of native functions (1st and 2nd) that use thread_local variables. They depend on each other: both must be called in the same native thread, as they access the same thread_local object. In C++ the relative safety of usage is achieved by calling the 1st function in constructor of guard object and the 2nd - in destructor.

It's still possible to create this guard object not in stack memory or to call those functions independently, but in C++ it looks so unnatural (class data member, new operator, etc.), that it never actually happen to us.

But they are also wrapped by mixed code and those wrappers are used in C# code. And there are async methods in C#, that cause the guard object to be constructed in allocated memory rather than in stack memory, in one native thread, and very often to be destructed in different native thread. And it's very transparent - you just add async, and all stack memory variables are now not in stack memory. Shooting yourself in the foot becomes very easy.

Is it possible to detect those illegal usages in compile-time? With some special attributes? Or compiler extensions/plugins?
I think, it can be achieved by analyzing the reflection of compiled output binaries, but it's less preferred approach.

Maybe there is a solution for more general problem: limit some object creation to in stack memory only? Btw, is the same possible for C++ code?

P.S. The functions are related to logging, and thread_local variable includes indentation depth.


问:
Self Signed server certificate validation - SecTrustResultType.recoverableTrustFailure error
I am using the CocoaMQTT (https://github.com/emqx/CocoaMQTT) to access a Mosquitto broker which uses a self signed certificate.

The library provides a delegate function where I can validate the server certificate.

I am not a security expert and I come up with the following code.

```<code>func mqtt(_ mqtt: CocoaMQTT, didReceive trust: SecTrust, completionHandler: @escaping (Bool) -> Void) {

    let caCertPath = Bundle.main.path(forResource: "ca", ofType: "der")
    let caCertData = try? Data(contentsOf: URL(fileURLWithPath: caCertPath!))
    let caCert = SecCertificateCreateWithData(nil, caCertData! as CFData)

    let remoteCert = SecTrustGetCertificateAtIndex(trust, 0)

    let policy = SecPolicyCreateBasicX509()
    var optionalTrust: SecTrust?
    var trustResult: SecTrustResultType = SecTrustResultType.invalid
    guard
        SecTrustCreateWithCertificates([remoteCert] as CFArray, policy, &optionalTrust) == errSecSuccess,
        let caTrust = optionalTrust,
        SecTrustSetAnchorCertificates(caTrust, [caCert] as CFArray) == errSecSuccess,
        SecTrustGetTrustResult(caTrust, &trustResult) == errSecSuccess
    else {
        completionHandler(false)
        return
    }

    switch trustResult {

    case .invalid:
        dprint("Invalid")

    case .proceed:
        dprint("Proceed")

    case .deny:
        dprint("Deny")

    case .unspecified:
        dprint("Proceed")

    case .recoverableTrustFailure:
        dprint("recoverableTrustFailure")

    case .fatalTrustFailure:
        dprint("fatalTrustFailure")

    case .otherError:
        dprint("otherError")

    @unknown default:
        dprint("default")
    }

    completionHandler(false)
}
</code>```

Problem is that SecTrustGetTrustResult always return:

```<code>SecTrustResultType.recoverableTrustFailure
</code>```

What am I doing wrong?

Body:
I am using the CocoaMQTT (https://github.com/emqx/CocoaMQTT) to access a Mosquitto broker which uses a self signed certificate.

The library provides a delegate function where I can validate the server certificate.

I am not a security expert and I come up with the following code.

func mqtt(_ mqtt: CocoaMQTT, didReceive trust: SecTrust, completionHandler: @escaping (Bool) -> Void) {

    let caCertPath = Bundle.main.path(forResource: "ca", ofType: "der")
    let caCertData = try? Data(contentsOf: URL(fileURLWithPath: caCertPath!))
    let caCert = SecCertificateCreateWithData(nil, caCertData! as CFData)

    let remoteCert = SecTrustGetCertificateAtIndex(trust, 0)

    let policy = SecPolicyCreateBasicX509()
    var optionalTrust: SecTrust?
    var trustResult: SecTrustResultType = SecTrustResultType.invalid
    guard
        SecTrustCreateWithCertificates([remoteCert] as CFArray, policy, &optionalTrust) == errSecSuccess,
        let caTrust = optionalTrust,
        SecTrustSetAnchorCertificates(caTrust, [caCert] as CFArray) == errSecSuccess,
        SecTrustGetTrustResult(caTrust, &trustResult) == errSecSuccess
    else {
        completionHandler(false)
        return
    }

    switch trustResult {

    case .invalid:
        dprint("Invalid")

    case .proceed:
        dprint("Proceed")

    case .deny:
        dprint("Deny")

    case .unspecified:
        dprint("Proceed")

    case .recoverableTrustFailure:
        dprint("recoverableTrustFailure")

    case .fatalTrustFailure:
        dprint("fatalTrustFailure")

    case .otherError:
        dprint("otherError")

    @unknown default:
        dprint("default")
    }

    completionHandler(false)
}

Problem is that SecTrustGetTrustResult always return:

SecTrustResultType.recoverableTrustFailure

What am I doing wrong?


问:
Problem with regex in Rust but not in Python
I have the following regex that works in Python but I am struggling to make it work in Rust.

My goal is to rewrite a function I have in Python into Rust. This is my rust

use lazy_static::lazy_static;
use regex::Regex;

fn find_danish_address(text: &str) -> Option<regex::Match<'_>> {
    lazy_static! {
        static ref RE: Regex = Regex::new(r"(?:[A-ZÅÆØ]{1}\w{2,80}\s?) # Street name
        (?:(?:\d{1,4}|\w{0,6}) # House number or other identifier
        (?:,|.|)(?:\s\d{0,5}|) # Optional apartment number
        (?:tv|st|kl|mf|th|sal|) # Optional address unit
        (?:,|.|)\s?){0,4} # Optional separator
        (?:DK-)?\d{4}\s # Postal code
        [A-ZÅÆØ]{1}\w{1,40} # City name
        (?:\s[CNVSKØ]{0,2}|) # Optional county code"
     ).unwrap();
    }
    RE.find(text)
}

fn main() {
    let text: &str = "Jeg bor i Gurrevej 48, 1. tv 2650 Hvidovre";

    println!("{:?}", find_danish_address(text))
}

```
<p>In Python I have:</p>
<pre class="lang-py prettyprint-override"><code>import re
from collections.abc import Iterator

# DK ADDRESSES RE
DK_ADDRESSES_RE = re.compile(r"(?:[A-ZÅÆØ]{1}\w{2,80}\s?)" # Street name
                            r"(?:(?:\d{1,4}|\w{,6})" # House number or other identifier
                            r"(?:,|.|)(?:\s\d{,5}|)" # Optional apartment number
                            r"(?:tv|st|kl|mf|th|sal|)" # Optional address unit
                            r"(?:,|.|)\s?){,4}" # Optional separator
                            r"(?:DK-)?\d{4}\s" # Postal code
                            r"[A-ZÅÆØ]{1}\w{1,40}" # City name
                            r"(?:\s[CNVSKØ]{,2}|)") # Optional county code

def find_danish_address(text: str) -> Iterator[str]:
    text_ = text.strip()
    captured = re.findall(DK_ADDRESSES_RE, text_)

    return (' '.join(add.split()) for add in captured)
</code>```

I am a 4 months old Rustaceans, and most possibly it’s my lack of understanding. Go easy on me.

I get the following traceback

Compiling playground v0.0.1 (/playground)
    Finished dev [unoptimized + debuginfo] target(s) in 0.97s
     Running `target/debug/playground`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CompiledTooBig(10485760)', src/main.rs:14:8
stack backtrace:
   0: rust_begin_unwind
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/result.rs:1785:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/result.rs:1107:23
   4: <playground::find_danish_address::RE as core::ops::deref::Deref>::deref::__static_ref_initialize
             at ./src/main.rs:6:32
   5: core::ops::function::FnOnce::call_once
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ops/function.rs:248:5
   6: lazy_static::lazy::Lazy<T>::get::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:31:29
   7: std::sync::once::Once::call_once::{{closure}}
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sync/once.rs:276:41
   8: std::sync::once::Once::call_inner
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sync/once.rs:434:21
   9: std::sync::once::Once::call_once
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sync/once.rs:276:9
  10: lazy_static::lazy::Lazy<T>::get
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:30:9
  11: <playground::find_danish_address::RE as core::ops::deref::Deref>::deref::__stability
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/lib.rs:142:21
  12: <playground::find_danish_address::RE as core::ops::deref::Deref>::deref
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/lib.rs:144:17
  13: playground::find_danish_address
             at ./src/main.rs:16:5
  14: playground::main
             at ./src/main.rs:22:19
  15: core::ops::function::FnOnce::call_once
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

```

Body:
I have the following regex that works in Python but I am struggling to make it work in Rust.

My goal is to rewrite a function I have in Python into Rust. This is my rust

use lazy_static::lazy_static;
use regex::Regex;

fn find_danish_address(text: &str) -> Option<regex::Match<'_>> {
    lazy_static! {
        static ref RE: Regex = Regex::new(r"(?:[A-ZÅÆØ]{1}\w{2,80}\s?) # Street name
        (?:(?:\d{1,4}|\w{0,6}) # House number or other identifier
        (?:,|.|)(?:\s\d{0,5}|) # Optional apartment number
        (?:tv|st|kl|mf|th|sal|) # Optional address unit
        (?:,|.|)\s?){0,4} # Optional separator
        (?:DK-)?\d{4}\s # Postal code
        [A-ZÅÆØ]{1}\w{1,40} # City name
        (?:\s[CNVSKØ]{0,2}|) # Optional county code"
     ).unwrap();
    }
    RE.find(text)
}

fn main() {
    let text: &str = "Jeg bor i Gurrevej 48, 1. tv 2650 Hvidovre";

    println!("{:?}", find_danish_address(text))
}

In Python I have:

import re
from collections.abc import Iterator

# DK ADDRESSES RE
DK_ADDRESSES_RE = re.compile(r"(?:[A-ZÅÆØ]{1}\w{2,80}\s?)" # Street name
                            r"(?:(?:\d{1,4}|\w{,6})" # House number or other identifier
                            r"(?:,|.|)(?:\s\d{,5}|)" # Optional apartment number
                            r"(?:tv|st|kl|mf|th|sal|)" # Optional address unit
                            r"(?:,|.|)\s?){,4}" # Optional separator
                            r"(?:DK-)?\d{4}\s" # Postal code
                            r"[A-ZÅÆØ]{1}\w{1,40}" # City name
                            r"(?:\s[CNVSKØ]{,2}|)") # Optional county code

def find_danish_address(text: str) -> Iterator[str]:
    text_ = text.strip()
    captured = re.findall(DK_ADDRESSES_RE, text_)

    return (' '.join(add.split()) for add in captured)

I am a 4 months old Rustaceans, and most possibly it’s my lack of understanding. Go easy on me.

I get the following traceback

Compiling playground v0.0.1 (/playground)
    Finished dev [unoptimized + debuginfo] target(s) in 0.97s
     Running `target/debug/playground`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CompiledTooBig(10485760)', src/main.rs:14:8
stack backtrace:
   0: rust_begin_unwind
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/panicking.rs:142:14
   2: core::result::unwrap_failed
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/result.rs:1785:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/result.rs:1107:23
   4: <playground::find_danish_address::RE as core::ops::deref::Deref>::deref::__static_ref_initialize
             at ./src/main.rs:6:32
   5: core::ops::function::FnOnce::call_once
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ops/function.rs:248:5
   6: lazy_static::lazy::Lazy<T>::get::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:31:29
   7: std::sync::once::Once::call_once::{{closure}}
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sync/once.rs:276:41
   8: std::sync::once::Once::call_inner
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sync/once.rs:434:21
   9: std::sync::once::Once::call_once
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/sync/once.rs:276:9
  10: lazy_static::lazy::Lazy<T>::get
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/inline_lazy.rs:30:9
  11: <playground::find_danish_address::RE as core::ops::deref::Deref>::deref::__stability
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/lib.rs:142:21
  12: <playground::find_danish_address::RE as core::ops::deref::Deref>::deref
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/lazy_static-1.4.0/src/lib.rs:144:17
  13: playground::find_danish_address
             at ./src/main.rs:16:5
  14: playground::main
             at ./src/main.rs:22:19
  15: core::ops::function::FnOnce::call_once
             at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.


问:
How to send message from Nodejs child process written in another language?
Nodejs child process has this IPC api that allows communication between nodejs parent and child processes. https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback

But this requires the child process to be a .js file. What if the the child process in an executable in another language, like golang.
How can I do the process.send equivalent operation in golang?


问:
Xterm.js blocking input
Does Xterm.js have a function for blocking input?
Similar to python's input()?

I tried everything about xterm.js, but the document really has nothing related.

Title: Xterm.js blocking input


问:
Time and Space Complexity for Leet Code Problem 39: Combination Sum
I was practicing backtracking problems and started off with the Combination Sum problem in Leetcode 39. I worked on my own solution after watching a few YouTube videos to understand the problem better since my solution was failing even though I felt that the logic was right. (Basically I wasn't handling the case to remove redundant solutions, i.e. I had a solution that would get the Permutation of the solution but not the Combination!!

I wrote my code in java, I honestly didn't find many java solutions to this. Python solutions seemed pretty simple though. Maybe it's not the best space and time. I'll try to optimize it and post the update here.

I'm struggling to calculate the time and space complexity for this problem. I'm pretty weak at calculating the time and space usually and with this problem particularly, it's really confusing considering each element can be used multiple times and hence will be part of multiple solutions with multiple counts. I'm trying to calculate space since I use recursion and I'm using the tree method to check the stack size. But if anyone has a good approach to calculate time and space to such problems will be really helpful.

My code below. Any inputs to optimize it will be helpful!

class Solution {

    public List<List<Integer>> combinationSum(int[] candidates, int target) {
        List<List<Integer>> mainList = new ArrayList<>();
        List<Integer> currList = new ArrayList<>();
        compute(0, currList, target, candidates, 0, mainList);
        return mainList;
    }

    void compute(int currSum, List<Integer> currList, int target, int[] candidates, int pos, List<List<Integer>> mainList){
        if(currSum > target || pos>(candidates.length-1)){
            return;
        }
        if(currSum == target){
            mainList.add(new ArrayList<>(currList));
            return;
        }
        currList.add(candidates[pos]);
        currSum = currSum+candidates[pos];
        compute(currSum, currList, target, candidates, pos, mainList);
        currSum = currSum-(currList.get(currList.size()-1));
        currList.remove(currList.size()-1);
        compute(currSum, currList, target, candidates, pos+1, mainList);
    }
}
```

I think one way is to sort the candidates array and if sum>target for position i we need not call the function for position i + 1.

Body:
I was practicing backtracking problems and started off with the Combination Sum problem in Leetcode 39. I worked on my own solution after watching a few YouTube videos to understand the problem better since my solution was failing even though I felt that the logic was right. (Basically I wasn't handling the case to remove redundant solutions, i.e. I had a solution that would get the Permutation of the solution but not the Combination!!

I wrote my code in java, I honestly didn't find many java solutions to this. Python solutions seemed pretty simple though. Maybe it's not the best space and time. I'll try to optimize it and post the update here.

I'm struggling to calculate the time and space complexity for this problem. I'm pretty weak at calculating the time and space usually and with this problem particularly, it's really confusing considering each element can be used multiple times and hence will be part of multiple solutions with multiple counts. I'm trying to calculate space since I use recursion and I'm using the tree method to check the stack size. But if anyone has a good approach to calculate time and space to such problems will be really helpful.

My code below. Any inputs to optimize it will be helpful!

class Solution {

    public List<List<Integer>> combinationSum(int[] candidates, int target) {
        List<List<Integer>> mainList = new ArrayList<>();
        List<Integer> currList = new ArrayList<>();
        compute(0, currList, target, candidates, 0, mainList);
        return mainList;
    }

    void compute(int currSum, List<Integer> currList, int target, int[] candidates, int pos, List<List<Integer>> mainList){
        if(currSum > target || pos>(candidates.length-1)){
            return;
        }
        if(currSum == target){
            mainList.add(new ArrayList<>(currList));
            return;
        }
        currList.add(candidates[pos]);
        currSum = currSum+candidates[pos];
        compute(currSum, currList, target, candidates, pos, mainList);
        currSum = currSum-(currList.get(currList.size()-1));
        currList.remove(currList.size()-1);
        compute(currSum, currList, target, candidates, pos+1, mainList);
    }
}

I think one way is to sort the candidates array and if sum>target for position i we need not call the function for position i + 1.