text:
Q: Prevent Zypper trying to use IPv6 I'm setting up a box with OpenSUSE 13.1. For reasons beyond my comprehension, Zypper utterly insists on using IPv6 addresses and refuses to use IPv4. Which is a problem, since IPv6 doesn't work on our LAN.
I've tried disabling IPv6 multiple ways:

*

*I told YaST to disable IPv6.

*I tried poking and prodding /etc/modprobe.

*I tried setting ipv6.disable=1 as a kernel boot parameter.

None of these things had the slightest effect; Zypper still refuses to use real IP addresses and keeps hopelessly trying to use IPv6.
Note that I can ping the download server just fine; the ping command looks up the IPv4 address of the server, and has no problem pinging it. And yet, Zypper still insists on using IPv6, and then giving up because the destination is unreachable. (Which is it - via IPv6.)
I am having the exact problem described in this question. (Even the failing IPv6 address is identical.) That question addresses an older release of OpenSUSE, and the accepted answer just says to disable IPv6, which I already tried.
I have now wasted multiple hours of my life trying to perform the trivial task of installing a few software packages. Does anybody know how I can completely destroy IPv6 and get networking to work again?

A: It seems like you've done the right things to zap IPv6 from a kernel perspective, but I might also -- assuming you don't care about IPv6 -- delete any IPv6 entries in /etc/hosts.  If that still doesn't do the trick (and this is reaching back), I had a problem with Amanda backup once that was very similar to your issue, and was only able to fix it by installing xinetd instead of inetutils-inetd (note that I have no idea what S.u.S.E. installs by default).  Lastly (and as a desperation measure) I might suggest using "strace" with something like:
strace -s 1024 -f -o /tmp/zypper.log /path/to/zypperexecutable
and then go through the log file looking for that IPv6 address, and seeing if there's anything informative that might be helpful.  (FYI, "strace" can generate a HUGE file, so you probably want to abort zypper as soon as it fails.)

A: Following the suggestion by user995746, I tried running strace. Here is what it has to say:
...
1179  socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = 5
1179  connect(5, {sa_family=AF_INET6, sin6_port=htons(80), inet_pton(AF_INET6, "2001:67c:2178:8::13", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = -1 ENETUNREACH (Network is unreachable)
1179  close(5)                          = 0
1179  madvise(0x7ff48750c000, 8368128, MADV_DONTNEED) = 0
1179  _exit(0)                          = ?
1179  +++ exited with 0 +++
1177  <... poll resumed> )              = 0 (Timeout)
1177  socket(PF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 5
1177  fcntl(5, F_GETFL)                 = 0x2 (flags O_RDWR)
1177  fcntl(5, F_SETFL, O_RDWR|O_NONBLOCK) = 0
1177  connect(5, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("195.135.221.134")}, 16) = -1 EINPROGRESS (Operation now in progress)
1177  poll([{fd=5, events=POLLOUT|POLLWRNORM}], 1, 0) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT}], 1, 1000) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT|POLLWRNORM}], 1, 0) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT}], 1, 1000) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT|POLLWRNORM}], 1, 0) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT}], 1, 1000) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT|POLLWRNORM}], 1, 0) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT}], 1, 1000) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT|POLLWRNORM}], 1, 0) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT}], 1, 1000) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT|POLLWRNORM}], 1, 0) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT}], 1, 1000) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT|POLLWRNORM}], 1, 0) = 0 (Timeout)
1177  poll([{fd=5, events=POLLOUT}], 1, 1000) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
1177  --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
...

It appears, then, that even though the error message from Zypper quite clearly says "Failed to connect to 2001:67c:2178:8::13: Network is unreachable", the program is actually seeing that IPv6 is unreachable, and falling back to IPv4. The question remains why it can't connect via IPv4 - this is probably some sort of firewall issue with our LAN.
In summary, it appears that IPv6 isn't the problem at all, it's just that the error message from Zypper is highly misleading.

A: Resolving download.opensuse.org (or whatever d/l server you care to use) and then feeding its IPv4 address into the .repo file(s) did it for me. I used sed(1) to search+replace everything in there; worked like a charm.
Not perfect, certainly; and not being able to fall back on a working(!) v4 connection is... less than stellar. Never mind that any other dualstack-capable application is perfectly capable (and able) to access, say, download.opensuse.org when there's a local v6 network that doesn't get routed out (because Mr ISP doesn't play along, for example).
Until that time, just use (numerical) IPv4 addresses.
Note: zypper uses libcurl but doesn't honor $HOME/.curlrc. Maybe it'll honor global curl configuration files or environment variables. curl itself wants -4 / --ipv4 to force ipv4.
Also, if one were to recompile libcurl itself without ipv6 support and then have zypper point there via ld.so.conf or something, I'd imagine things should work as expected as well.


text:
Q: Are Next.js and Gatsby.js using the split code Loadable Component? Are Next.js and Gatsby.js using the split code Loadable Component ?
The loadable component I am talking about is the one recommended by the Facebook team https://github.com/gregberge/loadable-components
I am lazy at searching this.
If you reply I'll give points.

A: If you're using npm, you may find that out by doing a deep search of dependency tree on your Next.js or Gatsby projects using the npm ls command.
Neither the latest version of Next.js, nor Gatsby use the package you specified.
Next.js implements this feature with dynamic imports.
And Gatsby has a separate plugin for the job: gatsby-plugin-loadable-components.

redpajama_set_name: RedPajamaStackExchange


text:
Q: Averaging of every five elements and discarding the sixth element So i have a Numpy array and i want to average every five elements and discard the sixth element, then average out the next five elements and discard the twelfth element and so on.
I have tried using the library function np.average()but it does not allow me to discard the factor of sixth value.
For Example: I have
Input:
a=[[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],
    [19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36],
    [37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54]]

Output:
a_avg=[[3,9,15],
       [21,27,33],
       [39,45,51]'

Also is it possible to make it dynamic to the size of array?

A: IIUC, you can first compute a mask to remove every 6th item.
Then reshape to have 5 elements in one dimension, compute the mean, and reshape again:
mask = np.arange(a.shape[1])%6 != 5

a[:, mask].reshape((-1,5)).mean(1).reshape((a.shape[0], -1))

output:
array([[ 3.,  9., 15.],
       [21., 27., 33.],
       [39., 45., 51.]])

input:
array([[ 1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16, 17, 18],
       [19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36],
       [37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54]])


text:
Q: How to test Azure slots when deploying bots I use the Azure slots feature for deploying my bot:

*

*Deploy to 'staging' slot

*Azure start this instance

*When up, I swap 'production' and 'staging' slots

I would like to test the staging instance before doing a slot, ideally using the Webchat test tool in Azure portal. However, I couldn't see a way to specify which slot instance this webchat tool points at.
Is there a way to test a bot running in a specific slot?

A:
I would like to test the staging instance before doing a slot, ideally using the Webchat test tool in Azure portal.

On Settings blade, you can modify the Messaging endpoint to point to your bot application that is deployed on staging slot, then test it via WebChat.
Change Messaging endpoint:

Test in WebChat:

Note: I clone configuration from original app when I add staging slot.


text:
Q: PHP - How to disable auto filling username and password in touch devices (iphone) If the user has saved his username and password in iphone for login, the same are override on another page username and password.
I have tried options like autocomplete="off" and autocomplete="false" but didn't worked.
Please suggest !


text:
Q: How to perform group-by over JSON data using JSONATA I have a JSON structure given below.
I want to perform a couple of transformations on this data. I came to know about JSONATA and it looks fantastic to me, but since I am new, I am struggling a little bit around transformation.
I want to calculate the total of count (sum) for each module date for the given date.
The expected result is given below.
Input:
{
    "id": "6332acbfe13e6063dcb740ef",
    "record": [
        {
            "date": "2022-09-22",
            "entries": [
                {
                    "repo": "SRE-MAC-PDM-TEAM",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 16
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBO-BONUS-PAYMENTS-REPO",
                    "prod": [
                        {
                            "name": "modules/dynatrace/monitors/http-monitors/basic",
                            "count": 3
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-ANAPostPurchase",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 17
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-ANA-SubscriptionsRewards",
                    "preprod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 8
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 8
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace/alerting_profiles",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/monitors/http-monitors/basic",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/notifications/splunk-on-call",
                            "count": 1
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace",
                            "count": 4
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-CSP-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 9
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBOIP-REPO",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 6
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBOLIFE-REPO",
                    "preprod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 1
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 2
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 3
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 5
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-PL-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 4
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 2
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-TPS-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace/alerting_profiles",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/notifications/splunk-on-call",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/calculated_service_metric",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/anomalies/custom/metric_id",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace",
                            "count": 11
                        }
                    ]
                }
            ]
        },
        {
            "date": "2022-09-19",
            "entries": [
                {
                    "repo": "SRE-MAC-PDM-TEAM",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 14
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBO-BONUS-PAYMENTS-REPO",
                    "prod": [
                        {
                            "name": "modules/dynatrace/monitors/http-monitors/basic",
                            "count": 3
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-ANAPostPurchase",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 15
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-ANA-SubscriptionsRewards",
                    "preprod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 5
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 5
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace/alerting_profiles",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/monitors/http-monitors/basic",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/notifications/splunk-on-call",
                            "count": 1
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace",
                            "count": 3
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-CSP-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 6
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBOIP-REPO",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 6
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBOLIFE-REPO",
                    "preprod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 1
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 2
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 3
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 4
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-PL-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 3
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 2
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-TPS-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace/alerting_profiles",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/notifications/splunk-on-call",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/calculated_service_metric",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/anomalies/custom/metric_id",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace",
                            "count": 9
                        }
                    ]
                }
            ]
        },
        {
            "date": "2022-09-12",
            "entries": [
                {
                    "repo": "SRE-MAC-PDM-TEAM",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 4
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBO-BONUS-PAYMENTS-REPO",
                    "prod": [
                        {
                            "name": "modules/dynatrace/monitors/http-monitors/basic",
                            "count": 2
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-ANAPostPurchase",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 3
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-ANA-SubscriptionsRewards",
                    "preprod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 3
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 4
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace/alerting_profiles",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/monitors/http-monitors/basic",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/notifications/splunk-on-call",
                            "count": 1
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace",
                            "count": 2
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-CSP-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 4
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBOIP-REPO",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 3
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBOLIFE-REPO",
                    "preprod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 1
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 2
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 2
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 3
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-PL-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 2
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 2
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-TPS-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace/alerting_profiles",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/notifications/splunk-on-call",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/calculated_service_metric",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/anomalies/custom/metric_id",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace",
                            "count": 7
                        }
                    ]
                }
            ]
        },
        {
            "date": "2022-09-05",
            "entries": [
                {
                    "repo": "SRE-MAC-PDM-TEAM",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 12
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBO-BONUS-PAYMENTS-REPO",
                    "prod": [
                        {
                            "name": "modules/dynatrace/monitors/http-monitors/basic",
                            "count": 1
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-ANAPostPurchase",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 11
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-ANA-SubscriptionsRewards",
                    "preprod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 2
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 5
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace/alerting_profiles",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/monitors/http-monitors/basic",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/notifications/splunk-on-call",
                            "count": 1
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace",
                            "count": 1
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-CSP-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 5
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBOIP-REPO",
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 3
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-IBOLIFE-REPO",
                    "preprod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 1
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace",
                            "count": 2
                        },
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-PL-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/splunk/hec-token",
                            "count": 1
                        },
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        }
                    ]
                },
                {
                    "repo": "SRE-MAC-TPS-APPLICATION",
                    "preprod": [
                        {
                            "name": "modules/aws/lambda/logs_streaming_splunk",
                            "count": 1
                        }
                    ],
                    "prod": [
                        {
                            "name": "modules/dynatrace/alerting_profiles",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/notifications/splunk-on-call",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/calculated_service_metric",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace/anomalies/custom/metric_id",
                            "count": 1
                        },
                        {
                            "name": "modules/dynatrace",
                            "count": 2
                        }
                    ]
                }
            ]
        }
    ],
    "metadata": {
        "name": "",
        "readCountRemaining": 98,
        "timeToExpire": 86389,
        "createdAt": "2022-09-27T07:56:47.003Z"
    }
}

Expected Output:
[
"2022-09-22" : [
{
"name" : "modules/dynatrace",
"count": 11
},
{
"name" : "modules/dynatrace",
"count": 4
},
{
"name" : "modules/splunk/hec-token",
"count": 14
}
....
],
"2022-09-19" : [
{
"name" : "modules/dynatrace",
"count": 52
},
.....
]
.
.
.
]

A: This should do the grouping for you:
(
  record{
    date: $reduce(entries.prod.name, function($acc, $item) {
      $merge([$acc, {
        $item: $count(entries.prod.name[$=$item])
      }])
    }, {}) ~> $each(function($value, $key) {
      { "name": $key, "count": $value }
    })
  }
)

You can check it out live here: https://stedi.link/LiOttdB
UPDATE - even shorter solution:
(
  record{
    date: entries.*{ $.name: $sum($.count) }
      ~> $each(function($c, $n) {{ "name": $n, "count": $c }})
  }
)

https://stedi.link/pQiCnJo

A: Thanks @mralex to answer my question. But unfortunately it is not working in older version which is getting used in the latest JSON-API Grafana module. So I myself create another solution which is given below:
(
  record.(
        $t1 := entries.preprod{ $.name: $sum($.count) };
        $t2 := entries.prod{ $.name: $sum($.count) };
        $t3 := $distinct($append($t1.$keys(),$t2.$keys()));
        $t3.(
            $t4 := ($exists($lookup($t1, $)) ? $lookup($t1, $) : 0) + ($exists($lookup($t2, $)) ? $lookup($t2, $): 0);
            {
                'name': $,
                'count' : $t4
            }
        )
    )
)


text:
Q: How can I redirect in the quick_view page after deleting feedback? My motive is that I want to redirect quick_view.html after deleting particular feedback on a particular product. How can I do it?
views.py:
def quick_view(request, quick_view_id):

    quick_view = get_object_or_404(Products, pk=quick_view_id)

    context = {
        "quick_view":quick_view,
    }

    return render(request, 'quickVIEW_item.html', context)

def feedBack(request,quick_view_id):
    quick_view = get_object_or_404(Products, pk=quick_view_id)
    if request.method == "POST" and request.user.is_authenticated:

        try:
            ProductREVIEWS.objects.create(
                user=request.user,
                product=quick_view,
                feedBACK=request.POST.get('feedBACK'),
            )
            return redirect('quick_view', quick_view_id)
        except:
            return redirect('quick_view', quick_view_id)

    else:
        return redirect('quick_view', quick_view_id)

After deleting the particular feedback, I want to redirect to the quick_view page of that particular product. Now shows below error:
def DeleteFeedback(request,id,quick_view_id):

    ProductREVIEWS.objects.get(pk=id).delete()
    messages.success(request,"Successfully your feedback deleted.")
    return redirect('quick_view', quick_view_id)

urls.py:
    path('quick_view/<int:quick_view_id>/', views.quick_view, name="quick_view"),
    path("feedBack/<int:quick_view_id>/", views.feedBack, name="feedBack"),
    path("DeleteFeedback/<int:id>/", views.DeleteFeedback, name="DeleteFeedback")

error:
TypeError at /DeleteFeedback/22/
DeleteFeedback() missing 1 required positional argument: 'quick_view_id'
Request Method: GET
Request URL:    http://127.0.0.1:8000/DeleteFeedback/22/
Django Version: 4.0.4
Exception Type: TypeError
Exception Value:
DeleteFeedback() missing 1 required positional argument: 'quick_view_id'
Exception Location: D:\1_WebDevelopment\17_Ecomerce Website\ecomerce site\env\lib\site-packages\django\core\handlers\base.py, line 197, in _get_response
Python Executable:  D:\1_WebDevelopment\17_Ecomerce Website\ecomerce site\env\Scripts\python.exe
Python Version: 3.9.5
Python Path:
['D:\\1_WebDevelopment\\17_Ecomerce Website\\ecomerce site',
 'c:\\users\\dcl\\appdata\\local\\programs\\python\\python39\\python39.zip',
 'c:\\users\\dcl\\appdata\\local\\programs\\python\\python39\\DLLs',
 'c:\\users\\dcl\\appdata\\local\\programs\\python\\python39\\lib',
 'c:\\users\\dcl\\appdata\\local\\programs\\python\\python39',
 'D:\\1_WebDevelopment\\17_Ecomerce Website\\ecomerce site\\env',
 'D:\\1_WebDevelopment\\17_Ecomerce Website\\ecomerce '
 'site\\env\\lib\\site-packages']
Server time:    Sat, 16 Jul 2022 05:49:50 +0000

A: I solved it and shared it, so that people can be benefited...
   def DeleteFeedback(request,id):

        feedback = ProductREVIEWS.objects.get(pk=id)
        product_id = feedback.product.id

        feedback.delete()
        messages.success(request,"Successfully your feedback deleted.")
        return redirect(reverse('quick_view', args=[product_id]))

Note:
here product = field of a feedback model
class ProductREVIEWS(models.Model):

    product = models.ForeignKey(Products, related_name='productREVIEWrelatedNAME',on_delete=models.CASCADE)
    feedBACK = models.TextField(blank=True, null=True)


text:
Q: Exercise with localization and minimal primes
Let $A$ be a ring and $p\subset A$ be a prime ideal. Call $f$ the canonical map $A\to A_p$, and set $I:=\operatorname {ker }f$. Show that $I\subseteq p$ and that $\sqrt I=p$ if and only if $p$ is minimal among the prime ideals of $A$.

$I\subseteq p$ is easy: $x\in I $ iff exists $t\in A\setminus p$ such that $tx=0$; since $0\in p$ and $t\notin p$, be $p$ prime $x\in p$.
Now I try to show that, if $p$ is a minimal prime, $\sqrt I=p$. Since $I\subseteq \sqrt I\subseteq p$, we can look at what happens in $A_p$. Here we have that the radical of $IA_p=0$ is $pA_p$, being the only prime containing it. Am I finished?
Now suppose that $\sqrt I=p$. Again, passing to $A_p$, we are in the situation that there is only a prime ideal, namely $\sqrt 0=pA_p$. Since any prime contained in $p$ would survive in $A_p$, can I conclude that $p$ is minimal?
These arguments actually seem defective to me, but I have not clear why. It seems to me that sometimes I reasoned like if the prime ideals of $A_p$ were in bijection with the primes of $A$ contained in $p$, other times like if the bijection was with the prime ideals contained in $p$ and containing $I$ (for example in saying that $\sqrt I A_p$ is the nilradical of $A_p$). Could you clear my ideas? Thanks

A: Here is a better way to prove this. The containment $\sqrt{I} \subseteq p$ is trivial once you have $I \subseteq p$ (by taking radical on both sides). By definition, $\sqrt{I} \supseteq p$ if an only if for all $x \in p$ there is $n>0$ and $t \in A \setminus p$ such that $tx^n=0$ if and only if $x/1 \in \mathfrak{N}(A_p)$ (for all $x \in p$). Recall that $\mathfrak{N}(A_p)$ is the intersection of all prime ideals of $A_p$.
If $p$ is minimal, then $x/1 \in pA_p = \mathfrak{N}(A_p)$ (there is only one prime ideal of $A_p$). Conversely, suppose $p$ is not minimal. Then we can find a minimal prime $q \subset p$. Assume, in contrary, that $x/1 \in \mathfrak{N}(A_p)$. In particular, $x/1 \in qA_p$. Thus, there exists $y \in q$, $t \in A \setminus q$ such that $x/1 = y/t$. Hence, for some $u \in A \setminus p$, $utx = uy \in q$ and so $x \in q$ by primality (since $u,t \not\in q$). Since $x \in p$ is arbitrary, we have $p \subseteq q$, a contradiction.

A: Here is an equivalent statement and proof, which do not involve localisation.  Thus you get a different perspective, and can see what is happening in the ring $A$ more explicitly.

Let $A$ be a commutative unital ring and let $P$ be a prime ideal.  Let $I$ be the ideal of $i\in A$ such that $ix=0$ for some $x\notin P$.
Then $\sqrt I\subseteq P$ as $a^nx=0$ with $x\notin P$ implies $a\in P$.  Similarly, for any prime ideal $P'\subsetneq P$, we have $a^nx=0$ with $x\notin P$ implies $x\notin P'$, so $a\in P'$.  Thus $\sqrt I \subseteq P'\subsetneq P$ and $\sqrt I\neq P$.
Conversely, suppose $\sqrt I \neq P$.  Pick $a\in P \backslash \sqrt I$.  Then $a$ and $A\backslash P$ generate a multiplicatively closed set $M$, disjoint from $\sqrt I$ (if $a^nx\in \sqrt I$ with $x\notin P$, then $(a^nx)^ky=0$, with $y\notin P$, which implies $a\in \sqrt I$ - a contradiction).  By Zorn's lemma, one may find an ideal $J\supseteq \sqrt I$, maximal amongst ideals disjoint from $M$.  Then $J$ is a prime ideal and $J\subsetneq P$, as it is disjoint from $M$.

Note the following lemma is used explicitly at the end of the above argument, and implicitly in the corresponding argument by @Ray (as it is the key ingredient of the proof that only nilpotent elements lie in the intersection of all primes):
Lemma Let $A$ be a commutative unital ring, let $M\subseteq A$ be a multiplicatively closed subset, and let $J$ be maximal among ideals disjoint from $M$.  Then $J$ is prime.
Proof: If $u,v\notin J$ then by the maximality property we have: $$\lambda u=j_1+m_1, \qquad \mu v=j_2+m_2,$$
with $\lambda,\mu\in A$, and $j_1,j_2\in J$, and $m_1,m_2\in M$.  However in that case: $$\lambda\mu uv=(j_1j_2+j_1m_2+j_2m_1)+m_1m_2,$$
so $uv\notin J$ (otherwise $m_1m_2\in J \cap M$ - a contradiction). $\qquad\qquad\qquad\Box$


text:
Q: How to sum a nested case statement I am trying to create a query that counts deductions added and modified by clients and the same for internal support reps. I'm getting error ORA-00905 missing keyword at right after the first "END" in the query. I can't figure out how to sum nested case statements.
SELECT
sum(CASE WHEN ded.ACTION = 'A' --added deduction
        THEN
        CASE WHEN REGEXP_LIKE(ded.oper_ID, '[[:digit:]]') THEN 1 ELSE 0 END)
END AS "Added By Clients", -- count # of client deductions

sum(CASE WHEN ded.ACTION = 'A' -- added deduction
    THEN
    CASE WHEN NOT REGEXP_LIKE(ded.oper_ID, '[[:digit:]]') THEN 1 ELSE 0 END)
END AS "Added by Internal Reps" -- count # of internal rep deductions

sum(CASE WHEN ded.ACTION <> 'A' --modified deduction
        THEN
        CASE WHEN REGEXP_LIKE(ded.oper_ID, '[[:digit:]]') THEN 1 ELSE 0 END)
END AS "Modified By Clients", -- count # of client deductions

sum(CASE WHEN ded.ACTION <> 'A' -- modified deduction
    THEN
    CASE WHEN NOT REGEXP_LIKE(ded.oper_ID, '[[:digit:]]') THEN 1 ELSE 0 END)
END AS "Modified by Internal Reps" -- count # of internal rep deductions

FROM DEDUCTIONS_TBL DED

Thanks for any help!

A: Why do you have nested CASE statements in the first place? Shouldn't it be something like
sum(CASE WHEN ded.ACTION = 'A'
        AND REGEXP_LIKE(ded.oper_ID, '[[:digit:]]') THEN 1 ELSE 0 END)

, etc?
You're getting an error because you have two CASE ... CASE ... but only one END inside the sum( ... ). There's an END outside of that, but that's effectively just a misnested bracketing group:
(CASE ...) END

A: @Jnevill's post helped me fix it. I deleted the parentheses after the first END and put it after the 2nd END, but before declaring the alias.
SELECT
sum(CASE WHEN ded.ACTION = 'A' --added deduction
        THEN
        CASE WHEN REGEXP_LIKE(ded.oper_ID, '[[:digit:]]') THEN 1 ELSE 0 END
END) AS "Added By Clients", -- count # of client deductions

sum(CASE WHEN ded.ACTION = 'A' --added deduction
        THEN
        CASE WHEN NOT REGEXP_LIKE(ded.oper_ID, '[[:digit:]]') THEN 1 ELSE 0 END
END) AS "Added by Internal Reps", -- count # of client deductions

sum(CASE WHEN ded.ACTION <> 'A' --modified deduction
        THEN
        CASE WHEN REGEXP_LIKE(ded.oper_ID, '[[:digit:]]') THEN 1 ELSE 0 END
END) AS "Modified By Clients", -- count # of client deductions

sum(CASE WHEN ded.ACTION <> 'A' -- modified deduction
    THEN
    CASE WHEN NOT REGEXP_LIKE(ded.oper_ID, '[[:digit:]]') THEN 1 ELSE 0 END
END) AS "Modified by Internal Reps" -- count # of internal rep deductions


text:
Q: Find duplicate values in list of dictionaries I need to find dictionaries in a list that have the same key-value, and create a new list in which only the first dictionary is kept.
Example list:
lst_in = [{'First': 1, 'Second': 4}, {'First': 2, 'Second': 5}, {'First': 3, 'Second': 4}]

Duplicate key-value to iterate over should be 'Second'. So in the example the first and third dictionary are the same.
I have tried looking at Find duplicates in python list of dictionaries and python list of dictionaries find duplicates based on value, but I can't find the exact answer. I am only looking at one key-value. The dictionaries will always have the same keys.
Expected output:
lst_out = [{'First': 1, 'Second': 4}, {'First': 2, 'Second': 5}]

A: Some solutions and a benchmark.
Solutions
Fun with a dict, going forwards to get the order and backwards to get the first value.
lst_out = list({d['Second']: d
                for s in [1, -1]
                for d in lst_in[::s]}.values())

Or using setdefault to keep track of each value's first dict:
tmp = {}
for d in lst_in:
    tmp.setdefault(d['Second'], d)
lst_out = list(tmp.values())

Fun and potentially faster version:
add = {}.setdefault
for d in lst_in:
    add(d['Second'], d)
lst_out = list(add.__self__.values())

Benchmark
Times for a list of 1000 dicts with 100 different Second values (using Python 3.10.0):
 361 μs   362 μs   364 μs  dict_forward_backward
 295 μs   297 μs   297 μs  dict_setdefault
 231 μs   231 μs   232 μs  dict_setdefault_optimized
 196 μs   196 μs   197 μs  set_in_list_comprehension
 190 μs   190 μs   190 μs  set_in_list_comprehension_optimized
 191 μs   191 μs   191 μs  set_in_list_comprehension_optimized_2
 201 μs   201 μs   201 μs  set_with_loop
1747 μs  1751 μs  1774 μs  with_lists

Benchmark code:
from timeit import repeat, default_timer as timer
from random import choices

lst_in = [{'First': i, 'Second': v}
          for i, v in enumerate(choices(range(100), k=1000))]

def dict_forward_backward(lst_in):
    return list({d['Second']: d
                 for s in [1, -1]
                 for d in lst_in[::s]}.values())

def dict_setdefault(lst_in):
    tmp = {}
    for d in lst_in:
        tmp.setdefault(d['Second'], d)
    return list(tmp.values())

def dict_setdefault_optimized(lst_in):
    add = {}.setdefault
    for d in lst_in:
        add(d['Second'], d)
    return list(add.__self__.values())

def set_in_list_comprehension(lst_in):
    return [s.add(v) or d
            for s in [set()]
            for d in lst_in
            for v in [d['Second']]
            if v not in s]

def set_in_list_comprehension_optimized(lst_in):
    return [add(v) or d
            for s in [set()]
            for add in [s.add]
            for d in lst_in
            for v in [d['Second']]
            if v not in s]

def set_in_list_comprehension_optimized_2(lst_in):
    s = set()
    add = s.add
    return [add(v) or d
            for d in lst_in
            for v in [d['Second']]
            if v not in s]

def set_with_loop(lst_in):
    found = set()
    lst_out = []
    for dct in lst_in:
        if dct['Second'] not in found:
            lst_out.append(dct)
            found.add( dct['Second'] )
    return lst_out

def with_lists(lst_in):
    out = {'keep':[], 'counter':[]}
    for dct in lst_in:
        if dct['Second'] not in out['counter']:
            out['keep'].append(dct)
            out['counter'].append(dct['Second'])
    return out['keep']

funcs = [
    dict_forward_backward,
    dict_setdefault,
    dict_setdefault_optimized,
    set_in_list_comprehension,
    set_in_list_comprehension_optimized,
    set_in_list_comprehension_optimized_2,
    set_with_loop,
    with_lists,
]

# Correctness
expect = funcs[0](lst_in)
for func in funcs[1:]:
    result = func(lst_in)
    print(result == expect, func.__name__)
print()

# Speed
for _ in range(3):
    for func in funcs:
        ts = sorted(repeat(lambda: func(lst_in), 'gc.enable(); gc.collect()', number=1000))[:3]
        print(*('%4d μs ' % (t * 1e3) for t in ts), func.__name__)
    print()

A: Sets are great for those "have I already seen this?" problems.
lst_in = [{'First': 1, 'Second': 4}, {'First': 2, 'Second': 5}, {'First': 3, 'Second': 4}]

found = set()
lst_out = []
for dct in lst_in:
    if dct['Second'] not in found:
        lst_out.append(dct)
        found.add( dct['Second'] )


text:
Q: Parallelization of Genetic Algorithm Slowed Algorithm Significantly. Why would this be? I've written a genetic algorithm and in an attempt to optimize its performance, I decided to parallelize the fitness testing for individuals. To see what kind of change this made in my algorithm, I redid a test run I had done before the parallelization where I tested the GA's performance for growing population sizes.
The parallel version of the GA actually took roughly 50% longer than the original version. I realize that sometimes the overhead of the parallelization can actually take more time than it saves, but I doubt that that should apply in this situation - my fitness test is finding the global minimum of a Sheckel's Foxholes function ( http://extreme.adorio-research.org/download/mvf/html/node51.html ), and my population sizes range from 10 to 1000. I would expect that in parallelizing 1000 executions of sheckel's foxholes the time saved would greatly outweigh the overhead of parallelization.
So my question is: why would the parallelization have slowed down the algorithm (and so significantly)?
For the record, I'm coding in Java and I'm parallelizing using a CountDownLatch that waits for all threads (fitness tests) to execute before continuing on.

A: Based upon your comments, it seems like you are doing things fairly reasonably, except perhaps for the number of threads.  But you mention that you are using a CountDownLatch gets me thinking...
I would strongly suggest that instead of your own code, you use an ExecutorService/Executors for the parallelization.  Make your class a Callable, create a bunch of them, and call invokeAll().  That way highly trained (not sure if they were highly paid) experts did most of the coding.
With Executors, it is simple to control the maximum number of threads.  You can call Runtime.availableProcessors() to get a first pass at how many threads to run at a time, then do some testing and tuning.
EDIT: Just posted an introduction to converting an algorithm to use ExecutorService. Enjoy, and comments/feedback welcome.

A: Okay, the answer is that it didn't parallelize as much as you thought it should.  The question is "why?" and the answer will be difficult to achieve without a look at the code.  but there are some obvious places to look:

*

*make sure (you're gonna hate this one) that you're using the right entry point for Thread.  One way to guarantee that your threads will serialize and not tell you a thing is to call the run() method instead of the start() method.  It sounds silly but I've been bitten by this.

*make sure, using eg jconsole, that the threads are running concurrently at all.  If not, you've got an unexpected lock on something.

*check what you synchronize on. Check the collection classes you're using.  Some of them aren't thread-safe at all, and some of them are thread-safe because they've got internal synchronization.  Any Collection class that's shared among threads is a possible miscreant.

*If nothing leaps out with that, walk through the code execution on paper with a colleague and hand-write out the threads.

A: So I figured out what the problem was - I had assumed that my fitness test was taking long enough that parellelization would be worthwhile, but it totally was not. I padded the fitness test, made it artificially long (it's just a test fitness test I'm using to monitor the performance of the GA anyway), and I now see a significant difference in the execution time - a growing population size now results in extending the execution time by 1000s of a second, instead of 10s of seconds. And I should point out that that's before implementing the Executor, as has been recommended.
Thank you all for your help!


text:
Q: How to scan outbound closed ports with nmap? I just noticed that my server is being blocked for rsync from a firewall outside of my server, so I can't rsync to any target. Now, I would also like to know what are all the ports that are being blocked by that firewall.
Is there any way to use nmap to do that? I know I can use nmap to scan the opened ports in a specific target, but what I want is to know what ports are closed in my server to send packets out.

A: No, you can not nmap to scan one computer from the same computer.
By definition, packets won't travel, and packets traveling is the whole base of the internet.
You need a router, printer, light-bulb or external computer that could run some commands and use it to look back to that computer.
I believe that you can send packets going out (to the outside) from any port to see which ports are being blocked in the outgoing direction without any security issue. But even to do that, you need some external address to send your packets to.
Trying to scan from outside to such firewalled computer may easily be seen as an attack and you may get banned or blocked even more than you are now. To actually perform such scan from the outside the best is to inform and ask for permission from the network managers in such system.


text:
Q: Why does my fetchedResultsController.ObjectAtIndexPath return NSFetchRequestResult instead of an object? I thought this would be a straight forward thing to do but for some unknown reason, I can't access the properties of the object at a given indexPath.
I'm trying to create my app using MVVM as much as possible (still using Swift 2.3) so my UITableViewController is backed by a view model called FormulasViewModelFromLiftEvent. The view model is initialized with a fetchedResultsController like so:
struct FormulasViewModelFromLiftEvent {
    var modelLiftEvent: LiftEventProtocol
    var fetchedResultsController: NSFetchedResultsController
    let dataManager = CoreDataHelper()

    init(withLiftEvent liftEventModel: LiftEventProtocol) {
        self.modelLiftEvent = liftEventModel

        let moc = modelLiftEvent.context
        fetchedResultsController = dataManager.fetchSelectableFormulas(moc)
    }
}

The results are a collection of Formula objects.
Back in my UITableViewController, I have this extension in which I'm putting the required table view methods. I can access the fetchResultsController of the view model within the numberOfSectionsInTableView and numberOfRowsInSection methods with no problems. In cellForRowAtIndexPath, I want to populate the cell with the formula name property but I can't access any of the properties of the objectAtIndexPath:
extension FormulasViewController: UITableViewDataSource {

  override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    guard let sections = viewModel.fetchedResultsController.sections else { return 0 }
    return sections.count
  }

  override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    guard let section = viewModel.fetchedResultsController.sections?[section] else { return 0 }
    return section.numberOfObjects
  }

  override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

        let cellViewModel: SelectionsRepresentable

        let cell = tableView.dequeueReusableCellWithIdentifier("formulasCell", forIndexPath: indexPath)

        let formula = viewModel.fetchedResultsController.objectAtIndexPath(indexPath)
        let formulaName = formula.    <-- None of the Formula properties are available

        cellViewModel = FormulaSelectionViewModel(defaultFormulaName: formulaName)

        cell.textLabel?.text = cellViewModel.text
        cell.accessoryType = cellViewModel.accessoryType

        return cell
      }
}

According to the documentation, let formula = viewModel.fetchedResultsController.objectAtIndexPath(indexPath) should return the Formula object at the given index path in the fetch results. But formula thinks it's an NSFetchRequestResult and so of course I can't access any Formula properties.

A: NSFetchRequestResult is the protocol NSManagedObject, NSDictionary, NSManagedObjectID and NSNumber conform to. You need to type cast the object:
let formula = viewModel.fetchedResultsController.objectAtIndexPath(indexPath) as! Formula


text:
Q: Fetching database into a tree I have a database like this for a restaurant automation system that I'm coding to get experience in php and mysql.
productcat  |  productname  |  productdesc  |  price  |
-------------------------------------------------------
Drink       |  Coke         | Ice cold coke |  3
Drink       |  Sprite       |Ice cold sprite|  3
Food        |  Kebab        |Delicious kebab|  10
Food        |  Rice         | Delicious rice|  5

I want to fetch them into a tree that divided by categories.
$data = mysql_query("SELECT * FROM $restadi")
or die(mysql_error());

//urunler kategorilerinin altina yerlestiriliyor
echo '
';
echo '
';
while($db = mysql_fetch_array( $data ))
{
echo '
'.$db['productcat'].'
';
echo '

'.$db['productname'].'

';
}
echo '
';
echo '
'

Obviusly this doesnt work the way I want. How can I achieve what I want here?
Thanks in advance and sorry for my sloppy English.

A: If you want to don't want to make tree from result in PHP, you can try this:
$data = mysql_query("SELECT * FROM $restadi ORDER BY productcat");

//urunler kategorilerinin altina yerlestiriliyor
echo '
';
echo '
';
$lastCategory = "";
while($db = mysql_fetch_array( $data ))
{

    if ($lastCategory != $db['productcat']) {
        // close opened ul of subitems (skip first false positive change of category)
        if (!empty($lastCategory)) {
            echo '
';
        }
        echo '
'.$db['productcat'].'

';
        $lastCategory = $db['productcat'];
    }
    echo '
'.$db['productname'].'
';
}
// if there was at least one product, close last product list
if (!empty($lastCategory)) {
   echo '
';
}
echo '
';
echo '
';


text:
Q: AJAX call and JSON data Good day!
I'm learning to create AJAX calls to PHP scripts.
Basically, I want to find the best solution to handle AJAX calls. In this question you can find my client-side part of the code.
Basically, I'd like to verify my knowledge here and if I'm wrong, get any tips how to make it correct way.
So... I'm using KohanaPHP framework (but also going to learn ZendFramework). I created a test controller with following code:
public function __construct()
{
    if (request::is_ajax()) {
        $this->auto_render = FALSE;
        header('content-type: application/json');
    }
}

public function index()
{
    $result['success'] = 1;

    $test_model = new Test_Model;
    $items = $test_model->get_test_rows();
    foreach($items as $item):
        $rows[] = $item;
    endforeach;
    $result['rows'] = json_encode($rows);

    if (request::is_ajax()) {
        echo json_encode($result);
    }
}

Now I got few questions related to this code. Let me ask them.
1) In thread mentioned above I was told I do not have to use $.parseJSON(); function and I can use data.rows[0]name instead. Unfortunately, it does not work. For the is't not a big problem, I can use $.parseJSON(); but I'd like to know if there's any bug in my PHP code?
2) I'm trying to learn good practices and techniques and I'm try to not violate MVC rules. I have a MVC related question. Is it possible to use echo() in controllers? You may notice I'm using it to return JSON encoded data.

A: 1) jQuery.ajax function is smart enough to parse your JSON response provided that you tell it that you are returning a JSON-enconded object. Here is how your backend Kohana can tell your frontend jQuery that they are talking in JSON, in your Controller:
$this->request->headers['Content-Type'] = 'application/json';

2) There's nothing wrong with using echo but since you are using Kohana, the recommended way of returning response to the browser client, from inside a controller, is:
$this->request->response = json_encode($result);

A: To answer question (2): Yes, it is normally bad form to echo in the controller.  I'd even go as far to say it's bad form to build any sort of string the controller either.
However, in the case where all that's being output is json, I think it's simply easier, and more concise to just echo json_encode($results);  If you really want to be an MVC purist, you can always create a file that does nothing but echo json(...);.

A: In your code:
$result['rows'] = json_encode($rows);

if (request::is_ajax()) {
    echo json_encode($result);
}

I would say it should be:
$result['rows'] = $rows;

if (request::is_ajax()) {
    echo json_encode($result);
}

I do not know what the purpose of the is_ajax is, but that may be an unnecessary check. But what was probably happening was that you were encoding the rows then encoding the entire result set. So when it came to parsing and you did the parseJSON, well you would have to do that again for the rows index of the array.


text:
Q: postgresql insert with multiple selects If this is how I insert one record:
insert into fund_data
    (fund_entries_id
     ,fund_val
     ,bbg_pulls_id)
(select fe.id, 1,20
    from
        fund_entries fe
    where
         fe.company_id = 399
        and fe.fiscal_prd_end_date = '2016-09-30')

And this is how I insert another record:
insert into fund_data
    (fund_entries_id
     ,fund_val
     ,bbg_pulls_id)
(select fe.id, 567,20
    from
        fund_entries fe
    where
         fe.company_id = 5
        and fe.fiscal_prd_end_date = '2016-09-28')

How do I insert them both in the same insert statement? Note, that in reality, there will be hundreds of thousands of inserts, not just two, so efficiency is very important.
In other words, from record to record in the insert company_id, fund_val, fiscal_prd_end_date change. bbg_pulls_idstays the same. But fund_entries_id is found via fiscal_prd_end_date in the fund_entries table for each insert.
My tables look like this:
CREATE TABLE public.fund_data
(
    id bigint NOT NULL DEFAULT nextval('fund_data_id_seq'::regclass),
    fund_entries_id integer NOT NULL,
    fund_val numeric,
    bbg_pulls_id integer,
    wh_calc_id integer,
    CONSTRAINT fund_data_pkey PRIMARY KEY (id),
    CONSTRAINT fund_data_fund_entries_id_bbg_pulls_id_key UNIQUE (fund_entries_id, bbg_pulls_id),
    CONSTRAINT fund_data_fund_entries_id_wh_calc_id_key UNIQUE (fund_entries_id, wh_calc_id),
    CONSTRAINT fund_data_bbg_pulls_id_fkey FOREIGN KEY (bbg_pulls_id)
        REFERENCES public.bbg_pulls (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT fund_data_fund_entries_id_fkey FOREIGN KEY (fund_entries_id)
        REFERENCES public.fund_entries (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT fund_data_wh_calc_id_fkey FOREIGN KEY (wh_calc_id)
        REFERENCES public.wh_calc (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        DEFERRABLE,
    CONSTRAINT fund_data_check CHECK ((wh_calc_id IS NULL) <> (bbg_pulls_id IS NULL)),
    CONSTRAINT fund_data_check1 CHECK (NOT (wh_calc_id IS NULL AND fund_val IS NULL))
)

CREATE TABLE public.fund_entries
(
    id integer NOT NULL DEFAULT nextval('fund_entries_id_seq'::regclass),
    fiscal_prd_end_date date NOT NULL,
    company_id integer NOT NULL,
    ern_dt_id integer NOT NULL,
    CONSTRAINT fund_entries_pkey PRIMARY KEY (id),
    CONSTRAINT fund_entries_company_id_fiscal_prd_end_date_key UNIQUE (company_id, fiscal_prd_end_date),
    CONSTRAINT fund_entries_ern_dt_id_key UNIQUE (ern_dt_id),
    CONSTRAINT fund_entries_company_id_fkey FOREIGN KEY (company_id)
        REFERENCES public.company (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION,
    CONSTRAINT fund_entries_ern_dt_id_fkey11 FOREIGN KEY (ern_dt_id)
        REFERENCES public.ern_dt (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
)

I am currently considering using WITH statements for the selects and access the fund_entries_id from the WITH queries. Not sure that is the cleanest way to do that.
Or maybe something like this:
One INSERT with multiple SELECT
Not sure how to implement that though.
Thanks!

A: You can prepare the data to be inserted in a CTE, e.g.:
with rows_to_insert(fund_val, bbg_pulls_id, company_id, fiscal_prd_end_date) as (
values
    (  1, 20, 399, '2016-09-30'::date),
    (567, 20,   5, '2016-09-28')
)

insert into fund_data (fund_entries_id, fund_val, bbg_pulls_id)
select fe.id, ri.fund_val, ri.bbg_pulls_id
from fund_entries fe
join rows_to_insert ri using (company_id, fiscal_prd_end_date)


text:
Q: How to split ECU string data on Arduino? I have a question for splitting engine control system string data from a serial port. The communication protocol description is below.
Example:
To retrieve the data displayed on the LCD screen of the FADEC. If the command is RSD, then the output would be:
**C7h 2Ch 52h 53h 44h 2Ch 0Dh**

C7h -> Sync
2Ch -> "," Separator
52h -> "R"
53h -> "S"
44h -> "D"
2Ch -> "," Separator
0Dh -> CR, last byte.

The ECU will return two strings. The first, a copy of the command received, followed by the data requested. In the above example, it will return:
**C7h, RSD, 0Dh**
C7h -> Sync byte
2Ch -> "," Separator

Payload in ASCII "TrimLow EGT 20CRpm 50.000Pw=124"
2Ch -> "," Separator
0Dh -> CR, last byte.

I read all the data on the screen in string format. When I send RCV to the ECU, it will return RPM, temperature, pump voltage, battery voltage and throttle according to the above form.

Xicoy description: ( Command, Meaning, Payload)
RCV Read Current Values RPM, EGT in ºC, Pump Power, Voltage of Battery,Throttle %

    byte veri[]= { 0xC7, 0x2C, 0x52, 0x43, 0x56, 0x2C, 0x0D }; // for RCV

And datasheet (page 5-6-7): http://www.xicoy.com/SerialAdapt1_0.pdf
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
int i=0;
byte veri[]= { 0xC7, 0x2C, 0x52, 0x43, 0x56, 0x2C, 0x0D }; // RCV
int myTimeout = 100;

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  mySerial.setTimeout(myTimeout);
}

void loop() {
  Serial.println(mySerial.readString());
  for(i=0;i<7;i++)
  {
    mySerial.write(veri[i]);
  }
}

How can I separate RPM, EGT °C, pump voltage, battery voltage and throttle % in the data packet that is coming back from the ECU? After the discrimination process, I will send it to LabView via the second serial port. The RPM values can be 6 digits (approx. 120000 RPM) and the exhaust gas temperature is 3 digits (EGT 800 °C), the figures may be missing because all are zero except throttle value. Can you share a sample? Thanks.
Picture:

A: Also answer is ;
#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // RX, TX

int i=0;
byte veri[]= { 0xC7, 0x2C, 0x52, 0x43, 0x56, 0x2C, 0x0D }; // RCV
int myTimeout = 10;
String veri2[]={};
void setup() {
Serial.begin(9600);
while (!Serial) {
}
analogWrite(5,250);
mySerial.begin(9600);
mySerial.setTimeout(myTimeout);
}

void loop() { // run over and over

for(i=0;i<7;i++)
{
mySerial.write(veri[i]);
}

String split = mySerial.readString();
String word3 = getValue(split, ',',0);
Serial.println(word3);
for(i=0;i<7;i++)
{
mySerial.write(veri[i]);
}

String  split2 = mySerial.readString();
String word4= getValue(split2, ',',1);
Serial.println(word4);
 /*
split = mySerial.readString();
word3 = getValue(split, ',',2);
Serial.println(word3);
split = mySerial.readString();
word3 = getValue(split, ',',3);
Serial.println(word3);
split = mySerial.readString();
word3 = getValue(split, ',',4);
Serial.println(word3);
split = mySerial.readString();
word3 = getValue(split, ',',5);
Serial.println(word3);
split = mySerial.readString();
word3 = getValue(split, ',',6);
Serial.println(word3);
split = mySerial.readString();
word3 = getValue(split, ',',7);
Serial.println(word3);
}

*/
 String getValue(String data, char separator, int index)
 {
 int found = 0;
 int strIndex[] = {0, -1};
 int maxIndex = data.length()-1;

 for(int i=0; i<=maxIndex && found<=index; i++){
 if(data.charAt(i)==separator || i==maxIndex){
    found++;
    strIndex[0] = strIndex[1]+1;
    strIndex[1] = (i == maxIndex) ? i+1 : i;
 }
 }

 return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
 }


text:
Q: dependency_overrides does not override dependency The following FastApi test should use my get_mock_db function instead of the get_db function, but it dosen't. Currently the test fails because it uses the real Database.
def get_mock_db():
    example_todo = Todo(title="test title", done=True, id=1)

    class MockDb:
        def query(self, _model):
            mock = Mock()
            mock.get = lambda _param: example_todo

        def all(self):
            return [example_todo]

        def add(self):
            pass

        def commit(self):
            pass

        def refresh(self, todo: CreateTodo):
            return Todo(title=todo.title, done=todo.done, id=1)

    return MockDb()

client = TestClient(app)

app.dependency_overrides[get_db] = get_mock_db

def test_get_all():
    response = client.get("/api/v1/todo")
    assert response.status_code == 200
    assert response.json() == [
        {
            "title": "test title",
            "done": True,
            "id": 1,
        }
    ]

A: Key is to understand that dependency_overrides is just a dictionary. In order to override something, you need to specify a key that matches the original dependency.
def get_db():
   return {'db': RealDb()}

def home(commons: dict= Depends(get_db))
   commons['db'].doStuff()

app.dependency_overrides[get_db] = lambda: {'db': MockDb()}

Here you have inside the Depends function call a reference to get_db function. Then you are referring to the exact same function with dependency_overrides[get_db]. Therefore it gets overridden. Start by verifying that 'xxx' in these two match exactly: Depends(xxx) and dependency_overrides[xxx].
It took some time to wrap my head around the fact that whatever is inside the Depends call is actually the identifier for the dependency. So in this example the identifier is function get_db and the same function is used as key in the dictionary.
So this means the following example does not work since you are overriding something else than what's specified for Depends.
def get_db(connection_string):
   return {'db': RealDb(connection_string)}

def home(commons: dict= Depends(get_db(os.environ['connectionString']))
   commons['db'].doStuff()

# Does not work
app.dependency_overrides[get_db] = lambda: {'db': MockDb()}


text:
Q: __doPostBack only works if there is a LinkButton, Calendar or WizardStep control on the page I have identified a problem with __doPostBack and found a work around. I am seeking an explanation for the cause and/or a better solution than my work around.
Scenario:
I have a dropdown populated with the values; "-Select-", "One" & "Two". If the user selects "One" than client side script is executed. If the user selects "Two" than server side script is executed.
Problem:
The client script initiates the postback by calling __doPostBack. However, no post back actually occurs unless there is also a LinkButton, Calendar or WizardStep control on the page. I actually went through all of the standard tools in the Visual Studio Toolbox and tested them all. It has to be one of those three.
Work Around:
Add a link button surrounded by a span with display set to none.

    <asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>

Question: Can somebody provide an explanation for this behavior or provide a better fix than my "Work Around"?
Source - Javascript (I placed it between the head tags)

Source - ASPX Controls
    <asp:DropDownList ID="DropDownList1" runat="server"  onchange="DropDownList1_change(this)" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
        <asp:ListItem>-Select-</asp:ListItem>
        <asp:ListItem>One</asp:ListItem>
        <asp:ListItem>Two</asp:ListItem>
    </asp:DropDownList>

        <asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton>

    Time of last Post Back: <asp:Label ID="Label1" runat="server"></asp:Label>

    Time of OnSelectedIndexChanged: <asp:Label ID="Label2" runat="server"></asp:Label>

Source - Code Behind
    protected void Page_Load(object sender, EventArgs e)
    {
        Label1.Text = DateTime.Now.ToLongTimeString();
    }

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label2.Text = DateTime.Now.ToLongTimeString();
    }

Additional Resource - I found the following article after posting this question. Its a very old Microsoft article and the only Microsoft article I found that mentions the specific limitation of DropDowns, return values & postbacks. I haven't digged deep into their solution and not sure time will allow me to. Mainly posting it in case my solution fails down the road or doesn't work for someone else.

Intuitively you might think adding a confirm dialog box for a
  DropDownList is identical to adding such a dialog box for a Button Web
  control. That is, simply set the DropDownList's client-side onchange
  attribute to something like: return confirm(...);. using:
  DropDownListID.Attributes("onchange") = "return confirm(...);"
  Unfortunately, this won't work as desired because an AutoPostBack
  DropDownList's onchange attribute will be set to a bit of JavaScript
  that causes a postback, namely a call to the client-side __doPostBack
  function. When setting the onchange attribute programmatically
  yourself, the end result is that the rendered client-side onchange
  event handler has both your code and the call to __doPostBack:

The article is long so search for "Confirmation with AutoPostBack DropDownLists"
https://msdn.microsoft.com/en-us/library/aa479302.aspx

A: There are 2 solutions.
Solution 1:
A better work around than adding a link button surrounded by hidden span tags is to add the following to the page load event. This ensures that the function __doPostBack is available.
protected void Page_Load(object sender, EventArgs e)
{
    Page.ClientScript.GetPostBackEventReference(this, string.Empty);
}

The function __doPostBack is generated only if a control in the form needs it to perform postbacks. This includes controls like the LinkButton and other controls for which AutoPostBack is set to true. In fact, only the Button and ImageButton controls can perform postbacks without __doPostBack (see this article). For example, we can see in the HTML output that a LinkButton is rendered this way:
My link

Solution 2: The following approach achieves the same thing without using __doPostBack.

In the present case, you could set AutoPostBack="true" for the DropDownList:
<asp:DropDownList AutoPostBack="true" onchange="if (!confirmPostBack(this)) return false;" ... >

The onchange event handler would return false when you want to prevent the postback. The Javascript function could be something like this:
function confirmPostBack(ddl)
{
    if (condition) {
        ...
        return true;
    }
    else {
        ...
        return false;
    }
}

Important: The onchange event handler should not return anything to allow the postback to occur. You can use this syntax:
onchange="if (!confirmPostBack(this)) return false;"

For reasons probably explained in the article mentioned in the question, the following syntax does not work. Returning true still prevents the postback.
onchange="return confirmPostBack(this);" // Does not work!


text:
Q: Flutter getAll operation from Firestore returning null I am trying to get all the documents related to a collection from Firestore, but it returns null. The below code is working for the users collection (retrieving only one user), but for masterclasses not.
This is my Firestore database:

And the code related to it:
    import 'dart:developer';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:womanverse/model/masterclass.dart';
import 'package:womanverse/model/user.dart';

class DatabaseService {

  final String? uid;
  DatabaseService ({ this.uid });
  final CollectionReference userCollection = FirebaseFirestore.instance.collection('users');
  final CollectionReference masterclassesCollection = FirebaseFirestore.instance.collection('masterclasses');

  Future updateUserData(String email, String name, String phoneNumber, bool isSubscribed) async {
    return userCollection.doc(uid).set({
      'email' : email,
      'name' : name,
      'phoneNumber' : phoneNumber,
      'isSubscribed' : isSubscribed,
    });
  }

  Future updateName(String name) async {
    return userCollection.doc(uid).update({
      'name' : name,
    });
  }

  Future updateEmail(String email) async {
    return userCollection.doc(uid).update({
      'email' : email,
    });
  }

  Future updatePhoneNumber(String phoneNumber) async {
    return userCollection.doc(uid).update({
      'phoneNumber' : phoneNumber,
    });
  }

  Future updateSubscribe(bool subscribe) async {
    return userCollection.doc(uid).update({
      'isSubscribed' : subscribe,
    });
  }

  //user from Document
  MyUser userFromDocument (DocumentSnapshot snapshot){

    var sn = snapshot.data() as Map<String, dynamic>;

    return MyUser(
      uid: sn['uid'],
      name: sn['name'],
      email: sn['email'],
      phoneNumber: sn['phoneNumber'],
      isSubscribed: sn['isSubscribed']
    );
  }

  Stream<MyUser> get mySingleUser {
    return userCollection.doc(uid).snapshots().map(userFromDocument);
  }

  List<Masterclass> masterclassesConvert (QuerySnapshot snapshot)  {
    return snapshot.docs.map((doc){
      return Masterclass(
          uid: doc.get('uid') ?? "",
          authorImage: doc.get('authorImage') ?? "",
          authorName: doc.get('authorName') ?? "",
          classImage: doc.get('classImage') ?? "",
          className: doc.get('className') ?? ""
      );
    }).toList();

}

  Stream<List<Masterclass>> get masterclasses {
    return masterclassesCollection.snapshots().map(masterclassesConvert);
  }

}

I am using Stream Provider to listen any changes for masterclass collection:
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:flutter/material.dart';
import 'package:persistent_bottom_nav_bar/persistent-tab-view.dart';
import 'package:provider/provider.dart';
import 'package:sizer/sizer.dart';
import 'package:womanverse/db/firestore_database.dart';
import 'package:womanverse/model/masterclass.dart';
import 'package:womanverse/pages/home/masterclasses/learnmore.dart';
import 'package:womanverse/pages/home/masterclasses/session.dart';
import 'package:womanverse/pages/home/masterclasses/education_sessions_list.dart';

class Education extends StatelessWidget {
  const Education({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    //precacheImage(const AssetImage("assets/background-marmura.png"), context);

    return StreamProvider<List<Masterclass>>.value(
      value: DatabaseService().masterclasses,
      initialData: const [],
      child: Sizer(
          builder: (context, orientation, deviceType) {
            return Scaffold(
                body: SafeArea(
                  child: SingleChildScrollView(
                      child: Column(
                        children: [
                          SizedBox(height:7.h),
                          Container(
                            margin: const EdgeInsets.fromLTRB(20, 0, 20, 0),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children:  [
                                Flexible(
                                    child: Text("ELITE MASTERCLASSES",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                        fontSize: SizerUtil.deviceType == DeviceType.mobile ? 20.sp : 17.sp,
                                        letterSpacing: 3,
                                        color: const Color(0xff393432),
                                        fontFamily: 'RoyaleBold',
                                      ),)
                                ),
                              ],
                            ),
                          ),
                          SizedBox(height:3.h),
                          ElevatedButton(
                            style: ButtonStyle(
                                padding: MaterialStateProperty.all(EdgeInsets.fromLTRB(3.w, 1.h, 3.w, 1.h)),
                                elevation: MaterialStateProperty.all(5), //Defines Elevation
                                backgroundColor: MaterialStateProperty.all(const Color(0xffE4BCB4)),
                                shape: MaterialStateProperty.all<RoundedRectangleBorder>(
                                    RoundedRectangleBorder(
                                      borderRadius: BorderRadius.circular(10.0),
                                    )
                                )
                            ),
                            onPressed: () {
                              pushNewScreen(context,
                                  screen: const LearnMore(),
                                  withNavBar: true,
                                  pageTransitionAnimation: PageTransitionAnimation.slideRight);
                            },
                            child: Text("LEARN MORE",
                                style: TextStyle(
                                  color: const Color(0xff393432),
                                  fontSize: SizerUtil.deviceType == DeviceType.mobile ? 10.sp : 9.sp,
                                  fontWeight: FontWeight.bold,
                                )
                            ),
                          ),
                          SizedBox(height: 2.h),
                          Container(
                            margin: const EdgeInsets.fromLTRB(10, 0, 0, 0),
                            child: SizedBox(
                              height: 35.h,
                              child: const SessionsList(),
                            ),
                          ),

                          SizedBox(height: 7.h),
                          Container(
                            width: 100.w,
                            color: Colors.black,
                            padding: const EdgeInsets.all(20),
                            child: Column(
                              children: [
                                Row(
                                  children: [
                                    Text("NFT",
                                      textAlign: TextAlign.center,
                                      style: TextStyle(
                                        fontSize: SizerUtil.deviceType == DeviceType.mobile ? 20.sp : 17.sp,
                                        letterSpacing: 3,
                                        color: Colors.white,
                                        fontFamily: 'RoyaleBold',
                                      ),),
                                  ],
                                ),
                                SizedBox(height: 2.h),
                                Row(
                                  children: [
                                    Stack(
                                      children:[
                                        SizedBox(
                                          width: 100.w - 40,
                                          height: 30.h,
                                          child: Card(
                                            semanticContainer: true,
                                            clipBehavior: Clip.antiAliasWithSaveLayer,
                                            child: Image.asset(
                                              'assets/background-marmura.png',
                                              fit: BoxFit.fill,
                                            ),
                                            shape: RoundedRectangleBorder(
                                              borderRadius: BorderRadius.circular(10.0),
                                            ),
                                            elevation: 5,
                                            margin: const EdgeInsets.all(10),
                                          ),
                                        ),
                                        Positioned(
                                          bottom: 20,
                                          right: 25,
                                          child: OutlinedButton(
                                            onPressed: () {

                                            },
                                            style: OutlinedButton.styleFrom(
                                              padding: const EdgeInsets.fromLTRB(17, 13, 17, 13),
                                              primary: const Color(0xffE4BCB4),
                                              shape: RoundedRectangleBorder(
                                                borderRadius: BorderRadius.circular(
                                                    10.0),
                                              ),
                                              side: const BorderSide(
                                                  width: 2, color: Color(0xff393432)),
                                            ),
                                            child: Text(
                                                'GO TO SESSION',
                                                style: TextStyle(
                                                  color: const Color(0xff393432),
                                                  fontSize: SizerUtil.deviceType == DeviceType.mobile ? 10.sp : 8.sp,
                                                  fontWeight: FontWeight.w700,
                                                )
                                            ),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ],
                                )
                              ],
                            ),
                          ),
                        ],
                      )
                  ),
                )
            );
          }
      ),
    );
  }
}

Where I listen to:
import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:persistent_bottom_nav_bar/persistent-tab-view.dart';
import 'package:provider/provider.dart';
import 'package:sizer/sizer.dart';
import 'package:womanverse/model/masterclass.dart';
import 'package:womanverse/pages/home/masterclasses/session.dart';

class SessionsList extends StatefulWidget {
  const SessionsList({Key? key}) : super(key: key);

  @override
  State<SessionsList> createState() => _SessionsListState();
}

class _SessionsListState extends State<SessionsList> {

  createSessionThumbnail(String image, Widget newPage, context) {
    print("asda");
    return Stack(
      children:[
        SizedBox(
          width: 75.w,
          height: 35.h,
          child: Card(
            semanticContainer: true,
            clipBehavior: Clip.antiAliasWithSaveLayer,
            child: Image.network(
              image,
              fit: BoxFit.fill,
            ),
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(10.0),
            ),
            elevation: 5,
            margin: const EdgeInsets.all(10),
          ),
        ),
        Positioned(
          bottom: 20,
          right: 30,
          child: OutlinedButton(
            onPressed: () {
              pushNewScreen(context,
                  screen: newPage,
                  withNavBar: true,
                  pageTransitionAnimation: PageTransitionAnimation.slideRight);
            },
            style: OutlinedButton.styleFrom(
              padding: const EdgeInsets.fromLTRB(17, 13, 17, 13),
              primary: const Color(0xffE4BCB4),
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(
                    10.0),
              ),
              side: const BorderSide(
                  width: 2, color: Color(0xff393432)),
            ),
            child: Text(
                'GO TO SESSION',
                style: TextStyle(
                  color: const Color(0xff393432),
                  fontSize: SizerUtil.deviceType == DeviceType.mobile ? 10.sp : 8.sp,
                  fontWeight: FontWeight.w700,
                )
            ),
          ),
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    log("aaaa");
    final masterclasses = Provider.of<List<Masterclass>>(context);
    log("a");
    return ListView.builder(
      scrollDirection: Axis.horizontal,
      itemCount: masterclasses.length,
      itemBuilder: (BuildContext ctx, int index) {
        print("aa");
        return createSessionThumbnail(masterclasses[index].classImage!, const Session(), ctx);
      },

    );
  }
}

A: I solved this issue by changing
  List<Masterclass> masterclassesConvert (QuerySnapshot snapshot)  {
    return snapshot.docs.map((doc){
      return Masterclass(
          uid: doc.data().toString().contains('uid') ? doc.get('uid') : '',
          authorImage: doc.data().toString().contains('authorImage') ? doc.get('authorImage') : '',
          authorName: doc.data().toString().contains('authorName') ? doc.get('authorName') : '',
          classImage: doc.data().toString().contains('classImage') ? doc.get('classImage') : '',
          className: doc.data().toString().contains('className') ? doc.get('className') : '',
      );
    }).toList();
  }

Somehow, the latest version of Firestore, should have this check: doc.data().toString().contains('authorImage')


text:
Q: VBScript not working when PC is locked I'm running a VBScript that communicates to an exe file in Windows 7.
The VBScript works great!
The issues I have, is that once the PC has been in locked, goes to sleep or hiberation the VBScript doesn't communicate with the exe application.
The VBScript is running (I have a log that tells me every time a loop is complete, but its not communicating to the exe.
Below is code that is not working when the PC is locked.
Set WSHShell = WScript.CreateObject("WScript.Shell")
' info for exporting data
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fso, MyFile, FileName, TextLine, cycles
Dim I
I = 0
Dim n
n = .1 'how often the program saves the data (in minutes)
cycles = 2 'how many times it will save
FileName = "C:\Users\Desktop\new.txt" 'location where the log file will save
Dim sl
sl = n * 60000 'change from seconds to ms for the sleep function
Set fso = CreateObject("Scripting.FileSystemObject")
' Open the file for output
Set MyFile = fso.OpenTextFile(FileName, ForAppending, True, TristateTrue)
' Write to the file.
MyFile.WriteLine "Log file for recording data from Yokogawa MX100 (" & cycles
& " cycles)"
WSHShell.Run "MXStandardE.exe"
WScript.Sleep 1000
WSHShell.AppActivate "MXStandardE.exe"
WScript.Sleep 1000
Do while I < cycles
a = Now()
WScript.Sleep 1000
WSHShell.Run "MXStandardE.exe"
WScript.Sleep 1000
WSHShell.AppActivate "MXStandardE.exe"
WScript.Sleep 1000
WSHShell.SendKeys "%A"
WScript.Sleep 1000
WSHShell.SendKeys "{DOWN}"
WScript.Sleep 1000
WSHShell.SendKeys "{ENTER}"
I = I + 1
MyFile.Writeline I & " of " & cycles & " at " & a & " --time of each cycle is
" & n & " minutes"
WScript.Sleep sl 'when sl is used loop time is in minutes
Loop
MyFile.Close
MsgBox ("Script has completed")

A: As Ansgar already said, it's pretty obvious that nothing will work while the PC sleeps or hibernates. In the case where the PC is locked, techniques that rely on window management or direct input such as SendKeys won't work as expected, because the user's session, along with user-level applications, is essentially shelved to make way for the login screen or another user.
You might want to do some research into the SendMessage/PostMessage API, or you can stop using VBScript and replace it with a Scheduled Task or system service that runs using a local service account, assuming you just want to execute an exe without any UI interaction.

A: The question is: do you need to go under hibernation or pc suspension? If not, you should simply configure or turn off those settings. By only locking the session, the vbscript should be run and generate an outpout without any trouble. By checking and configuring advanced windows energy settings it might help you solving this.