问:
SQL Statement takes 7h instead of 1:30min after update PostgreSQL 10 to PostgreSQL 13. Why? How to fix that?
There are a number of SQL Statement I have to repeat on a regular basis. After my PosgreSQL Version was updated from 10 to 13 one particular querytakes 7 hours instead of 1:30min.

That's the query:

```<code>SELECT
    polyssqlspatial.objid, pointssqlspatial.objid
from
    (polyssqlspatial join ax11001 on polyssqlspatial.objid = ax11001_objid)
join
        (pointssqlspatial join AX14004 on  AX14004_objid = pointssqlspatial.objid)
on
        ST_Touches(pointssqlspatial.shape, polyssqlspatial.shape) or ST_Within(pointssqlspatial.shape, polyssqlspatial.shape);
</code>```

polyssqlspatial and pointssqlspatial are the geometries
ax11001 and ax14004 contain data connected to the geometries.

Basically, the statement is just returning all geometries if the points touch the polygons or are inside them.

I have 45000 polygons and 95327 Points.

Does anyone have ideas why this query takes 7h in PostgreSQL 13 and how to reduce the runtime again? It used to be 1:30min.

EDIT:
Query Plan for PostgreSQL 10 Server:

```<code> "QUERY PLAN"
"Gather  (cost=14495.04..4907988.66 rows=2146510 width=77) (actual time=66.999..83240.204 rows=373890 loops=1)"
"  Output: polyssqlspatial.objid, pointssqlspatial.objid"
"  Workers Planned: 2"
"  Workers Launched: 2"
"  Buffers: shared hit=4138168"
"  ->  Hash Join  (cost=13495.04..4692337.66 rows=894379 width=77) (actual time=81.475..83104.722 rows=124630 loops=3)"
"        Output: polyssqlspatial.objid, pointssqlspatial.objid"
"        Hash Cond: (polyssqlspatial.objid = (ax11001.ax11001_objid)::bpchar)"
"        Buffers: shared hit=4138168"
"        Worker 0: actual time=89.307..83099.719 rows=124105 loops=1"
"          Buffers: shared hit=1374659"
"        Worker 1: actual time=88.927..83129.914 rows=124533 loops=1"
"          Buffers: shared hit=1379935"
"        ->  Nested Loop  (cost=8534.07..4668814.00 rows=2565040 width=77) (actual time=52.892..82607.729 rows=364807 loops=3)"
"              Output: polyssqlspatial.objid, pointssqlspatial.objid"
"              Buffers: shared hit=3935399"
"              Worker 0: actual time=56.983..82605.787 rows=363104 loops=1"
"                Buffers: shared hit=1306956"
"              Worker 1: actual time=56.789..82638.076 rows=364934 loops=1"
"                Buffers: shared hit=1311962"
"              ->  Hash Join  (cost=8532.41..25562.37 rows=59711 width=79) (actual time=52.276..185.790 rows=47769 loops=3)"
"                    Output: pointssqlspatial.objid, pointssqlspatial.shape"
"                    Hash Cond: (pointssqlspatial.objid = (ax14004x11003.ax14004x11003_objid)::bpchar)"
"                    Buffers: shared hit=29811"
"                    Worker 0: actual time=56.310..178.166 rows=47624 loops=1"
"                      Buffers: shared hit=8487"
"                    Worker 1: actual time=56.298..184.014 rows=47693 loops=1"
"                      Buffers: shared hit=8846"
"                    ->  Parallel Seq Scan on public.pointssqlspatial  (cost=0.00..15738.53 rows=185153 width=79) (actual time=0.006..37.606 rows=148123 loops=3)"
"                          Output: pointssqlspatial.objid, pointssqlspatial.layerid, pointssqlspatial.povchanged, pointssqlspatial.georestr, pointssqlspatial.dokucount, pointssqlspatial.defid, pointssqlspatial.objpri, pointssqlspatial.objclass, pointssqlspatial.alpha, pointssqlspatial.isdelta, pointssqlspatial.deltar, pointssqlspatial.deltah, pointssqlspatial.sigwidth, pointssqlspatial.sigheight, pointssqlspatial.shape, pointssqlspatial.tesselcode, pointssqlspatial.tesselnumh, pointssqlspatial.tesselnumr"
"                          Buffers: shared hit=13887"
"                          Worker 0: actual time=0.007..35.803 rows=101712 loops=1"
"                            Buffers: shared hit=3179"
"                          Worker 1: actual time=0.007..38.871 rows=113216 loops=1"
"                            Buffers: shared hit=3538"
"                    ->  Hash  (cost=6741.07..6741.07 rows=143307 width=39) (actual time=51.947..51.947 rows=143307 loops=3)"
"                          Output: ax14004x11003.ax14004x11003_objid"
"                          Buckets: 262144  Batches: 1  Memory Usage: 11985kB"
"                          Buffers: shared hit=15924"
"                          Worker 0: actual time=55.980..55.980 rows=143307 loops=1"
"                            Buffers: shared hit=5308"
"                          Worker 1: actual time=55.985..55.985 rows=143307 loops=1"
"                            Buffers: shared hit=5308"
"                          ->  Seq Scan on public.ax14004x11003  (cost=0.00..6741.07 rows=143307 width=39) (actual time=0.106..26.172 rows=143307 loops=3)"
"                                Output: ax14004x11003.ax14004x11003_objid"
"                                Buffers: shared hit=15924"
"                                Worker 0: actual time=0.143..30.242 rows=143307 loops=1"
"                                  Buffers: shared hit=5308"
"                                Worker 1: actual time=0.165..29.961 rows=143307 loops=1"
"                                  Buffers: shared hit=5308"
"              ->  Bitmap Heap Scan on public.polyssqlspatial  (cost=1.66..77.29 rows=47 width=386) (actual time=0.367..1.716 rows=8 loops=143306)"
"                    Output: polyssqlspatial.objid, polyssqlspatial.layerid, polyssqlspatial.povchanged, polyssqlspatial.georestr, polyssqlspatial.dokucount, polyssqlspatial.defid, polyssqlspatial.objpri, polyssqlspatial.objclass, polyssqlspatial.rsp, polyssqlspatial.hsp, polyssqlspatial.alphasp, polyssqlspatial.sigbegin, polyssqlspatial.sigend, polyssqlspatial.schalter, polyssqlspatial.alphafs, polyssqlspatial.sizemm, polyssqlspatial.shape, polyssqlspatial.tesselcode, polyssqlspatial.tesselnumh, polyssqlspatial.tesselnumr"
"                    Recheck Cond: ((pointssqlspatial.shape && polyssqlspatial.shape) OR (polyssqlspatial.shape ~ pointssqlspatial.shape))"
"                    Filter: (((pointssqlspatial.shape && polyssqlspatial.shape) AND _st_touches(pointssqlspatial.shape, polyssqlspatial.shape)) OR ((polyssqlspatial.shape ~ pointssqlspatial.shape) AND _st_contains(polyssqlspatial.shape, pointssqlspatial.shape)))"
"                    Rows Removed by Filter: 8"
"                    Heap Blocks: exact=664156"
"                    Buffers: shared hit=3905588"
"                    Worker 0: actual time=0.368..1.721 rows=8 loops=47624"
"                      Buffers: shared hit=1298469"
"                    Worker 1: actual time=0.367..1.719 rows=8 loops=47693"
"                      Buffers: shared hit=1303116"
"                    ->  BitmapOr  (cost=1.66..1.66 rows=142 width=0) (actual time=0.159..0.159 rows=0 loops=143306)"
"                          Buffers: shared hit=1916131"
"                          Worker 0: actual time=0.160..0.160 rows=0 loops=47624"
"                            Buffers: shared hit=636834"
"                          Worker 1: actual time=0.159..0.159 rows=0 loops=47693"
"                            Buffers: shared hit=639450"
"                          ->  Bitmap Index Scan on spatial_idx_polyssqlspatial  (cost=0.00..0.38 rows=13 width=0) (actual time=0.083..0.083 rows=15 loops=143306)"
"                                Index Cond: (pointssqlspatial.shape && polyssqlspatial.shape)"
"                                Buffers: shared hit=959006"
"                                Worker 0: actual time=0.083..0.083 rows=15 loops=47624"
"                                  Buffers: shared hit=318734"
"                                Worker 1: actual time=0.083..0.083 rows=15 loops=47693"
"                                  Buffers: shared hit=320027"
"                          ->  Bitmap Index Scan on spatial_idx_polyssqlspatial  (cost=0.00..1.25 rows=129 width=0) (actual time=0.075..0.075 rows=15 loops=143306)"
"                                Index Cond: (polyssqlspatial.shape ~ pointssqlspatial.shape)"
"                                Buffers: shared hit=957125"
"                                Worker 0: actual time=0.075..0.075 rows=15 loops=47624"
"                                  Buffers: shared hit=318100"
"                                Worker 1: actual time=0.075..0.075 rows=15 loops=47693"
"                                  Buffers: shared hit=319423"
"        ->  Hash  (cost=4399.32..4399.32 rows=44932 width=39) (actual time=28.007..28.007 rows=44932 loops=3)"
"              Output: ax11001.ax11001_objid"
"              Buckets: 65536  Batches: 1  Memory Usage: 3628kB"
"              Buffers: shared hit=11850"
"              Worker 0: actual time=31.586..31.586 rows=44932 loops=1"
"                Buffers: shared hit=3950"
"              Worker 1: actual time=31.563..31.563 rows=44932 loops=1"
"                Buffers: shared hit=3950"
"              ->  Seq Scan on public.ax11001  (cost=0.00..4399.32 rows=44932 width=39) (actual time=0.080..20.297 rows=44932 loops=3)"
"                    Output: ax11001.ax11001_objid"
"                    Buffers: shared hit=11850"
"                    Worker 0: actual time=0.145..23.801 rows=44932 loops=1"
"                      Buffers: shared hit=3950"
"                    Worker 1: actual time=0.081..23.693 rows=44932 loops=1"
"                      Buffers: shared hit=3950"
"Planning time: 24.645 ms"
"Execution time: 83260.579 ms"
</code>```

Query Plan for PostgreSQL 13 Server

```<code>    "Nested Loop  (cost=7653.57..426137274.01 rows=938 width=77) (actual time=43124.328..40067741.585 rows=373890 loops=1)"
"  Output: polyssqlspatial.objid, pointssqlspatial.objid"
"  Join Filter: (polyssqlspatial.objid = (ax11001.ax11001_objid)::bpchar)"
"  Rows Removed by Join Filter: 49174195414"
"  Buffers: shared read=323, temp read=521648910 written=11610"
"  ->  Index Only Scan using ixax11001_objid on public.ax11001  (cost=0.41..1489.39 rows=44932 width=39) (actual time=14.773..203.962 rows=44932 loops=1)"
"        Output: ax11001.ax11001_objid"
"        Heap Fetches: 0"
"        Buffers: shared hit=1 read=323"
"  ->  Materialize  (cost=7653.15..424321437.18 rows=2692 width=77) (actual time=0.027..368.951 rows=1094422 loops=44932)"
"        Output: polyssqlspatial.objid, pointssqlspatial.objid"
"        Buffers: shared hit=4561020, temp read=521648910 written=11610"
"        ->  Gather  (cost=7653.15..424321423.72 rows=2692 width=77) (actual time=116.830..40941.662 rows=1094422 loops=1)"
"              Output: polyssqlspatial.objid, pointssqlspatial.objid"
"              Workers Planned: 2"
"              Workers Launched: 2"
"              Buffers: shared hit=4561020"
"              ->  Nested Loop  (cost=6653.15..424320154.52 rows=1122 width=77) (actual time=55.248..41528.751 rows=364807 loops=3)"
"                    Output: polyssqlspatial.objid, pointssqlspatial.objid"
"                    Buffers: shared hit=4561020"
"                    Worker 0:  actual time=22.459..42090.385 rows=374235 loops=1"
"                      Buffers: shared hit=1558962"
"                    Worker 1:  actual time=28.819..41980.088 rows=365154 loops=1"
"                      Buffers: shared hit=1515646"
"                    ->  Parallel Hash Join  (cost=6651.50..23781.16 rows=59711 width=79) (actual time=54.054..317.307 rows=47769 loops=3)"
"                          Output: pointssqlspatial.objid, pointssqlspatial.shape"
"                          Hash Cond: (pointssqlspatial.objid = (ax14004x11003.ax14004x11003_objid)::bpchar)"
"                          Buffers: shared hit=19716"
"                          Worker 0:  actual time=20.690..315.936 rows=48973 loops=1"
"                            Buffers: shared hit=5797"
"                          Worker 1:  actual time=27.753..275.461 rows=47845 loops=1"
"                            Buffers: shared hit=4934"
"                          ->  Parallel Seq Scan on public.pointssqlspatial  (cost=0.00..16186.53 rows=185153 width=79) (actual time=0.024..55.810 rows=148123 loops=3)"
"                                Output: pointssqlspatial.objid, pointssqlspatial.layerid, pointssqlspatial.tesselcode, pointssqlspatial.tesselnumh, pointssqlspatial.tesselnumr, pointssqlspatial.povchanged, pointssqlspatial.georestr, pointssqlspatial.dokucount, pointssqlspatial.defid, pointssqlspatial.objpri, pointssqlspatial.objclass, pointssqlspatial.alpha, pointssqlspatial.isdelta, pointssqlspatial.deltar, pointssqlspatial.deltah, pointssqlspatial.sigwidth, pointssqlspatial.sigheight, pointssqlspatial.shape"
"                                Buffers: shared hit=14335"
"                                Worker 0:  actual time=0.024..64.994 rows=160983 loops=1"
"                                  Buffers: shared hit=5193"
"                                Worker 1:  actual time=0.026..49.194 rows=128340 loops=1"
"                                  Buffers: shared hit=4140"
"                          ->  Parallel Hash  (cost=5905.11..5905.11 rows=59711 width=39) (actual time=52.555..52.557 rows=47769 loops=3)"
"                                Output: ax14004x11003.ax14004x11003_objid"
"                                Buckets: 262144  Batches: 1  Memory Usage: 12192kB"
"                                Buffers: shared hit=5308"
"                                Worker 0:  actual time=20.150..20.151 rows=15354 loops=1"
"                                  Buffers: shared hit=569"
"                                Worker 1:  actual time=27.197..27.199 rows=20493 loops=1"
"                                  Buffers: shared hit=759"
"                                ->  Parallel Seq Scan on public.ax14004x11003  (cost=0.00..5905.11 rows=59711 width=39) (actual time=0.026..31.099 rows=47769 loops=3)"
"                                      Output: ax14004x11003.ax14004x11003_objid"
"                                      Buffers: shared hit=5308"
"                                      Worker 0:  actual time=0.028..11.930 rows=15354 loops=1"
"                                        Buffers: shared hit=569"
"                                      Worker 1:  actual time=0.027..16.306 rows=20493 loops=1"
"                                        Buffers: shared hit=759"
"                    ->  Bitmap Heap Scan on public.polyssqlspatial  (cost=1.65..7105.57 rows=26 width=385) (actual time=0.409..0.846 rows=8 loops=143306)"
"                          Output: polyssqlspatial.objid, polyssqlspatial.layerid, polyssqlspatial.tesselcode, polyssqlspatial.tesselnumh, polyssqlspatial.tesselnumr, polyssqlspatial.povchanged, polyssqlspatial.georestr, polyssqlspatial.dokucount, polyssqlspatial.defid, polyssqlspatial.objpri, polyssqlspatial.objclass, polyssqlspatial.rsp, polyssqlspatial.hsp, polyssqlspatial.alphasp, polyssqlspatial.sigbegin, polyssqlspatial.sigend, polyssqlspatial.schalter, polyssqlspatial.alphafs, polyssqlspatial.sizemm, polyssqlspatial.shape"
"                          Recheck Cond: (st_touches(pointssqlspatial.shape, polyssqlspatial.shape) OR st_within(pointssqlspatial.shape, polyssqlspatial.shape))"
"                          Filter: (st_touches(pointssqlspatial.shape, polyssqlspatial.shape) OR st_within(pointssqlspatial.shape, polyssqlspatial.shape))"
"                          Rows Removed by Filter: 8"
"                          Heap Blocks: exact=616261"
"                          Buffers: shared hit=4541304"
"                          Worker 0:  actual time=0.402..0.835 rows=8 loops=48973"
"                            Buffers: shared hit=1553165"
"                          Worker 1:  actual time=0.422..0.855 rows=8 loops=47845"
"                            Buffers: shared hit=1510712"
"                          ->  BitmapOr  (cost=1.65..1.65 rows=142 width=0) (actual time=0.301..0.301 rows=0 loops=143306)"
"                                Buffers: shared hit=2640396"
"                                Worker 0:  actual time=0.292..0.292 rows=0 loops=48973"
"                                  Buffers: shared hit=904433"
"                                Worker 1:  actual time=0.315..0.315 rows=0 loops=47845"
"                                  Buffers: shared hit=874797"
"                                ->  Bitmap Index Scan on spatial_idx_polyssqlspatial  (cost=0.00..0.38 rows=13 width=0) (actual time=0.158..0.158 rows=15 loops=143306)"
"                                      Index Cond: (polyssqlspatial.shape && pointssqlspatial.shape)"
"                                      Buffers: shared hit=1321443"
"                                      Worker 0:  actual time=0.150..0.150 rows=15 loops=48973"
"                                        Buffers: shared hit=452642"
"                                      Worker 1:  actual time=0.171..0.171 rows=15 loops=47845"
"                                        Buffers: shared hit=437805"
"                                ->  Bitmap Index Scan on spatial_idx_polyssqlspatial  (cost=0.00..1.25 rows=129 width=0) (actual time=0.142..0.142 rows=15 loops=143306)"
"                                      Index Cond: (polyssqlspatial.shape ~ pointssqlspatial.shape)"
"                                      Buffers: shared hit=1318953"
"                                      Worker 0:  actual time=0.140..0.140 rows=15 loops=48973"
"                                        Buffers: shared hit=451791"
"                                      Worker 1:  actual time=0.142..0.142 rows=15 loops=47845"
"                                        Buffers: shared hit=436992"
"Planning:"
"  Buffers: shared hit=477 dirtied=1"
"Planning Time: 77.195 ms"
"Execution Time: 40068039.569 ms"
</code>```

Body:
There are a number of SQL Statement I have to repeat on a regular basis. After my PosgreSQL Version was updated from 10 to 13 one particular querytakes 7 hours instead of 1:30min.

That's the query:

SELECT
    polyssqlspatial.objid, pointssqlspatial.objid
from
    (polyssqlspatial join ax11001 on polyssqlspatial.objid = ax11001_objid)
join
        (pointssqlspatial join AX14004 on  AX14004_objid = pointssqlspatial.objid)
on
        ST_Touches(pointssqlspatial.shape, polyssqlspatial.shape) or ST_Within(pointssqlspatial.shape, polyssqlspatial.shape);

polyssqlspatial and pointssqlspatial are the geometries
ax11001 and ax14004 contain data connected to the geometries.

Basically, the statement is just returning all geometries if the points touch the polygons or are inside them.

I have 45000 polygons and 95327 Points.

Does anyone have ideas why this query takes 7h in PostgreSQL 13 and how to reduce the runtime again? It used to be 1:30min.

EDIT:
Query Plan for PostgreSQL 10 Server:

 "QUERY PLAN"
"Gather  (cost=14495.04..4907988.66 rows=2146510 width=77) (actual time=66.999..83240.204 rows=373890 loops=1)"
"  Output: polyssqlspatial.objid, pointssqlspatial.objid"
"  Workers Planned: 2"
"  Workers Launched: 2"
"  Buffers: shared hit=4138168"
"  ->  Hash Join  (cost=13495.04..4692337.66 rows=894379 width=77) (actual time=81.475..83104.722 rows=124630 loops=3)"
"        Output: polyssqlspatial.objid, pointssqlspatial.objid"
"        Hash Cond: (polyssqlspatial.objid = (ax11001.ax11001_objid)::bpchar)"
"        Buffers: shared hit=4138168"
"        Worker 0: actual time=89.307..83099.719 rows=124105 loops=1"
"          Buffers: shared hit=1374659"
"        Worker 1: actual time=88.927..83129.914 rows=124533 loops=1"
"          Buffers: shared hit=1379935"
"        ->  Nested Loop  (cost=8534.07..4668814.00 rows=2565040 width=77) (actual time=52.892..82607.729 rows=364807 loops=3)"
"              Output: polyssqlspatial.objid, pointssqlspatial.objid"
"              Buffers: shared hit=3935399"
"              Worker 0: actual time=56.983..82605.787 rows=363104 loops=1"
"                Buffers: shared hit=1306956"
"              Worker 1: actual time=56.789..82638.076 rows=364934 loops=1"
"                Buffers: shared hit=1311962"
"              ->  Hash Join  (cost=8532.41..25562.37 rows=59711 width=79) (actual time=52.276..185.790 rows=47769 loops=3)"
"                    Output: pointssqlspatial.objid, pointssqlspatial.shape"
"                    Hash Cond: (pointssqlspatial.objid = (ax14004x11003.ax14004x11003_objid)::bpchar)"
"                    Buffers: shared hit=29811"
"                    Worker 0: actual time=56.310..178.166 rows=47624 loops=1"
"                      Buffers: shared hit=8487"
"                    Worker 1: actual time=56.298..184.014 rows=47693 loops=1"
"                      Buffers: shared hit=8846"
"                    ->  Parallel Seq Scan on public.pointssqlspatial  (cost=0.00..15738.53 rows=185153 width=79) (actual time=0.006..37.606 rows=148123 loops=3)"
"                          Output: pointssqlspatial.objid, pointssqlspatial.layerid, pointssqlspatial.povchanged, pointssqlspatial.georestr, pointssqlspatial.dokucount, pointssqlspatial.defid, pointssqlspatial.objpri, pointssqlspatial.objclass, pointssqlspatial.alpha, pointssqlspatial.isdelta, pointssqlspatial.deltar, pointssqlspatial.deltah, pointssqlspatial.sigwidth, pointssqlspatial.sigheight, pointssqlspatial.shape, pointssqlspatial.tesselcode, pointssqlspatial.tesselnumh, pointssqlspatial.tesselnumr"
"                          Buffers: shared hit=13887"
"                          Worker 0: actual time=0.007..35.803 rows=101712 loops=1"
"                            Buffers: shared hit=3179"
"                          Worker 1: actual time=0.007..38.871 rows=113216 loops=1"
"                            Buffers: shared hit=3538"
"                    ->  Hash  (cost=6741.07..6741.07 rows=143307 width=39) (actual time=51.947..51.947 rows=143307 loops=3)"
"                          Output: ax14004x11003.ax14004x11003_objid"
"                          Buckets: 262144  Batches: 1  Memory Usage: 11985kB"
"                          Buffers: shared hit=15924"
"                          Worker 0: actual time=55.980..55.980 rows=143307 loops=1"
"                            Buffers: shared hit=5308"
"                          Worker 1: actual time=55.985..55.985 rows=143307 loops=1"
"                            Buffers: shared hit=5308"
"                          ->  Seq Scan on public.ax14004x11003  (cost=0.00..6741.07 rows=143307 width=39) (actual time=0.106..26.172 rows=143307 loops=3)"
"                                Output: ax14004x11003.ax14004x11003_objid"
"                                Buffers: shared hit=15924"
"                                Worker 0: actual time=0.143..30.242 rows=143307 loops=1"
"                                  Buffers: shared hit=5308"
"                                Worker 1: actual time=0.165..29.961 rows=143307 loops=1"
"                                  Buffers: shared hit=5308"
"              ->  Bitmap Heap Scan on public.polyssqlspatial  (cost=1.66..77.29 rows=47 width=386) (actual time=0.367..1.716 rows=8 loops=143306)"
"                    Output: polyssqlspatial.objid, polyssqlspatial.layerid, polyssqlspatial.povchanged, polyssqlspatial.georestr, polyssqlspatial.dokucount, polyssqlspatial.defid, polyssqlspatial.objpri, polyssqlspatial.objclass, polyssqlspatial.rsp, polyssqlspatial.hsp, polyssqlspatial.alphasp, polyssqlspatial.sigbegin, polyssqlspatial.sigend, polyssqlspatial.schalter, polyssqlspatial.alphafs, polyssqlspatial.sizemm, polyssqlspatial.shape, polyssqlspatial.tesselcode, polyssqlspatial.tesselnumh, polyssqlspatial.tesselnumr"
"                    Recheck Cond: ((pointssqlspatial.shape && polyssqlspatial.shape) OR (polyssqlspatial.shape ~ pointssqlspatial.shape))"
"                    Filter: (((pointssqlspatial.shape && polyssqlspatial.shape) AND _st_touches(pointssqlspatial.shape, polyssqlspatial.shape)) OR ((polyssqlspatial.shape ~ pointssqlspatial.shape) AND _st_contains(polyssqlspatial.shape, pointssqlspatial.shape)))"
"                    Rows Removed by Filter: 8"
"                    Heap Blocks: exact=664156"
"                    Buffers: shared hit=3905588"
"                    Worker 0: actual time=0.368..1.721 rows=8 loops=47624"
"                      Buffers: shared hit=1298469"
"                    Worker 1: actual time=0.367..1.719 rows=8 loops=47693"
"                      Buffers: shared hit=1303116"
"                    ->  BitmapOr  (cost=1.66..1.66 rows=142 width=0) (actual time=0.159..0.159 rows=0 loops=143306)"
"                          Buffers: shared hit=1916131"
"                          Worker 0: actual time=0.160..0.160 rows=0 loops=47624"
"                            Buffers: shared hit=636834"
"                          Worker 1: actual time=0.159..0.159 rows=0 loops=47693"
"                            Buffers: shared hit=639450"
"                          ->  Bitmap Index Scan on spatial_idx_polyssqlspatial  (cost=0.00..0.38 rows=13 width=0) (actual time=0.083..0.083 rows=15 loops=143306)"
"                                Index Cond: (pointssqlspatial.shape && polyssqlspatial.shape)"
"                                Buffers: shared hit=959006"
"                                Worker 0: actual time=0.083..0.083 rows=15 loops=47624"
"                                  Buffers: shared hit=318734"
"                                Worker 1: actual time=0.083..0.083 rows=15 loops=47693"
"                                  Buffers: shared hit=320027"
"                          ->  Bitmap Index Scan on spatial_idx_polyssqlspatial  (cost=0.00..1.25 rows=129 width=0) (actual time=0.075..0.075 rows=15 loops=143306)"
"                                Index Cond: (polyssqlspatial.shape ~ pointssqlspatial.shape)"
"                                Buffers: shared hit=957125"
"                                Worker 0: actual time=0.075..0.075 rows=15 loops=47624"
"                                  Buffers: shared hit=318100"
"                                Worker 1: actual time=0.075..0.075 rows=15 loops=47693"
"                                  Buffers: shared hit=319423"
"        ->  Hash  (cost=4399.32..4399.32 rows=44932 width=39) (actual time=28.007..28.007 rows=44932 loops=3)"
"              Output: ax11001.ax11001_objid"
"              Buckets: 65536  Batches: 1  Memory Usage: 3628kB"
"              Buffers: shared hit=11850"
"              Worker 0: actual time=31.586..31.586 rows=44932 loops=1"
"                Buffers: shared hit=3950"
"              Worker 1: actual time=31.563..31.563 rows=44932 loops=1"
"                Buffers: shared hit=3950"
"              ->  Seq Scan on public.ax11001  (cost=0.00..4399.32 rows=44932 width=39) (actual time=0.080..20.297 rows=44932 loops=3)"
"                    Output: ax11001.ax11001_objid"
"                    Buffers: shared hit=11850"
"                    Worker 0: actual time=0.145..23.801 rows=44932 loops=1"
"                      Buffers: shared hit=3950"
"                    Worker 1: actual time=0.081..23.693 rows=44932 loops=1"
"                      Buffers: shared hit=3950"
"Planning time: 24.645 ms"
"Execution time: 83260.579 ms"

Query Plan for PostgreSQL 13 Server

    "Nested Loop  (cost=7653.57..426137274.01 rows=938 width=77) (actual time=43124.328..40067741.585 rows=373890 loops=1)"
"  Output: polyssqlspatial.objid, pointssqlspatial.objid"
"  Join Filter: (polyssqlspatial.objid = (ax11001.ax11001_objid)::bpchar)"
"  Rows Removed by Join Filter: 49174195414"
"  Buffers: shared read=323, temp read=521648910 written=11610"
"  ->  Index Only Scan using ixax11001_objid on public.ax11001  (cost=0.41..1489.39 rows=44932 width=39) (actual time=14.773..203.962 rows=44932 loops=1)"
"        Output: ax11001.ax11001_objid"
"        Heap Fetches: 0"
"        Buffers: shared hit=1 read=323"
"  ->  Materialize  (cost=7653.15..424321437.18 rows=2692 width=77) (actual time=0.027..368.951 rows=1094422 loops=44932)"
"        Output: polyssqlspatial.objid, pointssqlspatial.objid"
"        Buffers: shared hit=4561020, temp read=521648910 written=11610"
"        ->  Gather  (cost=7653.15..424321423.72 rows=2692 width=77) (actual time=116.830..40941.662 rows=1094422 loops=1)"
"              Output: polyssqlspatial.objid, pointssqlspatial.objid"
"              Workers Planned: 2"
"              Workers Launched: 2"
"              Buffers: shared hit=4561020"
"              ->  Nested Loop  (cost=6653.15..424320154.52 rows=1122 width=77) (actual time=55.248..41528.751 rows=364807 loops=3)"
"                    Output: polyssqlspatial.objid, pointssqlspatial.objid"
"                    Buffers: shared hit=4561020"
"                    Worker 0:  actual time=22.459..42090.385 rows=374235 loops=1"
"                      Buffers: shared hit=1558962"
"                    Worker 1:  actual time=28.819..41980.088 rows=365154 loops=1"
"                      Buffers: shared hit=1515646"
"                    ->  Parallel Hash Join  (cost=6651.50..23781.16 rows=59711 width=79) (actual time=54.054..317.307 rows=47769 loops=3)"
"                          Output: pointssqlspatial.objid, pointssqlspatial.shape"
"                          Hash Cond: (pointssqlspatial.objid = (ax14004x11003.ax14004x11003_objid)::bpchar)"
"                          Buffers: shared hit=19716"
"                          Worker 0:  actual time=20.690..315.936 rows=48973 loops=1"
"                            Buffers: shared hit=5797"
"                          Worker 1:  actual time=27.753..275.461 rows=47845 loops=1"
"                            Buffers: shared hit=4934"
"                          ->  Parallel Seq Scan on public.pointssqlspatial  (cost=0.00..16186.53 rows=185153 width=79) (actual time=0.024..55.810 rows=148123 loops=3)"
"                                Output: pointssqlspatial.objid, pointssqlspatial.layerid, pointssqlspatial.tesselcode, pointssqlspatial.tesselnumh, pointssqlspatial.tesselnumr, pointssqlspatial.povchanged, pointssqlspatial.georestr, pointssqlspatial.dokucount, pointssqlspatial.defid, pointssqlspatial.objpri, pointssqlspatial.objclass, pointssqlspatial.alpha, pointssqlspatial.isdelta, pointssqlspatial.deltar, pointssqlspatial.deltah, pointssqlspatial.sigwidth, pointssqlspatial.sigheight, pointssqlspatial.shape"
"                                Buffers: shared hit=14335"
"                                Worker 0:  actual time=0.024..64.994 rows=160983 loops=1"
"                                  Buffers: shared hit=5193"
"                                Worker 1:  actual time=0.026..49.194 rows=128340 loops=1"
"                                  Buffers: shared hit=4140"
"                          ->  Parallel Hash  (cost=5905.11..5905.11 rows=59711 width=39) (actual time=52.555..52.557 rows=47769 loops=3)"
"                                Output: ax14004x11003.ax14004x11003_objid"
"                                Buckets: 262144  Batches: 1  Memory Usage: 12192kB"
"                                Buffers: shared hit=5308"
"                                Worker 0:  actual time=20.150..20.151 rows=15354 loops=1"
"                                  Buffers: shared hit=569"
"                                Worker 1:  actual time=27.197..27.199 rows=20493 loops=1"
"                                  Buffers: shared hit=759"
"                                ->  Parallel Seq Scan on public.ax14004x11003  (cost=0.00..5905.11 rows=59711 width=39) (actual time=0.026..31.099 rows=47769 loops=3)"
"                                      Output: ax14004x11003.ax14004x11003_objid"
"                                      Buffers: shared hit=5308"
"                                      Worker 0:  actual time=0.028..11.930 rows=15354 loops=1"
"                                        Buffers: shared hit=569"
"                                      Worker 1:  actual time=0.027..16.306 rows=20493 loops=1"
"                                        Buffers: shared hit=759"
"                    ->  Bitmap Heap Scan on public.polyssqlspatial  (cost=1.65..7105.57 rows=26 width=385) (actual time=0.409..0.846 rows=8 loops=143306)"
"                          Output: polyssqlspatial.objid, polyssqlspatial.layerid, polyssqlspatial.tesselcode, polyssqlspatial.tesselnumh, polyssqlspatial.tesselnumr, polyssqlspatial.povchanged, polyssqlspatial.georestr, polyssqlspatial.dokucount, polyssqlspatial.defid, polyssqlspatial.objpri, polyssqlspatial.objclass, polyssqlspatial.rsp, polyssqlspatial.hsp, polyssqlspatial.alphasp, polyssqlspatial.sigbegin, polyssqlspatial.sigend, polyssqlspatial.schalter, polyssqlspatial.alphafs, polyssqlspatial.sizemm, polyssqlspatial.shape"
"                          Recheck Cond: (st_touches(pointssqlspatial.shape, polyssqlspatial.shape) OR st_within(pointssqlspatial.shape, polyssqlspatial.shape))"
"                          Filter: (st_touches(pointssqlspatial.shape, polyssqlspatial.shape) OR st_within(pointssqlspatial.shape, polyssqlspatial.shape))"
"                          Rows Removed by Filter: 8"
"                          Heap Blocks: exact=616261"
"                          Buffers: shared hit=4541304"
"                          Worker 0:  actual time=0.402..0.835 rows=8 loops=48973"
"                            Buffers: shared hit=1553165"
"                          Worker 1:  actual time=0.422..0.855 rows=8 loops=47845"
"                            Buffers: shared hit=1510712"
"                          ->  BitmapOr  (cost=1.65..1.65 rows=142 width=0) (actual time=0.301..0.301 rows=0 loops=143306)"
"                                Buffers: shared hit=2640396"
"                                Worker 0:  actual time=0.292..0.292 rows=0 loops=48973"
"                                  Buffers: shared hit=904433"
"                                Worker 1:  actual time=0.315..0.315 rows=0 loops=47845"
"                                  Buffers: shared hit=874797"
"                                ->  Bitmap Index Scan on spatial_idx_polyssqlspatial  (cost=0.00..0.38 rows=13 width=0) (actual time=0.158..0.158 rows=15 loops=143306)"
"                                      Index Cond: (polyssqlspatial.shape && pointssqlspatial.shape)"
"                                      Buffers: shared hit=1321443"
"                                      Worker 0:  actual time=0.150..0.150 rows=15 loops=48973"
"                                        Buffers: shared hit=452642"
"                                      Worker 1:  actual time=0.171..0.171 rows=15 loops=47845"
"                                        Buffers: shared hit=437805"
"                                ->  Bitmap Index Scan on spatial_idx_polyssqlspatial  (cost=0.00..1.25 rows=129 width=0) (actual time=0.142..0.142 rows=15 loops=143306)"
"                                      Index Cond: (polyssqlspatial.shape ~ pointssqlspatial.shape)"
"                                      Buffers: shared hit=1318953"
"                                      Worker 0:  actual time=0.140..0.140 rows=15 loops=48973"
"                                        Buffers: shared hit=451791"
"                                      Worker 1:  actual time=0.142..0.142 rows=15 loops=47845"
"                                        Buffers: shared hit=436992"
"Planning:"
"  Buffers: shared hit=477 dirtied=1"
"Planning Time: 77.195 ms"
"Execution Time: 40068039.569 ms"


来源: stackexchange

问:
Class member function with argument run asynchronously
I am trying to asynchronously run a member function, but I seem to have issues with every attempt.
Here is my code example:

```<code>A::A(){}
A::~A(){}
void A::asyncFunc(int i)
{
    std::cout<< i ;
}

void A::otherFunc()
{
    std::future<void> t;
    for(int i = 0; i<bigNumber; i++)
    {
        t = std::async(std::launch::async, &A::asyncFunc, this, i); // Problem code line
    }
}
</code>```

With this code I'm being prompted with: "No instance of overloaded function std::async matches the argument list".

```<code>t = std::async(std::launch::async, static_cast<void(A::*)(int)>(&A::asyncFunc), this, i);
</code>```

Same issue with explicitly casting it.
So I thought that maybe I can try lambdas.

```<code>t = std::async(std::launch::async, [=](){ asyncFunc(i); });
t = std::async(std::launch::async, [=](){ &A::asyncFunc(i); });
</code>```

But this time I'm prompted with: "An enclosing-function local variable cannot be referenced in a lambda body unless it is in the capture list".

Do you know what I'm doing wrong in both cases?

ContentLicense: CC BY-SA 4.0

Body:
I am trying to asynchronously run a member function, but I seem to have issues with every attempt.
Here is my code example:

A::A(){}
A::~A(){}
void A::asyncFunc(int i)
{
    std::cout<< i ;
}

void A::otherFunc()
{
    std::future<void> t;
    for(int i = 0; i<bigNumber; i++)
    {
        t = std::async(std::launch::async, &A::asyncFunc, this, i); // Problem code line
    }
}

With this code I'm being prompted with: "No instance of overloaded function std::async matches the argument list".

t = std::async(std::launch::async, static_cast<void(A::*)(int)>(&A::asyncFunc), this, i);

Same issue with explicitly casting it.
So I thought that maybe I can try lambdas.

t = std::async(std::launch::async, [=](){ asyncFunc(i); });
t = std::async(std::launch::async, [=](){ &A::asyncFunc(i); });

But this time I'm prompted with: "An enclosing-function local variable cannot be referenced in a lambda body unless it is in the capture list".

Do you know what I'm doing wrong in both cases?


问:
Esim: carrier privileges returns false
I shared app's release sha-256 key and package name with eSim creating vendor, he added to profile metadata, but

```<code>fun checkCarrierPrivileges(): Boolean {
    val telephonyManager =
        context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
    val isCarrier = telephonyManager.hasCarrierPrivileges()
    return if (isCarrier) {
        Log.i(EsimHandler.TAG_ESIM, context.getString(R.string.ready_carrier_privileges))
        true
    } else {
        Log.i(
            EsimHandler.TAG_ESIM,
            context.getString(R.string.no_carrier_privileges_detected)
        )
        false
    }
}
</code>```

code returns false

you can view code in this gist https://gist.github.com/AbrorEsonov/c8e8dce58c776d93185678e8af79bcb0  resultCode and detailedCode in this gist

when I have manualy added LPA code that vendor gave me to  samsung S21, I saw metadata on Logcat, package name and SHA-256 is included in it

Title: Esim: carrier privileges returns false

Body:
I shared app's release sha-256 key and package name with eSim creating vendor, he added to profile metadata, but

fun checkCarrierPrivileges(): Boolean {
    val telephonyManager =
        context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager
    val isCarrier = telephonyManager.hasCarrierPrivileges()
    return if (isCarrier) {
        Log.i(EsimHandler.TAG_ESIM, context.getString(R.string.ready_carrier_privileges))
        true
    } else {
        Log.i(
            EsimHandler.TAG_ESIM,
            context.getString(R.string.no_carrier_privileges_detected)
        )
        false
    }
}

code returns false

you can view code in this gist https://gist.github.com/AbrorEsonov/c8e8dce58c776d93185678e8af79bcb0  resultCode and detailedCode in this gist

when I have manualy added LPA code that vendor gave me to  samsung S21, I saw metadata on Logcat, package name and SHA-256 is included in it


问:
How to implement 2 neural networks using Pytorch for double Q-learning?
I am trying to implement double Q-learning (with a separate target and prediction network) using Pytorch and I am not sure if this is the right way

```<code>class Trainer:
    def __init__(self, model, lr, gamma) -> None:
        self.lr = lr
        self.gamma = gamma
        self.model = model
        self.model_target = copy.deepcopy(self.model)
        self.optimiser = optim.Adam(self.model.parameters(), lr=self.lr)
        self.criterion = nn.MSELoss()

    def train_step(self, state, action, reward, next_state, done, n_games):
        state = torch.tensor(state, dtype=torch.float)
        next_state = torch.tensor(next_state, dtype=torch.float)
        action = torch.tensor(action, dtype=torch.long)
        reward = torch.tensor(reward, dtype=torch.float)

        if len(state.shape) == 1:
            state = torch.unsqueeze(state, 0)
            next_state = torch.unsqueeze(next_state, 0)
            action = torch.unsqueeze(action, 0)
            reward = torch.unsqueeze(reward, 0)
            done = (done, )

        pred = self.model(state)
        target = pred.clone()

        for idx in range(len(done)):
            Q_new = reward[idx]
            if not done[idx]:
                # Q_new = reward[idx] + self.gamma*torch.max(self.model(next_state[idx]))
                Q_new = reward[idx] + self.gamma*torch.max(self.model_target(next_state[idx]))

            target[idx][torch.argmax(action[idx]).item()] = Q_new

        self.optimiser.zero_grad()
        loss = self.criterion(target, pred)
        loss.backward()
        self.optimiser.step()

        if n_games%10 == 0:
            self.model_target = copy.deepcopy(self.model)
</code>```

As you can see, I am trying to use the target network to predict Q_new as the TD target and only updates its weights every 10 games (episodes) by a deepcopy of the prediction model. But I am unsure if

```<code>optimiser.step()
</code>```

also updates the target network at every step.

Body:
I am trying to implement double Q-learning (with a separate target and prediction network) using Pytorch and I am not sure if this is the right way

class Trainer:
    def __init__(self, model, lr, gamma) -> None:
        self.lr = lr
        self.gamma = gamma
        self.model = model
        self.model_target = copy.deepcopy(self.model)
        self.optimiser = optim.Adam(self.model.parameters(), lr=self.lr)
        self.criterion = nn.MSELoss()

    def train_step(self, state, action, reward, next_state, done, n_games):
        state = torch.tensor(state, dtype=torch.float)
        next_state = torch.tensor(next_state, dtype=torch.float)
        action = torch.tensor(action, dtype=torch.long)
        reward = torch.tensor(reward, dtype=torch.float)

        if len(state.shape) == 1:
            state = torch.unsqueeze(state, 0)
            next_state = torch.unsqueeze(next_state, 0)
            action = torch.unsqueeze(action, 0)
            reward = torch.unsqueeze(reward, 0)
            done = (done, )

        pred = self.model(state)
        target = pred.clone()

        for idx in range(len(done)):
            Q_new = reward[idx]
            if not done[idx]:
                # Q_new = reward[idx] + self.gamma*torch.max(self.model(next_state[idx]))
                Q_new = reward[idx] + self.gamma*torch.max(self.model_target(next_state[idx]))

            target[idx][torch.argmax(action[idx]).item()] = Q_new

        self.optimiser.zero_grad()
        loss = self.criterion(target, pred)
        loss.backward()
        self.optimiser.step()

        if n_games%10 == 0:
            self.model_target = copy.deepcopy(self.model)

As you can see, I am trying to use the target network to predict Q_new as the TD target and only updates its weights every 10 games (episodes) by a deepcopy of the prediction model. But I am unsure if

optimiser.step()

also updates the target network at every step.


问:
iPad App Stops Loading Local HTML Page - Cache Problem?
I created an html file that opens when the user taps a button in the iPad app. The html page resides on the iPad device. Unfortunately, if the user opens the html page immediately after opening the app, some of the images don't load, and the the display won't rotate when your turn the device 90 degrees. Also, the spinner that indicates that some kind of processing is happening keeps spinning for 3 minutes or more.

If the user exits the app and then reopens the app and opens the html page, it usually works fine.

If you open a remote version of the html page using the same iPad device outside the app, the html file loads and rotates perfectly all the time.

The html page includes about 70 small images, which take up a total of 221 KB.

I know there is an Apple bug that stops a page from loading after 6.5 mb has been downloaded, but the 221 KB is well under the 6.5 MB limit.

I think the problem might lie with how the app calls the html file or caches the data, but I am stumpted as to what specifically needs to be fixed.

Can anyone help?  Thanks very much.

ContentLicense: CC BY-SA 3.0


问:
How to iterate the object array only if boolean condition false in angular?
I have two Json file below I attached, if one Json file boolean value false the corresponding another Json value field data need to show in the table format.

So if boolean value is false corresponding it is need to iterate in table

First Json file

```<code>    "gmbAuditData": [{
        "gmbtitle": [{
                "id": 1,
                "done": "Yes"
            },
            {
                "id": 2,
                "done": "Yes"
            },
            {
                "id": 3,
                "done": "Yes"
            }
        ],
        "gmbcategory": [{
                "id": 1,
                "done": "Yes"
            },
            {
                "id": 2,
                "done": "No"
            },
            {
                "id": 3,
                "done": "No"
            },
            {
                "id": 4,
                "done": "No"
            }
        ]

    }]
}
</code>```

Second Json file

**It needs to iterate only false **

It needs to come like this table format

It needs to come like this table

Body:
I have two Json file below I attached, if one Json file boolean value false the corresponding another Json value field data need to show in the table format.

So if boolean value is false corresponding it is need to iterate in table

First Json file

    "gmbAuditData": [{
        "gmbtitle": [{
                "id": 1,
                "done": "Yes"
            },
            {
                "id": 2,
                "done": "Yes"
            },
            {
                "id": 3,
                "done": "Yes"
            }
        ],
        "gmbcategory": [{
                "id": 1,
                "done": "Yes"
            },
            {
                "id": 2,
                "done": "No"
            },
            {
                "id": 3,
                "done": "No"
            },
            {
                "id": 4,
                "done": "No"
            }
        ]

    }]
}

Second Json file

**It needs to iterate only false **

It needs to come like this table format

It needs to come like this table


问:
onCleared() not Triggered in Jetpack Compose when app closes
So I'm initializing a simple View Model inside the scope of a single composable screen:

```<code>composable(route = "MainScreen") {
    val viewModel: MainViewModel = viewModel()
    MainScreen()
}
</code>```

When I try to navigate back from that MainScreen to my HomeScreen, by using the navController.popBackStack() function, then the onCleared() function of a View Model is actually triggered. Which is expected.

However, when I exit/close the app from my smartphone, by using the navigation bar on the bottom, then that onCleared() function is NOT triggered, even though the app is closed along with the View Model itself. I'm confused, how's that possible?

Body:
So I'm initializing a simple View Model inside the scope of a single composable screen:

composable(route = "MainScreen") {
    val viewModel: MainViewModel = viewModel()
    MainScreen()
}

When I try to navigate back from that MainScreen to my HomeScreen, by using the navController.popBackStack() function, then the onCleared() function of a View Model is actually triggered. Which is expected.

However, when I exit/close the app from my smartphone, by using the navigation bar on the bottom, then that onCleared() function is NOT triggered, even though the app is closed along with the View Model itself. I'm confused, how's that possible?


问:
jib maven plugin configuration settings in pom.xml aren't inherited from parent maven project
I have a parent project where it contains maven jib plugin configuration.
I'm creating an image of the child project (mapped to the parent project), the image is created however it's not inheriting the parent maven jib plugin configuration.

Kindly advice if there's any settings to be done to force inherit jib maven plugin configuration from parent project.

PS: in eclipse Effective POM of the child project, I can see the inherited configuration however when running the image build they are skipped.


Body:
How can solve that issue?

What is the error here? And how can I fix that? I tried previous code but I faced that value error problem. How can easily fix that?

data = np.load('/test.npy')

data.shape

(3, 1985, 2257)

cv.imwrite('/zlatan1598797521604a_0.png', data\[2\])

cv.imwrite('/zlatan1598797521604a_1.png', data\[2\])

cv.imwrite('/zlatan1598797521604a_2.png', data\[2\])

cv.imread('/zlatan1598797521604a_0.png', 0)

cv.imread('/zlatan1598797521604a_1.png', 0)

cv.imread('/zlatan1598797521604a_2.png', 0)

array([[ 78,  55,  58, ..., 170, 180, 181],
       [ 74,  80,  70, ..., 180, 178, 172],
       [ 73,  82,  66, ..., 196, 200, 197],
       ...,
       [  8,   9,  11, ..., 184, 181, 183],
       [  9,  13,  15, ..., 181, 181, 180],
       [ 10,   5,  13, ..., 188, 185, 179]], dtype=uint8)

Img_example1[:,:,0]=data[0,:,:]
Img_example1[:,:,1]=data[1,:,:]
Img_example1[:,:,2]=data[2,:,:]
plt.imshow(Img_example1)
plt.savefig('zlatan1598797521604a.png')
plt.show()

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_17764/3038824776.py in <module>
----> 1 Img_example1[:,:,0]=data[0,:,:]
      2 Img_example1[:,:,1]=data[1,:,:]
      3 Img_example1[:,:,2]=data[2,:,:]
      4 plt.imshow(Img_example1)
      5 plt.savefig('zlatan1598797521604a.png')

ValueError: could not broadcast input array from shape (1985,2257) into shape (3024,4032)


问:
Is there a way to retrieve all the edges chain from a large graph, based on certain edges parameters?
Problem statement:
A directed graph with vertices A, B, C, D, E, F, G, H & I is present.
sample graph
The program should be able to extract all the possible edge chains on basis of certain edge property. As per this graph, say angle of edges is considered relative to its connected edge and an edges with angle less than 20 degrees would belong to same edges chain.

```<code>Expected output would be
Edge chain 1: [A-C, C-F]
Edge chain 2: [H-G, G-C, C-B]
Edge chain 3: [C-E]
and so on...
</code>```

Explanation: A-C has neighbouring edges C-B, C-D, C-E, & C-F. Note that G-C is not considered as it is in the opposite direction. A-C & C-F have the minimal angle if a straight line is formed from A-C.

Approaches explored:

For a very small graph, using a simple DFS would be a good solution.

For a large dataset, a distributed computation is being explored using Apache Spark but I am not able to build a DFS to work with JavaRDD. I can simply perform a .collect() on my JavaRDD & create a

```<code>Map<Vertex, List<Edges>>.
</code>```

But again, this is same as approach 1 & not at all efficient.

I am looking at Spark GraphFrame, but from the documentations, I am not able to figure our how can I scan the entire graph and get all the edge chains.

I have been thinking dividing my large dataset into groups of smaller

```<code>Map<Vertex, List<Edges>>
</code>```

& create smaller edge chains & then merge them. But again I won't know when should I stop merging.

Anyone faced a similar scenario & what can be a better solution here? Is it possible to achieve this using Spark GraphFrame?

Body:
Problem statement:
A directed graph with vertices A, B, C, D, E, F, G, H & I is present.
sample graph
The program should be able to extract all the possible edge chains on basis of certain edge property. As per this graph, say angle of edges is considered relative to its connected edge and an edges with angle less than 20 degrees would belong to same edges chain.

Expected output would be
Edge chain 1: [A-C, C-F]
Edge chain 2: [H-G, G-C, C-B]
Edge chain 3: [C-E]
and so on...

Explanation: A-C has neighbouring edges C-B, C-D, C-E, & C-F. Note that G-C is not considered as it is in the opposite direction. A-C & C-F have the minimal angle if a straight line is formed from A-C.

Approaches explored:

For a very small graph, using a simple DFS would be a good solution.

For a large dataset, a distributed computation is being explored using Apache Spark but I am not able to build a DFS to work with JavaRDD. I can simply perform a .collect() on my JavaRDD & create a

Map<Vertex, List<Edges>>.

But again, this is same as approach 1 & not at all efficient.

I am looking at Spark GraphFrame, but from the documentations, I am not able to figure our how can I scan the entire graph and get all the edge chains.

I have been thinking dividing my large dataset into groups of smaller

Map<Vertex, List<Edges>>

& create smaller edge chains & then merge them. But again I won't know when should I stop merging.

Anyone faced a similar scenario & what can be a better solution here? Is it possible to achieve this using Spark GraphFrame?


问:
Bringing Earth Observation results from Python into Squarespace using Leaflet
The broader question is confirming how to set up even a basic leaflet map in a Squarespace code block.

My end goal is to have an easy way to display the results of Earth observation approaches done mainly in Python without building a website from scratch. I am wondering if anyone here has a good way of organizing this. Some ideas...

Work in Python and use leaflet to export to HTML

Use Github to host outside of Squarespace, maybe then using an Iframe to bring it in

The setup of Squarespace has a separate section for the header in the menu's advanced settings. That may be what is throwing me off. At the moment I have links to leaflet.js there and am working in the code block with javascript. I think I am missing the format between them.

Thanks for the help!

I have tried:

Direct HTML paste into the header section of squarespace's menu. This code was used for testing: https://joshuafrazier.info/leaflet-basics/

This resulted in a map created as expected at the top of the page. Close, but not exactly what I am looking for.

Direct HTML paste into the code block with the same code. This did not work.


问:
How to migrate context.Resource as AuthorizationFilterContext from asp.net core 2.1 to .NET 6?
I have migrated my project from asp.net core 2.1 to .NET 6, and now I am facing an error with
context.Resource as AuthorizationFilterContext which is return NULL.

I have implemented a custom Policy-based authorization using AuthorizationFilterContext,  It seems that.NET 6 does not support AuthorizationFilterContext Please help me how to modify the below code from asp.net core 2.1 to .NET6. thank you.

Here is the error message in this line var mvcContext = context.Resource as AuthorizationFilterContext;

mvcContext == NULL

Here is the Implementation Code of AuthorizationHandler and AuthorizationHandlerContext

```<code>public class HasAccessRequirment : IAuthorizationRequirement { }
    public class HasAccessHandler : AuthorizationHandler<HasAccessRequirment>
    {
        public readonly HoshmandDBContext _context;
        public HasAccessHandler(HoshmandDBContext context)
        {
            _context = context;
        }
        protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, HasAccessRequirment requirement)
        {
            Contract.Ensures(Contract.Result<Task>() != null);
            List<int?> userGroupIds = new List<int?>();
            // receive the function informations

            var mvcContext = context.Resource as AuthorizationFilterContext;
            if ((mvcContext != null) && !context.User.Identity.IsAuthenticated)
            {
                mvcContext.Result = new RedirectToActionResult("UserLogin", "Logins", null);
                return Task.FromResult(Type.Missing);
            }
            if (!(mvcContext?.ActionDescriptor is ControllerActionDescriptor descriptor))
            {
                return Task.FromResult(Type.Missing);
            }
            var currntActionAddress = descriptor.ControllerName + "/" + descriptor.ActionName;
            // finding all information about controller and method from Tables
            // check user has access to current action which is being called
            //allActionInfo = ListAcctionsFromDatabase;
            //bool isPostBack = allActionInfo.FirstOrDefault(a => a.action == currntActionAddress)?.IsMenu ?? true;
            bool isPostBack = false;
            if (!isPostBack)
            {
                mvcContext.Result = new RedirectToActionResult("AccessDenied", descriptor.ControllerName, null);
                context.Succeed(requirement);
                return Task.CompletedTask;
            }
            else
            {
                mvcContext.Result = new RedirectToActionResult("AccessDeniedView", descriptor.ControllerName, null);
                context.Succeed(requirement);
                return Task.CompletedTask;
            }

        }
    }
</code>```

Here is my Program.cs Code:

```<code>builder.Services.AddAuthorization(options =>
{
    options.AddPolicy("HasAccess", policy => policy.AddRequirements(new HasAccessRequirment()));
});

builder.Services.AddTransient<IAuthorizationHandler, HasAccessHandler>();
</code>```

Here is the Controller Code:

```<code>   [Authorize(policy: "HasAccess")]
    public class HomeController : BaseController
    {
    }
</code>```

Body:
I have migrated my project from asp.net core 2.1 to .NET 6, and now I am facing an error with
context.Resource as AuthorizationFilterContext which is return NULL.

I have implemented a custom Policy-based authorization using AuthorizationFilterContext,  It seems that.NET 6 does not support AuthorizationFilterContext Please help me how to modify the below code from asp.net core 2.1 to .NET6. thank you.

Here is the error message in this line var mvcContext = context.Resource as AuthorizationFilterContext;

mvcContext == NULL

Here is the Implementation Code of AuthorizationHandler and AuthorizationHandlerContext

public class HasAccessRequirment : IAuthorizationRequirement { }
    public class HasAccessHandler : AuthorizationHandler<HasAccessRequirment>
    {
        public readonly HoshmandDBContext _context;
        public HasAccessHandler(HoshmandDBContext context)
        {
            _context = context;
        }
        protected override Task HandleRequirementAsync(AuthorizationHandlerContext context, HasAccessRequirment requirement)
        {
            Contract.Ensures(Contract.Result<Task>() != null);
            List<int?> userGroupIds = new List<int?>();
            // receive the function informations

            var mvcContext = context.Resource as AuthorizationFilterContext;
            if ((mvcContext != null) && !context.User.Identity.IsAuthenticated)
            {
                mvcContext.Result = new RedirectToActionResult("UserLogin", "Logins", null);
                return Task.FromResult(Type.Missing);
            }
            if (!(mvcContext?.ActionDescriptor is ControllerActionDescriptor descriptor))
            {
                return Task.FromResult(Type.Missing);
            }
            var currntActionAddress = descriptor.ControllerName + "/" + descriptor.ActionName;
            // finding all information about controller and method from Tables
            // check user has access to current action which is being called
            //allActionInfo = ListAcctionsFromDatabase;
            //bool isPostBack = allActionInfo.FirstOrDefault(a => a.action == currntActionAddress)?.IsMenu ?? true;
            bool isPostBack = false;
            if (!isPostBack)
            {
                mvcContext.Result = new RedirectToActionResult("AccessDenied", descriptor.ControllerName, null);
                context.Succeed(requirement);
                return Task.CompletedTask;
            }
            else
            {
                mvcContext.Result = new RedirectToActionResult("AccessDeniedView", descriptor.ControllerName, null);
                context.Succeed(requirement);
                return Task.CompletedTask;
            }

        }
    }

Here is my Program.cs Code:

builder.Services.AddAuthorization(options =>
{
    options.AddPolicy("HasAccess", policy => policy.AddRequirements(new HasAccessRequirment()));
});

builder.Services.AddTransient<IAuthorizationHandler, HasAccessHandler>();

Here is the Controller Code:

   [Authorize(policy: "HasAccess")]
    public class HomeController : BaseController
    {
    }


问:
Pip SSLError only in virtual environment
I'm trying to set up a virtual environment for a coworker. I've never had any troubles installing Python packages via Pip, not in global nor in an environment. However, he is not able to install any packages in the environment. He can install them globally, however.

The error is:
"Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=pypi.org, port=443): Max retries exceed with url /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL Module is not available.")) - skipping"

We frist created the environment before installing any packages whatsoever. Then we deleted the environment, installed some packages (requests) and created a new environment. This did not help.

We tried

```<code>pip install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org
</code>```

which did not help either with the same error message.

I'm running out of ideas, any help is appreciated!

Body:
I'm trying to set up a virtual environment for a coworker. I've never had any troubles installing Python packages via Pip, not in global nor in an environment. However, he is not able to install any packages in the environment. He can install them globally, however.

The error is:
"Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=pypi.org, port=443): Max retries exceed with url /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL Module is not available.")) - skipping"

We frist created the environment before installing any packages whatsoever. Then we deleted the environment, installed some packages (requests) and created a new environment. This did not help.

We tried

pip install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org

which did not help either with the same error message.

I'm running out of ideas, any help is appreciated!


问:
Rails: Use strings like "1", "1.2", "1.2.1", and "1.2.1a" as ID values of a model
I have a tree-like structure of the Web Content Accessibility Guidelines (WCAG) with my model wcag_elements.

class WcagElement < ApplicationRecord
  acts_as_tree order: :position

  def to_param
    "#{id}-#{name.parameterize}"
  end
end
```
<p>The tree looks something like this:</p>
```1. Perceivable
1.1 Text Alternatives
1.1.1 Non-text Content
1.2 Time-based Media
(etc.)
```
<p>I even introduced another sub-level like this: <code>1.3.1a</code>, <code>1.3.1b</code>, etc.</p>
<p>This works very well. But now I want to make my URLs more use-friendly: at the moment, each element has a random ID, i.e. <code>1.1.1</code> has ID <code>3</code>. A typical URL would look like this:</p>
```www.my-app.com/wcag/3-non-text-content
```
<p>But I would rather have it like this:</p>
```www.my-app.com/wcag/1.1.1-non-text-content
```

So far, I calculated the 1.1.1 string through a method in the model, which would iterate reversely though the ancestors. But now I just store them in a field slug in the DB (their value will never change).

But I'm facing the following problem now:

Fullstops (.) don't seem to be allowed in URLs:

When entering http://localhost:3333/wcag/1.3.1 into my browser, I get a No route matches [GET] "/wcag/1.3.1" error, although I have a get "wcag/:slug", to: "wcag#show" route.

When entering http://localhost:3333/wcag/1-3-1, it will forward correctly to WcagController#show.

Is there a way to make fullstops work in this special case?

And: Should I use the slug as ID (and drop the current integer)?

I have no idea whether there's any benefit from that. I already looked into friendly_id gem, but this feels like over-engineered for my specific use case.

Thank you.

Body:
I have a tree-like structure of the Web Content Accessibility Guidelines (WCAG) with my model wcag_elements.

class WcagElement < ApplicationRecord
  acts_as_tree order: :position

  def to_param
    "#{id}-#{name.parameterize}"
  end
end

The tree looks something like this:

1. Perceivable
1.1 Text Alternatives
1.1.1 Non-text Content
1.2 Time-based Media
(etc.)

I even introduced another sub-level like this: 1.3.1a, 1.3.1b, etc.

This works very well. But now I want to make my URLs more use-friendly: at the moment, each element has a random ID, i.e. 1.1.1 has ID 3. A typical URL would look like this:

www.my-app.com/wcag/3-non-text-content

But I would rather have it like this:

www.my-app.com/wcag/1.1.1-non-text-content

So far, I calculated the 1.1.1 string through a method in the model, which would iterate reversely though the ancestors. But now I just store them in a field slug in the DB (their value will never change).

But I'm facing the following problem now:

Fullstops (.) don't seem to be allowed in URLs:

When entering http://localhost:3333/wcag/1.3.1 into my browser, I get a No route matches [GET] "/wcag/1.3.1" error, although I have a get "wcag/:slug", to: "wcag#show" route.

When entering http://localhost:3333/wcag/1-3-1, it will forward correctly to WcagController#show.

Is there a way to make fullstops work in this special case?

And: Should I use the slug as ID (and drop the current integer)?

I have no idea whether there's any benefit from that. I already looked into friendly_id gem, but this feels like over-engineered for my specific use case.

Thank you.


问:
Getting "Missing required parameters: spreadsheetId at createAPIRequestAsync" despite correct and complete request body. Does anyone know why?
Let me first start by saying that I've read through countless of StackOverflow post, here are a few I've read so far:

Google sheets API update call missing parameter - a solution on this question talked about missing OAuth2 parameter but I'm passing them down. So no problem there

google sheets api fails with missing parameter: spreadsheetId -  this one wasn't helpful either because they just wrote the name of spreadsheetid wrong

Now to my code. It's written in Node.js and runs on an AWS Lambda that is triggered by an s3-Bucket:

```<code>// IMPORT LIBRARIES, PACKAGES AND CONFIG FILES
const fs = require("fs");
const aws = require("aws-sdk");
const s3 = new aws.S3({region: 'eu-central-1'});
const { google } = require("googleapis");
const spreadSheetId = "SOME ID";

const credentials = require("./credentials.json")

// FUNCTION HANDLER FOR AWS LAMBDA
// TODO: TRY OUT METADATA AND FILENAME AND COMPARE THESE TWO
// TODO: FILENAME FIRST. BASIS IS ALREADY THERE
exports.handler = async (event, context) => {
  var datas = { processType: "update" };
  // FETCH CONTENT OF FILE
  const Bucket = event.Records[0].s3.bucket.name;
  const Key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, ' '));
  console.log("Name of file is: ", Key)
  var data = await s3.getObject({ Bucket, Key }).promise();
  console.log("Raw text:\n" + data.Body.toString('ascii'));

  // LOGIN WITH SERVICE ACCOUNT
  const jwtClient = new google.auth.JWT(
    credentials.client_id,
    null,
    credentials.private_key,
    ["https://www.googleapis.com/auth/spreadsheets"] // SCOPE
  );
  jwtClient.authorize(function (err, tokens) {
    if (err) {
      console.log(err);
      return;
    } else {
      console.log("You are now logged in!");
    }
  });

  const sheets = google.sheets({ version: "v4", auth: jwtClient });

  console.log(datas.processType)
  // check event payload for parameters
  if (!datas) {
    console.log("Event payload couldn't be found! Please try again.");
    return;
  } else {
    switch (datas.processType) {
      // case append currently not in use as update is more important
      case "append":
        var resources = {
          spreadSheetId: "SOME ID",
          resource: {
            requests: [
            {
            appendCells: {
            sheetId: 0,
            rows: [
              {
                values: [
                  {
                    userEnteredValue: {
                      stringValue: payload,
                    },
                  },
                ],
              },
            ],
            fields: "*",
          },
          }]}
        };
        break;
      case "update":
        var payloadFile =  {
          spreadsheetId: "SOME ID",
          resource: {
            requests: [
            {
              updateCells: {
                start: {
                  sheetId: 0,
                },
                rows: [
                {
                  values: [
                    {
                      userEnteredValue: {
                        stringValue: data.Body,
                      },
                    },
                  ],
                },
              ],
              fields: "*",
            },
          },
        ],
      },
    }
        break;
      default:
        console.log("Something went wrong!");
        break;
    }
    console.log("wgatgwat", payloadFile);
    await sheets.spreadsheets.batchUpdate(JSON.stringify(payloadFile)).then(function (){console.log("It worked!")}).catch(function (err){console.log(err)})
  }
};
</code>```

When being triggered by the s3 Bucket it executes but returns this error message:
Error: Missing required parameters: spreadsheetId at createAPIRequestAsync, I sadly couldn't find anything online to help me with it.

I'm just trying to connect to my Google Sheet and update or append some data but it won't let me. I've tried everything I could think of and I'm hoping that someone could point me in the right direction or show me my mistake. Thank you in advance

I tried adding/ removing an await and hoped this would change things. It didn't change anything.
I tried using JSON.stringify(payload) to see if it changes anything. It didn't change the outcome.

Body:
Let me first start by saying that I've read through countless of StackOverflow post, here are a few I've read so far:

Google sheets API update call missing parameter - a solution on this question talked about missing OAuth2 parameter but I'm passing them down. So no problem there

google sheets api fails with missing parameter: spreadsheetId -  this one wasn't helpful either because they just wrote the name of spreadsheetid wrong

Now to my code. It's written in Node.js and runs on an AWS Lambda that is triggered by an s3-Bucket:

// IMPORT LIBRARIES, PACKAGES AND CONFIG FILES
const fs = require("fs");
const aws = require("aws-sdk");
const s3 = new aws.S3({region: 'eu-central-1'});
const { google } = require("googleapis");
const spreadSheetId = "SOME ID";

const credentials = require("./credentials.json")

// FUNCTION HANDLER FOR AWS LAMBDA
// TODO: TRY OUT METADATA AND FILENAME AND COMPARE THESE TWO
// TODO: FILENAME FIRST. BASIS IS ALREADY THERE
exports.handler = async (event, context) => {
  var datas = { processType: "update" };
  // FETCH CONTENT OF FILE
  const Bucket = event.Records[0].s3.bucket.name;
  const Key = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, ' '));
  console.log("Name of file is: ", Key)
  var data = await s3.getObject({ Bucket, Key }).promise();
  console.log("Raw text:\n" + data.Body.toString('ascii'));

  // LOGIN WITH SERVICE ACCOUNT
  const jwtClient = new google.auth.JWT(
    credentials.client_id,
    null,
    credentials.private_key,
    ["https://www.googleapis.com/auth/spreadsheets"] // SCOPE
  );
  jwtClient.authorize(function (err, tokens) {
    if (err) {
      console.log(err);
      return;
    } else {
      console.log("You are now logged in!");
    }
  });

  const sheets = google.sheets({ version: "v4", auth: jwtClient });

  console.log(datas.processType)
  // check event payload for parameters
  if (!datas) {
    console.log("Event payload couldn't be found! Please try again.");
    return;
  } else {
    switch (datas.processType) {
      // case append currently not in use as update is more important
      case "append":
        var resources = {
          spreadSheetId: "SOME ID",
          resource: {
            requests: [
            {
            appendCells: {
            sheetId: 0,
            rows: [
              {
                values: [
                  {
                    userEnteredValue: {
                      stringValue: payload,
                    },
                  },
                ],
              },
            ],
            fields: "*",
          },
          }]}
        };
        break;
      case "update":
        var payloadFile =  {
          spreadsheetId: "SOME ID",
          resource: {
            requests: [
            {
              updateCells: {
                start: {
                  sheetId: 0,
                },
                rows: [
                {
                  values: [
                    {
                      userEnteredValue: {
                        stringValue: data.Body,
                      },
                    },
                  ],
                },
              ],
              fields: "*",
            },
          },
        ],
      },
    }
        break;
      default:
        console.log("Something went wrong!");
        break;
    }
    console.log("wgatgwat", payloadFile);
    await sheets.spreadsheets.batchUpdate(JSON.stringify(payloadFile)).then(function (){console.log("It worked!")}).catch(function (err){console.log(err)})
  }
};

When being triggered by the s3 Bucket it executes but returns this error message:
Error: Missing required parameters: spreadsheetId at createAPIRequestAsync, I sadly couldn't find anything online to help me with it.

I'm just trying to connect to my Google Sheet and update or append some data but it won't let me. I've tried everything I could think of and I'm hoping that someone could point me in the right direction or show me my mistake. Thank you in advance

I tried adding/ removing an await and hoped this would change things. It didn't change anything.
I tried using JSON.stringify(payload) to see if it changes anything. It didn't change the outcome.


Title: How to remove duplicate date values in pyspark prioritize non null values

Body:
This is my pyspark dataframe where you can row number 2 and 3 are duplicates if we exclude the column date2_chek, i would like to keep the columns with date having 2019-05-15, and the other to be deleted.

+---------+----------+---------+------------+-------+----------+----------+----------+
|Regnummer|gid       |user_id  |  user_pnr  |Leasing|     Date1|     Date2|Date2_chek|
+---------+----------+---------+------------+-------+----------+----------+----------+
|   XXX295|         2| 20000000|123123123233|      0|2019-03-08|      null|2022-12-07|
|   XXX295|         2|  3232323|222222200171|      0|2019-04-27|      null|2022-12-07|
|   XXX295|         2|  3232323|222222200171|      0|2019-04-27|2019-05-15|2019-05-15|
|   XXX295|         2|  9898988|        null|      0|2015-08-15|2015-12-22|2015-12-22|
|   XXX295|         2|  1234123|        null|      0|2015-12-23|2019-03-03|2019-03-03|
|   XXX295|         2|  3434344|192131231223|      0|2019-03-04|2019-03-07|2019-03-07|
+---------+----------+---------+------------+-------+----------+----------+----------+

I am expecting the below results, i want to prioritze the non null values compared to null values while removing the duplicates.

+---------+----------+---------+------------+-------+----------+----------+----------+
|Regnummer|gid       |user_id  |  user_pnr  |Leasing|     Date1|     Date2|Date2_chek|
+---------+----------+---------+------------+-------+----------+----------+----------+
|   XXX295|         2| 20000000|123123123233|      0|2019-03-08|      null|2022-12-07|
|   XXX295|         2|  3232323|222222200171|      0|2019-04-27|2019-05-15|2019-05-15|
|   XXX295|         2|  9898988|        null|      0|2015-08-15|2015-12-22|2015-12-22|
|   XXX295|         2|  1234123|        null|      0|2015-12-23|2019-03-03|2019-03-03|
|   XXX295|         2|  3434344|192131231223|      0|2019-03-04|2019-03-07|2019-03-07|
+---------+----------+---------+------------+-------+----------+----------+----------+


问:
how to implement vcard on website, to open up email program and add as contact
so I'm trying to add a button to my site, with the purpose of opening up a vcf file. I want it to work just like the "mailto:"

```<code><a href="mailto:random.mail@gmail.com">
</code>```

since this opens up the email app.
Is there a way to implement the same functionality with a vcf file?

```<code><a href="../resources/vcardfile.vcf" download>
    <button class="save-button" t="[html]contact.saveContact"></button>
</a>
</code>```

Maybe something in this direction.

Body:
so I'm trying to add a button to my site, with the purpose of opening up a vcf file. I want it to work just like the "mailto:"

since this opens up the email app.
Is there a way to implement the same functionality with a vcf file?

    <button class="save-button" t="[html]contact.saveContact"></button>

Maybe something in this direction.


问:
Knex, how to select rows that are within a certain date range
I want to select all rows using Knex which have been created in the past 30 days but I can't figure out how to do that. I know that I could for example select the rows manually using this code here:

```<code>knex('table')
  .where('createdAt', '>=', '2009-01-01T00:00:00Z')
  .where('createdAt', '<', '2010-01-01T00:00:00Z')
</code>```

However, I'd like the selection to update automatically so that I don't have to update the code every month.

Meaning, that it should now automatically select the rows from the 7th of November till the 7th of December, next month it should select the rows from the 7th of December till 7th of January, and so on.

I'm using MySQL but I don't know that should make a difference as I'm using Knex for the queries anyway.

Body:
I want to select all rows using Knex which have been created in the past 30 days but I can't figure out how to do that. I know that I could for example select the rows manually using this code here:

knex('table')
  .where('createdAt', '>=', '2009-01-01T00:00:00Z')
  .where('createdAt', '<', '2010-01-01T00:00:00Z')

However, I'd like the selection to update automatically so that I don't have to update the code every month.

Meaning, that it should now automatically select the rows from the 7th of November till the 7th of December, next month it should select the rows from the 7th of December till 7th of January, and so on.

I'm using MySQL but I don't know that should make a difference as I'm using Knex for the queries anyway.


问:
Use Amazon artifactory via vpn
Is there any way to use the amazon artifactory having a VPN instead of logging in everytime during the build?

So far, only the loggin everytime works for me

Title: Use Amazon artifactory via vpn


问:
cannot fill up form because of certain pop up after filling up some textboxes using python selenium
please help, I cannot proceed filling up the other text boxes due to the.. I think it is pop up
here is my code:

```<code>from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support import  expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import Select
import time

options = webdriver.ChromeOptions()
options.add_argument("start-maximized")

s = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=s,options=options)
main_link = r"https://www.lambdatest.com/selenium-playground/input-form-demo"
driver.get(main_link)
wait = WebDriverWait(driver,30)

name = wait.until(ec.visibility_of_element_located((By.XPATH,"//input[@id='name']")))
name.send_keys("test")
email = driver.find_element(By.XPATH,"//input[@placeholder='Email']")
email.send_keys("test@test.com")
password =  driver.find_element(By.XPATH,"//input[@placeholder='Password']")
password.send_keys("test")
company = driver.find_element(By.XPATH,"//input[@id='company']")
company.send_keys("test")
website = driver.find_element(By.XPATH,"//input[contains(@id,'website')]")
website.send_keys("test")
country = Select(driver.find_element(By.XPATH,"//select[@name='country']"))
country.select_by_visible_text("Philippines")
#pop up occurs here, pls see attached screenshot
time.sleep(5) #close the pop up
city = driver.find_element(By.XPATH,"//input[@placeholder='City']")
city.send_keys("test")
add1 = driver.find_element(By.XPATH,"//input[@id='inputAddress1']")
add1.send_keys("test")
add2 = driver.find_element(By.XPATH,"//input[@id='inputAddress2']")
add2.send_keys("test")
state = driver.find_element(By.XPATH,"//input[@placeholder='State']")
state.send_keys("test")
zip_var = driver.find_element(By.XPATH,"//input[contains(@placeholder,'Zip')]")
zip_var.send_keys("test")
button = driver.find_element(By.XPATH,"//button[text()='Submit']")
button.click()
output = wait.until(ec.visibility_of_element_located((By.XPATH,"//p[contains(@class,'success-msg')]")))
print(output.text)
</code>```

any help will do, I tried everything that I can but I am manually closing the close button on the image attached here. thanks

Body:
please help, I cannot proceed filling up the other text boxes due to the.. I think it is pop up
here is my code:

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support import  expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import Select
import time

options = webdriver.ChromeOptions()
options.add_argument("start-maximized")

s = Service(ChromeDriverManager().install())
driver = webdriver.Chrome(service=s,options=options)
main_link = r"https://www.lambdatest.com/selenium-playground/input-form-demo"
driver.get(main_link)
wait = WebDriverWait(driver,30)

name = wait.until(ec.visibility_of_element_located((By.XPATH,"//input[@id='name']")))
name.send_keys("test")
email = driver.find_element(By.XPATH,"//input[@placeholder='Email']")
email.send_keys("test@test.com")
password =  driver.find_element(By.XPATH,"//input[@placeholder='Password']")
password.send_keys("test")
company = driver.find_element(By.XPATH,"//input[@id='company']")
company.send_keys("test")
website = driver.find_element(By.XPATH,"//input[contains(@id,'website')]")
website.send_keys("test")
country = Select(driver.find_element(By.XPATH,"//select[@name='country']"))
country.select_by_visible_text("Philippines")
#pop up occurs here, pls see attached screenshot
time.sleep(5) #close the pop up
city = driver.find_element(By.XPATH,"//input[@placeholder='City']")
city.send_keys("test")
add1 = driver.find_element(By.XPATH,"//input[@id='inputAddress1']")
add1.send_keys("test")
add2 = driver.find_element(By.XPATH,"//input[@id='inputAddress2']")
add2.send_keys("test")
state = driver.find_element(By.XPATH,"//input[@placeholder='State']")
state.send_keys("test")
zip_var = driver.find_element(By.XPATH,"//input[contains(@placeholder,'Zip')]")
zip_var.send_keys("test")
button = driver.find_element(By.XPATH,"//button[text()='Submit']")
button.click()
output = wait.until(ec.visibility_of_element_located((By.XPATH,"//p[contains(@class,'success-msg')]")))
print(output.text)

any help will do, I tried everything that I can but I am manually closing the close button on the image attached here. thanks


问:
How to start reading excel file from second row in Nestjs?
I have app in which I have excel file reader and I need to start read it in nest js from second row. Who can give me a simple way how to do it ?</p>


问:
How to display back button on pdf file in swift?
I tried to display back button on the pdf viewController but it is not working properly.

This is the button. using this button will open the pdf

```<code> @IBAction func claim_btnActn(_ sender: Any) {
        let vc = self.storyboard?.instantiateViewController(withIdentifier: "ClaimProcedure") as! ClaimProcedure
        self.navigationController?.pushViewController(vc, animated: true)
    }
</code>```

This is the view using this view will display my pdf

```<code>import Foundation
import WebKit
import PDFKit

class ClaimProcedure : UIViewController{

    @IBOutlet weak var backButton: UIButton!
    let claimPdf = "claim_process"

    override func viewDidLoad() {
       super.viewDidLoad()
//        self.displayPdf()
        let pdfView = PDFView(frame: view.frame)

                title = "Your_title_here"

                if let url = Bundle.main.url(forResource: claimPdf, withExtension: "pdf"),
                    let pdfDocument = PDFDocument(url: url) {
                    pdfView.displayMode = .singlePageContinuous
                    pdfView.autoScales = true
                    pdfView.displayDirection = .vertical
                    pdfView.document = pdfDocument
                    view.addSubview(pdfView)
                    pdfView.goBack(navigationController?.popViewController(animated: true))
                }
    }

    @IBAction func back(_ sender: Any) {
        navigationController?.popViewController(animated: true)
    }
}
</code>```

I tried above code.. In that I called pdf with using bundle.main.url. I want to display pdf after click button and when will pdf display on that view I want to display there back button to come back to button view.

Body:
I tried to display back button on the pdf viewController but it is not working properly.

This is the button. using this button will open the pdf

 @IBAction func claim_btnActn(_ sender: Any) {
        let vc = self.storyboard?.instantiateViewController(withIdentifier: "ClaimProcedure") as! ClaimProcedure
        self.navigationController?.pushViewController(vc, animated: true)
    }

This is the view using this view will display my pdf

import Foundation
import WebKit
import PDFKit

class ClaimProcedure : UIViewController{

    @IBOutlet weak var backButton: UIButton!
    let claimPdf = "claim_process"

    override func viewDidLoad() {
       super.viewDidLoad()
//        self.displayPdf()
        let pdfView = PDFView(frame: view.frame)

                title = "Your_title_here"

                if let url = Bundle.main.url(forResource: claimPdf, withExtension: "pdf"),
                    let pdfDocument = PDFDocument(url: url) {
                    pdfView.displayMode = .singlePageContinuous
                    pdfView.autoScales = true
                    pdfView.displayDirection = .vertical
                    pdfView.document = pdfDocument
                    view.addSubview(pdfView)
                    pdfView.goBack(navigationController?.popViewController(animated: true))
                }
    }

    @IBAction func back(_ sender: Any) {
        navigationController?.popViewController(animated: true)
    }
}

I tried above code.. In that I called pdf with using bundle.main.url. I want to display pdf after click button and when will pdf display on that view I want to display there back button to come back to button view.


问:
Python wrong list output using recursion
I have to write a simple version of a game called Minesweeper. I made several functions to run the program (which are tested and work fine), but the function below returns a wrong output for 'changed_tiles' (although the output for 'board' is correct). This is, I think, because at every recursion call, the 'changed_tiles' is set to an empty list. But I don't know how to fix this. The function below has to return the adjusted board when you open a tile (x,y), and also a list of coordinates of every element on the board that changed when you open a tile (x,y).

Important: I'm not allowed to add input variables in a function (here: board, mines, x, y are fixed), although it's allowed to create auxiliary functions. Also import statements are not allowed.

To add some background information:

board = a list of lists which refer to the game board -> ex.: board = [['', '', ''],['', '', ''],['', '', '']]

mines = a list of the coordinates of every mine -> ex.: mines = [(0,1), (1,1), (2,2)]

x and y = integers = coordinates of tiles you want to check

functions called 'get_adjacent_mines' and get_adjacent_tiles' are checked and return correct outputs

I wrote some comments after several lines which (hopefully) clarify my coding steps (see code below).

```<code>def reveal_tile(board, mines, x, y):
    changed_tiles = []      # empty list: keeps track of the changed coordinates if you 'click' on one tile to open
    adjacent_mines = get_adjacent_mines(board, mines, x, y)     # returns number of adjacent mines
    adjacent_tiles = get_adjacent_tiles(board, x, y)            # returns coordinates (x,y) of adjacent tiles
    if not tile_lies_in_board(board, x, y):     # if the tile is not in board dimensions: return original board and empty list
        return board, []
    elif board[x][y] == 'M' or board[x][y] == 'F' or board[x][y] in range(0,len(mines)):    # if an already opened tile is opened; M = mine; F = Flag; ir tile contains a number
        return None, None
    elif (x,y) in mines:
        board[x][y] = 'M'   # if coordinate is a mine: place 'M' in tile
        changed_tiles.append((x,y))     # append the coordinate to list changed_tiles
        return board,changed_tiles
    elif adjacent_mines > 0:
        board[x][y] = adjacent_mines    # if coordinate has more than 0 adjacent mines: place the number of adjacent mines in this tile
        changed_tiles.append((x,y))     # append the coordinate to list changed_tiles
        return board, changed_tiles
    elif adjacent_mines == 0:
        board[x][y] = 0         # if coordinate has no adjacent mines: place 0 in this tile
        changed_tiles.append((x,y))     # append the coordinate to list changed_tiles
        for tile in adjacent_tiles:     # for each adjacent tile of (x,y): repeat the function recursively with tile[0],tile[1] = x_tile,y_tile for each new adjacent tile
            x_tile, y_tile = tile[0], tile[1]
            reveal_tile(board, mines, x_tile, y_tile)
        return board, changed_tiles     # output PROBLEM: adjusted board = OK, but changed_tiles contains wrong elements -> I think it's because every time the recursion occurs, changed_tiles is set to an empty list (see above: line 2)  -> how do I solve this?
</code>```

Can anyone help me or give some instructions? Thanks in advance!

Body:
I have to write a simple version of a game called Minesweeper. I made several functions to run the program (which are tested and work fine), but the function below returns a wrong output for 'changed_tiles' (although the output for 'board' is correct). This is, I think, because at every recursion call, the 'changed_tiles' is set to an empty list. But I don't know how to fix this. The function below has to return the adjusted board when you open a tile (x,y), and also a list of coordinates of every element on the board that changed when you open a tile (x,y).

Important: I'm not allowed to add input variables in a function (here: board, mines, x, y are fixed), although it's allowed to create auxiliary functions. Also import statements are not allowed.

To add some background information:

board = a list of lists which refer to the game board -> ex.: board = [['', '', ''],['', '', ''],['', '', '']]

mines = a list of the coordinates of every mine -> ex.: mines = [(0,1), (1,1), (2,2)]

x and y = integers = coordinates of tiles you want to check

functions called 'get_adjacent_mines' and get_adjacent_tiles' are checked and return correct outputs

I wrote some comments after several lines which (hopefully) clarify my coding steps (see code below).

def reveal_tile(board, mines, x, y):
    changed_tiles = []      # empty list: keeps track of the changed coordinates if you 'click' on one tile to open
    adjacent_mines = get_adjacent_mines(board, mines, x, y)     # returns number of adjacent mines
    adjacent_tiles = get_adjacent_tiles(board, x, y)            # returns coordinates (x,y) of adjacent tiles
    if not tile_lies_in_board(board, x, y):     # if the tile is not in board dimensions: return original board and empty list
        return board, []
    elif board[x][y] == 'M' or board[x][y] == 'F' or board[x][y] in range(0,len(mines)):    # if an already opened tile is opened; M = mine; F = Flag; ir tile contains a number
        return None, None
    elif (x,y) in mines:
        board[x][y] = 'M'   # if coordinate is a mine: place 'M' in tile
        changed_tiles.append((x,y))     # append the coordinate to list changed_tiles
        return board,changed_tiles
    elif adjacent_mines > 0:
        board[x][y] = adjacent_mines    # if coordinate has more than 0 adjacent mines: place the number of adjacent mines in this tile
        changed_tiles.append((x,y))     # append the coordinate to list changed_tiles
        return board, changed_tiles
    elif adjacent_mines == 0:
        board[x][y] = 0         # if coordinate has no adjacent mines: place 0 in this tile
        changed_tiles.append((x,y))     # append the coordinate to list changed_tiles
        for tile in adjacent_tiles:     # for each adjacent tile of (x,y): repeat the function recursively with tile[0],tile[1] = x_tile,y_tile for each new adjacent tile
            x_tile, y_tile = tile[0], tile[1]
            reveal_tile(board, mines, x_tile, y_tile)
        return board, changed_tiles     # output PROBLEM: adjusted board = OK, but changed_tiles contains wrong elements -> I think it's because every time the recursion occurs, changed_tiles is set to an empty list (see above: line 2)  -> how do I solve this?

Can anyone help me or give some instructions? Thanks in advance!


问:
tensorflow model predict runs out of memory
We have a tensorflow keras model which we would like to evaluate after training but the predict call after the training runs into out of memory errors even though the fit call works just fine.

The dataset is loaded like this:

options = tf.data.Options()
options.experimental_distribute.auto_shard_policy = tf.data.experimental.AutoShardPolicy.OFF
dataset = (
            tf.data.Dataset.list_files(f'{dataset_location}/*.csv')
            .flat_map(tf.data.TextLineDataset)
            .skip(1)
            .map(decode_line) # custom function how to read the csv files
        )
dataset = dataset.apply(tf.data.experimental.ignore_errors())
dataset = dataset.batch(batch_size).with_options(options)
```
<p>Using model.fit on the dataset just works fine with batch size of 128</p>
<pre class="lang-py prettyprint-override"><code>model.fit(dataset, epochs=10)
</code>```

But using predict after the model is trained gives me an out of memory error even when I used batch size 1.

model.predict(dataset)
```
<p>We are using google AI-platform with a custom image which is using the following base image:
gcr.io/deeplearning-platform-release/tf-gpu.2-8</p>
<p>Why would the fit call work but the predict call for the same model with the same dataset runs out of memory?
I would expect that the fit call is more memory intensive than the predict call.</p>
<p>This happens on tensorflow 2.8</p>
<p><strong>Update:</strong></p>
<p>I found a way how to solve the problem although I still think there is a memory leak in the predict function in tensorflow 2.8.</p>
<p>The solution which worked for me is not to load all csv files in the dataset but load one by one and do the prediction on the smaller datasets. Even though for training loading all csv files in one dataset works.</p>
```predictions = []
for file_name in tf.io.gfile.listdir(dataset_location):
    file_path = f'{dataset_location}/{file_name}'
    dataset = tf.data.experimental.make_csv_dataset(
        file_pattern=file_path,
        batch_size=10,
        shuffle=False,
        label_name="label",
        field_delim=';',
        column_defaults=[[""], [""], [0.0]],
        num_epochs=1
    )
    pred = model.predict(dataset)
    predictions.append(pred)
```

Body:
We have a tensorflow keras model which we would like to evaluate after training but the predict call after the training runs into out of memory errors even though the fit call works just fine.

The dataset is loaded like this:

options = tf.data.Options()
options.experimental_distribute.auto_shard_policy = tf.data.experimental.AutoShardPolicy.OFF
dataset = (
            tf.data.Dataset.list_files(f'{dataset_location}/*.csv')
            .flat_map(tf.data.TextLineDataset)
            .skip(1)
            .map(decode_line) # custom function how to read the csv files
        )
dataset = dataset.apply(tf.data.experimental.ignore_errors())
dataset = dataset.batch(batch_size).with_options(options)

Using model.fit on the dataset just works fine with batch size of 128

model.fit(dataset, epochs=10)

But using predict after the model is trained gives me an out of memory error even when I used batch size 1.

model.predict(dataset)

We are using google AI-platform with a custom image which is using the following base image:
gcr.io/deeplearning-platform-release/tf-gpu.2-8

Why would the fit call work but the predict call for the same model with the same dataset runs out of memory?
I would expect that the fit call is more memory intensive than the predict call.

This happens on tensorflow 2.8

Update:

I found a way how to solve the problem although I still think there is a memory leak in the predict function in tensorflow 2.8.

The solution which worked for me is not to load all csv files in the dataset but load one by one and do the prediction on the smaller datasets. Even though for training loading all csv files in one dataset works.

predictions = []
for file_name in tf.io.gfile.listdir(dataset_location):
    file_path = f'{dataset_location}/{file_name}'
    dataset = tf.data.experimental.make_csv_dataset(
        file_pattern=file_path,
        batch_size=10,
        shuffle=False,
        label_name="label",
        field_delim=';',
        column_defaults=[[""], [""], [0.0]],
        num_epochs=1
    )
    pred = model.predict(dataset)
    predictions.append(pred)