问:
Back-transforming predictions from glmmTMB with truncated distribution
I'm running a glmmTMB with truncated count distributions, and am interested in predicting on the link scale and back-transforming the result. This is a follow-up to this question. The answer to the linked question addressed predicting from a glmmTMB with a truncated distribution on the response scale. I'm interested in predicting on the link scale and back-transforming, since my sample size is not large and the variability is high, so predicting on response scale results in lower CIs below 0.

As shown in the toy example, a simple exp() obviously is the wrong way to back-transform, since the resulting values do not account for the truncation. Any help would be appreciated!

```<code>library(dplyr)
library(extraDistr)
library(glmmTMB)
library(ggplot2)

set.seed(1)
df <- data.frame(Group = rep(c("a", "b"), each = 20),
                 N = rtpois(40, 1, a = 0))
m <- glmmTMB(N ~ Group, data = df, family = "truncated_poisson")

preds <- predict(m, type = "response", se.fit = TRUE)
df$PredResponse <- preds$fit
df$PredResponseLower <- preds$fit - 1.98*preds$se.fit
df$PredResponseUpper <- preds$fit + 1.98*preds$se.fit

preds <- predict(m, type = "link", se.fit = TRUE)
df$PredLink <- exp(preds$fit)
df$PredLinkLower <- exp(preds$fit - 1.98*preds$se.fit)
df$PredLinkUpper <- exp(preds$fit + 1.98*preds$se.fit)

df %>%
    group_by(Group) %>%
    mutate(Mean = mean(N)) %>%
    ggplot() +
    geom_point(aes(x = Group, y = Mean), size = 5) +
    geom_point(aes(x = Group, y = PredLink, colour = "Link")) +
    geom_point(aes(x = Group, y = PredResponse, colour = "Response")) +
    geom_errorbar(aes(x = Group, ymin = PredLinkLower, ymax = PredLinkUpper, colour = "Link")) +
    geom_errorbar(aes(x = Group, ymin = PredResponseLower, ymax = PredResponseUpper, colour = "Response"))

</code>```

Body:
I'm running a glmmTMB with truncated count distributions, and am interested in predicting on the link scale and back-transforming the result. This is a follow-up to this question. The answer to the linked question addressed predicting from a glmmTMB with a truncated distribution on the response scale. I'm interested in predicting on the link scale and back-transforming, since my sample size is not large and the variability is high, so predicting on response scale results in lower CIs below 0.

As shown in the toy example, a simple exp() obviously is the wrong way to back-transform, since the resulting values do not account for the truncation. Any help would be appreciated!

library(dplyr)
library(extraDistr)
library(glmmTMB)
library(ggplot2)

set.seed(1)
df <- data.frame(Group = rep(c("a", "b"), each = 20),
                 N = rtpois(40, 1, a = 0))
m <- glmmTMB(N ~ Group, data = df, family = "truncated_poisson")

preds <- predict(m, type = "response", se.fit = TRUE)
df$PredResponse <- preds$fit
df$PredResponseLower <- preds$fit - 1.98*preds$se.fit
df$PredResponseUpper <- preds$fit + 1.98*preds$se.fit

preds <- predict(m, type = "link", se.fit = TRUE)
df$PredLink <- exp(preds$fit)
df$PredLinkLower <- exp(preds$fit - 1.98*preds$se.fit)
df$PredLinkUpper <- exp(preds$fit + 1.98*preds$se.fit)

df %>%
    group_by(Group) %>%
    mutate(Mean = mean(N)) %>%
    ggplot() +
    geom_point(aes(x = Group, y = Mean), size = 5) +
    geom_point(aes(x = Group, y = PredLink, colour = "Link")) +
    geom_point(aes(x = Group, y = PredResponse, colour = "Response")) +
    geom_errorbar(aes(x = Group, ymin = PredLinkLower, ymax = PredLinkUpper, colour = "Link")) +
    geom_errorbar(aes(x = Group, ymin = PredResponseLower, ymax = PredResponseUpper, colour = "Response"))


来源: stackexchange

问:
BASH bug or feature?: Shadowing a readonly global variable with a writable local variable
(Possibly this is the same question as Function local read-only vs. global read-only variable with the same name)

In a script I wrote I'm using readonly key="$1" (for the program parameter) at the global level, and a function uses local key="$1" (for the function parameter this time), too.

To my surprise BASH 4.4 outputs:

...: local: key: readonly variable

In my understanding there is a global readonly variable, but the local variable should be independent of it, even when having the same name, right?

Or did I misunderstand something?
Reading the manual page on local did not bring me any further.
Or is it that local does not declare a local variable, but a local value for a (global) variable (thus the global read-only status preventing even a local change)?

Would be a rather confusing concept then IMHO.

ContentLicense: CC BY-SA 4.0


问:
Failed to execute transaction In ServiceWorker?
I am trying to create a service worker for uploading files to the server, but getting an error

```<code>Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.
</code>```

I am trying that when a user uploads a file and if the internet is slow or the user closes the window while uploading, the data will be in the queue, and once available it should start uploading in the background.

```<code>    function addToQueue(request) {
  return new Promise(function (resolve, reject) {
    // Open an IndexedDB database and store the file in the Que object store
    var openRequest = indexedDB.open("uploadQueue", 1);

    openRequest.onupgradeneeded = function () {
      var db = openRequest.result;
      db.createObjectStore("queue", { autoIncrement: true });
    };

    openRequest.onsuccess = function () {
      var db = openRequest.result;
      var transaction = db.transaction(["queue"], "readwrite");
      var objectStore = transaction.objectStore("queue");
      objectStore.add(request);
      transaction.oncomplete = function () {
        db.close();
        resolve();
      };
    };
  });
}

setInterval(function () {

  if (navigator.onLine) {
    // Check if there are any queued files
    var openRequest = indexedDB.open("uploadQueue", 1);
    openRequest.onsuccess = function () {
      var db = openRequest.result;
      var transaction = db.transaction(["queue"], "readonly");
      var objectStore = transaction.objectStore("queue");
      var request = objectStore.getAll();
      request.onsuccess = function () {
        // If there are queued file, start uploading them
        if (request.result.length > 0) {
          request.result.forEach(function (request) {
            fetch("https://abc.in/serviceworker/", {
              method: "POST",
              body: request.body,
            });

            objectStore.delete(request.id);
          });
        }
      };
    };
  }
}, 60000);
</code>```

Body:
I am trying to create a service worker for uploading files to the server, but getting an error

Failed to execute 'transaction' on 'IDBDatabase': One of the specified object stores was not found.

I am trying that when a user uploads a file and if the internet is slow or the user closes the window while uploading, the data will be in the queue, and once available it should start uploading in the background.

    function addToQueue(request) {
  return new Promise(function (resolve, reject) {
    // Open an IndexedDB database and store the file in the Que object store
    var openRequest = indexedDB.open("uploadQueue", 1);

    openRequest.onupgradeneeded = function () {
      var db = openRequest.result;
      db.createObjectStore("queue", { autoIncrement: true });
    };

    openRequest.onsuccess = function () {
      var db = openRequest.result;
      var transaction = db.transaction(["queue"], "readwrite");
      var objectStore = transaction.objectStore("queue");
      objectStore.add(request);
      transaction.oncomplete = function () {
        db.close();
        resolve();
      };
    };
  });
}

setInterval(function () {

  if (navigator.onLine) {
    // Check if there are any queued files
    var openRequest = indexedDB.open("uploadQueue", 1);
    openRequest.onsuccess = function () {
      var db = openRequest.result;
      var transaction = db.transaction(["queue"], "readonly");
      var objectStore = transaction.objectStore("queue");
      var request = objectStore.getAll();
      request.onsuccess = function () {
        // If there are queued file, start uploading them
        if (request.result.length > 0) {
          request.result.forEach(function (request) {
            fetch("https://abc.in/serviceworker/", {
              method: "POST",
              body: request.body,
            });

            objectStore.delete(request.id);
          });
        }
      };
    };
  }
}, 60000);


问:
How to detect realtime webstreamed video frozen at webrtc using javascript?
when I was creating the videoCall App Using webrtc, the issue was when a remote streamed
video disconnects due to a network issue, the video was frozen,

How to detect real-time web-streamed video frozen at Webrtc?


问:
how to compress an image in react while using react-dropzone
I'm using react dropzone package in my next JS app. and i wanted to implement image compression automatically.

first after i got the images i converted the blob/ preview into a file reader. then i used compressorjs package. but after i did that the image is not getting compressed?

how can i compress an image/images in react when the image is passed from dropzone?

```<code>const [files, setFiles] = useState([]);
onDrop: (acceptedFiles) => {

const newFiles = acceptedFiles.map((file, index) => {
        return Object.assign(file, {
          preview: URL.createObjectURL(file),
        });
      });

if (files.length < 9) {
        setFiles((prev) => [...prev, ...newFiles]);

        files.map((file) => {
          newFiles.forEach((newFile) => {
            if (newFile.name == file.name) {
              alert(newFile.name + " is a duplicate file");

              setFiles(
                files,
                files.filter((val) => val !== newFile)
              );
            }
          });
        });
      } else if (acceptedFiles.length >= 9) {
        alert("select maximum of 9 images");
      } else {
        alert("maximum images to be selected is 9");
      }
    },
  });

const removeFile = (file) => () => {
    const newFiles = [...files];
    newFiles.splice(newFiles.indexOf(file), 1);
    setFiles(newFiles);
    if (files.length == 1) {
      setText("Drag and Drop or click here to upload Images");
    }
  };
  useEffect(() => {
    // Make sure to revoke the data uris to avoid memory leaks, will run on unmount
    return () => files.forEach((file) => URL.revokeObjectURL(file.preview));
  }, []);
</code>```

the compressorjs code i used is

```<code>    acceptedFiles.map((file, index) => {
        const reader = new FileReader();

        reader.onload = function (e) {
new Compressor(e.target.result, {
    quality: 0.8,
    success: (compressedFile) => {
      setFiles((prev) => [
        ...prev,
        compressedFile
      ]);
    },
  });

        };
        reader.readAsDataURL(file);
        return file;
      });
</code>```

please any contribution on this.

Body:
I'm using react dropzone package in my next JS app. and i wanted to implement image compression automatically.

first after i got the images i converted the blob/ preview into a file reader. then i used compressorjs package. but after i did that the image is not getting compressed?

how can i compress an image/images in react when the image is passed from dropzone?

const [files, setFiles] = useState([]);
onDrop: (acceptedFiles) => {

const newFiles = acceptedFiles.map((file, index) => {
        return Object.assign(file, {
          preview: URL.createObjectURL(file),
        });
      });

if (files.length < 9) {
        setFiles((prev) => [...prev, ...newFiles]);

        files.map((file) => {
          newFiles.forEach((newFile) => {
            if (newFile.name == file.name) {
              alert(newFile.name + " is a duplicate file");

              setFiles(
                files,
                files.filter((val) => val !== newFile)
              );
            }
          });
        });
      } else if (acceptedFiles.length >= 9) {
        alert("select maximum of 9 images");
      } else {
        alert("maximum images to be selected is 9");
      }
    },
  });

const removeFile = (file) => () => {
    const newFiles = [...files];
    newFiles.splice(newFiles.indexOf(file), 1);
    setFiles(newFiles);
    if (files.length == 1) {
      setText("Drag and Drop or click here to upload Images");
    }
  };
  useEffect(() => {
    // Make sure to revoke the data uris to avoid memory leaks, will run on unmount
    return () => files.forEach((file) => URL.revokeObjectURL(file.preview));
  }, []);

the compressorjs code i used is

    acceptedFiles.map((file, index) => {
        const reader = new FileReader();

        reader.onload = function (e) {
new Compressor(e.target.result, {
    quality: 0.8,
    success: (compressedFile) => {
      setFiles((prev) => [
        ...prev,
        compressedFile
      ]);
    },
  });

        };
        reader.readAsDataURL(file);
        return file;
      });

please any contribution on this.


问:
What's the best way to set up mysql given I code with WSL2?
I'm on Windows and use WSL2 for all my development. I currently have MySQL set up in WSL2, but I'd like to set up MySQL Workbench as well.

I'm unsure if I should install that in Windows and configure Workbench authentication/ports so they communicate (as indicated in this post and a few others) or would it be better practice/easier to install MySQL workbench in WSL2 (and set up support for Linux GUI apps)?

Alternatively, I could uninstall mysql from WSL2 and install it on Windows and run the server there and just connect to it in my scripts/apps that are running in WSL2.

With so many options on how to set this up, I'm unsure what to do.

Let me know if any more info is needed or if this is a bad question.


问:
Object fails to get deserialized when returning back to WebFluxTest context
I am writing unit tests for my API controller,
on one of the tests - i am facing a problem of deserializing an object when it returns from the endpoint, when debugging it in the controller's function i see that everything goes as expected but the error is being thrown on expectBody(UserDto.class)

It works in production but throws error on test context

```<code>        String Id = "123";
        UserTimestampDto userTimestampDto = new             UserTimestampDto(LocalDateTime.now().toString());
        TimestampsDto timestampsDto = new TimestampsDto(userTimestampDto, userTimestampDto);
        UserDto userDto = new UserDto("123",timestampsDto);

        webTestClient
                .get()
                .uri(uriBuilder -> uriBuilder
                        .path(UserController.BASE_URL + "/" + Id)
                        .build())
                .accept(MediaType.APPLICATION_JSON)
                .exchange()
                .expectStatus().isOk()
                .expectBody(UserDto.class)
                .value(userItem -> userItem, equalTo(userDto));
</code>```

The Error:

org.springframework.core.codec.DecodingException: JSON decoding error: Cannot construct instance of com.project.v1.model.timestamps.UserTimestampDto (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of com.project.v1.model.timestamps.UserTimestampDto (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (org.springframework.core.io.buffer.DefaultDataBuffer$DefaultDataBufferInputStream); line: 1, column: 296] (through reference chain: com.project.v1.model.customer.UserDto["internalTimestamps"]->com.project.v1.model.timestamps.TimestampsDto["createdDate"])

Body:
I am writing unit tests for my API controller,
on one of the tests - i am facing a problem of deserializing an object when it returns from the endpoint, when debugging it in the controller's function i see that everything goes as expected but the error is being thrown on expectBody(UserDto.class)

It works in production but throws error on test context

        String Id = "123";
        UserTimestampDto userTimestampDto = new             UserTimestampDto(LocalDateTime.now().toString());
        TimestampsDto timestampsDto = new TimestampsDto(userTimestampDto, userTimestampDto);
        UserDto userDto = new UserDto("123",timestampsDto);

        webTestClient
                .get()
                .uri(uriBuilder -> uriBuilder
                        .path(UserController.BASE_URL + "/" + Id)
                        .build())
                .accept(MediaType.APPLICATION_JSON)
                .exchange()
                .expectStatus().isOk()
                .expectBody(UserDto.class)
                .value(userItem -> userItem, equalTo(userDto));

The Error:

org.springframework.core.codec.DecodingException: JSON decoding error: Cannot construct instance of com.project.v1.model.timestamps.UserTimestampDto (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of com.project.v1.model.timestamps.UserTimestampDto (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: (org.springframework.core.io.buffer.DefaultDataBuffer$DefaultDataBufferInputStream); line: 1, column: 296] (through reference chain: com.project.v1.model.customer.UserDto["internalTimestamps"]->com.project.v1.model.timestamps.TimestampsDto["createdDate"])


问:
NameError: uninitialized constant Mail::TestMailer on Elastic Beanstalk
I'm getting this error

```<code>NameError: uninitialized constant Mail::TestMailer
</code>```

on my Ruby on Rails project on Elastic Beanstalk.

Other sources told me to install 3 gems.

```<code>gem 'net-smtp', '>= 0.3.3'
gem 'net-imap', '>= 0.1.2'
gem 'net-pop', '>= 0.1.2'
</code>```

I have already installed them, but it still does not work.
eb deploy fails every time.

Ruby version 3.0.5, rails 6.1.7

Code from application mailer, not sure if this helps but just in case.

```<code>class ApplicationMailer < ActionMailer::Base
  default from: 'from@example.com'
  layout 'mailer'
end
</code>```

Please see the error log below
eb deploy Creating application version archive "app-4523-230109_233425301397". Uploading: [##################################################] 100% Done... 2023-01-09 14:38:30    INFO    Environment update is starting.       2023-01-09 14:38:36    INFO    Deploying new version to instance(s). 2023-01-09 14:40:51    ERROR   Instance deployment failed. For details, see 'eb-engine.log'. 2023-01-09 14:40:53    ERROR   [Instance: i-0e263523f982bac43] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error.. 2023-01-09 14:40:53    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1]. 2023-01-09 14:40:53    ERROR   Unsuccessful command execution on instance id(s) 'i-0e263523f982bac43'. Aborting the operation. 2023-01-09 14:40:54    ERROR   Failed to deploy application.
I hope this helps.
Let me know if you need more information.

Body:
I'm getting this error

NameError: uninitialized constant Mail::TestMailer

on my Ruby on Rails project on Elastic Beanstalk.

Other sources told me to install 3 gems.

gem 'net-smtp', '>= 0.3.3'
gem 'net-imap', '>= 0.1.2'
gem 'net-pop', '>= 0.1.2'

I have already installed them, but it still does not work.
eb deploy fails every time.

Ruby version 3.0.5, rails 6.1.7

Code from application mailer, not sure if this helps but just in case.

class ApplicationMailer < ActionMailer::Base
  default from: 'from@example.com'
  layout 'mailer'
end

Please see the error log below
eb deploy Creating application version archive "app-4523-230109_233425301397". Uploading: [##################################################] 100% Done... 2023-01-09 14:38:30    INFO    Environment update is starting.       2023-01-09 14:38:36    INFO    Deploying new version to instance(s). 2023-01-09 14:40:51    ERROR   Instance deployment failed. For details, see 'eb-engine.log'. 2023-01-09 14:40:53    ERROR   [Instance: i-0e263523f982bac43] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error.. 2023-01-09 14:40:53    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1]. 2023-01-09 14:40:53    ERROR   Unsuccessful command execution on instance id(s) 'i-0e263523f982bac43'. Aborting the operation. 2023-01-09 14:40:54    ERROR   Failed to deploy application.
I hope this helps.
Let me know if you need more information.


问:
Bash - Using 'expect' with process substitution
Trying to use process substituion <() inside expect to add a SSH key pair. Is this possible?

```<code>ssh_key="""
----PRIVATE-----
....
"""

expect <<- EOF
  spawn ssh-add <(echo "${ssh_key}")
  expect "Enter passphrase"
  send "$password"
  expect eof
EOF
</code>```

Error:

```<code>Trying to add key to SSH agent...
extra characters after close-quote
    while executing
"spawn ssh-add <(echo "----PRIVATE-----
...."

Failed to add key to
</code>```

Body:
Trying to use process substituion <() inside expect to add a SSH key pair. Is this possible?

ssh_key="""
----PRIVATE-----
....
"""

expect <<- EOF
  spawn ssh-add <(echo "${ssh_key}")
  expect "Enter passphrase"
  send "$password"
  expect eof
EOF

Error:

Trying to add key to SSH agent...
extra characters after close-quote
    while executing
"spawn ssh-add <(echo "----PRIVATE-----
...."

Failed to add key to


问:
Is there a way to inspect the current content of metaspace in my tomcat application running with Java 8?
Since recently, the metaspace memory of my tomcat application grew to unreasonable sizes, completely overcapping the maximum memory capacity of my server. I have a hunch about what is the cause of this issue, but I would like to confirm that first, so I need a way to inspect the metaspace's content. The application is running with Java 8, which I plan to upgrade in a few months.

From what I've found out during my researches, checking the metaspace of Java 8 applications is very tricky to do. I've tried software such as JMC, but they are only able to inspect the heap memory, which the metaspace isn't a part of. I've already set a maximum size for the metaspace memory usage, which fixed the issue for now. But this is only a workaround, I would like to fix what suddenly causes the metaspace to grow so quickly, as this definitely didn't happen until a few months ago.


问:
Olingo (OData 4) + JPA: how to redefine the Metadata?
In Odata2 there is a possibility to redefine the metamodel. The following page describes the process: https://olingo.apache.org/doc/odata2/tutorials/jparedefinemetadata.html

I haven't found a way to do such conversion with OData v4/Olingo/JPA. I am using the SAP implementation olingo-jpa-processor-v4 which exists at https://github.com/SAP/olingo-jpa-processor-v4

What I am looking for is to change the external name of some classes or attributes.

I have tried to use the JPAEdmNameBuilder class but the methods of that class do not have enough information to make the changes of the attributes according to the entity from which they come. These methods only receive the name of the attribute (and not the name of the entity) so it would not be possible to selectively rename an attribute that appears in two entities.

Any suggestions on how to do that conversion?

Thank you very much

Note: there is a related question at: Olingo (OData 4): how set translation of EntitySet (Entity) names? but it is quite old and very specific. My hope is that a functionality similar to what exists in Odata2 would have been implemented during this time.


问:
Pass JavaScript Object data from client side HTML to server side using google app script
When the button is clicked, I want to capture the email ID and account name and pass this information to the server side.

The code works on the client side, but the server function does not fire, but it fails. I can see it under the execution log ad Failed.

I also tried using JSON stringify in the code. gs function, but doesn't work either.

HTML

```<code><script>

$('#btn').click(function () {

  console.log('Button is clicked');

            var accountId = $('select#accountData').val();
            console.log(accountId);
            var emailId = $('input#emailaddressId').val();
            console.log(emailId);

            var gaAccountData = {};

            gaAccountData.account = accountId
            gaAccountData.email = emailId
            console.log(gaAccountData);

            gaAccountData=JSON.stringify(gaAccountData)
            gaAccountData=JSON.parse(gaAccountData)
            google.script.run.onboardUsertoAccount(gaAccountData);
        });

</script>

</code>```

Code.gs

```<code>function onboardUsertoAccount(gaAccountData) {

    const Userdata = {
        "emailAddress": gaAccountData.email,
        "directRoles": [
            "predefinedRoles/viewer"
        ]
    }
    AnalyticsAdmin.Accounts.UserLinks.create(Userdata, gaAccountData.account, {
        "notifyNewUser": false
    });
}

</code>```

Body:
When the button is clicked, I want to capture the email ID and account name and pass this information to the server side.

The code works on the client side, but the server function does not fire, but it fails. I can see it under the execution log ad Failed.

I also tried using JSON stringify in the code. gs function, but doesn't work either.

HTML

Code.gs

function onboardUsertoAccount(gaAccountData) {

    const Userdata = {
        "emailAddress": gaAccountData.email,
        "directRoles": [
            "predefinedRoles/viewer"
        ]
    }
    AnalyticsAdmin.Accounts.UserLinks.create(Userdata, gaAccountData.account, {
        "notifyNewUser": false
    });
}


问:
Accessing state inside a function in functional component
I'm creating socket io app, where I'm setting some value from incoming event using setState. I have two event handlers. One is to modify the value and second is supposed to read this value and eventually change it. Setting the value works well and it is rendered as expected. However, when I try to read the value from second handler, there is still initial one.

See below simplified code below.

```<code>import {useEffect, useRef, useState} from "react";
import {EventEmitter} from "events";

const NumComponent = () => {
    const [num, setNum] = useState(0)
    const emitter = new EventEmitter()
    const emitterRef = new useRef(emitter)

    useEffect(() => {
        emitterRef.current.on('setNum', () => setNum(10))
        emitterRef.current.on('readNum', () => console.log(num))
    }, [])

    return <div>
        {num}
        <div>
            <button onClick={() => emitterRef.current.emit('setNum')}>set num</button>
        </div>

        <div>
            <button onClick={() => emitterRef.current.emit('readNum')}>read num</button>
        </div>
    </div>

}
export default NumComponent
</code>```

How can I read the modified value from the second function?

Thank you!

Body:
I'm creating socket io app, where I'm setting some value from incoming event using setState. I have two event handlers. One is to modify the value and second is supposed to read this value and eventually change it. Setting the value works well and it is rendered as expected. However, when I try to read the value from second handler, there is still initial one.

See below simplified code below.

import {useEffect, useRef, useState} from "react";
import {EventEmitter} from "events";

const NumComponent = () => {
    const [num, setNum] = useState(0)
    const emitter = new EventEmitter()
    const emitterRef = new useRef(emitter)

    useEffect(() => {
        emitterRef.current.on('setNum', () => setNum(10))
        emitterRef.current.on('readNum', () => console.log(num))
    }, [])

    return

        {num}

            <button onClick={() => emitterRef.current.emit('setNum')}>set num</button>

            <button onClick={() => emitterRef.current.emit('readNum')}>read num</button>

}
export default NumComponent

How can I read the modified value from the second function?

Thank you!


问:
Exporting information from google forms with selection information to create a ticket
I’m working on creating a Google Form that will serve as a front end for a support ticketing system using Zapier to import into Mojo Helpdesk.

I have on my Google Form a list of potential problems that can occur and would like to have these drive the creation of the topic in Mojo. But it will only allow me to have the “response” to the Form but not what that response goes to. Is there a way I can have it say “Broken Screen” as the selection instead of “Select” which is where the checkbox is for the form

I’m expecting the responses to be able to drive the creation of a helpdesk ticket topic using a multiple choice google form. Instead I am getting the “response” to the topic instead which is unhelpful.


问:
Getting this error messages when using npx create-react-app on Ubuntu
```<code>(base) akj@JammyJellyfish:~/Desktop/Social-Media-App/client$ npx create-react-app .
npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
npm WARN config location in the cache, and they are managed by
npm WARN config     [`cacache`](http://npm.im/cacache).
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /home/akj/.var/app/com.visualstudio.code/data/node_modules
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/home/akj/.var/app/com.visualstudio.code/data/node_modules'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/akj/.npm/_logs/2023-01-09T14_52_48_118Z-debug-0.log
(base) akj@JammyJellyfish:~/Desktop/Social-Media-App/client$
</code>```

When trying to create a new react app using create-react-app generator I seem to run into this error. Not sure how to fix it. I've use npx create-react-app many time before but recently it has stopped working. Any suggestions? I am currently using UBUNTU Ubuntu 22.04.1 LTS.

Body:
(base) akj@JammyJellyfish:~/Desktop/Social-Media-App/client$ npx create-react-app .
npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
npm WARN config location in the cache, and they are managed by
npm WARN config     [`cacache`](http://npm.im/cacache).
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /home/akj/.var/app/com.visualstudio.code/data/node_modules
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/home/akj/.var/app/com.visualstudio.code/data/node_modules'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/akj/.npm/_logs/2023-01-09T14_52_48_118Z-debug-0.log
(base) akj@JammyJellyfish:~/Desktop/Social-Media-App/client$

When trying to create a new react app using create-react-app generator I seem to run into this error. Not sure how to fix it. I've use npx create-react-app many time before but recently it has stopped working. Any suggestions? I am currently using UBUNTU Ubuntu 22.04.1 LTS.


问:
What is the stategy of a Codepush rollout?
Can anyone elaborate on this as there is no information in the Microsoft documentation.

My theory is that the first X% of users who start the app and qualify for the upgrade (based on the total number of AppCenter users) actually get it.

My colleague thinks it's based on a randomly generated number to know if you can download it.

Please tell us who is correct, I think this information might be useful to other people.

I did not make any test for now.


问:
Latex tikzpicture space between data and frame
I have a problem with a graphic I created in Latex. If the graphic has few data entries, then everything looks great. The distance between the border and the first and last data point fits. Then it looks like this:

However, the more entries the graph receives, the greater the distance between the first and the last data point to the frame. This looks like this again:

The code to my graphic looks like this:

```<code>\resizebox{\textwidth}{!}{
\begin{tikzpicture}[framed,tlabel/.style={yshift=2pt,above right,font=\small}]
    \begin{axis}[
        clip=false,
        axis line style={draw=none},
        legend style={at={(1.15,-0.1)},anchor=south west},
        reverse legend,
        xmin = 0,
        xmax = 15,
        xbar,
        bar width=2.5pt,
        xlabel = Label1,
        ylabel = Label2,
        symbolic y coords = {
            Coordinate1,
            Coordinate2,
        },
        y dir = reverse,
        y=0.7cm,
        xtick = {0,5,10,15},
        xtick pos = bottom,
        ytick = data,
        ytick pos = right,
        yticklabel pos = right,
    ]
        \addplot[draw=red!80!white,fill=red!80!white] coordinates {
            (10,Coordinate1)
            (5,Coordinate2)
        };
        \addplot[draw=blue!80!white,fill=blue!80!white,point meta=explicit symbolic,nodes near coords] coordinates {
            (5,Coordinate1)
            (10,Coordinate2)
        };
        \legend{1, 2}
    \end{axis}
\end{tikzpicture}
}
</code>```

Maybe someone of you has an idea what could be the reason that the distance grows with the number of entries and how I can prevent this? thanks in advance!

EDIT:
It was asked to provide a minimal example. Therefore now follows a minimal example with 2 graphics:

```<code>\documentclass[
11pt,
a4paper,
]{scrreprt}

\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{backgrounds}

\begin{document}
\resizebox{\textwidth}{!}{
    \begin{tikzpicture}[framed,tlabel/.style={yshift=2pt,above right,font=\small}]
        \begin{axis}[
            clip=false,
            axis line style={draw=none},
            legend style={at={(1.15,-0.2)},anchor=south west},
            reverse legend,
            xmin = 0,
            xmax = 15,
            xbar,
            bar width=2.5pt,
            xlabel = Label,
            ylabel = Label,
            symbolic y coords = {
                content1,
                content2,
                content3,
                content4
            },
            y dir = reverse,
            y=0.7cm,
            xtick = {1,2,3,4},
            xtick pos = bottom,
            ytick = data,
            ytick pos = right,
            yticklabel pos = right,

]
            \addplot[draw=red!80!white,fill=red!80!white] coordinates {
                (1,content1)
                (2,content2)
                (3,content3)
                (4,content4)
            };
            \addplot[draw=blue!80!white,fill=blue!80!white,point meta=explicit symbolic,nodes near coords] coordinates {
                (4,content1)
                (3,content2)
                (2,content3)
                (1,content4)
            };
            \legend{label1, label2}
        \end{axis}
    \end{tikzpicture}
}

\resizebox{\textwidth}{!}{
    \begin{tikzpicture}[framed,tlabel/.style={yshift=2pt,above right,font=\small}]
        \begin{axis}[
            clip=false,
            axis line style={draw=none},
            legend style={at={(1.15,-0.2)},anchor=south west},
            reverse legend,
            xmin = 0,
            xmax = 15,
            xbar,
            bar width=2.5pt,
            xlabel = Label,
            ylabel = Label,
            symbolic y coords = {
                content1,
                content2,
                content3,
                content4,
                content5,
                content6,
                content7,
                content8,
                content9,
                content10,
                content11,
                content12,
                content13,
                content14,
                content15,
                content16,
                content17,
                content18,
                content19,
                content20
            },
            y dir = reverse,
            y=0.7cm,
            xtick = {1,2,3,4},
            xtick pos = bottom,
            ytick = data,
            ytick pos = right,
            yticklabel pos = right,
        ]
            \addplot[draw=red!80!white,fill=red!80!white] coordinates {
                (1,content1)
                (2,content2)
                (3,content3)
                (4,content4)
                (1,content5)
                (2,content6)
                (3,content7)
                (4,content8)
                (1,content9)
                (2,content10)
                (3,content11)
                (4,content12)
                (4,content13)
                (4,content14)
                (4,content15)
                (4,content16)
                (4,content17)
                (4,content18)
                (4,content19)
                (4,content20)
            };
            \addplot[draw=blue!80!white,fill=blue!80!white,point meta=explicit symbolic,nodes near coords] coordinates {
                (4,content1)
                (3,content2)
                (2,content3)
                (1,content4)
                (1,content5)
                (2,content6)
                (3,content7)
                (4,content8)
                (1,content9)
                (2,content10)
                (3,content11)
                (4,content12)
                (4,content13)
                (4,content14)
                (4,content15)
                (4,content16)
                (4,content17)
                (4,content18)
                (4,content19)
                (4,content20)
            };
            \legend{label1, label2}
        \end{axis}
    \end{tikzpicture}
}
\end{document}
</code>```

Body:
I have a problem with a graphic I created in Latex. If the graphic has few data entries, then everything looks great. The distance between the border and the first and last data point fits. Then it looks like this:

However, the more entries the graph receives, the greater the distance between the first and the last data point to the frame. This looks like this again:

The code to my graphic looks like this:

\resizebox{\textwidth}{!}{
\begin{tikzpicture}[framed,tlabel/.style={yshift=2pt,above right,font=\small}]
    \begin{axis}[
        clip=false,
        axis line style={draw=none},
        legend style={at={(1.15,-0.1)},anchor=south west},
        reverse legend,
        xmin = 0,
        xmax = 15,
        xbar,
        bar width=2.5pt,
        xlabel = Label1,
        ylabel = Label2,
        symbolic y coords = {
            Coordinate1,
            Coordinate2,
        },
        y dir = reverse,
        y=0.7cm,
        xtick = {0,5,10,15},
        xtick pos = bottom,
        ytick = data,
        ytick pos = right,
        yticklabel pos = right,
    ]
        \addplot[draw=red!80!white,fill=red!80!white] coordinates {
            (10,Coordinate1)
            (5,Coordinate2)
        };
        \addplot[draw=blue!80!white,fill=blue!80!white,point meta=explicit symbolic,nodes near coords] coordinates {
            (5,Coordinate1)
            (10,Coordinate2)
        };
        \legend{1, 2}
    \end{axis}
\end{tikzpicture}
}

Maybe someone of you has an idea what could be the reason that the distance grows with the number of entries and how I can prevent this? thanks in advance!

EDIT:
It was asked to provide a minimal example. Therefore now follows a minimal example with 2 graphics:

\documentclass[
11pt,
a4paper,
]{scrreprt}

\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{backgrounds}

\begin{document}
\resizebox{\textwidth}{!}{
    \begin{tikzpicture}[framed,tlabel/.style={yshift=2pt,above right,font=\small}]
        \begin{axis}[
            clip=false,
            axis line style={draw=none},
            legend style={at={(1.15,-0.2)},anchor=south west},
            reverse legend,
            xmin = 0,
            xmax = 15,
            xbar,
            bar width=2.5pt,
            xlabel = Label,
            ylabel = Label,
            symbolic y coords = {
                content1,
                content2,
                content3,
                content4
            },
            y dir = reverse,
            y=0.7cm,
            xtick = {1,2,3,4},
            xtick pos = bottom,
            ytick = data,
            ytick pos = right,
            yticklabel pos = right,

]
            \addplot[draw=red!80!white,fill=red!80!white] coordinates {
                (1,content1)
                (2,content2)
                (3,content3)
                (4,content4)
            };
            \addplot[draw=blue!80!white,fill=blue!80!white,point meta=explicit symbolic,nodes near coords] coordinates {
                (4,content1)
                (3,content2)
                (2,content3)
                (1,content4)
            };
            \legend{label1, label2}
        \end{axis}
    \end{tikzpicture}
}

\resizebox{\textwidth}{!}{
    \begin{tikzpicture}[framed,tlabel/.style={yshift=2pt,above right,font=\small}]
        \begin{axis}[
            clip=false,
            axis line style={draw=none},
            legend style={at={(1.15,-0.2)},anchor=south west},
            reverse legend,
            xmin = 0,
            xmax = 15,
            xbar,
            bar width=2.5pt,
            xlabel = Label,
            ylabel = Label,
            symbolic y coords = {
                content1,
                content2,
                content3,
                content4,
                content5,
                content6,
                content7,
                content8,
                content9,
                content10,
                content11,
                content12,
                content13,
                content14,
                content15,
                content16,
                content17,
                content18,
                content19,
                content20
            },
            y dir = reverse,
            y=0.7cm,
            xtick = {1,2,3,4},
            xtick pos = bottom,
            ytick = data,
            ytick pos = right,
            yticklabel pos = right,
        ]
            \addplot[draw=red!80!white,fill=red!80!white] coordinates {
                (1,content1)
                (2,content2)
                (3,content3)
                (4,content4)
                (1,content5)
                (2,content6)
                (3,content7)
                (4,content8)
                (1,content9)
                (2,content10)
                (3,content11)
                (4,content12)
                (4,content13)
                (4,content14)
                (4,content15)
                (4,content16)
                (4,content17)
                (4,content18)
                (4,content19)
                (4,content20)
            };
            \addplot[draw=blue!80!white,fill=blue!80!white,point meta=explicit symbolic,nodes near coords] coordinates {
                (4,content1)
                (3,content2)
                (2,content3)
                (1,content4)
                (1,content5)
                (2,content6)
                (3,content7)
                (4,content8)
                (1,content9)
                (2,content10)
                (3,content11)
                (4,content12)
                (4,content13)
                (4,content14)
                (4,content15)
                (4,content16)
                (4,content17)
                (4,content18)
                (4,content19)
                (4,content20)
            };
            \legend{label1, label2}
        \end{axis}
    \end{tikzpicture}
}
\end{document}


问:
pyproject.toml run custom installation script
I have to download some binary files from a location during the installation to have all necessary data files in place for my program. What is the correct place to do this in pyproject.toml, the setup.py approach was simple having the full programming power. Is this still possible with pyproject.toml?


问:
Create a SAM application from all the resources used in zone
I have created some lambda functions, some events, and DynamoDB and etc, I want to transfer all resources and configurations I made to another account.

I want to know is there a way that all configurations to be saved to a SAM application semi automatically


问:
Reducing sorting time on a complex query in Postgresql
So i have this query

```<code> with table1_group1 as materialized(
    select rh.data_id, rh.uuid,
    coalesce(c.name, (select "name" from group1 where "default" = true)) parsed_contractor
    from table1 rh
    left join group1 c on c.name = rh.group1
    group by rh.data_id, 2, 3
),
table1_verifications as materialized (
    select rh.data_id, rhcn.parsed_group1,
    count(vh) filter (where vh.result = 'true' and (vh.cargo_status = 'full' or vh.cargo_status is null) and vh.delivery = true) as successful_delivery_count,
    count(vh.uuid)                                            as verifications,
    count(vh.uuid) filter (where vh.result = 'false')         as unsuccessful_verifications
    from table1 rh
    join table1_group1 rhcn on rhcn.uuid = rh.uuid
    left join verification_history vh on rh.uuid = vh.vehicle_record_uuid
    group by rh.data_id, rhcn.parsed_group1
),
latest_per_group1 as materialized(
    select distinct on (rh.data_id, rhcn.parsed_group1)
    rh.data_id, rhcn.parsed_group1 group1,
    rh.uuid, rh.inspection_list_name,
    r.uuid is not null and rh.expiration_time > now() currently_active,
    case when b.uuid is not null then 'black' else rh.status end as status
    from table1 rh
    join table1_group1 rhcn on rhcn.uuid = rh.uuid
    left join table3 b on b.record_uuid = rh.uuid
    left join table2 r on rh.uuid = r.uuid
    order by rh.data_id, rhcn.parsed_group1, rh.created_ts desc
)
select
rhcn.parsed_group1 group1,
coalesce(lpc.inspection_list_name, v.vehicle_type) as inspection_list_name,
rh.data_id,
lpc.status,
vh.successful_delivery_count,
exists(
select uuid from revocation rev
where rh.data_id = rev.data_id
and rev.expiration_time > now())                          as currently_revoked,
lpc.currently_active,
vh.verifications,
vh.unsuccessful_verifications,
string_agg(distinct coalesce(rh.driver_name, '-'), ', ')  as driver_name,
lpc.uuid
from table1 rh
join table4 v on rh.data_id = v.data_id
join table1_group1 rhcn on rhcn.uuid = rh.uuid
join latest_per_group1 lpc on rh.data_id = lpc.data_id
and rhcn.parsed_group1 = lpc.group1
join table1_verifications vh on rh.data_id = vh.data_id and
rhcn.parsed_group1 = vh.parsed_group1
group by 1, 2, rh.data_id, 4, lpc.uuid, 7, vh.successful_delivery_count,vh.verifications,
vh.unsuccessful_verifications
</code>```

And it has a execution plan like this

```<code>    "GroupAggregate  (cost=16740.53..16818.88 rows=1 width=177) (actual time=249.485..268.757 rows=9704 loops=1)"
"  Group Key: rhcn.parsed_contractor, (COALESCE(lpc.inspection_list_name, v.vehicle_type)), rh.data_id, lpc.status, lpc.uuid, lpc.currently_active, vh.successful_delivery_count, vh.verifications, vh.unsuccessful_verifications"
"  CTE record_history_contractor_name"
"    ->  HashAggregate  (cost=1917.34..2026.00 rows=10866 width=55) (actual time=10.067..12.119 rows=10866 loops=1)"
"          Group Key: rh_1.uuid, COALESCE(c.name, $0)"
"          InitPlan 1 (returns $0)"
"            ->  Seq Scan on group1  (cost=0.00..1.24 rows=12 width=32) (actual time=0.010..0.011 rows=1 loops=1)"
"                  Filter: ""default"""
"                  Rows Removed by Filter: 23"
"          ->  Hash Left Join  (cost=1.54..1861.77 rows=10866 width=55) (actual time=0.064..7.030 rows=10866 loops=1)"
"                Hash Cond: (rh_1.group1 = c.name)"
"                ->  Seq Scan on table1 rh_1  (cost=0.00..1764.66 rows=10866 width=30) (actual time=0.017..2.772 rows=10866 loops=1)"
"                ->  Hash  (cost=1.24..1.24 rows=24 width=32) (actual time=0.040..0.041 rows=24 loops=1)"
"                      Buckets: 1024  Batches: 1  Memory Usage: 9kB"
"                      ->  Seq Scan on group1 c  (cost=0.00..1.24 rows=24 width=32) (actual time=0.015..0.017 rows=24 loops=1)"
"  CTE table1_verifications"
"    ->  GroupAggregate  (cost=6422.63..6775.77 rows=10866 width=63) (actual time=85.415..94.441 rows=9704 loops=1)"
"          Group Key: rh_2.data_id, rhcn_1.parsed_group1"
"          ->  Sort  (cost=6422.63..6449.79 rows=10866 width=655) (actual time=85.407..89.565 rows=12481 loops=1)"
"                Sort Key: rh_2.data_id, rhcn_1.parsed_group1"
"                Sort Method: external merge  Disk: 1704kB"
"                ->  Hash Right Join  (cost=2282.16..2537.19 rows=10866 width=655) (actual time=12.835..17.560 rows=12481 loops=1)"
"                      Hash Cond: (vh_1.vehicle_record_uuid = rh_2.uuid)"
"                      ->  Seq Scan on verification_history vh_1  (cost=0.00..219.08 rows=2808 width=632) (actual time=0.031..2.531 rows=2808 loops=1)"
"                      ->  Hash  (cost=2146.34..2146.34 rows=10866 width=55) (actual time=12.718..12.719 rows=10866 loops=1)"
"                            Buckets: 16384  Batches: 1  Memory Usage: 786kB"
"                            ->  Hash Join  (cost=1900.49..2146.34 rows=10866 width=55) (actual time=3.354..10.644 rows=10866 loops=1)"
"                                  Hash Cond: (rhcn_1.uuid = rh_2.uuid)"
"                                  ->  CTE Scan on table1_group1 rhcn_1  (cost=0.00..217.32 rows=10866 width=48) (actual time=0.000..4.605 rows=10866 loops=1)"
"                                  ->  Hash  (cost=1764.66..1764.66 rows=10866 width=23) (actual time=3.282..3.282 rows=10866 loops=1)"
"                                        Buckets: 16384  Batches: 1  Memory Usage: 715kB"
"                                        ->  Seq Scan on table1 rh_2  (cost=0.00..1764.66 rows=10866 width=23) (actual time=0.018..1.891 rows=10866 loops=1)"
"  CTE latest_per_group1"
"    ->  Unique  (cost=4616.17..4697.67 rows=10866 width=100) (actual time=49.350..51.416 rows=9704 loops=1)"
"          ->  Sort  (cost=4616.17..4643.34 rows=10866 width=100) (actual time=49.348..49.871 rows=10866 loops=1)"
"                Sort Key: rh_3.data_id, rhcn_2.parsed_group1, rh_3.created_ts DESC"
"                Sort Method: quicksort  Memory: 1526kB"
"                ->  Hash Left Join  (cost=3518.26..3887.74 rows=10866 width=100) (actual time=9.119..15.989 rows=10866 loops=1)"
"                      Hash Cond: (rh_3.uuid = r.uuid)"
"                      ->  Hash Left Join  (cost=1908.22..2194.83 rows=10866 width=96) (actual time=5.929..10.629 rows=10866 loops=1)"
"                            Hash Cond: (rh_3.uuid = b.record_uuid)"
"                            ->  Hash Join  (cost=1900.49..2146.34 rows=10866 width=80) (actual time=5.876..9.412 rows=10866 loops=1)"
"                                  Hash Cond: (rhcn_2.uuid = rh_3.uuid)"
"                                  ->  CTE Scan on table1_group1 rhcn_2  (cost=0.00..217.32 rows=10866 width=48) (actual time=0.003..0.824 rows=10866 loops=1)"
"                                  ->  Hash  (cost=1764.66..1764.66 rows=10866 width=48) (actual time=5.807..5.807 rows=10866 loops=1)"
"                                        Buckets: 16384  Batches: 1  Memory Usage: 1012kB"
"                                        ->  Seq Scan on table1 rh_3  (cost=0.00..1764.66 rows=10866 width=48) (actual time=0.021..3.854 rows=10866 loops=1)"
"                            ->  Hash  (cost=5.66..5.66 rows=166 width=32) (actual time=0.046..0.046 rows=0 loops=1)"
"                                  Buckets: 1024  Batches: 1  Memory Usage: 8kB"
"                                  ->  Seq Scan on table3 b  (cost=0.00..5.66 rows=166 width=32) (actual time=0.019..0.041 rows=166 loops=1)"
"                      ->  Hash  (cost=1496.13..1496.13 rows=9113 width=16) (actual time=3.181..3.182 rows=9113 loops=1)"
"                            Buckets: 16384  Batches: 1  Memory Usage: 556kB"
"                            ->  Seq Scan on table2 r  (cost=0.00..1496.13 rows=9113 width=16) (actual time=0.014..2.235 rows=9113 loops=1)"
"  ->  Sort  (cost=3241.10..3241.10 rows=1 width=157) (actual time=248.922..250.305 rows=10866 loops=1)"
"        Sort Key: rhcn.parsed_group1, (COALESCE(lpc.inspection_list_name, v.vehicle_type)), rh.data_id, lpc.status, lpc.uuid, lpc.currently_active, vh.successful_delivery_count, vh.verifications, vh.unsuccessful_verifications"
"        Sort Method: quicksort  Memory: 1913kB"
"        ->  Hash Join  (cost=2942.26..3241.09 rows=1 width=157) (actual time=184.588..189.834 rows=10866 loops=1)"
"              Hash Cond: ((rhcn.uuid = rh.uuid) AND (rhcn.parsed_group1 = lpc.group1))"
"              ->  CTE Scan on table1_group1 rhcn  (cost=0.00..217.32 rows=10866 width=48) (actual time=10.069..10.747 rows=10866 loops=1)"
"              ->  Hash  (cost=2941.11..2941.11 rows=77 width=210) (actual time=174.505..174.507 rows=12333 loops=1)"
"                    Buckets: 16384 (originally 1024)  Batches: 1 (originally 1)  Memory Usage: 1854kB"
"                    ->  Hash Join  (cost=1134.94..2941.11 rows=77 width=210) (actual time=163.983..170.545 rows=12333 loops=1)"
"                          Hash Cond: (rh.data_id = v.data_id)"
"                          ->  Seq Scan on table1 rh  (cost=0.00..1764.66 rows=10866 width=36) (actual time=0.021..1.531 rows=10866 loops=1)"
"                          ->  Hash  (cost=1134.14..1134.14 rows=64 width=245) (actual time=163.956..163.958 rows=9704 loops=1)"
"                                Buckets: 16384 (originally 1024)  Batches: 1 (originally 1)  Memory Usage: 1356kB"
"                                ->  Hash Join  (cost=834.69..1134.14 rows=64 width=245) (actual time=145.559..160.447 rows=9704 loops=1)"
"                                      Hash Cond: ((vh.data_id = v.data_id) AND (vh.parsed_group1 = lpc.group1))"
"                                      ->  CTE Scan on table1_verifications vh  (cost=0.00..217.32 rows=10866 width=88) (actual time=85.418..96.757 rows=9704 loops=1)"
"                                      ->  Hash  (cost=671.70..671.70 rows=10866 width=157) (actual time=60.114..60.115 rows=9704 loops=1)"
"                                            Buckets: 16384  Batches: 1  Memory Usage: 926kB"
"                                            ->  Hash Join  (cost=425.84..671.70 rows=10866 width=157) (actual time=51.938..57.676 rows=9704 loops=1)"
"                                                  Hash Cond: (lpc.data_id = v.data_id)"
"                                                  ->  CTE Scan on latest_per_group1 lpc  (cost=0.00..217.32 rows=10866 width=145) (actual time=49.354..53.184 rows=9704 loops=1)"
"                                                  ->  Hash  (cost=310.93..310.93 rows=9193 width=12) (actual time=2.565..2.565 rows=9193 loops=1)"
"                                                        Buckets: 16384  Batches: 1  Memory Usage: 526kB"
"                                                        ->  Seq Scan on table4 v  (cost=0.00..310.93 rows=9193 width=12) (actual time=0.028..1.503 rows=9193 loops=1)"
"  SubPlan 5"
"    ->  Seq Scan on revocation rev  (cost=0.00..78.30 rows=1 width=0) (never executed)"
"          Filter: ((rh.data_id = data_id) AND (expiration_time > now()))"
"  SubPlan 6"
"    ->  Seq Scan on revocation rev_1  (cost=0.00..74.40 rows=14 width=7) (actual time=0.075..0.524 rows=9 loops=1)"
"          Filter: (expiration_time > now())"
"          Rows Removed by Filter: 1551"
"Planning Time: 1.814 ms"
"Execution Time: 273.485 ms"
</code>```

The problem im having is that over half of the time is spent on sorting the data. I dont have any indexes beyond primary key index. The query started with execution time of over 500ms. With some modifications and fixes i got it to this result. Occationally i get execution time of 160ms. But on average its somewhere 250-300ms.

Right now the dataset is relatively small. Biggest table here has about 12000 rows, for now. But it can be expected to reach many hundred thousands. This query is used in conjuction with paging (limit offset), but also there is a need to know the total amount of rows.

Body:
So i have this query

 with table1_group1 as materialized(
    select rh.data_id, rh.uuid,
    coalesce(c.name, (select "name" from group1 where "default" = true)) parsed_contractor
    from table1 rh
    left join group1 c on c.name = rh.group1
    group by rh.data_id, 2, 3
),
table1_verifications as materialized (
    select rh.data_id, rhcn.parsed_group1,
    count(vh) filter (where vh.result = 'true' and (vh.cargo_status = 'full' or vh.cargo_status is null) and vh.delivery = true) as successful_delivery_count,
    count(vh.uuid)                                            as verifications,
    count(vh.uuid) filter (where vh.result = 'false')         as unsuccessful_verifications
    from table1 rh
    join table1_group1 rhcn on rhcn.uuid = rh.uuid
    left join verification_history vh on rh.uuid = vh.vehicle_record_uuid
    group by rh.data_id, rhcn.parsed_group1
),
latest_per_group1 as materialized(
    select distinct on (rh.data_id, rhcn.parsed_group1)
    rh.data_id, rhcn.parsed_group1 group1,
    rh.uuid, rh.inspection_list_name,
    r.uuid is not null and rh.expiration_time > now() currently_active,
    case when b.uuid is not null then 'black' else rh.status end as status
    from table1 rh
    join table1_group1 rhcn on rhcn.uuid = rh.uuid
    left join table3 b on b.record_uuid = rh.uuid
    left join table2 r on rh.uuid = r.uuid
    order by rh.data_id, rhcn.parsed_group1, rh.created_ts desc
)
select
rhcn.parsed_group1 group1,
coalesce(lpc.inspection_list_name, v.vehicle_type) as inspection_list_name,
rh.data_id,
lpc.status,
vh.successful_delivery_count,
exists(
select uuid from revocation rev
where rh.data_id = rev.data_id
and rev.expiration_time > now())                          as currently_revoked,
lpc.currently_active,
vh.verifications,
vh.unsuccessful_verifications,
string_agg(distinct coalesce(rh.driver_name, '-'), ', ')  as driver_name,
lpc.uuid
from table1 rh
join table4 v on rh.data_id = v.data_id
join table1_group1 rhcn on rhcn.uuid = rh.uuid
join latest_per_group1 lpc on rh.data_id = lpc.data_id
and rhcn.parsed_group1 = lpc.group1
join table1_verifications vh on rh.data_id = vh.data_id and
rhcn.parsed_group1 = vh.parsed_group1
group by 1, 2, rh.data_id, 4, lpc.uuid, 7, vh.successful_delivery_count,vh.verifications,
vh.unsuccessful_verifications

And it has a execution plan like this

    "GroupAggregate  (cost=16740.53..16818.88 rows=1 width=177) (actual time=249.485..268.757 rows=9704 loops=1)"
"  Group Key: rhcn.parsed_contractor, (COALESCE(lpc.inspection_list_name, v.vehicle_type)), rh.data_id, lpc.status, lpc.uuid, lpc.currently_active, vh.successful_delivery_count, vh.verifications, vh.unsuccessful_verifications"
"  CTE record_history_contractor_name"
"    ->  HashAggregate  (cost=1917.34..2026.00 rows=10866 width=55) (actual time=10.067..12.119 rows=10866 loops=1)"
"          Group Key: rh_1.uuid, COALESCE(c.name, $0)"
"          InitPlan 1 (returns $0)"
"            ->  Seq Scan on group1  (cost=0.00..1.24 rows=12 width=32) (actual time=0.010..0.011 rows=1 loops=1)"
"                  Filter: ""default"""
"                  Rows Removed by Filter: 23"
"          ->  Hash Left Join  (cost=1.54..1861.77 rows=10866 width=55) (actual time=0.064..7.030 rows=10866 loops=1)"
"                Hash Cond: (rh_1.group1 = c.name)"
"                ->  Seq Scan on table1 rh_1  (cost=0.00..1764.66 rows=10866 width=30) (actual time=0.017..2.772 rows=10866 loops=1)"
"                ->  Hash  (cost=1.24..1.24 rows=24 width=32) (actual time=0.040..0.041 rows=24 loops=1)"
"                      Buckets: 1024  Batches: 1  Memory Usage: 9kB"
"                      ->  Seq Scan on group1 c  (cost=0.00..1.24 rows=24 width=32) (actual time=0.015..0.017 rows=24 loops=1)"
"  CTE table1_verifications"
"    ->  GroupAggregate  (cost=6422.63..6775.77 rows=10866 width=63) (actual time=85.415..94.441 rows=9704 loops=1)"
"          Group Key: rh_2.data_id, rhcn_1.parsed_group1"
"          ->  Sort  (cost=6422.63..6449.79 rows=10866 width=655) (actual time=85.407..89.565 rows=12481 loops=1)"
"                Sort Key: rh_2.data_id, rhcn_1.parsed_group1"
"                Sort Method: external merge  Disk: 1704kB"
"                ->  Hash Right Join  (cost=2282.16..2537.19 rows=10866 width=655) (actual time=12.835..17.560 rows=12481 loops=1)"
"                      Hash Cond: (vh_1.vehicle_record_uuid = rh_2.uuid)"
"                      ->  Seq Scan on verification_history vh_1  (cost=0.00..219.08 rows=2808 width=632) (actual time=0.031..2.531 rows=2808 loops=1)"
"                      ->  Hash  (cost=2146.34..2146.34 rows=10866 width=55) (actual time=12.718..12.719 rows=10866 loops=1)"
"                            Buckets: 16384  Batches: 1  Memory Usage: 786kB"
"                            ->  Hash Join  (cost=1900.49..2146.34 rows=10866 width=55) (actual time=3.354..10.644 rows=10866 loops=1)"
"                                  Hash Cond: (rhcn_1.uuid = rh_2.uuid)"
"                                  ->  CTE Scan on table1_group1 rhcn_1  (cost=0.00..217.32 rows=10866 width=48) (actual time=0.000..4.605 rows=10866 loops=1)"
"                                  ->  Hash  (cost=1764.66..1764.66 rows=10866 width=23) (actual time=3.282..3.282 rows=10866 loops=1)"
"                                        Buckets: 16384  Batches: 1  Memory Usage: 715kB"
"                                        ->  Seq Scan on table1 rh_2  (cost=0.00..1764.66 rows=10866 width=23) (actual time=0.018..1.891 rows=10866 loops=1)"
"  CTE latest_per_group1"
"    ->  Unique  (cost=4616.17..4697.67 rows=10866 width=100) (actual time=49.350..51.416 rows=9704 loops=1)"
"          ->  Sort  (cost=4616.17..4643.34 rows=10866 width=100) (actual time=49.348..49.871 rows=10866 loops=1)"
"                Sort Key: rh_3.data_id, rhcn_2.parsed_group1, rh_3.created_ts DESC"
"                Sort Method: quicksort  Memory: 1526kB"
"                ->  Hash Left Join  (cost=3518.26..3887.74 rows=10866 width=100) (actual time=9.119..15.989 rows=10866 loops=1)"
"                      Hash Cond: (rh_3.uuid = r.uuid)"
"                      ->  Hash Left Join  (cost=1908.22..2194.83 rows=10866 width=96) (actual time=5.929..10.629 rows=10866 loops=1)"
"                            Hash Cond: (rh_3.uuid = b.record_uuid)"
"                            ->  Hash Join  (cost=1900.49..2146.34 rows=10866 width=80) (actual time=5.876..9.412 rows=10866 loops=1)"
"                                  Hash Cond: (rhcn_2.uuid = rh_3.uuid)"
"                                  ->  CTE Scan on table1_group1 rhcn_2  (cost=0.00..217.32 rows=10866 width=48) (actual time=0.003..0.824 rows=10866 loops=1)"
"                                  ->  Hash  (cost=1764.66..1764.66 rows=10866 width=48) (actual time=5.807..5.807 rows=10866 loops=1)"
"                                        Buckets: 16384  Batches: 1  Memory Usage: 1012kB"
"                                        ->  Seq Scan on table1 rh_3  (cost=0.00..1764.66 rows=10866 width=48) (actual time=0.021..3.854 rows=10866 loops=1)"
"                            ->  Hash  (cost=5.66..5.66 rows=166 width=32) (actual time=0.046..0.046 rows=0 loops=1)"
"                                  Buckets: 1024  Batches: 1  Memory Usage: 8kB"
"                                  ->  Seq Scan on table3 b  (cost=0.00..5.66 rows=166 width=32) (actual time=0.019..0.041 rows=166 loops=1)"
"                      ->  Hash  (cost=1496.13..1496.13 rows=9113 width=16) (actual time=3.181..3.182 rows=9113 loops=1)"
"                            Buckets: 16384  Batches: 1  Memory Usage: 556kB"
"                            ->  Seq Scan on table2 r  (cost=0.00..1496.13 rows=9113 width=16) (actual time=0.014..2.235 rows=9113 loops=1)"
"  ->  Sort  (cost=3241.10..3241.10 rows=1 width=157) (actual time=248.922..250.305 rows=10866 loops=1)"
"        Sort Key: rhcn.parsed_group1, (COALESCE(lpc.inspection_list_name, v.vehicle_type)), rh.data_id, lpc.status, lpc.uuid, lpc.currently_active, vh.successful_delivery_count, vh.verifications, vh.unsuccessful_verifications"
"        Sort Method: quicksort  Memory: 1913kB"
"        ->  Hash Join  (cost=2942.26..3241.09 rows=1 width=157) (actual time=184.588..189.834 rows=10866 loops=1)"
"              Hash Cond: ((rhcn.uuid = rh.uuid) AND (rhcn.parsed_group1 = lpc.group1))"
"              ->  CTE Scan on table1_group1 rhcn  (cost=0.00..217.32 rows=10866 width=48) (actual time=10.069..10.747 rows=10866 loops=1)"
"              ->  Hash  (cost=2941.11..2941.11 rows=77 width=210) (actual time=174.505..174.507 rows=12333 loops=1)"
"                    Buckets: 16384 (originally 1024)  Batches: 1 (originally 1)  Memory Usage: 1854kB"
"                    ->  Hash Join  (cost=1134.94..2941.11 rows=77 width=210) (actual time=163.983..170.545 rows=12333 loops=1)"
"                          Hash Cond: (rh.data_id = v.data_id)"
"                          ->  Seq Scan on table1 rh  (cost=0.00..1764.66 rows=10866 width=36) (actual time=0.021..1.531 rows=10866 loops=1)"
"                          ->  Hash  (cost=1134.14..1134.14 rows=64 width=245) (actual time=163.956..163.958 rows=9704 loops=1)"
"                                Buckets: 16384 (originally 1024)  Batches: 1 (originally 1)  Memory Usage: 1356kB"
"                                ->  Hash Join  (cost=834.69..1134.14 rows=64 width=245) (actual time=145.559..160.447 rows=9704 loops=1)"
"                                      Hash Cond: ((vh.data_id = v.data_id) AND (vh.parsed_group1 = lpc.group1))"
"                                      ->  CTE Scan on table1_verifications vh  (cost=0.00..217.32 rows=10866 width=88) (actual time=85.418..96.757 rows=9704 loops=1)"
"                                      ->  Hash  (cost=671.70..671.70 rows=10866 width=157) (actual time=60.114..60.115 rows=9704 loops=1)"
"                                            Buckets: 16384  Batches: 1  Memory Usage: 926kB"
"                                            ->  Hash Join  (cost=425.84..671.70 rows=10866 width=157) (actual time=51.938..57.676 rows=9704 loops=1)"
"                                                  Hash Cond: (lpc.data_id = v.data_id)"
"                                                  ->  CTE Scan on latest_per_group1 lpc  (cost=0.00..217.32 rows=10866 width=145) (actual time=49.354..53.184 rows=9704 loops=1)"
"                                                  ->  Hash  (cost=310.93..310.93 rows=9193 width=12) (actual time=2.565..2.565 rows=9193 loops=1)"
"                                                        Buckets: 16384  Batches: 1  Memory Usage: 526kB"
"                                                        ->  Seq Scan on table4 v  (cost=0.00..310.93 rows=9193 width=12) (actual time=0.028..1.503 rows=9193 loops=1)"
"  SubPlan 5"
"    ->  Seq Scan on revocation rev  (cost=0.00..78.30 rows=1 width=0) (never executed)"
"          Filter: ((rh.data_id = data_id) AND (expiration_time > now()))"
"  SubPlan 6"
"    ->  Seq Scan on revocation rev_1  (cost=0.00..74.40 rows=14 width=7) (actual time=0.075..0.524 rows=9 loops=1)"
"          Filter: (expiration_time > now())"
"          Rows Removed by Filter: 1551"
"Planning Time: 1.814 ms"
"Execution Time: 273.485 ms"

The problem im having is that over half of the time is spent on sorting the data. I dont have any indexes beyond primary key index. The query started with execution time of over 500ms. With some modifications and fixes i got it to this result. Occationally i get execution time of 160ms. But on average its somewhere 250-300ms.

Right now the dataset is relatively small. Biggest table here has about 12000 rows, for now. But it can be expected to reach many hundred thousands. This query is used in conjuction with paging (limit offset), but also there is a need to know the total amount of rows.


问:
htaccess: combining mod_geoip and mod_rewrite for security
As a mental health therapist, it is important to have an available and stable website, the corona crisis taught me. Due to intensive hacking attempts of foreign IP addresses, I have had to take drastic measures and now restrict access to my site to only two countries using mod_geoip in my htaccess file.

All visitors outside these two countries are redirected to another site.

```<code><IfModule mod_geoip.c>
GeoIPEnable On
SetEnvIf GEOIP_COUNTRY_CODE BE PermitCountry
SetEnvIf GEOIP_COUNTRY_CODE NL PermitCountry
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(AF|AX)$
RewriteRule ^(.*)$ https://goto.some-other.site/$1 [L]
Allow from env=PermitCountry
</IfModule>
</code>```

This works fine, but with this negative consequence, that my site is no longer indexed by Google, Bing,... So I looked for the lists of urls used by Google and Bing and wanted to allow them to access my site.

```<code><ifModule mod_rewrite.c>
RewriteEngine on
Allow from 34.100.182.96/28
#Example for Google
Allow from 157.55.39.0/24
#Example for Bing
</IfModule>
</code>```

But, how do I combine both inside my htaccess, allowing just users from these two countries and allowing the crawlers to access my site?

I tried this, without any real result: the site is not accessible in Search console and webmaster tools. What am I doing wrong here?

```<code><IfModule mod_geoip.c>
GeoIPEnable On
#Add countries you wish to permit here
SetEnvIf GEOIP_COUNTRY_CODE BE PermitCountry
SetEnvIf GEOIP_COUNTRY_CODE NL PermitCountry
RewriteEngine on
#Allow Google
Allow from 34.100.182.96/28
#Allow Bing
Allow from 157.55.39.0/24
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(AF|AX)$
RewriteRule ^(.*)$ https://goto.some-other.site/$1 [L]
Allow from env=PermitCountry
</IfModule>
</code>```

The site needs to be accessible in search console and webmaster tools; and only accessible in the BE and NL countries.

Body:
As a mental health therapist, it is important to have an available and stable website, the corona crisis taught me. Due to intensive hacking attempts of foreign IP addresses, I have had to take drastic measures and now restrict access to my site to only two countries using mod_geoip in my htaccess file.

All visitors outside these two countries are redirected to another site.

<IfModule mod_geoip.c>
GeoIPEnable On
SetEnvIf GEOIP_COUNTRY_CODE BE PermitCountry
SetEnvIf GEOIP_COUNTRY_CODE NL PermitCountry
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(AF|AX)$
RewriteRule ^(.*)$ https://goto.some-other.site/$1 [L]
Allow from env=PermitCountry
</IfModule>

This works fine, but with this negative consequence, that my site is no longer indexed by Google, Bing,... So I looked for the lists of urls used by Google and Bing and wanted to allow them to access my site.

<ifModule mod_rewrite.c>
RewriteEngine on
Allow from 34.100.182.96/28
#Example for Google
Allow from 157.55.39.0/24
#Example for Bing
</IfModule>

But, how do I combine both inside my htaccess, allowing just users from these two countries and allowing the crawlers to access my site?

I tried this, without any real result: the site is not accessible in Search console and webmaster tools. What am I doing wrong here?

<IfModule mod_geoip.c>
GeoIPEnable On
#Add countries you wish to permit here
SetEnvIf GEOIP_COUNTRY_CODE BE PermitCountry
SetEnvIf GEOIP_COUNTRY_CODE NL PermitCountry
RewriteEngine on
#Allow Google
Allow from 34.100.182.96/28
#Allow Bing
Allow from 157.55.39.0/24
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(AF|AX)$
RewriteRule ^(.*)$ https://goto.some-other.site/$1 [L]
Allow from env=PermitCountry
</IfModule>

The site needs to be accessible in search console and webmaster tools; and only accessible in the BE and NL countries.


问:
NGINX Api command unknown
Im trying to setup an additional proxy to a local api with different port.
i managed to get the connection but somethings wrong with the header.
Trying to call https://example.com/**broker**/help (help is the api command)
getting error "command broker unknown" from the api.

Nginx Config snipped:

```<code>http {

    include /etc/nginx/conf.d/botblocker-nginx-settings.conf;
    include /etc/nginx/conf.d/globalblacklist.conf;

# this is required to proxy Grafana Live WebSocket connections.
map $http_upgrade $connection_upgrade {
  default upgrade;
  '' close;
}

upstream grafana {
  server 192.168.133.5:3333;
}

upstream broker {
  server 192.168.133.5:8087;
}

server {
        server_name grafana;
        listen 443 ssl;
        ssl_certificate /etc/nginx/rogs.app_ssl_certificate.cer;
        ssl_certificate_key /etc/nginx/_.rogs.app_private_key.key;
        error_page 500 502 503 504 /offline.html;
        location = /offline.html {
        root /var/www/html/;
        }
        location = /bg.jpg {
        root /nginx/html/;
}

        ##### GRAFANA PROXY #####

        location / {
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $http_host;
            proxy_pass http://grafana;

        }

  location /broker/ {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $http_host;
    proxy_pass http://broker;
  }

}

server {
    if ($host = example.com) {
        return 301 https://$host$request_uri;
    }

        server_name grafana;

    return 404;

}

server {
        listen 81;
        listen [::]:81;
        location /nginx_status {

            stub_status;
            allow 192.168.133.5;    #only allow requests from localhost
            deny all;       #deny all other hosts
 }

  # Proxy Grafana Live WebSocket connections.
  location /api/live/ {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $http_host;
    proxy_pass http://grafana;
  }

  }
</code>```

i tried different settings like
location /broker
location ~ +/broker
location /broker/

but it always takes the broker url for the api command

Title: NGINX Api command unknown

Body:
Im trying to setup an additional proxy to a local api with different port.
i managed to get the connection but somethings wrong with the header.
Trying to call https://example.com/**broker**/help (help is the api command)
getting error "command broker unknown" from the api.

Nginx Config snipped:

http {

    include /etc/nginx/conf.d/botblocker-nginx-settings.conf;
    include /etc/nginx/conf.d/globalblacklist.conf;

# this is required to proxy Grafana Live WebSocket connections.
map $http_upgrade $connection_upgrade {
  default upgrade;
  '' close;
}

upstream grafana {
  server 192.168.133.5:3333;
}

upstream broker {
  server 192.168.133.5:8087;
}

server {
        server_name grafana;
        listen 443 ssl;
        ssl_certificate /etc/nginx/rogs.app_ssl_certificate.cer;
        ssl_certificate_key /etc/nginx/_.rogs.app_private_key.key;
        error_page 500 502 503 504 /offline.html;
        location = /offline.html {
        root /var/www/html/;
        }
        location = /bg.jpg {
        root /nginx/html/;
}

        ##### GRAFANA PROXY #####

        location / {
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $http_host;
            proxy_pass http://grafana;

        }

  location /broker/ {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $http_host;
    proxy_pass http://broker;
  }

}

server {
    if ($host = example.com) {
        return 301 https://$host$request_uri;
    }

        server_name grafana;

    return 404;

}

server {
        listen 81;
        listen [::]:81;
        location /nginx_status {

            stub_status;
            allow 192.168.133.5;    #only allow requests from localhost
            deny all;       #deny all other hosts
 }

  # Proxy Grafana Live WebSocket connections.
  location /api/live/ {
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_set_header Host $http_host;
    proxy_pass http://grafana;
  }

  }

i tried different settings like
location /broker
location ~ +/broker
location /broker/

but it always takes the broker url for the api command


问:
ESLint error in HTML-Files with Angular: Cannot read properties of undefined (reading '0') Occurred while linting
I'm setting up a new project with Angular 15. Therefore I also want ESLint so I installed some Plugins. At the moment it is working fine for .ts-files and also fix errors when I'm saving the file.

Because ESLint is not working for HTML-Files itself, I added eslint-plugin-html. Now when I leave out a specific line (extends: ['plugin:@angular-eslint/template/recommended'],) for the HTML-overrides it is not linting at all - but when added it's throwing the output error. Either ESLint doesn't understand the errors or it is throwing an error-message in output instead fixing them. I'm not sure! The error for line 1 is even thrown when I start with a comment.

My goal is too use ESLint correctly for HTML-Files and not just to turn it off.
Could you please give me a hint how I could debug this or what is the issue?

This is the error in output:

TypeError: Cannot read properties of undefined (reading '0')
Occurred while linting D:\Users\XXX\XXX\src\app\app.component.html:1
Rule: "indent"

My IDE is VSCode, my package manager is npm and these are my config-files:

.eslintrc.js

```<code>module.exports = {
  env: {
    browser: true,
    es2021: true
  },
  extends: [
    'standard-with-typescript'
  ],
  overrides: [
    {
      files: [
        '*.ts'
      ],
      extends: [
        'eslint:recommended',
        'plugin:@typescript-eslint/recommended',
        'plugin:@angular-eslint/recommended',
        'plugin:@angular-eslint/template/process-inline-templates'
      ],
      rules: {
        '@angular-eslint/directive-selector': [
          'error',
          {
            type: 'attribute',
            prefix: 'app',
            style: 'camelCase'
          }
        ],
        '@angular-eslint/component-selector': [
          'error',
          {
            type: 'element',
            prefix: 'app',
            style: 'kebab-case'
          }
        ]
      }
    },
    {
      files: [
        '*.html'
      ],
      plugins: [
        'html'
      ],
      extends: [
        'plugin:@angular-eslint/template/recommended'
      ],
      rules: {}
    }
  ],
  parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
    project: 'tsconfig.json'
  }
}
</code>```

package.json

```<code>{
  "name": "catshop",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "lint": "ng lint"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^15.0.0",
    "@angular/common": "^15.0.0",
    "@angular/compiler": "^15.0.0",
    "@angular/core": "^15.0.0",
    "@angular/forms": "^15.0.0",
    "@angular/platform-browser": "^15.0.0",
    "@angular/platform-browser-dynamic": "^15.0.0",
    "@angular/router": "^15.0.0",
    "bootstrap": "^5.2.3",
    "eslint-plugin-html": "^7.1.0",
    "rxjs": "~7.5.0",
    "stylelint": "^14.16.0",
    "stylelint-config-standard-scss": "^6.1.0",
    "stylelint-scss": "^4.3.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.12.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.0.3",
    "@angular-eslint/builder": "15.1.0",
    "@angular-eslint/eslint-plugin": "^15.1.0",
    "@angular-eslint/eslint-plugin-template": "15.1.0",
    "@angular-eslint/schematics": "15.1.0",
    "@angular-eslint/template-parser": "15.1.0",
    "@angular/cli": "~15.0.3",
    "@angular/compiler-cli": "^15.0.0",
    "@types/jasmine": "~4.3.0",
    "@typescript-eslint/eslint-plugin": "^5.46.1",
    "@typescript-eslint/parser": "5.44.0",
    "eslint": "^8.29.0",
    "eslint-config-standard-with-typescript": "^23.0.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-n": "^15.6.0",
    "eslint-plugin-promise": "^6.1.1",
    "jasmine-core": "~4.5.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": "^4.8.4"
  }
}

</code>```

node_modules:

Body:
I'm setting up a new project with Angular 15. Therefore I also want ESLint so I installed some Plugins. At the moment it is working fine for .ts-files and also fix errors when I'm saving the file.

Because ESLint is not working for HTML-Files itself, I added eslint-plugin-html. Now when I leave out a specific line (extends: ['plugin:@angular-eslint/template/recommended'],) for the HTML-overrides it is not linting at all - but when added it's throwing the output error. Either ESLint doesn't understand the errors or it is throwing an error-message in output instead fixing them. I'm not sure! The error for line 1 is even thrown when I start with a comment.

My goal is too use ESLint correctly for HTML-Files and not just to turn it off.
Could you please give me a hint how I could debug this or what is the issue?

This is the error in output:

TypeError: Cannot read properties of undefined (reading '0')
Occurred while linting D:\Users\XXX\XXX\src\app\app.component.html:1
Rule: "indent"

My IDE is VSCode, my package manager is npm and these are my config-files:

.eslintrc.js

module.exports = {
  env: {
    browser: true,
    es2021: true
  },
  extends: [
    'standard-with-typescript'
  ],
  overrides: [
    {
      files: [
        '*.ts'
      ],
      extends: [
        'eslint:recommended',
        'plugin:@typescript-eslint/recommended',
        'plugin:@angular-eslint/recommended',
        'plugin:@angular-eslint/template/process-inline-templates'
      ],
      rules: {
        '@angular-eslint/directive-selector': [
          'error',
          {
            type: 'attribute',
            prefix: 'app',
            style: 'camelCase'
          }
        ],
        '@angular-eslint/component-selector': [
          'error',
          {
            type: 'element',
            prefix: 'app',
            style: 'kebab-case'
          }
        ]
      }
    },
    {
      files: [
        '*.html'
      ],
      plugins: [
        'html'
      ],
      extends: [
        'plugin:@angular-eslint/template/recommended'
      ],
      rules: {}
    }
  ],
  parserOptions: {
    ecmaVersion: 'latest',
    sourceType: 'module',
    project: 'tsconfig.json'
  }
}

package.json

{
  "name": "catshop",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "lint": "ng lint"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^15.0.0",
    "@angular/common": "^15.0.0",
    "@angular/compiler": "^15.0.0",
    "@angular/core": "^15.0.0",
    "@angular/forms": "^15.0.0",
    "@angular/platform-browser": "^15.0.0",
    "@angular/platform-browser-dynamic": "^15.0.0",
    "@angular/router": "^15.0.0",
    "bootstrap": "^5.2.3",
    "eslint-plugin-html": "^7.1.0",
    "rxjs": "~7.5.0",
    "stylelint": "^14.16.0",
    "stylelint-config-standard-scss": "^6.1.0",
    "stylelint-scss": "^4.3.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.12.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.0.3",
    "@angular-eslint/builder": "15.1.0",
    "@angular-eslint/eslint-plugin": "^15.1.0",
    "@angular-eslint/eslint-plugin-template": "15.1.0",
    "@angular-eslint/schematics": "15.1.0",
    "@angular-eslint/template-parser": "15.1.0",
    "@angular/cli": "~15.0.3",
    "@angular/compiler-cli": "^15.0.0",
    "@types/jasmine": "~4.3.0",
    "@typescript-eslint/eslint-plugin": "^5.46.1",
    "@typescript-eslint/parser": "5.44.0",
    "eslint": "^8.29.0",
    "eslint-config-standard-with-typescript": "^23.0.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-n": "^15.6.0",
    "eslint-plugin-promise": "^6.1.1",
    "jasmine-core": "~4.5.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": "^4.8.4"
  }
}

node_modules:


问:
Airflow Cloud composer: While appending the parquet columns in BQ which is having null value columns itself not appearing in the final Bigquery
I am trying to load the data(parquest) from GCS(.parquet files) to BigQuery.

I have written a code to append the column in the bigQuery based on the new schemes if added in the source parquet file , so it will append this new column in the existing table.

Below code is working fine but only 3 below scenario is not working need help as a priority:

prority1:
It is not able to append or load the schemas/column's which is having null data in parquet file.

Priority2:
suppose file1.parquet file have 3 rows load into the final table 1-jan-2023, Now In 2-jan-2023 when the file2 came only with 1 row so in the final table the total number of records is 7 as again it is reloading the file1.parquet data, is there machining to remove the duplicate records  after successfully loaded ino the final table 'sl_dim_parquet'

prirority3:
while load the data from .parquet file to BiQuery ,how will include the timestamp column which will indicate the loading time as an addition column.

Code:

# -*- coding: utf-8 -*-
import datetime,time
from airflow import DAG,models
from airflow.contrib.operators.gcs_to_bq import GoogleCloudStorageToBigQueryOperator
from airflow.operators import dummy_operator
import logging
import json,os
from airflow.operators import bash_operator
from airflow.providers.google.cloud.sensors.bigquery import (
    BigQueryTableExistenceSensor,
    BigQueryTablePartitionExistenceSensor,
)
from airflow.utils import timezone

yesterday = datetime.datetime.now() - datetime.timedelta(days=1)

default_args = {
    'owner': 'airflow',
    'start_date': yesterday

}

with models.DAG(
        'Parquet_GCS_to_BQ',
        default_args=default_args,
        catchup=False,
        #schedule_interval='* 5 * * * ') as dag:
        schedule_interval=None) as dag:
    start = dummy_operator.DummyOperator(
        task_id='start',
        trigger_rule='all_success'
    )

    end = dummy_operator.DummyOperator(
        task_id='end',
        trigger_rule='all_success'
    )

    GCS_to_BQ = GoogleCloudStorageToBigQueryOperator(
            task_id='Loading_Parquet_Into_BQ',
            bucket='europe-west2-composer-dev-d0d0fe57-bucket',
            source_objects=['ee-nba-prd-cnba-traceability/traceability-v3/year=2021/month=8/*.parquet',  'ee-nba-prd-cnba-traceability/traceability-v3/year=2022/month=9/*.parquet'],
            source_format='parquet',
            destination_project_dataset_table='bt-bvp-dataprod-dp-dev.cons_ccn_ov_rw.sl_dim_parquet',
            create_disposition='CREATE_IF_NEEDED',
            write_disposition='WRITE_APPEND',
            schema_update_options=['ALLOW_FIELD_RELAXATION', 'ALLOW_FIELD_ADDITION'],
            autodetect=True,
            skip_leading_rows =1,
            google_cloud_storage_conn_id='google_cloud_default',
            bigquery_conn_id='google_cloud_default'
        )

    start >> GCS_to_BQ >> end
```

Need help to update the given code with the 3 scenarios.

Body:
I am trying to load the data(parquest) from GCS(.parquet files) to BigQuery.

I have written a code to append the column in the bigQuery based on the new schemes if added in the source parquet file , so it will append this new column in the existing table.

Below code is working fine but only 3 below scenario is not working need help as a priority:

prority1:
It is not able to append or load the schemas/column's which is having null data in parquet file.

Priority2:
suppose file1.parquet file have 3 rows load into the final table 1-jan-2023, Now In 2-jan-2023 when the file2 came only with 1 row so in the final table the total number of records is 7 as again it is reloading the file1.parquet data, is there machining to remove the duplicate records  after successfully loaded ino the final table 'sl_dim_parquet'

prirority3:
while load the data from .parquet file to BiQuery ,how will include the timestamp column which will indicate the loading time as an addition column.

Code:

# -*- coding: utf-8 -*-
import datetime,time
from airflow import DAG,models
from airflow.contrib.operators.gcs_to_bq import GoogleCloudStorageToBigQueryOperator
from airflow.operators import dummy_operator
import logging
import json,os
from airflow.operators import bash_operator
from airflow.providers.google.cloud.sensors.bigquery import (
    BigQueryTableExistenceSensor,
    BigQueryTablePartitionExistenceSensor,
)
from airflow.utils import timezone

yesterday = datetime.datetime.now() - datetime.timedelta(days=1)

default_args = {
    'owner': 'airflow',
    'start_date': yesterday

}

with models.DAG(
        'Parquet_GCS_to_BQ',
        default_args=default_args,
        catchup=False,
        #schedule_interval='* 5 * * * ') as dag:
        schedule_interval=None) as dag:
    start = dummy_operator.DummyOperator(
        task_id='start',
        trigger_rule='all_success'
    )

    end = dummy_operator.DummyOperator(
        task_id='end',
        trigger_rule='all_success'
    )

    GCS_to_BQ = GoogleCloudStorageToBigQueryOperator(
            task_id='Loading_Parquet_Into_BQ',
            bucket='europe-west2-composer-dev-d0d0fe57-bucket',
            source_objects=['ee-nba-prd-cnba-traceability/traceability-v3/year=2021/month=8/*.parquet',  'ee-nba-prd-cnba-traceability/traceability-v3/year=2022/month=9/*.parquet'],
            source_format='parquet',
            destination_project_dataset_table='bt-bvp-dataprod-dp-dev.cons_ccn_ov_rw.sl_dim_parquet',
            create_disposition='CREATE_IF_NEEDED',
            write_disposition='WRITE_APPEND',
            schema_update_options=['ALLOW_FIELD_RELAXATION', 'ALLOW_FIELD_ADDITION'],
            autodetect=True,
            skip_leading_rows =1,
            google_cloud_storage_conn_id='google_cloud_default',
            bigquery_conn_id='google_cloud_default'
        )

    start >> GCS_to_BQ >> end

Need help to update the given code with the 3 scenarios.


问:
Median for data between 2 dates
In one column I have date/time format ranging from July - Dec 2022. In another column I have the corresponding time values for task completion. Example of the data is as below -

Sample Data:

I want to calculate the median for the date range of

Median Date Range:

How can I calculate the median hours for particular date range?

I am expecting the data as below:

Title: Median for data between 2 dates


问:
Git: Can't push to a newly initialised repository in Visual Studio Code
I am not able to push a local repository to a GitHub repo, both created at the same time.

The steps I took:

In Visual Studio Code (VS Code) I select Open Folder to add the project folder.

I click on the Source Control pane and then Initialise Repository.

I Stage and Commit the files using the VS Code GUI.

On GitHub online I create a New repository, naming it and not adding any other files (e.g. .gitignore).

I copy from the GitHub instructions that appear and run the command in the VS Code terminal (git bash): git remote add origin https://github.com/username/reponame.git

I then try to Publish Branch via VS Code GUI, or run the code in the VS Code terminal from GitHub: git push -u origin main, BUT both fail and produce the error that follows:

```<code># GIT ERROR

> git push origin main
error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
Everything up-to-date
</code>```
```<code># TERMINAL OUTPUT

$ git push -u origin main
Enumerating objects: 45, done.
Counting objects: 100% (45/45), done.
Delta compression using up to 8 threads
Compressing objects: 100% (44/44), done.
error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (45/45), 151.59 MiB | 10.27 MiB/s, done.
Total 45 (delta 5), reused 0 (delta 0), pack-reused 0
fatal: the remote end hung up unexpectedly
Everything up-to-date
</code>```

I've deleted the local .git folder and the GitHub repo and tried multiple times, but can't get it to work.
I appreciate any help.

Body:
I am not able to push a local repository to a GitHub repo, both created at the same time.

The steps I took:

In Visual Studio Code (VS Code) I select Open Folder to add the project folder.

I click on the Source Control pane and then Initialise Repository.

I Stage and Commit the files using the VS Code GUI.

On GitHub online I create a New repository, naming it and not adding any other files (e.g. .gitignore).

I copy from the GitHub instructions that appear and run the command in the VS Code terminal (git bash): git remote add origin https://github.com/username/reponame.git

I then try to Publish Branch via VS Code GUI, or run the code in the VS Code terminal from GitHub: git push -u origin main, BUT both fail and produce the error that follows:

# GIT ERROR

> git push origin main
error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
Everything up-to-date

# TERMINAL OUTPUT

$ git push -u origin main
Enumerating objects: 45, done.
Counting objects: 100% (45/45), done.
Delta compression using up to 8 threads
Compressing objects: 100% (44/44), done.
error: RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)
send-pack: unexpected disconnect while reading sideband packet
Writing objects: 100% (45/45), 151.59 MiB | 10.27 MiB/s, done.
Total 45 (delta 5), reused 0 (delta 0), pack-reused 0
fatal: the remote end hung up unexpectedly
Everything up-to-date

I've deleted the local .git folder and the GitHub repo and tried multiple times, but can't get it to work.
I appreciate any help.