问:
Add keyboard shortcut for Search

Overview

I have a SwiftUI list with a search field

I would like to add a keyboard shortcut for search field to be in focus

Questions:

How can I add a keyboard shortcut for search field?

```<code>import SwiftUI

struct ContentView: View {

    @State private var searchText = ""

    var body: some View {
        NavigationStack {
            List(0..<100) { index in
                Text("Cell \(index)")
            }
            .searchable(text: $searchText)
        }
    }
}
</code>```

Title: Add keyboard shortcut for Search

Body:
Overview

I have a SwiftUI list with a search field

I would like to add a keyboard shortcut for search field to be in focus

Questions:

How can I add a keyboard shortcut for search field?

import SwiftUI

struct ContentView: View {

    @State private var searchText = ""

    var body: some View {
        NavigationStack {
            List(0..<100) { index in
                Text("Cell \(index)")
            }
            .searchable(text: $searchText)
        }
    }
}


来源: stackexchange

问:
How can I trap for the 409 error on too much contention when updating an entity in Google Datastore
Every few days, on Google Datastore, when I update an entity then I receive the error "Aborted: Too much contention when updating entity". It is certainly possible that other streams could be accessing the entity at the same time. Related questions have been asked over the past 10 years and I can't find an answer, also maybe there are some newer options available. For an early example, see

"Too much contention" when creating new entity in dataStore

Consider a very basic update:

```<code>    average_data = codecs.encode(json.dumps(json_data).encode('utf-8'), encoding='zlib_codec')
    with client.transaction():
        entity = client.get(key)
        entity["average_data"] = average_data
        client.put(entity)
</code>```

How can I best trap for a 409 exception? The client.put() method doesnt seem to actually return anything. I could try something like this, although it a bit seems dumb:

```<code>average_data = codecs.encode(json.dumps(json_data).encode('utf-8'), encoding='zlib_codec')
with client.transaction():
    entity = client.get(key)
    entity["average_data"] = average_data
    try:
       client.put(entity)
    except:
       try:
          sleep(0.1)
          client.put(entity)
       except:
          sleep(0.5)
          client.put(entity)
</code>```

But maybe that is indeed the best option?

Thanks,

ContentLicense: CC BY-SA 4.0

Body:
Every few days, on Google Datastore, when I update an entity then I receive the error "Aborted: Too much contention when updating entity". It is certainly possible that other streams could be accessing the entity at the same time. Related questions have been asked over the past 10 years and I can't find an answer, also maybe there are some newer options available. For an early example, see

"Too much contention" when creating new entity in dataStore

Consider a very basic update:

    average_data = codecs.encode(json.dumps(json_data).encode('utf-8'), encoding='zlib_codec')
    with client.transaction():
        entity = client.get(key)
        entity["average_data"] = average_data
        client.put(entity)

How can I best trap for a 409 exception? The client.put() method doesnt seem to actually return anything. I could try something like this, although it a bit seems dumb:

average_data = codecs.encode(json.dumps(json_data).encode('utf-8'), encoding='zlib_codec')
with client.transaction():
    entity = client.get(key)
    entity["average_data"] = average_data
    try:
       client.put(entity)
    except:
       try:
          sleep(0.1)
          client.put(entity)
       except:
          sleep(0.5)
          client.put(entity)

But maybe that is indeed the best option?

Thanks,


问:
map with tidy eval with paste
I need to run lm on nested data and use map with lm. But I put it in a function to have a different set of independent variables in the model. The code looks like this

predictors1<-c("TWO_YEAR_PRIOR_SCALE_0","PV1.Dim1")

```<code>student_progress_model<-function(df, predictors){
  lm(
  as.formula(paste("SCALE_SCORE_0", paste(predictors, collapse="+"), sep="~")),
  data=df, na.action=na.exclude)
}

data_nested<-data_nested%>%
  mutate(
    model=map(data, student_progress_model(df=., predictors=predictors1)),
    stand_resids = map2(data, model, rstandard)
  )
</code>```

It comes up with the error that object 'SCALE_SCORE_0' not found

How can i specify that my variables are in the data passed to the function? Is it something to do with tidy eval?
I tried to put {{}} in my function like

```<code>lm(
      as.formula(paste("SCALE_SCORE_0", paste({{predictors}}, collapse="+"), sep="~")),
      data=df, na.action=na.exclude)
</code>```

But it does not help...

also, will rstandard give me standardised residuals this way?

Thank you

Title: map with tidy eval with paste

Body:
I need to run lm on nested data and use map with lm. But I put it in a function to have a different set of independent variables in the model. The code looks like this

predictors1<-c("TWO_YEAR_PRIOR_SCALE_0","PV1.Dim1")

student_progress_model<-function(df, predictors){
  lm(
  as.formula(paste("SCALE_SCORE_0", paste(predictors, collapse="+"), sep="~")),
  data=df, na.action=na.exclude)
}

data_nested<-data_nested%>%
  mutate(
    model=map(data, student_progress_model(df=., predictors=predictors1)),
    stand_resids = map2(data, model, rstandard)
  )

It comes up with the error that object 'SCALE_SCORE_0' not found

How can i specify that my variables are in the data passed to the function? Is it something to do with tidy eval?
I tried to put {{}} in my function like

lm(
      as.formula(paste("SCALE_SCORE_0", paste({{predictors}}, collapse="+"), sep="~")),
      data=df, na.action=na.exclude)

But it does not help...

also, will rstandard give me standardised residuals this way?

Thank you


问:
Error creating bean with name 'authorController' defined in file "..." : Unsatisfied dependency expressed through constructor parameter 0
I have spent three days on this problem and still haven't found the solution why my program doesn't start.
I try to run the application and I get this huge problem text, I checked countless simular projects and they all are structured quite the same, with one major difference, mine doesn't start.
I tried every possible solution I could find, I am guessing I am missing something in the definition on the class but I literally checked every character.</p>
```<code>Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2022-12-07T22:48:47.782+01:00 ERROR 5504 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorController' defined in file [C:\Users\Sashko\IdeaProjects\task_01\target\classes\com\example\task_01\controller\AuthorController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'authorServiceImpl' defined in file [C:\Users\Sashko\IdeaProjects\task_01\target\classes\com\example\task_01\service\impl\AuthorServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'authorRepository' defined in com.example.task_01.repository.AuthorRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.task_01.entity.Author
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:793) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:242) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1188) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:915) ~[spring-context-6.0.2.jar:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[spring-context-6.0.2.jar:6.0.2]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring-boot-3.0.0.jar:3.0.0]
    at com.example.task_01.Task01Application.main(Task01Application.java:22) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-3.0.0.jar:3.0.0]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorServiceImpl' defined in file [C:\Users\Sashko\IdeaProjects\task_01\target\classes\com\example\task_01\service\impl\AuthorServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'authorRepository' defined in com.example.task_01.repository.AuthorRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.task_01.entity.Author
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:793) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:242) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1188) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:880) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:784) ~[spring-beans-6.0.2.jar:6.0.2]
    ... 24 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authorRepository' defined in com.example.task_01.repository.AuthorRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.task_01.entity.Author
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1751) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:880) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:784) ~[spring-beans-6.0.2.jar:6.0.2]
    ... 38 common frames omitted
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.example.task_01.entity.Author
    at org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl.managedType(JpaMetamodelImpl.java:181) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:496) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:99) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:77) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:69) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:246) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:211) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:194) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:317) ~[spring-data-commons-3.0.0.jar:3.0.0]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:279) ~[spring-data-commons-3.0.0.jar:3.0.0]
    at org.springframework.data.util.Lazy.getNullable(Lazy.java:229) ~[spring-data-commons-3.0.0.jar:3.0.0]
    at org.springframework.data.util.Lazy.get(Lazy.java:113) ~[spring-data-commons-3.0.0.jar:3.0.0]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:285) ~[spring-data-commons-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:132) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1797) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747) ~[spring-beans-6.0.2.jar:6.0.2]
    ... 49 common frames omitted

`
```

Here is a snippet of my code:
[Author entity class](https://i.stack.imgur.com/qmN4x.png)
[Author service class](https://i.stack.imgur.com/HczT4.png)
[Author serviceImpl class](https://i.stack.imgur.com/Ntc9K.png)
[Author controller class](https://i.stack.imgur.com/S8ZdV.png)
</code>```

Body:
I have spent three days on this problem and still haven't found the solution why my program doesn't start.
I try to run the application and I get this huge problem text, I checked countless simular projects and they all are structured quite the same, with one major difference, mine doesn't start.
I tried every possible solution I could find, I am guessing I am missing something in the definition on the class but I literally checked every character.

Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2022-12-07T22:48:47.782+01:00 ERROR 5504 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorController' defined in file [C:\Users\Sashko\IdeaProjects\task_01\target\classes\com\example\task_01\controller\AuthorController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'authorServiceImpl' defined in file [C:\Users\Sashko\IdeaProjects\task_01\target\classes\com\example\task_01\service\impl\AuthorServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'authorRepository' defined in com.example.task_01.repository.AuthorRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.task_01.entity.Author
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:793) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:242) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1188) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:961) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:915) ~[spring-context-6.0.2.jar:6.0.2]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:584) ~[spring-context-6.0.2.jar:6.0.2]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot-3.0.0.jar:3.0.0]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring-boot-3.0.0.jar:3.0.0]
    at com.example.task_01.Task01Application.main(Task01Application.java:22) ~[classes/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:568) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-3.0.0.jar:3.0.0]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorServiceImpl' defined in file [C:\Users\Sashko\IdeaProjects\task_01\target\classes\com\example\task_01\service\impl\AuthorServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'authorRepository' defined in com.example.task_01.repository.AuthorRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.task_01.entity.Author
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:793) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:242) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1344) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1188) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:561) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:880) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:784) ~[spring-beans-6.0.2.jar:6.0.2]
    ... 24 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authorRepository' defined in com.example.task_01.repository.AuthorRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class com.example.task_01.entity.Author
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1751) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:599) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:521) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:326) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:324) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:200) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:254) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1405) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1325) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:880) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:784) ~[spring-beans-6.0.2.jar:6.0.2]
    ... 38 common frames omitted
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.example.task_01.entity.Author
    at org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl.managedType(JpaMetamodelImpl.java:181) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:496) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:99) ~[hibernate-core-6.1.5.Final.jar:6.1.5.Final]
    at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:77) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:69) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:246) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:211) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:194) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:81) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:317) ~[spring-data-commons-3.0.0.jar:3.0.0]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:279) ~[spring-data-commons-3.0.0.jar:3.0.0]
    at org.springframework.data.util.Lazy.getNullable(Lazy.java:229) ~[spring-data-commons-3.0.0.jar:3.0.0]
    at org.springframework.data.util.Lazy.get(Lazy.java:113) ~[spring-data-commons-3.0.0.jar:3.0.0]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:285) ~[spring-data-commons-3.0.0.jar:3.0.0]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:132) ~[spring-data-jpa-3.0.0.jar:3.0.0]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1797) ~[spring-beans-6.0.2.jar:6.0.2]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1747) ~[spring-beans-6.0.2.jar:6.0.2]
    ... 49 common frames omitted

`
```

Here is a snippet of my code:
[Author entity class](https://i.stack.imgur.com/qmN4x.png)
[Author service class](https://i.stack.imgur.com/HczT4.png)
[Author serviceImpl class](https://i.stack.imgur.com/Ntc9K.png)
[Author controller class](https://i.stack.imgur.com/S8ZdV.png)


问:
How to convert object to encoded query string
I tried converting an object into a querystring, but I don't understand how to convert a nested object and an array.

```<code>const queryObj = {
  page: 1,
  title: 'myTitle',
  startDate: '2222-01-01',
  endDate: '2022-02-05',
  id: 'jsgfdasjgfui2323gsdaa34g345',
  additional: [
    {
      placeNumber: 1,
      productNumber: 3,
      productSpec: [3, 12, 6],
    },
  ],
  price: {
    min: 1,
    max: 10000,
  },
};
</code>```

I tried it this way:

```<code>const fn = (queryObj, query = '') => {
  for (const [key, value] of Object.entries(queryObj)) {
    query += `${key}=${value}&`
  }
  return encodeURI(query);
}
</code>```

The result I got:

```<code>page=1&title=myTitle&startDate=2222-01-01&endDate=2022-02-05&id=jsgfdasjgfui2323gsdaa34g345&additional=%5Bobject%20Object%5D&price=%5Bobject%20Object%5D&
</code>```

Do I need to use recursion to somehow convert the nested object and array? (I don't know how to do this yet, can anyone show me?)

The result I need:

```<code>page=1&title=myTitle&startDate=2222-01-01&endDate=2022-02-05&id=jsgfdasjgfui2323gsdaa34g345&additional=%5B%7B"placeNumber"%3A1%2C"productNumber"%3A0%2C"productSpec"%3A%5B%5D%7D%5D&price=%7B"min"%3A1%2C"max"%3A10000%7D
</code>```

Body:
I tried converting an object into a querystring, but I don't understand how to convert a nested object and an array.

const queryObj = {
  page: 1,
  title: 'myTitle',
  startDate: '2222-01-01',
  endDate: '2022-02-05',
  id: 'jsgfdasjgfui2323gsdaa34g345',
  additional: [
    {
      placeNumber: 1,
      productNumber: 3,
      productSpec: [3, 12, 6],
    },
  ],
  price: {
    min: 1,
    max: 10000,
  },
};

I tried it this way:

const fn = (queryObj, query = '') => {
  for (const [key, value] of Object.entries(queryObj)) {
    query += `${key}=${value}&`
  }
  return encodeURI(query);
}

The result I got:

page=1&title=myTitle&startDate=2222-01-01&endDate=2022-02-05&id=jsgfdasjgfui2323gsdaa34g345&additional=%5Bobject%20Object%5D&price=%5Bobject%20Object%5D&

Do I need to use recursion to somehow convert the nested object and array? (I don't know how to do this yet, can anyone show me?)

The result I need:

page=1&title=myTitle&startDate=2222-01-01&endDate=2022-02-05&id=jsgfdasjgfui2323gsdaa34g345&additional=%5B%7B"placeNumber"%3A1%2C"productNumber"%3A0%2C"productSpec"%3A%5B%5D%7D%5D&price=%7B"min"%3A1%2C"max"%3A10000%7D


问:
Resetting file handler name in python logging
I have a code structure that looks like this:

```<code>.
├── scripts
│   └── test.py
└── utils
    ├── __init__.py
    └── lib.py
</code>```

In my utils/__init__.py file I've set up logging like so:

```<code>import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
ch = logging.FileHandler("logfile", mode="w")
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter(
    "%(levelname)s:%(name)s:[%(funcName)s]:%(message)s", "%m/%d/%Y %I:%M:%S %p"
)
ch.setFormatter(formatter)
logger.addHandler(ch)
</code>```

This works, and if I log in lib.py using code like so

```<code>LOGGER = logging.getLogger(__name__)

def a_function():
    LOGGER.info('This works')
</code>```

then everything runs and gets logged.

However, I often find myself wanting to run different scripts while in the same environment and I'd like to have a log that's named differently for each run (I don't want them writing over each other or appending to the same log). What is the best way to modify the logging name when logging is set up like this? I've tried doing things like the following in scripts/test.py:

```<code>import logging

from utils.lib import a_function

def main():
    # rename handler
    fh = logging.FileHandler("logfile2", "w")
    formatter = logging.Formatter(
        "%(levelname)s:%(name)s:[%(funcName)s]:%(message)s", "%m/%d/%Y %I:%M:%S %p"
    )
    fh.setFormatter(formatter)
    log = logging.getLogger()
    log.handlers.clear()
    log.addHandler(fh)

    a_function()

if __name__ == '__main__':
    main()
</code>```

This works in adding a new log called logfile2, but I still get logging in the original logfile. I would have thought that the log.handlers.clear() command would have cleared that out.

What am I doing wrong here?

Body:
I have a code structure that looks like this:

.
├── scripts
│   └── test.py
└── utils
    ├── __init__.py
    └── lib.py

In my utils/__init__.py file I've set up logging like so:

import logging

logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
ch = logging.FileHandler("logfile", mode="w")
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter(
    "%(levelname)s:%(name)s:[%(funcName)s]:%(message)s", "%m/%d/%Y %I:%M:%S %p"
)
ch.setFormatter(formatter)
logger.addHandler(ch)

This works, and if I log in lib.py using code like so

LOGGER = logging.getLogger(__name__)

def a_function():
    LOGGER.info('This works')

then everything runs and gets logged.

However, I often find myself wanting to run different scripts while in the same environment and I'd like to have a log that's named differently for each run (I don't want them writing over each other or appending to the same log). What is the best way to modify the logging name when logging is set up like this? I've tried doing things like the following in scripts/test.py:

import logging

from utils.lib import a_function

def main():
    # rename handler
    fh = logging.FileHandler("logfile2", "w")
    formatter = logging.Formatter(
        "%(levelname)s:%(name)s:[%(funcName)s]:%(message)s", "%m/%d/%Y %I:%M:%S %p"
    )
    fh.setFormatter(formatter)
    log = logging.getLogger()
    log.handlers.clear()
    log.addHandler(fh)

    a_function()

if __name__ == '__main__':
    main()

This works in adding a new log called logfile2, but I still get logging in the original logfile. I would have thought that the log.handlers.clear() command would have cleared that out.

What am I doing wrong here?


问:
I'm trying to convert a functional componet into a class component
I have a table of data which adds a new column for each new object within an array.  The functional component works just fine, but I want to practice over class components so I started to play around with some small components that I made and convert them to class components.

```<code>import someData from ...

export default function PageTable(): JSX.Element {

    const [tableData, setTableData] = useState(someData);

    function addNewRowsWithRandomData() {
        let randomObject = tableData[Math.floor(Math.random() * tableData.length)];
        setTableData((prevData): any => {
            let newDataArray = [...prevData, randomObject];
            return newDataArray;
        })
    }

    return (
        <div>
            <div className="card">
                    <div className='card data-table' style={{ height: 'calc(80vh - 25vh)' }}>
                        <DataTable value={tableData} scrollable scrollHeight="flex" responsiveLayout="scroll" paginator
                            paginatorTemplate="CurrentPageReport FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"
                            currentPageReportTemplate="Showing {first} to {last} of {totalRecords}" rows={10} rowsPerPageOptions={[5, 10, 20, 50]}
                            resizableColumns columnResizeMode="fit" showGridlines>
                            <Column field="id" header="ID" sortable></Column>
                            <Column field="employeeStatus" header="Status" sortable></Column>
                            <Column field="lastName" header="Last Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }}></Column>
                            <Column field="firstName" header="First Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }}></Column>
                            <Column field="salutation" header="Honorifics"></Column>
                        </DataTable>
                        <Button label="Add Data" onClick={addNewRowsWithRandomData} />
                    </div>
</code>```

Here is my approach for the class component. I tried different solutions including lifecycle methods but none worked. When I press the Add Data button nothing happens.

```<code>export default class ClassPageTable extends Component<{}, unknown> {
    state = {
        data: someData
    }

    addNewRowsWithRandomData = () => {
        let randomObject = someData[Math.floor(Math.random() * someData.length)];
        this.setState((prevData: any): any => {
            [...prevData.data, randomObject];

        })
    }

    render() {
        return (
            <div>
                <div className="card">
                    <div className='card data-table' style={{ height: 'calc(80vh - 25vh)' }}>
                        <DataTable value={this.state.data} scrollable scrollHeight="flex" responsiveLayout="scroll" paginator
                            paginatorTemplate="CurrentPageReport FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"
                            currentPageReportTemplate="Showing {first} to {last} of {totalRecords}" rows={10} rowsPerPageOptions={[5, 10, 20, 50]}
                            resizableColumns columnResizeMode="fit" showGridlines>
                            <Column field="id" header="ID" sortable></Column>
                            <Column field="employeeStatus" header="Status" sortable></Column>
                            <Column field="lastName" header="Last Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }}></Column>
                            <Column field="firstName" header="First Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }}></Column>
                            <Column field="salutation" header="Honorifics"></Column>
                        </DataTable>
                        <Button label="Add Data" onClick={this.addNewRowsWithRandomData} />
                    </div>
                </div>
            </div>
        )
</code>```

Body:
I have a table of data which adds a new column for each new object within an array.  The functional component works just fine, but I want to practice over class components so I started to play around with some small components that I made and convert them to class components.

import someData from ...

export default function PageTable(): JSX.Element {

    const [tableData, setTableData] = useState(someData);

    function addNewRowsWithRandomData() {
        let randomObject = tableData[Math.floor(Math.random() * tableData.length)];
        setTableData((prevData): any => {
            let newDataArray = [...prevData, randomObject];
            return newDataArray;
        })
    }

    return (

                        <DataTable value={tableData} scrollable scrollHeight="flex" responsiveLayout="scroll" paginator
                            paginatorTemplate="CurrentPageReport FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"
                            currentPageReportTemplate="Showing {first} to {last} of {totalRecords}" rows={10} rowsPerPageOptions={[5, 10, 20, 50]}
                            resizableColumns columnResizeMode="fit" showGridlines>
                            <Column field="id" header="ID" sortable></Column>
                            <Column field="employeeStatus" header="Status" sortable></Column>
                            <Column field="lastName" header="Last Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }}></Column>
                            <Column field="firstName" header="First Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }}></Column>
                            <Column field="salutation" header="Honorifics"></Column>
                        </DataTable>
                        <Button label="Add Data" onClick={addNewRowsWithRandomData} />

Here is my approach for the class component. I tried different solutions including lifecycle methods but none worked. When I press the Add Data button nothing happens.

export default class ClassPageTable extends Component<{}, unknown> {
    state = {
        data: someData
    }

    addNewRowsWithRandomData = () => {
        let randomObject = someData[Math.floor(Math.random() * someData.length)];
        this.setState((prevData: any): any => {
            [...prevData.data, randomObject];

        })
    }

    render() {
        return (

                        <DataTable value={this.state.data} scrollable scrollHeight="flex" responsiveLayout="scroll" paginator
                            paginatorTemplate="CurrentPageReport FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown"
                            currentPageReportTemplate="Showing {first} to {last} of {totalRecords}" rows={10} rowsPerPageOptions={[5, 10, 20, 50]}
                            resizableColumns columnResizeMode="fit" showGridlines>
                            <Column field="id" header="ID" sortable></Column>
                            <Column field="employeeStatus" header="Status" sortable></Column>
                            <Column field="lastName" header="Last Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }}></Column>
                            <Column field="firstName" header="First Name" filter filterPlaceholder="Search by name" style={{ minWidth: '12rem' }}></Column>
                            <Column field="salutation" header="Honorifics"></Column>
                        </DataTable>
                        <Button label="Add Data" onClick={this.addNewRowsWithRandomData} />

        )


问:
RabbıtMq connection reset by peer
I have a problem. when I create a connection with python to rabbitmq. When it takes the data from the rabbit. This data goes into the model. If model takes about 2-3 minutes, I can print the result of the model to rabbit. But when it takes about 5 minutes, the connection dies and my code gives an error. How can solve this problem ?

I've tried to recreate the connection, but it didn't work.

Title: RabbıtMq connection reset by peer


问:
ModernGL context rendering brakes Pygame (nothing appearing on the screen)
On monday i wrote a python script with modernGL that runs a fragment and a vertex shader everything worked fine and I had like 40 FPS. Two days later, I tried to rerun that same script and nothing appeared. All my old scripts that worked too were not functioning this time. So I tried to isolate the problem, and it seems that there is something to do with the context rendering of modernGL; I will explain.

I wrote this code with just the faulty lines. It creates the context and everything then render it but don't display it. Then in the main loop I just want to display a screen with a background color and a Hello World text.

```<code>`import moderngl as mgl
import numpy as np

import pygame

init = pygame.init()
print(init)

screen = pygame.display.set_mode([1920, 1080], pygame.RESIZABLE)
clock = pygame.time.Clock()
font = pygame.font.SysFont("Arial", 32)
font2 = pygame.font.SysFont("Arial", 64)

SIZE = WIDTH, HEIGHT = int(500), int(500)
COLOR_MODE = "RGBA"

ctx = mgl.create_context()
fbo = ctx.simple_framebuffer(SIZE, components=len(COLOR_MODE))
fbo = ctx.simple_framebuffer(SIZE, components=len(COLOR_MODE))
fbo.use()
vbo = ctx.buffer(np.array([
    # x     y    z     u    v
     1,  1, 0.0,  1., 1.,
     1, -1, 0.0,  1., -1.,
    -1, -1, 0.0,  -1., -1.,
    -1,  1, 0.0,  -1., 1.,
], dtype=np.float32))

ibo = ctx.buffer(np.array([
    0, 1, 3,
    1, 2, 3,
], dtype=np.int32))

with open('shaders/Fragment.glsl', 'r') as file:
     FS = file.read()

with open('shaders/Vertex.glsl', 'r') as file:
     VS = file.read()

prog = ctx.program(vertex_shader=VS, fragment_shader=FS)
vao = ctx.vertex_array(prog, [(vbo, "3f 2f", "in_vert", "in_uv")], ibo)
vao.render(mode=mgl.TRIANGLES)

run = True
while run:
  screen.fill(255)
  text = font2.render("Hello World", 1, pygame.Color("orange"))
  screen.blit(text, (10,20))

  for event in pygame.event.get():
      if event.type == pygame.QUIT:
        run = False
  pygame.display.update()
pygame.quit()`
</code>```

The is 3 states with this code. If I just run this, I have a black pygame window:
Black window when executing

If I comment the line 21: fbo.use(), then the shader that should be a square image of 500*500 is displayed as the background (but I never asked pygame to show it).:
Distorded shader

Then, last case I also comment the line 42:

```<code>vao.render(mode=mgl.TRIANGLES)
</code>```

and then the pygame window looks like what I want.
Normal pygame window

For every situation, main loop is well running and the pygame events are working as expected.

I tried to uninstall and reinstall moderngl, pygame and glcontext (even with different older versions) but every time the script don't work.

Also I am sure I didn't modify my scripts, I copied some working backups and they don't work also.

If you have any hints I would be so nice.
Thank you!

Body:
On monday i wrote a python script with modernGL that runs a fragment and a vertex shader everything worked fine and I had like 40 FPS. Two days later, I tried to rerun that same script and nothing appeared. All my old scripts that worked too were not functioning this time. So I tried to isolate the problem, and it seems that there is something to do with the context rendering of modernGL; I will explain.

I wrote this code with just the faulty lines. It creates the context and everything then render it but don't display it. Then in the main loop I just want to display a screen with a background color and a Hello World text.

`import moderngl as mgl
import numpy as np

import pygame

init = pygame.init()
print(init)

screen = pygame.display.set_mode([1920, 1080], pygame.RESIZABLE)
clock = pygame.time.Clock()
font = pygame.font.SysFont("Arial", 32)
font2 = pygame.font.SysFont("Arial", 64)

SIZE = WIDTH, HEIGHT = int(500), int(500)
COLOR_MODE = "RGBA"

ctx = mgl.create_context()
fbo = ctx.simple_framebuffer(SIZE, components=len(COLOR_MODE))
fbo = ctx.simple_framebuffer(SIZE, components=len(COLOR_MODE))
fbo.use()
vbo = ctx.buffer(np.array([
    # x     y    z     u    v
     1,  1, 0.0,  1., 1.,
     1, -1, 0.0,  1., -1.,
    -1, -1, 0.0,  -1., -1.,
    -1,  1, 0.0,  -1., 1.,
], dtype=np.float32))

ibo = ctx.buffer(np.array([
    0, 1, 3,
    1, 2, 3,
], dtype=np.int32))

with open('shaders/Fragment.glsl', 'r') as file:
     FS = file.read()

with open('shaders/Vertex.glsl', 'r') as file:
     VS = file.read()

prog = ctx.program(vertex_shader=VS, fragment_shader=FS)
vao = ctx.vertex_array(prog, [(vbo, "3f 2f", "in_vert", "in_uv")], ibo)
vao.render(mode=mgl.TRIANGLES)

run = True
while run:
  screen.fill(255)
  text = font2.render("Hello World", 1, pygame.Color("orange"))
  screen.blit(text, (10,20))

  for event in pygame.event.get():
      if event.type == pygame.QUIT:
        run = False
  pygame.display.update()
pygame.quit()`

The is 3 states with this code. If I just run this, I have a black pygame window:
Black window when executing

If I comment the line 21: fbo.use(), then the shader that should be a square image of 500*500 is displayed as the background (but I never asked pygame to show it).:
Distorded shader

Then, last case I also comment the line 42:

vao.render(mode=mgl.TRIANGLES)

and then the pygame window looks like what I want.
Normal pygame window

For every situation, main loop is well running and the pygame events are working as expected.

I tried to uninstall and reinstall moderngl, pygame and glcontext (even with different older versions) but every time the script don't work.

Also I am sure I didn't modify my scripts, I copied some working backups and they don't work also.

If you have any hints I would be so nice.
Thank you!


问:
Sharepoint API post gets access denied, permissions seem correct
I am tryin to post to sharepoint's api. I can read just find, just cant add items.
Here are my permissions.

When i post a new item in a list I get:

```<code>System.UnauthorizedAccessException
</code>```

What am i missing

Body:
I am tryin to post to sharepoint's api. I can read just find, just cant add items.
Here are my permissions.

When i post a new item in a list I get:

System.UnauthorizedAccessException

What am i missing


问:
ActiveRecord::AssociationRelation loses foreign key value when combined with a UNION
I'm trying to write a named scope that uses a union:

# Simplified example
class MyModel < ActiveRecord::Base

  belongs_to :owner

  scope :my_named_scope, -> {
    scope_a = where("#{arel_table.name}.a = 'foo'")
    scope_b = where("#{arel_table.name}.b = 'bar'")
    union = scope_a.union(scope_b)
    from(union)
  }
end
```

MyModel.my_named_scope works fine

owner.my_models.my_named_scope does not

In the failing case, I can call .to_sql on the ActiveRecord::AssociationRelation which my_named_scope returns, and that SQL has a syntax error:

SELECT "my_models".* FROM ( SELECT "my_models".* FROM "my_models" WHERE "my_models"."owner_id" = 1001 AND (my_models.a = 'foo') UNION SELECT "my_models".* FROM "my_models" WHERE "my_models"."owner_id" =  AND (my_models.b = 'bar') ) WHERE "my_models"."owner_id" =

...The sql just cuts off after "owner_id" =  as if it can't find the owner_id, even though the owner_id (1001) appears earlier in the query. How do I correct this?

TMI: Rails 4.2 (I know it's old. I'm at a big company with big tech debt.)

Body:
I'm trying to write a named scope that uses a union:

# Simplified example
class MyModel < ActiveRecord::Base

  belongs_to :owner

  scope :my_named_scope, -> {
    scope_a = where("#{arel_table.name}.a = 'foo'")
    scope_b = where("#{arel_table.name}.b = 'bar'")
    union = scope_a.union(scope_b)
    from(union)
  }
end

MyModel.my_named_scope works fine

owner.my_models.my_named_scope does not

In the failing case, I can call .to_sql on the ActiveRecord::AssociationRelation which my_named_scope returns, and that SQL has a syntax error:

SELECT "my_models".* FROM ( SELECT "my_models".* FROM "my_models" WHERE "my_models"."owner_id" = 1001 AND (my_models.a = 'foo') UNION SELECT "my_models".* FROM "my_models" WHERE "my_models"."owner_id" =  AND (my_models.b = 'bar') ) WHERE "my_models"."owner_id" =

...The sql just cuts off after "owner_id" =  as if it can't find the owner_id, even though the owner_id (1001) appears earlier in the query. How do I correct this?

TMI: Rails 4.2 (I know it's old. I'm at a big company with big tech debt.)


问:
Convert hostname to url
So I have a problem that's related to converting / finding final destination based on hostname.
Are there any automated tools / npm packagets, or if you could point me in the right direction for writing my own implementation for following:
I have multiple hostnames, I would like to do the same thing browsers (Chrome in my case) do, enter only hostname and it automatically checks for http, https, and redirects me to the final for example "https://www.google.com/blahblah". I am sure this is achievable but I am not entirely sure how.
Any help is welcome :)

I tried navigating using multiple libraries in node.js (long ago in c# as well) but non of them accept hostname without http / https (and I don't want to manually try both because some old servers are accepting both).

In short: I want the same thing Chrome does when you navigate to hostname :D

Title: Convert hostname to url


问:
Make text wrap or truncate in ng2-smart-table column
I am using the ng2-smart-table and have a column with a list of emails that are separated by a semicolon. I want to have the text wrap so the column doesn't fill the width of the page. I have tried setting the width like this

```<code>  emailTo: {
        title: 'Email To',
        className: ['office-header', 'text-success'],
        width: "10%"

</code>```

but that didn't do anything. I also would be ok with truncating with ...

Body:
I am using the ng2-smart-table and have a column with a list of emails that are separated by a semicolon. I want to have the text wrap so the column doesn't fill the width of the page. I have tried setting the width like this

  emailTo: {
        title: 'Email To',
        className: ['office-header', 'text-success'],
        width: "10%"

but that didn't do anything. I also would be ok with truncating with ...


问:
What could be raising this "RuntimeError: Trying to resize storage that is not resizable"?
Has anyone ever experienced the error above? Any idea what could be raising it?

I get the error only on a specific dataset and it is thrown as batch 19 is loaded, always 19. Even though the data was split randomly.

The dataset is composed of 5 second audio .wav files that I transform into a spectrogram upon fetch.

```<code>Starting training for 1000 epoch(s)
Epoch 1/1000
 26%|█████████████████████▉                                                             | 19/72 [00:04<00:13,  3.86it/s, loss=33.745]
Traceback (most recent call last):
  File "train.py", line 202, in <module>
    train_and_evaluate(model, train_dl, test_dl, optimizer, cost, params, args.model_dir, args.experiment_name, args.restore_file)
  File "train.py", line 129, in train_and_evaluate
    train(model, optimizer, loss_fn, train_dataloader, params, epoch, writer)
  File "train.py", line 52, in train
    for i, (train_batch, current_rpm, next_rpm, next_pr) in enumerate(dataloader):
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 628, in __next__
    data = self._next_data()
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1333, in _next_data
    return self._process_data(data)
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1359, in _process_data
    data.reraise()
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/_utils.py", line 543, in reraise
    raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 3.
Original Traceback (most recent call last):
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 61, in fetch
    return self.collate_fn(data)
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 265, in default_collate
    return collate(batch, collate_fn_map=default_collate_fn_map)
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 143, in collate
    return [collate(samples, collate_fn_map=collate_fn_map) for samples in transposed]  # Backwards compatibility.
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 143, in <listcomp>
    return [collate(samples, collate_fn_map=collate_fn_map) for samples in transposed]  # Backwards compatibility.
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 120, in collate
    return collate_fn_map[elem_type](batch, collate_fn_map=collate_fn_map)
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 162, in collate_tensor_fn
    out = elem.new(storage).resize_(len(batch), *list(elem.size()))
RuntimeError: Trying to resize storage that is not resizable
</code>```

I've tried a different dataset of 2 second .wav recordings and it works fine.

Body:
Has anyone ever experienced the error above? Any idea what could be raising it?

I get the error only on a specific dataset and it is thrown as batch 19 is loaded, always 19. Even though the data was split randomly.

The dataset is composed of 5 second audio .wav files that I transform into a spectrogram upon fetch.

Starting training for 1000 epoch(s)
Epoch 1/1000
 26%|█████████████████████▉                                                             | 19/72 [00:04<00:13,  3.86it/s, loss=33.745]
Traceback (most recent call last):
  File "train.py", line 202, in <module>
    train_and_evaluate(model, train_dl, test_dl, optimizer, cost, params, args.model_dir, args.experiment_name, args.restore_file)
  File "train.py", line 129, in train_and_evaluate
    train(model, optimizer, loss_fn, train_dataloader, params, epoch, writer)
  File "train.py", line 52, in train
    for i, (train_batch, current_rpm, next_rpm, next_pr) in enumerate(dataloader):
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 628, in __next__
    data = self._next_data()
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1333, in _next_data
    return self._process_data(data)
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1359, in _process_data
    data.reraise()
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/_utils.py", line 543, in reraise
    raise exception
RuntimeError: Caught RuntimeError in DataLoader worker process 3.
Original Traceback (most recent call last):
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 302, in _worker_loop
    data = fetcher.fetch(index)
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 61, in fetch
    return self.collate_fn(data)
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 265, in default_collate
    return collate(batch, collate_fn_map=default_collate_fn_map)
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 143, in collate
    return [collate(samples, collate_fn_map=collate_fn_map) for samples in transposed]  # Backwards compatibility.
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 143, in <listcomp>
    return [collate(samples, collate_fn_map=collate_fn_map) for samples in transposed]  # Backwards compatibility.
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 120, in collate
    return collate_fn_map[elem_type](batch, collate_fn_map=collate_fn_map)
  File "/home/ubuntu/miniconda3/envs/SFB/lib/python3.8/site-packages/torch/utils/data/_utils/collate.py", line 162, in collate_tensor_fn
    out = elem.new(storage).resize_(len(batch), *list(elem.size()))
RuntimeError: Trying to resize storage that is not resizable

I've tried a different dataset of 2 second .wav recordings and it works fine.


问:
what is time conditional and how to calculate time conditional estimates for mean and variance in python?
thank you for reading my question.
I am really a beginner in python and do not know python and financial data.
I calculate four moments, but I have no idea about time conditional. (question 3 below)
Would you help me to solve the problems below question 3?
Thank you in advance.

Use YFinance in order to select five stocks from 2000-01-01 to 2021-12-31.

Calculate and display the four moments of each stock.

Use appropriate methods to calculate time conditional estimates for the first two moments. Compare the results for the conditional and unconditional estimates for all of your stocks. What differences can you see when comparing crisis and non-crisis periods?

Describe which stock you would have chosen for the crisis periods as well as the total period based on their respective return and risk profil.

here is my code.

```<code>import yfinance as yf
import pandas as pd
import numpy as np
</code>```

#question 1

```<code>from yfinance.tickers import Ticker
Ticker_liste = ["BAC","PG","KO","JNJ","WHR"]

df = pd.DataFrame()

for i,v in enumerate(Ticker_liste):
  temp = yf.Ticker(v)
  df[v] = temp.history(start="2000-01-01",end="2021-12-31")["Close"]
</code>```

#question 3

```<code>def download_logr(Ticker_liste, start_date, end_date):
  for i, ticker in enumerate(Ticker_liste):
    yf_ticker = yf.Ticker(Ticker_liste)
    df = yf_ticker.history(start = start_date, end = end_date)

    if i == 0:
      logr_df = df.Close.apply(np.log).diff().dropna().to_frame(f'logr_{ticker}')
    else:
      logr_df.loc[:, f'logr_{ticker}'] = df.Close.apply(np.log).diff().dropna().values

  return logr_df
</code>```
```<code>for i, ticker in enumerate(Ticker_liste):
  yf_ticker = yf.Ticker(ticker)
  df = yf_ticker.history
  if i == 0:
    logr_df = df.Close.apply(np.log).diff().dropna().to_frame(f'logr_{ticker}')
  else:
    logr_df.loc[:, f'logr_{ticker}'] = df.Close.apply(np.log).diff().dropna().values
</code>```

Body:
thank you for reading my question.
I am really a beginner in python and do not know python and financial data.
I calculate four moments, but I have no idea about time conditional. (question 3 below)
Would you help me to solve the problems below question 3?
Thank you in advance.

Use YFinance in order to select five stocks from 2000-01-01 to 2021-12-31.

Calculate and display the four moments of each stock.

Use appropriate methods to calculate time conditional estimates for the first two moments. Compare the results for the conditional and unconditional estimates for all of your stocks. What differences can you see when comparing crisis and non-crisis periods?

Describe which stock you would have chosen for the crisis periods as well as the total period based on their respective return and risk profil.

here is my code.

import yfinance as yf
import pandas as pd
import numpy as np

#question 1

from yfinance.tickers import Ticker
Ticker_liste = ["BAC","PG","KO","JNJ","WHR"]

df = pd.DataFrame()

for i,v in enumerate(Ticker_liste):
  temp = yf.Ticker(v)
  df[v] = temp.history(start="2000-01-01",end="2021-12-31")["Close"]

#question 3

def download_logr(Ticker_liste, start_date, end_date):
  for i, ticker in enumerate(Ticker_liste):
    yf_ticker = yf.Ticker(Ticker_liste)
    df = yf_ticker.history(start = start_date, end = end_date)

    if i == 0:
      logr_df = df.Close.apply(np.log).diff().dropna().to_frame(f'logr_{ticker}')
    else:
      logr_df.loc[:, f'logr_{ticker}'] = df.Close.apply(np.log).diff().dropna().values

  return logr_df

for i, ticker in enumerate(Ticker_liste):
  yf_ticker = yf.Ticker(ticker)
  df = yf_ticker.history
  if i == 0:
    logr_df = df.Close.apply(np.log).diff().dropna().to_frame(f'logr_{ticker}')
  else:
    logr_df.loc[:, f'logr_{ticker}'] = df.Close.apply(np.log).diff().dropna().values


问:
How do I edit multiple widgets all copied from one widget?
From the code below, I'm pulling 6 containers into something like a grid. The problem is that I'm trying to place images in said containers, but I don't know how to. If I edit that container, all 6 would be edited, right?

My main.dart page:

import 'package:flutter/material.dart';
import 'inputpage.dart';

void main() => runApp(BMICalculator());

class BMICalculator extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        appBarTheme: AppBarTheme(
          backgroundColor: Color(0xFF0a0e21),
        ),
        scaffoldBackgroundColor: Color(0xffffffff),
      ),
      home: InputPage(),
    );
  }
}

```
<p>First part of the code:</p>
<pre class="lang-dart prettyprint-override"><code>import 'package:flutter/material.dart';

class InputPage extends StatefulWidget {
  @override
  _InputPageState createState() => _InputPageState();
}

class _InputPageState extends State<InputPage> {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: Row(
          children: <Widget>[
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.fromLTRB(20 , 20 , 20 , 10),
                    child: CircleAvatar(
                      radius: 35,
                      backgroundImage: AssetImage('images/avatarslika.jpg'),
                    ),
                  ),
                  Expanded(
                    child: Row(
                      children: <Widget>[
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Row(
                      children: <Widget>[
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Row(
                      children: <Widget>[
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
</code>```

Here is the code I'm pulling the containers from:

class ReusableCard extends StatefulWidget {
  ReusableCard({required this.color});

  final Color color;

  @override
  State<ReusableCard> createState() => _ReusableCardState();
}

class _ReusableCardState extends State<ReusableCard> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        print('You have clicked me');
      },
      child: Container(
        margin: EdgeInsets.all(25),
        decoration: BoxDecoration(
          color: widget.color,
          borderRadius: BorderRadius.circular(10),
          boxShadow: [
            BoxShadow(
              blurRadius: 25,
              color: Color(0xd6d6d6d6).withOpacity(0.6),
            ),
          ],
        ),
      ),
    );
  }
}
```

Body:
From the code below, I'm pulling 6 containers into something like a grid. The problem is that I'm trying to place images in said containers, but I don't know how to. If I edit that container, all 6 would be edited, right?

My main.dart page:

import 'package:flutter/material.dart';
import 'inputpage.dart';

void main() => runApp(BMICalculator());

class BMICalculator extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        appBarTheme: AppBarTheme(
          backgroundColor: Color(0xFF0a0e21),
        ),
        scaffoldBackgroundColor: Color(0xffffffff),
      ),
      home: InputPage(),
    );
  }
}

First part of the code:

import 'package:flutter/material.dart';

class InputPage extends StatefulWidget {
  @override
  _InputPageState createState() => _InputPageState();
}

class _InputPageState extends State<InputPage> {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: Row(
          children: <Widget>[
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.fromLTRB(20 , 20 , 20 , 10),
                    child: CircleAvatar(
                      radius: 35,
                      backgroundImage: AssetImage('images/avatarslika.jpg'),
                    ),
                  ),
                  Expanded(
                    child: Row(
                      children: <Widget>[
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Row(
                      children: <Widget>[
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                      ],
                    ),
                  ),
                  Expanded(
                    child: Row(
                      children: <Widget>[
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                        Expanded(
                          child: ReusableCard(color: Colors.white),
                        ),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Here is the code I'm pulling the containers from:

class ReusableCard extends StatefulWidget {
  ReusableCard({required this.color});

  final Color color;

  @override
  State<ReusableCard> createState() => _ReusableCardState();
}

class _ReusableCardState extends State<ReusableCard> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        print('You have clicked me');
      },
      child: Container(
        margin: EdgeInsets.all(25),
        decoration: BoxDecoration(
          color: widget.color,
          borderRadius: BorderRadius.circular(10),
          boxShadow: [
            BoxShadow(
              blurRadius: 25,
              color: Color(0xd6d6d6d6).withOpacity(0.6),
            ),
          ],
        ),
      ),
    );
  }
}


问:
Inheriting class javadoc
Are you able to have a subclass inherit a superclass's class javadoc?
Something like this:</p>
```<code>/**
 * Parent javadoc
 */
class Superclass {}

/**
 * {@inheritDoc}
 * Child javadoc
 */
class Subclass extends Superclass {}
</code>```

Title: Inheriting class javadoc

Body:
Are you able to have a subclass inherit a superclass's class javadoc?
Something like this:

/**
 * Parent javadoc
 */
class Superclass {}

/**
 * {@inheritDoc}
 * Child javadoc
 */
class Subclass extends Superclass {}


问:
Power calculation of paired Wilcoxon signed rank test
I hope someone can help me with this.
I am comparing rates of change (unit/year, the scale is continuous including positive and negative numbers) before and after a certain treatment. The data is not normally distributed so I used Wilcoxon signed rank test to do the comparison. I have 60 observations, pre-treatment summary values are mean = -0.44, sd = 0.70, median = -0.29 and pos-treatment summary values are mean = -0.28, sd = 1.25, median = -0.18.
I have this code to detect the power of the Wilcoxon test but I am not sure if it is ok as I am comparing median (pre and post-treatment) of my data (not mean) and the code includes mean, sd

```<code>library(MKpower)

rxy \<- function(n) rnorm(n, mean = -0.44, sd = 0.70)
sim.ssize.wilcox.test(rx = rxy, mu = 0, type = "paired", n.max = 100,
iter = 1000)
</code>```

I also need to calculate the sample size to detect a reduction of 50% in the rate. Should I use mu = the half of the value of mean? half of median? Other?
PLEASE, HELP!

Body:
I hope someone can help me with this.
I am comparing rates of change (unit/year, the scale is continuous including positive and negative numbers) before and after a certain treatment. The data is not normally distributed so I used Wilcoxon signed rank test to do the comparison. I have 60 observations, pre-treatment summary values are mean = -0.44, sd = 0.70, median = -0.29 and pos-treatment summary values are mean = -0.28, sd = 1.25, median = -0.18.
I have this code to detect the power of the Wilcoxon test but I am not sure if it is ok as I am comparing median (pre and post-treatment) of my data (not mean) and the code includes mean, sd

library(MKpower)

rxy \<- function(n) rnorm(n, mean = -0.44, sd = 0.70)
sim.ssize.wilcox.test(rx = rxy, mu = 0, type = "paired", n.max = 100,
iter = 1000)

I also need to calculate the sample size to detect a reduction of 50% in the rate. Should I use mu = the half of the value of mean? half of median? Other?
PLEASE, HELP!


问:
How to push user to the current route but with new parameters using react-router-dom
I am an experienced vue.js dev learning React.

The application I am working on has an account dropdown, that allows the user to change the active account they are viewing within the app. A user should be able to change the account from any page. This means the route would be changed on account selection.

In Vue I am able to do this with:

```<code>import { useRouter, useRoute } from 'vue-router'

export default {
  setup() {
    const router = useRouter()
    const route = useRoute()

    function pushTo(accountId) {
      router.push({
        name: route.name,
        params: {
          accountId,
        },
      })
    }
  },
}
</code>```

I am not sure how to cleanly do this using react-router-dom.

The useLocation hook is returning the string url as /account/123/assets.

The useParams hook returns { accountId: 123 }.

Is there a simple way to say push user to the currentRoute with a new param, or do I need to manually parse the string url /account/123/assets and replacing the 123 with the new value?

Body:
I am an experienced vue.js dev learning React.

The application I am working on has an account dropdown, that allows the user to change the active account they are viewing within the app. A user should be able to change the account from any page. This means the route would be changed on account selection.

In Vue I am able to do this with:

import { useRouter, useRoute } from 'vue-router'

export default {
  setup() {
    const router = useRouter()
    const route = useRoute()

    function pushTo(accountId) {
      router.push({
        name: route.name,
        params: {
          accountId,
        },
      })
    }
  },
}

I am not sure how to cleanly do this using react-router-dom.

The useLocation hook is returning the string url as /account/123/assets.

The useParams hook returns { accountId: 123 }.

Is there a simple way to say push user to the currentRoute with a new param, or do I need to manually parse the string url /account/123/assets and replacing the 123 with the new value?


问:
Akka gRPC authorization rejection causes "12 INTERNAL" error
As mentioned on Akka gRPC documentation (https://doc.akka.io/docs/akka-grpc/current/server/akka-http.html) we can interop with Akka Http.

According to sample, request can be rejected (if check fails). But when rejection occures,
always getting "13 INTERNAL" error.
How can we return UNAUTHENTICATED(16) instead of Internal error?

```<code>val authorizationDirective: Directive0 =
  headerValueByName("token").flatMap { token =>
    if (token == "XYZ") pass
    else reject
  }
</code>```

also throwing exception did not work:

```<code>val authorizationDirective: Directive0 =
  headerValueByName("token").flatMap { token =>
    if (token == "XYZ") pass
    else throw new AuthenticationException("Invalid Token!")
  }
</code>```
```<code>01:06:50.972|ERROR|              akka.actor.ActorSystemImpl Error during processing of request: 'Invalid Token!'. Completing with 500 Internal Server Error response. To change default exception handling behavior, provide a custom ExceptionHandler.
com.xworks.affixzone.api.integration.definition.exception.AuthenticationException: Invalid Token!
</code>```

ps: I tried to use custom ExceptionHandler but it did not work.

Body:
As mentioned on Akka gRPC documentation (https://doc.akka.io/docs/akka-grpc/current/server/akka-http.html) we can interop with Akka Http.

According to sample, request can be rejected (if check fails). But when rejection occures,
always getting "13 INTERNAL" error.
How can we return UNAUTHENTICATED(16) instead of Internal error?

val authorizationDirective: Directive0 =
  headerValueByName("token").flatMap { token =>
    if (token == "XYZ") pass
    else reject
  }

also throwing exception did not work:

val authorizationDirective: Directive0 =
  headerValueByName("token").flatMap { token =>
    if (token == "XYZ") pass
    else throw new AuthenticationException("Invalid Token!")
  }

01:06:50.972|ERROR|              akka.actor.ActorSystemImpl Error during processing of request: 'Invalid Token!'. Completing with 500 Internal Server Error response. To change default exception handling behavior, provide a custom ExceptionHandler.
com.xworks.affixzone.api.integration.definition.exception.AuthenticationException: Invalid Token!

ps: I tried to use custom ExceptionHandler but it did not work.


问:
Odata feed failing out of memory exception when client makes too many calls
When a client job makes too many back to back calls (10-20 times) to below Odata feed, this feed fails with out of memory exception.
feed returns only 11K records and takes less than 10 seconds to response. I noticed with each call memory usage goes up but even after response usage doesn't come down even after long time.

I found that method "GetAll" is causing out of memory exception. It is fetching data from Mongo database using "await Collection
.Find(_ => true).ToListAsync();".

[Authorize(AuthenticationSchemes = "BasicAuthentication")]
    [Route("emp/[controller]")]
    [ApiController]
    public class EmpController
    {
        private readonly IEmpRepository _empRepository;

        public EmpController(IEmpRepository empRepository)
        {
            _empRepository = empRepository;

        }

        public async Task<IEnumerable<OdataResponse>> GetEmp(ODataQueryOptions opts)
        {
            var data = await _empRepository.GetAll();
           return OdataResponse.AllEmpForOdata(data);
        }
    }```