问:
How can I move the grid div down while using grid template columns in percentage
I was making my website responsive but while making it I found that I have used grid template columns in % but before I used use this format which help me make it easier to move down the other div

```<code>grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
</code>```

I want my div2 come down to div1 after it touches 1000px
here is my code for grid container

```<code>.LOR_s2-gridContainer{
    /* background-color: rgb(177, 130, 130); */
    display: grid;
    /* grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); */
    grid-template-columns: 90% 40%;
    /* grid-auto-rows: 755px; */
    margin-top: 90px;
    width: 70%;
    margin-left: 240px;
    gap: 20px;
}
</code>```

here is the 2 div under the grid

```<code>.LOR_s2-gridDiv1{
    /* background-color: rgb(114, 178, 87); */
    width: 75%;
}
.LOR_s2-gridDiv2{
    /* background-color: rgb(39, 64, 85); */
    width: 80%;
    margin-left: -210px;
}
</code>```

and here is the main jsx file

```<code><>
      <div className="LOR_s2-mainContainer">
        <div className="LOR_s2-gridContainer">
          <div className="LOR_s2-gridDiv1">
            <div className="LOR_s2-gridDiv1-imgDiv">
              <img className="LOR_s2-gridDiv1-img" src={img1} alt="" />
            </div>
            <div className="LOR_s2-gridDiv1-Head">
              LOR: Letter Of Recommendation
            </div>
            <div className="LOR_s2-gridDiv1-Text">
              Letter of Recommendation acts as an aide to your Statement of
              Purpose. It supports your Statement of Purpose by insights into
              your performance, projects, and personality. The Letter of
              Recommendation is signed and validated by your teachers,
              professors, mentors, and managers. Letter of Recommendation is
              both for <b>Educational</b> and <b>Professional </b> Professional
              Reasons. Correct recommendations lead to strengthening your
              application. The LoR has to correctly state your performance,
              accomplishments, and strengths in a way that does justice to your
              actual performance. We draft professional LoRs to highlight your
              mettle.
            </div>
            <div className="LOR_s2-gridDiv1-Text">
              Teachers often are unable to articulate the feats of the student.
              Also, the sources are not justified at times to validate the
              content.
            </div>
            <div className="LOR_s2-gridDiv1-head-Text">
              Educational Letter of Recommendation
            </div>
            <div className="LOR_s2-gridDiv1-Text">
              It is drafted to apply to educational institutions. An Educational
              LoR involves getting recommendations signed by teachers in school
              and professors in college. You need to decide which feats would
              strengthen your application and are worthy to be included in the
              LoR.
              <br />
              <b>Rates: ₹1000/- | US$ 15.00</b> View Sample
            </div>
            <div className="LOR_s2-gridDiv1-head-Text">
              Professional Letter of Recommendation
            </div>
            <div className="LOR_s2-gridDiv1-Text">
              A professional LoR is drafted to gain a better position in your
              professional tenure or shift jobs. It involves highlighting
              achievements that do justice to the job profile that you are
              applying to.
              <br />
              <b>Rates: ₹1000/- | US$ 15.00 </b> View Sample
            </div>
          </div>
          <div className="LOR_s2-gridDiv2">
            <div className="LOR_s2-gridDiv2-mainContainer">
              <div className="LOR_s2-gridDiv2-mainContainer-headContainer">
                <div className="LOR_s2-gridDiv2-mainContainer-head">
                  Apply Now
                </div>
                <div className="LOR_s2-gridDiv2-mainContainer-Text">
                  Please fill all your information correctly to get an idea
                  about your proper requirement.
                </div>
                <div className="LOR_s2-gridDiv2-mainContainer-Text">
                  Chose from the below buttons to choose your LOR type Academic
                  or Professional
                </div>
                <div className="LOR_s2-gridDiv2-mainContainer-button">
                  <div className="LOR_s2-gridDiv2-mainContainer-button-span1">
                    Academic
                  </div>
                  <div className="LOR_s2-gridDiv2-mainContainer-button-span2">
                    Professional
                  </div>
                  {/* <div className="LOR_s2-gridDiv2-mainContainer-button-span3">
                    OR
                  </div> */}
                </div>
              </div>
            </div>
            <div className="LOR_s2-gridDiv2-mainContainer-mainButton">
              LOR: Letter of Recommendation
              <span class="material-symbols-outlined arrow-symbol-LOR">
                chevron_right
              </span>
            </div>
            <div className="LOR_s2-gridDiv2-mainContainer-mainButton2">
              Assignment
              <span class="material-symbols-outlined arrow-symbol-LOR2">
                chevron_right
              </span>
            </div>
            <div className="LOR_s2-gridDiv2-mainContainer-mainButton2">
              SOP: Statement of Purpose
              <span class="material-symbols-outlined arrow-symbol-LOR2">
                chevron_right
              </span>
            </div>
            <div className="LOR_s2-gridDiv2-mainContainer-mainDiv2">
              <div className="LOR_s2-gridDiv2-mainContainer-mainDiv2-imgDiv">

                <img
                  className="LOR_s2-gridDiv2-mainContainer-mainDiv2-img"
                  src={img2}
                  alt=""
                />
                <div className="LOR_s2-gridDiv2-mainContainer-mainDiv2-callIconDiv">
                <span class="material-symbols-outlined LOR-callIcon" >call</span>
                </div>
                <div className="LOR_s2-gridDiv2-mainContainer-mainDiv2-Text">
                  Have any Questions?  Call us Now !
                </div>
                <div className="LOR_s2-gridDiv2-mainContainer-mainDiv2-Text2">
                +91 70165 22535
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </>
</code>```

Body:
I was making my website responsive but while making it I found that I have used grid template columns in % but before I used use this format which help me make it easier to move down the other div

grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));

I want my div2 come down to div1 after it touches 1000px
here is my code for grid container

.LOR_s2-gridContainer{
    /* background-color: rgb(177, 130, 130); */
    display: grid;
    /* grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); */
    grid-template-columns: 90% 40%;
    /* grid-auto-rows: 755px; */
    margin-top: 90px;
    width: 70%;
    margin-left: 240px;
    gap: 20px;
}

here is the 2 div under the grid

.LOR_s2-gridDiv1{
    /* background-color: rgb(114, 178, 87); */
    width: 75%;
}
.LOR_s2-gridDiv2{
    /* background-color: rgb(39, 64, 85); */
    width: 80%;
    margin-left: -210px;
}

and here is the main jsx file

<>

              LOR: Letter Of Recommendation

              Letter of Recommendation acts as an aide to your Statement of
              Purpose. It supports your Statement of Purpose by insights into
              your performance, projects, and personality. The Letter of
              Recommendation is signed and validated by your teachers,
              professors, mentors, and managers. Letter of Recommendation is
              both for Educational and Professional  Professional
              Reasons. Correct recommendations lead to strengthening your
              application. The LoR has to correctly state your performance,
              accomplishments, and strengths in a way that does justice to your
              actual performance. We draft professional LoRs to highlight your
              mettle.

              Teachers often are unable to articulate the feats of the student.
              Also, the sources are not justified at times to validate the
              content.

              Educational Letter of Recommendation

              It is drafted to apply to educational institutions. An Educational
              LoR involves getting recommendations signed by teachers in school
              and professors in college. You need to decide which feats would
              strengthen your application and are worthy to be included in the
              LoR.

              Rates: ₹1000/- | US$ 15.00 View Sample

              Professional Letter of Recommendation

              A professional LoR is drafted to gain a better position in your
              professional tenure or shift jobs. It involves highlighting
              achievements that do justice to the job profile that you are
              applying to.

              Rates: ₹1000/- | US$ 15.00  View Sample

                  Apply Now

                  Please fill all your information correctly to get an idea
                  about your proper requirement.

                  Chose from the below buttons to choose your LOR type Academic
                  or Professional

                    Academic

                    Professional

                  {/*

                    OR

 */}

              LOR: Letter of Recommendation

                chevron_right

              Assignment

                chevron_right

              SOP: Statement of Purpose

                chevron_right

                call

                  Have any Questions?  Call us Now !

                +91 70165 22535

    </>


来源: stackexchange

问:
Can static_cast gives nullpt for non-nullptr argument?
The following code gives me a warning "null pointer dereference" despite checking the pointer value before casting:

```<code>struct ID { virtual ~ID() = default; };
struct IF { virtual void g() = 0; };
struct F : IF { void g() {} };
struct D : ID, F { };

int main() {
    D* d;
    if (d) static_cast<IF*>(d)->g();
}
</code>```

Is it based on using uninitialized pointer value with -O2 optimization mode or static_cast really can result in null pointer value for non-null argument (e.g. when multiple inheritance is in action)?

ContentLicense: CC BY-SA 4.0

Body:
The following code gives me a warning "null pointer dereference" despite checking the pointer value before casting:

struct ID { virtual ~ID() = default; };
struct IF { virtual void g() = 0; };
struct F : IF { void g() {} };
struct D : ID, F { };

int main() {
    D* d;
    if (d) static_cast<IF*>(d)->g();
}

Is it based on using uninitialized pointer value with -O2 optimization mode or static_cast really can result in null pointer value for non-null argument (e.g. when multiple inheritance is in action)?


问:
Producer/Consumer "produce" and "consume" function are not working
For the Producer/Consumer use semaphore in c language

Ask from user whether producer should run or consumer. Producer/consumer shouldn't call each other in your code. The call should be made explicitly from user only.

If producer is called to execute , the buffer should fill one slot. For consumer it should consume one slot.

Your code should make usage of bounded buffer. The capacity of buffer will be decided by user after execution of code.

For every producer/consumer call, the system should generate output how many filled slots are available and how many free slots are available in your buffer array.

Producer should be notified that it can't make more products if the array is full and consumer should be notified if there is no available slot to be consumed.

My produce and consume function are not working it just stucks after entering 'P' or 'C'

`

```<code>#include <stdio.h>
#include <semaphore.h>

#define MAX_BUFFER_SIZE 100

int buffer[MAX_BUFFER_SIZE];
int capacity;
int count = 0;

sem_t full;
sem_t empty;
sem_t mutex;

void produce() {
    sem_wait(&empty);
    sem_wait(&mutex);
    buffer[count] = 1;
    count++;
    printf("Produced 1 item, %d slots available\n", capacity - count);
    sem_post(&mutex);
    sem_post(&full);
}

void consume() {
    sem_wait(&full);
    sem_wait(&mutex);
    count--;
    printf("Consumed 1 item, %d slots available\n", capacity - count);
    sem_post(&mutex);
    sem_post(&empty);
}

int main() {
    sem_init(&full, 0, 0);
    sem_init(&empty, 0, capacity);
    sem_init(&mutex, 0, 1);

    printf("Enter capacity of buffer: ");
    scanf("%d", &capacity);

    char choice;
    while (1) {
        printf("Enter P to produce or C to consume: ");
        scanf(" %c", &choice);

        if (choice == 'P') {
            produce();
        } else if (choice == 'C') {
            consume();
        } else {
            break;
        }
    }

    sem_destroy(&full);
    sem_destroy(&empty);
    sem_destroy(&mutex);
    return 0;
}

</code>```

`

I tried to enter 'p' or 'C' it just does nothing
Terminal Output it just stuck

Body:
For the Producer/Consumer use semaphore in c language

Ask from user whether producer should run or consumer. Producer/consumer shouldn't call each other in your code. The call should be made explicitly from user only.

If producer is called to execute , the buffer should fill one slot. For consumer it should consume one slot.

Your code should make usage of bounded buffer. The capacity of buffer will be decided by user after execution of code.

For every producer/consumer call, the system should generate output how many filled slots are available and how many free slots are available in your buffer array.

Producer should be notified that it can't make more products if the array is full and consumer should be notified if there is no available slot to be consumed.

My produce and consume function are not working it just stucks after entering 'P' or 'C'

`

#include <stdio.h>
#include <semaphore.h>

#define MAX_BUFFER_SIZE 100

int buffer[MAX_BUFFER_SIZE];
int capacity;
int count = 0;

sem_t full;
sem_t empty;
sem_t mutex;

void produce() {
    sem_wait(&empty);
    sem_wait(&mutex);
    buffer[count] = 1;
    count++;
    printf("Produced 1 item, %d slots available\n", capacity - count);
    sem_post(&mutex);
    sem_post(&full);
}

void consume() {
    sem_wait(&full);
    sem_wait(&mutex);
    count--;
    printf("Consumed 1 item, %d slots available\n", capacity - count);
    sem_post(&mutex);
    sem_post(&empty);
}

int main() {
    sem_init(&full, 0, 0);
    sem_init(&empty, 0, capacity);
    sem_init(&mutex, 0, 1);

    printf("Enter capacity of buffer: ");
    scanf("%d", &capacity);

    char choice;
    while (1) {
        printf("Enter P to produce or C to consume: ");
        scanf(" %c", &choice);

        if (choice == 'P') {
            produce();
        } else if (choice == 'C') {
            consume();
        } else {
            break;
        }
    }

    sem_destroy(&full);
    sem_destroy(&empty);
    sem_destroy(&mutex);
    return 0;
}

`

I tried to enter 'p' or 'C' it just does nothing
Terminal Output it just stuck


问:
ch.qos.logback.classic.servlet.LogbackServletContainerInitializer
I have been trying to deploy my spring boot WAR file into a separated tomcat local server.
Unfortunately while its working in embedded tomcat in independent tomcat I confront with

has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 (unable to load class [ch.qos.logback.classic.servlet.LogbackServletContainerInitializer]) error

whole of my dependency:

```<code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>3.0.1</version>
      <relativePath/> <!-- lookup parent from repository -->
   </parent>
   <groupId>com.inteligent</groupId>
   <artifactId>demo</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>war</packaging>
   <name>demo</name>
   <description>Demo project for Spring Boot</description>
   <properties>
      <maven.compiler.source>17</maven.compiler.source>
      <maven.compiler.target>17</maven.compiler.target>
   </properties>
   <dependencies>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter</artifactId>
         <version>3.0.0</version>
      </dependency>

      <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-logging -->
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-logging</artifactId>
         <version>3.0.0</version>
      </dependency>

      <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <scope>runtime</scope>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
         <version>3.0.0</version>
      </dependency>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-data-jpa</artifactId>
         <version>3.0.0</version>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-log4j2</artifactId>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-tomcat</artifactId>
         <scope>provided</scope>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-integration</artifactId>
         <version>3.0.0</version>
      </dependency>
      <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>jstl</artifactId>
         <version>1.2</version>
      </dependency>

      <!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api -->
      <dependency>
         <groupId>javax.persistence</groupId>
         <artifactId>javax.persistence-api</artifactId>
         <version>2.2</version>
      </dependency>

      <dependency>
         <groupId>org.springframework.integration</groupId>
         <artifactId>spring-integration-ip</artifactId>
         <version>6.0.0</version>
      </dependency>

      <!-- https://mvnrepository.com/artifact/org.hibernate.validator/hibernate-validator -->
      <dependency>
         <groupId>org.hibernate.validator</groupId>
         <artifactId>hibernate-validator</artifactId>
         <version>8.0.0.Final</version>
      </dependency>

   </dependencies>

   <build>
      <plugins>

         <!-- Configure the Tomcat Maven plugin -->
         <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0</version>
            <configuration>
               <url>http://localhost:8088/manager/text</url>
               <path>/rps</path>
            </configuration>
         </plugin>

         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
         </plugin>

         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
               <source>19</source>
               <target>19</target>
            </configuration>
         </plugin>
      </plugins>
   </build>

</project>
</code>```

also I changed project structure in InteliJ Idea as below

Project settings

SDK settings

Modules settings(https://i.stack.imgur.com/XDF2j.png)

but nothing has been changed

Body:
I have been trying to deploy my spring boot WAR file into a separated tomcat local server.
Unfortunately while its working in embedded tomcat in independent tomcat I confront with

has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 (unable to load class [ch.qos.logback.classic.servlet.LogbackServletContainerInitializer]) error

whole of my dependency:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>3.0.1</version>
      <relativePath/>
   </parent>
   <groupId>com.inteligent</groupId>
   <artifactId>demo</artifactId>
   <version>0.0.1-SNAPSHOT</version>
   <packaging>war</packaging>
   <name>demo</name>
   <description>Demo project for Spring Boot</description>
   <properties>
      <maven.compiler.source>17</maven.compiler.source>
      <maven.compiler.target>17</maven.compiler.target>
   </properties>
   <dependencies>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter</artifactId>
         <version>3.0.0</version>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-logging</artifactId>
         <version>3.0.0</version>
      </dependency>

      <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <scope>runtime</scope>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
         <version>3.0.0</version>
      </dependency>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-data-jpa</artifactId>
         <version>3.0.0</version>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-log4j2</artifactId>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-tomcat</artifactId>
         <scope>provided</scope>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-integration</artifactId>
         <version>3.0.0</version>
      </dependency>
      <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>jstl</artifactId>
         <version>1.2</version>
      </dependency>

      <dependency>
         <groupId>javax.persistence</groupId>
         <artifactId>javax.persistence-api</artifactId>
         <version>2.2</version>
      </dependency>

      <dependency>
         <groupId>org.springframework.integration</groupId>
         <artifactId>spring-integration-ip</artifactId>
         <version>6.0.0</version>
      </dependency>

      <dependency>
         <groupId>org.hibernate.validator</groupId>
         <artifactId>hibernate-validator</artifactId>
         <version>8.0.0.Final</version>
      </dependency>

   </dependencies>

   <build>
      <plugins>

         <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0</version>
            <configuration>
               <url>http://localhost:8088/manager/text</url>
               <path>/rps</path>
            </configuration>
         </plugin>

         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
         </plugin>

         <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
               <source>19</source>
               <target>19</target>
            </configuration>
         </plugin>
      </plugins>
   </build>

</project>

also I changed project structure in InteliJ Idea as below

Project settings

SDK settings

Modules settings(https://i.stack.imgur.com/XDF2j.png)

but nothing has been changed


问:
Problem with getting multiple values from mySQL Join
I am having an issue recalling multiple values from the same Join.

Work Order

woID
truckID
trailerID

1
1
10

2
4
12

Assets

assetID
logo_no
type

1
100
Truck

4
250
Truck

10
420
Trailer

12
105
Trailer

```<code>SELECT workorder.woID AS `Workorder ID`
       assets.logo_no AS 'Logo Number`
FROM workorder
JOIN assets ON assets.id = workorder.truckID
</code>```

Now I can not add workorder.trailerID as it gives an error:

Error Code: 1066. Not unique table/alias: 'assets'

Also, how can I call the trailer in the field selection list.

The only workaround I found was to create a view joining once the Truck with the Workorder and once with the Trailer. I then joined the table with the 2 views.

But due to the number of tables and joins I am dealing with, I dont prefer this approach as I will end up creating a ridiculous amount of views. I also want to avoid using GROUP_CONCAT.

Body:
I am having an issue recalling multiple values from the same Join.

Work Order

woID
truckID
trailerID

1
1
10

2
4
12

Assets

assetID
logo_no
type

1
100
Truck

4
250
Truck

10
420
Trailer

12
105
Trailer

SELECT workorder.woID AS `Workorder ID`
       assets.logo_no AS 'Logo Number`
FROM workorder
JOIN assets ON assets.id = workorder.truckID

Now I can not add workorder.trailerID as it gives an error:

Error Code: 1066. Not unique table/alias: 'assets'

Also, how can I call the trailer in the field selection list.

The only workaround I found was to create a view joining once the Truck with the Workorder and once with the Trailer. I then joined the table with the 2 views.

But due to the number of tables and joins I am dealing with, I dont prefer this approach as I will end up creating a ridiculous amount of views. I also want to avoid using GROUP_CONCAT.


Body:
x_train.shape

.................output..............
(172, 1177, 1)

x_test.shape

.................output..............
(30, 1177, 1)

 y_train.shape

..................Output................
(172,)

y_test.shape

..................Output................
(30,)

model=Sequential()
model.add(Convolution1D(32,2,data_format='channels_last',activation='relu', input_shape=(1177, 1)))
model.add(MaxPooling1D())
model.add(Flatten())
model.add(Dense(100))
model.add(Dropout(0.5))
model.add(Dense(10))
model.add(Activation('relu'))
model.compile(loss='categorical_crossentropy', optimizer='adadelta',metrics=['accuracy'])
model.summary()

.....................output.............................

Model: "sequential"
_________________________________________________________________
 Layer (type)                Output Shape              Param #
=================================================================
 conv1d (Conv1D)             (None, 1176, 32)          96

 max_pooling1d (MaxPooling1D  (None, 588, 32)          0
 )

 flatten (Flatten)           (None, 18816)             0

 dense (Dense)               (None, 100)               1881700

 dropout (Dropout)           (None, 100)               0

 dense_1 (Dense)             (None, 10)                1010

 activation (Activation)     (None, 10)                0

=================================================================
Total params: 1,882,806
Trainable params: 1,882,806
Non-trainable params: 0
_________________________________________________________________

model.fit(x_train,y_train,validation_data=(x_test,y_test))

..................................Error Message...................................

    ValueError: Shapes (None, 1) and (None, 10) are incompatible

I am applying CNN Model on textual data; Model is built successfully but at the time of model fitting error message got. I applied many solutions to solve this problem, but none work.


问:
drf-yasg Swagger documentation does not recognize authorized users
I've set up DRF-YASG documentation for my Django project, but the endpoints that require authentication show no parameters (fields to fill) even when logged as an authorized user.

swagger ui

In fact, none of my endpoints show their respective parameter fields in the UI.

Here are my REST_FRAMEWORK settings in settings.py :

```<code>REST_FRAMEWORK = {
    "NON_FIELD_ERRORS_KEY": "errors",
    "DEFAULT_AUTHENTICATION_CLASSES":(
        "rest_framework.authentication.SessionAuthentication",
        "rest_framework.authentication.TokenAuthentication"
    ),
    "DEFAULT_PERMISSON_CLASSES":(
        "rest_framework.permissions.IsAuthenticated"
    )
}
</code>```

and urls.py:

```<code>from django.contrib import admin
from django.urls import path, include, re_path
from EmployeeApp import views

from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi

schema_view = get_schema_view(
    openapi.Info(
        title="Snippets API",
        default_version='v1',
        description="Test description",
        terms_of_service="https://www.google.com/policies/terms/",
        contact=openapi.Contact(email="contact@snippets.local"),
        license=openapi.License(name="BSD License"),
    ),
    public=True,
    permission_classes=[permissions.AllowAny],
)

urlpatterns = [
    re_path(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0),
            name='schema-json'),
    path('', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
    re_path(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
    path('admin/', admin.site.urls),
    path('', views.api_home),
    path('api/', include('EmployeeApp.urls')),
    path('api/auth/', include('accounts.urls')),
]
</code>```

I am using standard token authentication and here are my views.

```<code>from django.contrib.auth import authenticate
from .serializers import SignUpSerializer, UserSerializer
from rest_framework import generics, status
from rest_framework.response import Response
from rest_framework.request import Request
from rest_framework.views import APIView
from drf_yasg.utils import swagger_auto_schema

class SignUpView(generics.GenericAPIView):
    serializer_class = SignUpSerializer

    def post(self, request: Request):
        data = request.data

        serializer = self.serializer_class(data=data)

        if serializer.is_valid():
            serializer.save()

            response = {
                "message": "User Created Successfully",
                "data": serializer.data
            }

            return Response(data=response, status=status.HTTP_201_CREATED)

        return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)

class LoginView(APIView):

    @swagger_auto_schema(request_body=UserSerializer)
    def post(self, request: Request):
        email = request.data.get('email')
        password = request.data.get('password')

        user = authenticate(email=email, password=password)

        if user:
            response = {
                "message": "Login Successful",
                "token": user.auth_token.key
            }
            return Response(data=response, status=status.HTTP_200_OK)
        else:
            return Response(data={"message": "Invalid username or password"},
                            status=status.HTTP_401_UNAUTHORIZED)

    def get(self, request: Request):
        content = {
            "user": str(request.user),
            "auth": str(request.auth)
        }

        return Response(data=content, status=status.HTTP_200_OK)
</code>```

In Postman everything works as expected, but in the Swagger documentation the authenticated user is not being recognized and the parameter fields on endpoints are missing.

Not sure if these two issues are connected, but I would apprechiate any type of helpful input on this!

I have tested the endpoints with direct Postman requests and everything works as expected.

Here is the endpoint to Create(POST) a company as a logged User:

```<code>class CompanyCreate(APIView):

    permission_classes = [IsAuthenticated]

    @swagger_auto_schema(
        operation_summary="Create a company",
        operation_description="This allows logged-in user to create a company"
    )
    def post(self, request):
        company_name_exists = Companies.objects.filter(company_name=request.data['company_name']).exists()
        if company_name_exists:
            raise ValidationError("Company with the same name already exists")

        data = {**request.data, 'user_id': request.auth.user_id}

        serializer = CompanySerializer(data=data)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        else:
            return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
</code>```

and it's serializer:

```<code>class CompanySerializer(serializers.ModelSerializer):
    user_id = serializers.IntegerField(write_only=True)

    class Meta:
        model = Companies
        fields = ('user_id', 'company_name', 'company_description', 'company_logo')

    def create(self, validated_data):
        company, is_created = Companies.objects.get_or_create(
                                        company_name=validated_data['company_name'],
                                        company_description=validated_data['company_description'],
                                        company_logo=validated_data['company_logo'],
                                        user_id=validated_data['user_id'],
                                        )
        return company
</code>```

I've attached `

```<code>@swagger_auto_schema(request_body=UserSerializer)
</code>```

`
to my login endpoint and it gives me a filed to put the request body data in a JSON format.

enter image description here

that works, but it still does not show the Swagger UI parameter fields and the auth does not persist when I try to test endpoints that require it.

Body:
I've set up DRF-YASG documentation for my Django project, but the endpoints that require authentication show no parameters (fields to fill) even when logged as an authorized user.

swagger ui

In fact, none of my endpoints show their respective parameter fields in the UI.

Here are my REST_FRAMEWORK settings in settings.py :

REST_FRAMEWORK = {
    "NON_FIELD_ERRORS_KEY": "errors",
    "DEFAULT_AUTHENTICATION_CLASSES":(
        "rest_framework.authentication.SessionAuthentication",
        "rest_framework.authentication.TokenAuthentication"
    ),
    "DEFAULT_PERMISSON_CLASSES":(
        "rest_framework.permissions.IsAuthenticated"
    )
}

and urls.py:

from django.contrib import admin
from django.urls import path, include, re_path
from EmployeeApp import views

from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi

schema_view = get_schema_view(
    openapi.Info(
        title="Snippets API",
        default_version='v1',
        description="Test description",
        terms_of_service="https://www.google.com/policies/terms/",
        contact=openapi.Contact(email="contact@snippets.local"),
        license=openapi.License(name="BSD License"),
    ),
    public=True,
    permission_classes=[permissions.AllowAny],
)

urlpatterns = [
    re_path(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0),
            name='schema-json'),
    path('', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
    re_path(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
    path('admin/', admin.site.urls),
    path('', views.api_home),
    path('api/', include('EmployeeApp.urls')),
    path('api/auth/', include('accounts.urls')),
]

I am using standard token authentication and here are my views.

from django.contrib.auth import authenticate
from .serializers import SignUpSerializer, UserSerializer
from rest_framework import generics, status
from rest_framework.response import Response
from rest_framework.request import Request
from rest_framework.views import APIView
from drf_yasg.utils import swagger_auto_schema

class SignUpView(generics.GenericAPIView):
    serializer_class = SignUpSerializer

    def post(self, request: Request):
        data = request.data

        serializer = self.serializer_class(data=data)

        if serializer.is_valid():
            serializer.save()

            response = {
                "message": "User Created Successfully",
                "data": serializer.data
            }

            return Response(data=response, status=status.HTTP_201_CREATED)

        return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)

class LoginView(APIView):

    @swagger_auto_schema(request_body=UserSerializer)
    def post(self, request: Request):
        email = request.data.get('email')
        password = request.data.get('password')

        user = authenticate(email=email, password=password)

        if user:
            response = {
                "message": "Login Successful",
                "token": user.auth_token.key
            }
            return Response(data=response, status=status.HTTP_200_OK)
        else:
            return Response(data={"message": "Invalid username or password"},
                            status=status.HTTP_401_UNAUTHORIZED)

    def get(self, request: Request):
        content = {
            "user": str(request.user),
            "auth": str(request.auth)
        }

        return Response(data=content, status=status.HTTP_200_OK)

In Postman everything works as expected, but in the Swagger documentation the authenticated user is not being recognized and the parameter fields on endpoints are missing.

Not sure if these two issues are connected, but I would apprechiate any type of helpful input on this!

I have tested the endpoints with direct Postman requests and everything works as expected.

Here is the endpoint to Create(POST) a company as a logged User:

class CompanyCreate(APIView):

    permission_classes = [IsAuthenticated]

    @swagger_auto_schema(
        operation_summary="Create a company",
        operation_description="This allows logged-in user to create a company"
    )
    def post(self, request):
        company_name_exists = Companies.objects.filter(company_name=request.data['company_name']).exists()
        if company_name_exists:
            raise ValidationError("Company with the same name already exists")

        data = {**request.data, 'user_id': request.auth.user_id}

        serializer = CompanySerializer(data=data)
        if serializer.is_valid():
            serializer.save()
            return Response(serializer.data, status=status.HTTP_201_CREATED)
        else:
            return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)

and it's serializer:

class CompanySerializer(serializers.ModelSerializer):
    user_id = serializers.IntegerField(write_only=True)

    class Meta:
        model = Companies
        fields = ('user_id', 'company_name', 'company_description', 'company_logo')

    def create(self, validated_data):
        company, is_created = Companies.objects.get_or_create(
                                        company_name=validated_data['company_name'],
                                        company_description=validated_data['company_description'],
                                        company_logo=validated_data['company_logo'],
                                        user_id=validated_data['user_id'],
                                        )
        return company

I've attached `

@swagger_auto_schema(request_body=UserSerializer)

`
to my login endpoint and it gives me a filed to put the request body data in a JSON format.

enter image description here

that works, but it still does not show the Swagger UI parameter fields and the auth does not persist when I try to test endpoints that require it.


问:
Can I remove a set of ManyToMany objects using SafeDeleteModel?
Soft_delete_cascade was applied to the entire model using the django-safedelete library.

However, if you remove the corresponding many to many object as in the code below, it is not deleted from the set of objects.

What should I do?

# models.py
from django.db import models
from safedelete import SOFT_DELETE_CASCADE, HARD_DELETE
from safedelete.models import SafeDeleteModel

class Post(SafeDeleteModel):
    _safedelete_policy: int = SOFT_DELETE_CASCADE

    category = models.CharField("카테고리", max_length=100, null=True, blank=True)
    title = models.CharField("제목", max_length=300, null=True, blank=True)

    created_at = models.DateTimeField("생성일시", auto_now_add=True)
    updated_at = models.DateTimeField("수정시간", auto_now=True)

    tags = models.ManyToManyField("Tag", through="TagPostAssociation", related_name="posts")

    def __str__(self):
        return f"글(ID:{self.id}/제목:{self.title})"

class Tag(SafeDeleteModel):
    _safedelete_policy: int = SOFT_DELETE_CASCADE

    value = models.CharField("태그 값", max_length=100)
    created_at = models.DateTimeField("생성일시", auto_now_add=True)
    updated_at = models.DateTimeField("수정시간", auto_now=True)

    class Meta:
        verbose_name = verbose_name_plural = "태그"

    def __str__(self):
        return f"태그(ID:{self.id}/값:{self.value})"

class TagPostAssociation(SafeDeleteModel):
    _safedelete_policy: int = HARD_DELETE

    tag = models.ForeignKey(to=Tag, verbose_name="태그", on_delete=models.CASCADE)
    post = models.ForeignKey(to=Post, verbose_name="글", on_delete=models.CASCADE)
    created_at = models.DateTimeField("생성일시", auto_now_add=True)
    updated_at = models.DateTimeField("수정시간", auto_now=True)

    class Meta:
        verbose_name = verbose_name_plural = "글-태그"

    def __str__(self):
        return f"글{self.post.id})-태그({self.tag.id})"

```
<pre class="lang-bash prettyprint-override"><code>>>> post = Post.objects.get(id=2)
>>> tag = Tag.objects.get(id=2)
>>> post.tags.all()
<SafeDeleteQueryset [<Tag: 태그(ID:2/값:hair)>, <Tag: 태그(ID:1/값:test)>]>
>>> post.tags.remove(tag)
>>> post.tags.all()
<SafeDeleteQueryset [<Tag: 태그(ID:2/값:hair)>, <Tag: 태그(ID:1/값:test)>]>
</code>```

I tried to delete the many to many object using the m2m_changed signal, but it didn't work.

Body:
Soft_delete_cascade was applied to the entire model using the django-safedelete library.

However, if you remove the corresponding many to many object as in the code below, it is not deleted from the set of objects.

What should I do?

# models.py
from django.db import models
from safedelete import SOFT_DELETE_CASCADE, HARD_DELETE
from safedelete.models import SafeDeleteModel

class Post(SafeDeleteModel):
    _safedelete_policy: int = SOFT_DELETE_CASCADE

    category = models.CharField("카테고리", max_length=100, null=True, blank=True)
    title = models.CharField("제목", max_length=300, null=True, blank=True)

    created_at = models.DateTimeField("생성일시", auto_now_add=True)
    updated_at = models.DateTimeField("수정시간", auto_now=True)

    tags = models.ManyToManyField("Tag", through="TagPostAssociation", related_name="posts")

    def __str__(self):
        return f"글(ID:{self.id}/제목:{self.title})"

class Tag(SafeDeleteModel):
    _safedelete_policy: int = SOFT_DELETE_CASCADE

    value = models.CharField("태그 값", max_length=100)
    created_at = models.DateTimeField("생성일시", auto_now_add=True)
    updated_at = models.DateTimeField("수정시간", auto_now=True)

    class Meta:
        verbose_name = verbose_name_plural = "태그"

    def __str__(self):
        return f"태그(ID:{self.id}/값:{self.value})"

class TagPostAssociation(SafeDeleteModel):
    _safedelete_policy: int = HARD_DELETE

    tag = models.ForeignKey(to=Tag, verbose_name="태그", on_delete=models.CASCADE)
    post = models.ForeignKey(to=Post, verbose_name="글", on_delete=models.CASCADE)
    created_at = models.DateTimeField("생성일시", auto_now_add=True)
    updated_at = models.DateTimeField("수정시간", auto_now=True)

    class Meta:
        verbose_name = verbose_name_plural = "글-태그"

    def __str__(self):
        return f"글{self.post.id})-태그({self.tag.id})"

>>> post = Post.objects.get(id=2)
>>> tag = Tag.objects.get(id=2)
>>> post.tags.all()
<SafeDeleteQueryset [<Tag: 태그(ID:2/값:hair)>, <Tag: 태그(ID:1/값:test)>]>
>>> post.tags.remove(tag)
>>> post.tags.all()
<SafeDeleteQueryset [<Tag: 태그(ID:2/값:hair)>, <Tag: 태그(ID:1/값:test)>]>

I tried to delete the many to many object using the m2m_changed signal, but it didn't work.


问:
Radiobutton values are not passing to Controller
In my View I am using following radio buttons

```<code>   <div class="row">
        <div class="col-md-4">
            <input name="type" asp-for="loremType" value="1"  type="radio" /><label for="rdbLetters">Letters</label>
        </div>
        <div class="col-md-4">
            <input name="type" asp-for="loremType" value="2" type="radio" /><label for="rdbWords">Words</label>
        </div>
        <div class="col-md-4">
            <input name="type" asp-for="loremType" value="3" checked="checked" type="radio" /><label for="rdbParagraphs">Paragraphs</label>
        </div>
    </div>
</code>```

loremType is the parameter from the Model Class. Even though the value set as 1,2,3 these values are not passed to the controller.

Am I doing something wrong?

Body:
In my View I am using following radio buttons

            <input name="type" asp-for="loremType" value="1"  type="radio" />Letters

            <input name="type" asp-for="loremType" value="2" type="radio" />Words

            <input name="type" asp-for="loremType" value="3" checked="checked" type="radio" />Paragraphs

loremType is the parameter from the Model Class. Even though the value set as 1,2,3 these values are not passed to the controller.

Am I doing something wrong?


问:
Execution time in NetBeans appears as a sequence of question marks

I want to get the time of my application runs in NetBeans, but it appears as a sequence of question marks. Does anyone know how to solve this?


问:
Why is my first int value in C always 0 although I assign another value than 0?
I build a simple Calculator in C where I Put at first my first value number1, then the operation (+, -, *, /) and then the second value number2.

always when i put in the value of number1 via scanf i can see in the output console, that only my first value number1 gets the value 0.

Can you say me why this happens?

`

```<code>#include <stdio.h>
#include <stdlib.h>

int main(){
    int number1;
    int number2;
    char operation;
    int userResult;

    printf("Please enter the first number: ");
    scanf("%d", &number1);

    printf("\nPlease enter the operation: ");
    scanf("%s", &operation);

    printf("\nPlease enter the second number: ");
    scanf("%d", &number2);

    printf("\nPlease give me your guessed result: ");
    scanf("%d", &userResult);

    printf("---------------------------------------------------------------");

    switch (operation)
    {
    case '+':

        printf("\nyou are right:  %d + %d = %d", number1, number2, (number1+number2));
        break;

    case '-':

        printf("\nyou are right:  %d - %d = %d", number1, number2, (number1-number2));
        break;

    case '*':

        printf("\nyou are right:  %d * %d = %d", number1, number2, (number1*number2));
        break;

    case '/':

        printf("\nyou are right:  %d / %d = %d", number1, number2, (number1/number2));
        break;

    default:
        break;
    }
    return 0;
}
</code>```

`

`Please enter the first number: 32

Please enter the operation: +

Please enter the second number: 66

Please give me your guessed result: 9

you are right:  0 + 66 = 66

`

Here in the output you can see, that my number1 value is 32. but in the last line it gets the value 0.

Body:
I build a simple Calculator in C where I Put at first my first value number1, then the operation (+, -, *, /) and then the second value number2.

always when i put in the value of number1 via scanf i can see in the output console, that only my first value number1 gets the value 0.

Can you say me why this happens?

`

#include <stdio.h>
#include <stdlib.h>

int main(){
    int number1;
    int number2;
    char operation;
    int userResult;

    printf("Please enter the first number: ");
    scanf("%d", &number1);

    printf("\nPlease enter the operation: ");
    scanf("%s", &operation);

    printf("\nPlease enter the second number: ");
    scanf("%d", &number2);

    printf("\nPlease give me your guessed result: ");
    scanf("%d", &userResult);

    printf("---------------------------------------------------------------");

    switch (operation)
    {
    case '+':

        printf("\nyou are right:  %d + %d = %d", number1, number2, (number1+number2));
        break;

    case '-':

        printf("\nyou are right:  %d - %d = %d", number1, number2, (number1-number2));
        break;

    case '*':

        printf("\nyou are right:  %d * %d = %d", number1, number2, (number1*number2));
        break;

    case '/':

        printf("\nyou are right:  %d / %d = %d", number1, number2, (number1/number2));
        break;

    default:
        break;
    }
    return 0;
}

`

`Please enter the first number: 32

Please enter the operation: +

Please enter the second number: 66

Please give me your guessed result: 9

you are right:  0 + 66 = 66

`

Here in the output you can see, that my number1 value is 32. but in the last line it gets the value 0.


问:
Adding header controls in GoldenLayout to only 1 component, breaks layout drag and drop capabilities
I have read through the documentation which provides an example on how to add the same custom control header to all components of a layout see: https://golden-layout.com/tutorials/adding-controls-to-header.html. I would like to add a custom control in the header to 1 specific component only. I have managed to successfully add it to a single component by targeting the component using "id" argument of the component object, but when I drag and drop tabs in my layout, this seems to have broken the dragabilty, and repositioning of the layout. My code is as follows:

myLayout = new GoldenLayout({
    content:[{
        type: 'row',
        content:[{
            type: 'component',
            componentName: 'testComponent',
            title:'First',
            componentState: { color: '#1D84BD' },
            id:"firstTarget",
        }
    ,{
            type: 'component',
            componentName: 'testComponent',
            title:'Second',
            componentState: { color: '#F15C25' },
            id:"secondTarget",
        }]
    }]
});

myLayout.registerComponent( 'testComponent', function( container, state ){
    container.getElement().css('background-color', state.color);
});

myLayout.on( 'stackCreated', function( stack ){

    var colorDropdown = $( $( 'template' ).html() ),
        colorDropdownBtn = colorDropdown.find( '.selectedColor' );

    var setColor = function( color ){
        var container = stack.getActiveContentItem().container;

        colorDropdownBtn.css( 'background-color', color );
        container.getElement().css( 'background-color', color );

        container.extendState({ color: color });
    };

    // Check if the current componenent in the loop is "firstTarget"
    if (stack.config.content[0].id === "firstTarget"){
      // Add Drop Down only to "firstTarget" Header
     myLayout.root.contentItems[ 0 ].contentItems[ 0 ].header.controlsContainer.prepend( colorDropdown )
    }

    stack.on( 'activeContentItemChanged', function( contentItem ){
         setColor( contentItem.container.getState().color );
    });

    colorDropdown.find( 'li' ).click(function(){
        setColor( $(this).css( 'background-color' ) );
    });
});

myLayout.init();```
<pre class="snippet-code-css lang-css prettyprint-override"><code>.chooseColor{
    width: 10px;
    height: 10px;
    background: #fff;
    float: left;
    margin: 5px 5px 0 0;
    cursor: pointer;
}

.chooseColor .selectedColor{
    width: 10px;
    height: 10px;
}

.chooseColor ul{
    display: none;
  box-shadow: 2px 2px 3px rgba( 0, 0, 0, 0.7 );
}

.chooseColor:hover ul{
    display: block;
}

.chooseColor ul,
.chooseColor ul li{
    margin: 0;
    padding: 0;
    list-style-type: none;
}

.chooseColor ul li{
    width: 10px;
    height: 10px;
    cursor: pointer;
}

.chooseColor ul li:hover{
    border: 1px solid orange;
    width: 8px;
    height: 8px;
};</code>```

<link type="text/css" rel="stylesheet" href="//golden-layout.com/assets/css/goldenlayout-base.css" />
<link type="text/css" rel="stylesheet" href="//golden-layout.com/assets/css/goldenlayout-dark-theme.css" />

<template type="text/html">

</template>```

.

Body:
I have read through the documentation which provides an example on how to add the same custom control header to all components of a layout see: https://golden-layout.com/tutorials/adding-controls-to-header.html. I would like to add a custom control in the header to 1 specific component only. I have managed to successfully add it to a single component by targeting the component using "id" argument of the component object, but when I drag and drop tabs in my layout, this seems to have broken the dragabilty, and repositioning of the layout. My code is as follows:

myLayout = new GoldenLayout({
    content:[{
        type: 'row',
        content:[{
            type: 'component',
            componentName: 'testComponent',
            title:'First',
            componentState: { color: '#1D84BD' },
            id:"firstTarget",
        }
    ,{
            type: 'component',
            componentName: 'testComponent',
            title:'Second',
            componentState: { color: '#F15C25' },
            id:"secondTarget",
        }]
    }]
});

myLayout.registerComponent( 'testComponent', function( container, state ){
    container.getElement().css('background-color', state.color);
});

myLayout.on( 'stackCreated', function( stack ){

    var colorDropdown = $( $( 'template' ).html() ),
        colorDropdownBtn = colorDropdown.find( '.selectedColor' );

    var setColor = function( color ){
        var container = stack.getActiveContentItem().container;

        colorDropdownBtn.css( 'background-color', color );
        container.getElement().css( 'background-color', color );

        container.extendState({ color: color });
    };

    // Check if the current componenent in the loop is "firstTarget"
    if (stack.config.content[0].id === "firstTarget"){
      // Add Drop Down only to "firstTarget" Header
     myLayout.root.contentItems[ 0 ].contentItems[ 0 ].header.controlsContainer.prepend( colorDropdown )
    }

    stack.on( 'activeContentItemChanged', function( contentItem ){
         setColor( contentItem.container.getState().color );
    });

    colorDropdown.find( 'li' ).click(function(){
        setColor( $(this).css( 'background-color' ) );
    });
});

myLayout.init();

.chooseColor{
    width: 10px;
    height: 10px;
    background: #fff;
    float: left;
    margin: 5px 5px 0 0;
    cursor: pointer;
}

.chooseColor .selectedColor{
    width: 10px;
    height: 10px;
}

.chooseColor ul{
    display: none;
  box-shadow: 2px 2px 3px rgba( 0, 0, 0, 0.7 );
}

.chooseColor:hover ul{
    display: block;
}

.chooseColor ul,
.chooseColor ul li{
    margin: 0;
    padding: 0;
    list-style-type: none;
}

.chooseColor ul li{
    width: 10px;
    height: 10px;
    cursor: pointer;
}

.chooseColor ul li:hover{
    border: 1px solid orange;
    width: 8px;
    height: 8px;
};

<link type="text/css" rel="stylesheet" href="//golden-layout.com/assets/css/goldenlayout-base.css" />
<link type="text/css" rel="stylesheet" href="//golden-layout.com/assets/css/goldenlayout-dark-theme.css" />

<template type="text/html">

</template>

.


问:
Speed up image loading in TImage
How can I speed up image loading in TImage in Delphi 10.2?

I want to move a project from Delphi 7 to Delphi 10.2, but I'm having trouble loading files. In Delphi 10.2, images take much longer to load, and quality is lost.

In Delphi 7, it takes about 3 seconds. In Delphi 10.2, it takes 15 seconds.

From Delphi 7:

From Delphi 10.2:

This is how I load the file:

```<code>IMG.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + IMG.Hint);
</code>```

I tried to connect GDIPAPI, GDIPOBJ, GDIPUTIL, but it did not work.

I finally tried to make a program snippet to demonstrate my problem:
https://github.com/MrDimain/TestPicsSpeed.git

Title: Speed up image loading in TImage

Body:
How can I speed up image loading in TImage in Delphi 10.2?

I want to move a project from Delphi 7 to Delphi 10.2, but I'm having trouble loading files. In Delphi 10.2, images take much longer to load, and quality is lost.

In Delphi 7, it takes about 3 seconds. In Delphi 10.2, it takes 15 seconds.

From Delphi 7:

From Delphi 10.2:

This is how I load the file:

IMG.Picture.LoadFromFile(ExtractFilePath(ParamStr(0)) + IMG.Hint);

I tried to connect GDIPAPI, GDIPOBJ, GDIPUTIL, but it did not work.

I finally tried to make a program snippet to demonstrate my problem:
https://github.com/MrDimain/TestPicsSpeed.git


问:
Store and restore exec's "execution state" / global namespace
I'm trying to run code snippets with pythons exec function and I want to be able to rerun (single) snippets so that they start their execution from the "execution state" the previous snippet (it's "parent") stored.

Probably easier to explain as code:

class Snippet:
    def __init__(self, source, parent):
        self.source = source
        self.parent = parent
        self.namespace = None

    def execute(self):
        self.namespace = cloneNamespace(self.parent)
        executeInNamespace(self.source, self.namespace)

snip1 = Snippet('a = 1', None)
snip2 = Snippet('print(a)', snip1)
snip3 = Snippet('a = 2', snip2)

snip1.execute() # a = 1
snip2.execute() # print(a) --> 1
snip3.execute() # a = 2

snip2.execute() # print(a) --> 1 (!)
```
<p>The second call to <code>snip2</code> should run again from the namespace / execution state after/of <code>snip1</code>. <code>parent.namespace</code> is still <code>snip1.namespace</code> so <code>a</code> is 1 and <code>snip2.execute</code> should print out 1.</p>
<p>The question is how should <code>cloneNamespace</code> and <code>executeInNamespace</code> look like.</p>
<p>The best solution I could come up with so far is:</p>
<pre class="lang-py prettyprint-override"><code>import dill
import types

def cloneNamespace(parent):
    if parent == None:
        return {}

    newNamespace = {}
    for k, v in parent.namespace.items():
        # function and classes as refs, because they store a __globals__ ref
        if isinstance(v, types.FunctionType) or isinstance(v, type):
            newNamespace[k] = v
        else:
            newNamespace[k] = dill.copy(v)

    return newNamespace

# global "wrapper namespace" so that __globals__ of funcs and classes don't get invalid
globalNamespace = {}

def executeInNamespace(source, namespace):
    globalNamespace.clear()
    globalNamespace.update(namespace)
    exec(source, globalNamespace)
    namespace.update(globalNamespace)
</code>```

That work's for basic stuff but fails for example with these snippets:

snip1 = Snippet('''class A:
                       def bla(self):
                           print(x)''', None)
snip2 = Snippet('aInst = A()', snip1)
snip3 = Snippet('x = 1', snip2)
snip4 = Snippet('aInst.bla()', snip3)
```

I also tried dill.[dump,load]_module but couldn't get it working in the exec environment.

I know there are gonna be issues with file descriptors and similar, but I'd like to handle them the straight forward way everything else is also handled (rerun from the previous state).

Any ideas?

Are there other options -- wihtout exec -- to achieve this?

Thx!

Body:
I'm trying to run code snippets with pythons exec function and I want to be able to rerun (single) snippets so that they start their execution from the "execution state" the previous snippet (it's "parent") stored.

Probably easier to explain as code:

class Snippet:
    def __init__(self, source, parent):
        self.source = source
        self.parent = parent
        self.namespace = None

    def execute(self):
        self.namespace = cloneNamespace(self.parent)
        executeInNamespace(self.source, self.namespace)

snip1 = Snippet('a = 1', None)
snip2 = Snippet('print(a)', snip1)
snip3 = Snippet('a = 2', snip2)

snip1.execute() # a = 1
snip2.execute() # print(a) --> 1
snip3.execute() # a = 2

snip2.execute() # print(a) --> 1 (!)

The second call to snip2 should run again from the namespace / execution state after/of snip1. parent.namespace is still snip1.namespace so a is 1 and snip2.execute should print out 1.

The question is how should cloneNamespace and executeInNamespace look like.

The best solution I could come up with so far is:

import dill
import types

def cloneNamespace(parent):
    if parent == None:
        return {}

    newNamespace = {}
    for k, v in parent.namespace.items():
        # function and classes as refs, because they store a __globals__ ref
        if isinstance(v, types.FunctionType) or isinstance(v, type):
            newNamespace[k] = v
        else:
            newNamespace[k] = dill.copy(v)

    return newNamespace

# global "wrapper namespace" so that __globals__ of funcs and classes don't get invalid
globalNamespace = {}

def executeInNamespace(source, namespace):
    globalNamespace.clear()
    globalNamespace.update(namespace)
    exec(source, globalNamespace)
    namespace.update(globalNamespace)

That work's for basic stuff but fails for example with these snippets:

snip1 = Snippet('''class A:
                       def bla(self):
                           print(x)''', None)
snip2 = Snippet('aInst = A()', snip1)
snip3 = Snippet('x = 1', snip2)
snip4 = Snippet('aInst.bla()', snip3)

I also tried dill.[dump,load]_module but couldn't get it working in the exec environment.

I know there are gonna be issues with file descriptors and similar, but I'd like to handle them the straight forward way everything else is also handled (rerun from the previous state).

Any ideas?

Are there other options -- wihtout exec -- to achieve this?

Thx!


问:
Is there any difference when using AVX2 on the stack and the heap?
In this example I'm adding two arrays using AVX2. If I declare the arrays on the stack, it all works as expected. However, when the memory is allocated on the heap it compiles, but throws a Segmentation Fault at runtime.

Compilation succeeds but throws the following warning:

```<code> AVX vector return without AVX enabled changes the ABI [-Wpsabi]
</code>```

I'm trying this on a i7-8550U with AVX2 support, and compiling with the flags: -march=native -mavx2.

Here is a minimal example using static memory:

```<code>#include <immintrin.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    __attribute__((aligned(32))) uint32_t buffer1[8];
    __attribute__((aligned(32))) uint32_t buffer2[8];
    __attribute__((aligned(32))) uint32_t buffer3[8];

    __m256i* buffer1_s = (__m256i*)buffer1;
    __m256i* buffer2_s = (__m256i*)buffer2;
    __m256i* buffer3_s = (__m256i*)buffer3;

    for (uint32_t i = 0; i < 8; ++i) {
        buffer1[i] = rand() % 64;
        buffer2[i] = rand() % 64;
    }

    *buffer3_s = _mm256_add_epi32(*buffer1_s, *buffer2_s);

    for (uint32_t i = 0; i < 8; ++i) {
        printf("%d ", buffer1[i]);
        printf("%d ", buffer2[i]);
        printf("%d ", buffer3[i]);
        printf("\n");
    }
}
</code>```

And here a broken one allocating dynamic memory:

```<code>#include <immintrin.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    __attribute__((aligned(32))) uint32_t* buffer1 = malloc(8 * sizeof(uint32_t));
    __attribute__((aligned(32))) uint32_t* buffer2 = malloc(8 * sizeof(uint32_t));
    __attribute__((aligned(32))) uint32_t* buffer3 = malloc(8 * sizeof(uint32_t));

    __m256i* buffer1_s = (__m256i*)buffer1;
    __m256i* buffer2_s = (__m256i*)buffer2;
    __m256i* buffer3_s = (__m256i*)buffer3;

    for (uint32_t i = 0; i < 8; ++i) {
        buffer1[i] = rand() % 64;
        buffer2[i] = rand() % 64;
    }

    *buffer3_s = _mm256_add_epi32(*buffer1_s, *buffer2_s);

    for (uint32_t i = 0; i < 8; ++i) {
        printf("%d ", buffer1[i]);
        printf("%d ", buffer2[i]);
        printf("%d ", buffer3[i]);
        printf("\n");
    }

    free(buffer1);
    free(buffer2);
    free(buffer3);
}
</code>```

They are both compiled with:

```<code>gcc -O0 -g -march=native -mavx2 -o test_avx2 test_avx2.c
</code>```

What is causing the segmentation fault?

What would be the correct way to use AVX2 on memory that's been malloc'd?

Solution:

Memory needs to be allocated with the correct alignment. The compiler attribute is not enough to force the compiler to do it.

```<code>__attribute__((aligned(32))) uint32_t* buffer1 = malloc(8 * sizeof(uint32_t));
</code>```

should instead be

```<code>uint32_t* buffer1 = aligned_alloc(32, 8 * sizeof(uint32_t));
</code>```

Body:
In this example I'm adding two arrays using AVX2. If I declare the arrays on the stack, it all works as expected. However, when the memory is allocated on the heap it compiles, but throws a Segmentation Fault at runtime.

Compilation succeeds but throws the following warning:

 AVX vector return without AVX enabled changes the ABI [-Wpsabi]

I'm trying this on a i7-8550U with AVX2 support, and compiling with the flags: -march=native -mavx2.

Here is a minimal example using static memory:

#include <immintrin.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    __attribute__((aligned(32))) uint32_t buffer1[8];
    __attribute__((aligned(32))) uint32_t buffer2[8];
    __attribute__((aligned(32))) uint32_t buffer3[8];

    __m256i* buffer1_s = (__m256i*)buffer1;
    __m256i* buffer2_s = (__m256i*)buffer2;
    __m256i* buffer3_s = (__m256i*)buffer3;

    for (uint32_t i = 0; i < 8; ++i) {
        buffer1[i] = rand() % 64;
        buffer2[i] = rand() % 64;
    }

    *buffer3_s = _mm256_add_epi32(*buffer1_s, *buffer2_s);

    for (uint32_t i = 0; i < 8; ++i) {
        printf("%d ", buffer1[i]);
        printf("%d ", buffer2[i]);
        printf("%d ", buffer3[i]);
        printf("\n");
    }
}

And here a broken one allocating dynamic memory:

#include <immintrin.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>

int main()
{
    __attribute__((aligned(32))) uint32_t* buffer1 = malloc(8 * sizeof(uint32_t));
    __attribute__((aligned(32))) uint32_t* buffer2 = malloc(8 * sizeof(uint32_t));
    __attribute__((aligned(32))) uint32_t* buffer3 = malloc(8 * sizeof(uint32_t));

    __m256i* buffer1_s = (__m256i*)buffer1;
    __m256i* buffer2_s = (__m256i*)buffer2;
    __m256i* buffer3_s = (__m256i*)buffer3;

    for (uint32_t i = 0; i < 8; ++i) {
        buffer1[i] = rand() % 64;
        buffer2[i] = rand() % 64;
    }

    *buffer3_s = _mm256_add_epi32(*buffer1_s, *buffer2_s);

    for (uint32_t i = 0; i < 8; ++i) {
        printf("%d ", buffer1[i]);
        printf("%d ", buffer2[i]);
        printf("%d ", buffer3[i]);
        printf("\n");
    }

    free(buffer1);
    free(buffer2);
    free(buffer3);
}

They are both compiled with:

gcc -O0 -g -march=native -mavx2 -o test_avx2 test_avx2.c

What is causing the segmentation fault?

What would be the correct way to use AVX2 on memory that's been malloc'd?

Solution:

Memory needs to be allocated with the correct alignment. The compiler attribute is not enough to force the compiler to do it.

__attribute__((aligned(32))) uint32_t* buffer1 = malloc(8 * sizeof(uint32_t));

should instead be

uint32_t* buffer1 = aligned_alloc(32, 8 * sizeof(uint32_t));


问:
Why am i receiving so many warnings about peer dependencies when using Yarn?
I have just started using Yarn for the first time in a bare react native project. I started adding all dependencies that I need one-by-one. When I ran this one yarn add geofirestore, it showed many warnings after adding it:

Now, every time I run a new command to add another dependencies I see the same warnings.
I am not sure what to do, or if I have to do something about it. It just seems like I shouldnt ignore.


问:
How to fix "android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class fragment"
I'm new to Android and I'm having an annoying problem that I don't know how to deal with. I am trying to create an application that uses two fragments. But when you open the application, it crumbles.
I've tried commenting out parts of code that I thought might be contributing to it but I believe that the problem has something to do with my xml, but I am not very familiar with them yet.

MainActivity.java

```<code>public class MainActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    private String ADBPATH;
    MyIO myIO = new MyIO();
    RunCmd runCmd = new RunCmd();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        androidx.appcompat.widget.Toolbar toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
        NavController navController = Navigation.findNavController(this, R.id.my_nav_host_fragment);
        NavigationUI.setupWithNavController(navigationView, navController);
        ADBPATH = this.getFilesDir().getAbsolutePath() + File.separator;
        firstStart();
        navigationView.getMenu().getItem(0).setChecked(true);

    }

    @Override
    protected void onDestroy() {
        if (!runCmd.runCMD("getprop service.adb.tcp.port").equals("-1")) {
            runCmd.runCMD("su -c setprop service.adb.tcp.port -1 && stop adbd && start adbd && "
                    + ADBPATH + "/arnold kill-server");
        }
        super.onDestroy();
    }

    public void firstStart() {
        SharedPreferences pref = getSharedPreferences("share", MODE_PRIVATE);
        boolean isFirstRun = pref.getBoolean("isFirstRun", true);
        SharedPreferences.Editor editor = getSharedPreferences("share", MODE_PRIVATE).edit();
        if (isFirstRun) {
            editor.putBoolean("isFirstRun", false);
            editor.apply();
            myIO.copy(MainActivity.this, "arnold");
            myIO.copy(MainActivity.this, "arnold.bin");
        }
    }

    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.installFragment2) {

        } else if (id == R.id.screenFragment2) {

        } else if (id == R.id.nav_manage) {

        }

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }
}
</code>```

activity_main.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <RelativeLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

        <fragment
            android:id="@+id/my_nav_host_fragment"
            android:name="androidx.navigation.fragment.NavHostFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/toolbar"
            app:defaultNavHost="true"
            app:navGraph="@navigation/nav" />

    </RelativeLayout>

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@android:color/white"
        android:fitsSystemWindows="false"
        android:isScrollContainer="true"
        android:saveEnabled="true"
        android:scrollY="1dp"
        android:scrollbars="none"
        app:elevation="2dp"
        app:insetForeground="@color/colorPrimaryDark"
        app:itemIconTint="@color/colorPrimaryDark"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

</androidx.drawerlayout.widget.DrawerLayout>

</code>```

Log

```<code>2022-12-25 16:03:38.873 9611-9611/com.buratinoapps.aweartool E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.buratinoapps.aweartool, PID: 9611
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.buratinoapps.aweartool/com.buratinoapps.aweartool.MainActivity}: android.view.InflateException: Binary XML file line #23 in com.buratinoapps.aweartool:layout/activity_main: Binary XML file line #23 in com.buratinoapps.aweartool:layout/activity_main: Error inflating class fragment
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3685)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3842)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2252)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7842)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
     Caused by: android.view.InflateException: Binary XML file line #23 in com.buratinoapps.aweartool:layout/activity_main: Binary XML file line #23 in com.buratinoapps.aweartool:layout/activity_main: Error inflating class fragment
     Caused by: android.view.InflateException: Binary XML file line #23 in com.buratinoapps.aweartool:layout/activity_main: Error inflating class fragment
     Caused by: java.lang.ClassCastException: com.buratinoapps.aweartool.InstallFragment cannot be cast to androidx.fragment.app.Fragment
        at androidx.fragment.app.Fragment.instantiate(Fragment.java:613)
        at androidx.navigation.fragment.FragmentNavigator.instantiateFragment(FragmentNavigator.java:184)
        at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:212)
        at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:58)
        at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:80)
        at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:30)
        at androidx.navigation.NavController.navigate(NavController.java:823)
        at androidx.navigation.NavController.onGraphCreated(NavController.java:521)
        at androidx.navigation.NavController.setGraph(NavController.java:482)
        at androidx.navigation.NavController.setGraph(NavController.java:447)
        at androidx.navigation.NavController.setGraph(NavController.java:429)
        at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:226)
        at androidx.fragment.app.Fragment.performCreate(Fragment.java:2949)
        at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:475)
        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:278)
        at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:140)
        at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
        at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:319)
        at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:298)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1073)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1001)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
2022-12-25 16:03:38.874 9611-9611/com.buratinoapps.aweartool E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:485)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:710)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
        at com.buratinoapps.aweartool.MainActivity.onCreate(MainActivity.java:31)
        at android.app.Activity.performCreate(Activity.java:8054)
        at android.app.Activity.performCreate(Activity.java:8034)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1341)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3666)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3842)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2252)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7842)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
2022-12-25 16:03:38.928 9611-9611/com.buratinoapps.aweartool I/Process: Sending signal. PID: 9611 SIG: 9

</code>```

Body:
I'm new to Android and I'm having an annoying problem that I don't know how to deal with. I am trying to create an application that uses two fragments. But when you open the application, it crumbles.
I've tried commenting out parts of code that I thought might be contributing to it but I believe that the problem has something to do with my xml, but I am not very familiar with them yet.

MainActivity.java

public class MainActivity extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {

    private String ADBPATH;
    MyIO myIO = new MyIO();
    RunCmd runCmd = new RunCmd();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        androidx.appcompat.widget.Toolbar toolbar = (androidx.appcompat.widget.Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();

        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
        NavController navController = Navigation.findNavController(this, R.id.my_nav_host_fragment);
        NavigationUI.setupWithNavController(navigationView, navController);
        ADBPATH = this.getFilesDir().getAbsolutePath() + File.separator;
        firstStart();
        navigationView.getMenu().getItem(0).setChecked(true);

    }

    @Override
    protected void onDestroy() {
        if (!runCmd.runCMD("getprop service.adb.tcp.port").equals("-1")) {
            runCmd.runCMD("su -c setprop service.adb.tcp.port -1 && stop adbd && start adbd && "
                    + ADBPATH + "/arnold kill-server");
        }
        super.onDestroy();
    }

    public void firstStart() {
        SharedPreferences pref = getSharedPreferences("share", MODE_PRIVATE);
        boolean isFirstRun = pref.getBoolean("isFirstRun", true);
        SharedPreferences.Editor editor = getSharedPreferences("share", MODE_PRIVATE).edit();
        if (isFirstRun) {
            editor.putBoolean("isFirstRun", false);
            editor.apply();
            myIO.copy(MainActivity.this, "arnold");
            myIO.copy(MainActivity.this, "arnold.bin");
        }
    }

    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        int id = item.getItemId();

        if (id == R.id.installFragment2) {

        } else if (id == R.id.screenFragment2) {

        } else if (id == R.id.nav_manage) {

        }

        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }
}

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <RelativeLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">

        <androidx.appcompat.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:popupTheme="@style/AppTheme.PopupOverlay" />

        <fragment
            android:id="@+id/my_nav_host_fragment"
            android:name="androidx.navigation.fragment.NavHostFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_below="@id/toolbar"
            app:defaultNavHost="true"
            app:navGraph="@navigation/nav" />

    </RelativeLayout>

    <com.google.android.material.navigation.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@android:color/white"
        android:fitsSystemWindows="false"
        android:isScrollContainer="true"
        android:saveEnabled="true"
        android:scrollY="1dp"
        android:scrollbars="none"
        app:elevation="2dp"
        app:insetForeground="@color/colorPrimaryDark"
        app:itemIconTint="@color/colorPrimaryDark"
        app:headerLayout="@layout/nav_header_main"
        app:menu="@menu/activity_main_drawer" />

</androidx.drawerlayout.widget.DrawerLayout>

Log

2022-12-25 16:03:38.873 9611-9611/com.buratinoapps.aweartool E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.buratinoapps.aweartool, PID: 9611
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.buratinoapps.aweartool/com.buratinoapps.aweartool.MainActivity}: android.view.InflateException: Binary XML file line #23 in com.buratinoapps.aweartool:layout/activity_main: Binary XML file line #23 in com.buratinoapps.aweartool:layout/activity_main: Error inflating class fragment
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3685)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3842)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2252)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7842)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
     Caused by: android.view.InflateException: Binary XML file line #23 in com.buratinoapps.aweartool:layout/activity_main: Binary XML file line #23 in com.buratinoapps.aweartool:layout/activity_main: Error inflating class fragment
     Caused by: android.view.InflateException: Binary XML file line #23 in com.buratinoapps.aweartool:layout/activity_main: Error inflating class fragment
     Caused by: java.lang.ClassCastException: com.buratinoapps.aweartool.InstallFragment cannot be cast to androidx.fragment.app.Fragment
        at androidx.fragment.app.Fragment.instantiate(Fragment.java:613)
        at androidx.navigation.fragment.FragmentNavigator.instantiateFragment(FragmentNavigator.java:184)
        at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:212)
        at androidx.navigation.fragment.FragmentNavigator.navigate(FragmentNavigator.java:58)
        at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:80)
        at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:30)
        at androidx.navigation.NavController.navigate(NavController.java:823)
        at androidx.navigation.NavController.onGraphCreated(NavController.java:521)
        at androidx.navigation.NavController.setGraph(NavController.java:482)
        at androidx.navigation.NavController.setGraph(NavController.java:447)
        at androidx.navigation.NavController.setGraph(NavController.java:429)
        at androidx.navigation.fragment.NavHostFragment.onCreate(NavHostFragment.java:226)
        at androidx.fragment.app.Fragment.performCreate(Fragment.java:2949)
        at androidx.fragment.app.FragmentStateManager.create(FragmentStateManager.java:475)
        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:278)
        at androidx.fragment.app.FragmentLayoutInflaterFactory.onCreateView(FragmentLayoutInflaterFactory.java:140)
        at androidx.fragment.app.FragmentController.onCreateView(FragmentController.java:135)
        at androidx.fragment.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:319)
        at androidx.fragment.app.FragmentActivity.onCreateView(FragmentActivity.java:298)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1073)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1001)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:965)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1127)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1130)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1088)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:686)
2022-12-25 16:03:38.874 9611-9611/com.buratinoapps.aweartool E/AndroidRuntime:     at android.view.LayoutInflater.inflate(LayoutInflater.java:538)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:485)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:710)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
        at com.buratinoapps.aweartool.MainActivity.onCreate(MainActivity.java:31)
        at android.app.Activity.performCreate(Activity.java:8054)
        at android.app.Activity.performCreate(Activity.java:8034)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1341)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3666)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3842)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2252)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7842)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
2022-12-25 16:03:38.928 9611-9611/com.buratinoapps.aweartool I/Process: Sending signal. PID: 9611 SIG: 9


问:
How to make a required field Disable on a certain view?
In my ASP.NET Core application, I have a BassModel class.

In it, I have a field that is marked as required:

```<code>[Required(ErrorMessage = "Required field")]
public string InputText { get; set; }
</code>```

So all other classes were inherited from this class. Now there is a second class and in that class, I am not passing this value to the controller from the view.

Simply I want to make this required attribute disabled.

I know most people suggest making that parent attribute allow null. But I don't want to do it either. Is there a better approach?

Body:
In my ASP.NET Core application, I have a BassModel class.

In it, I have a field that is marked as required:

[Required(ErrorMessage = "Required field")]
public string InputText { get; set; }

So all other classes were inherited from this class. Now there is a second class and in that class, I am not passing this value to the controller from the view.

Simply I want to make this required attribute disabled.

I know most people suggest making that parent attribute allow null. But I don't want to do it either. Is there a better approach?


问:
Skip cognito hosted ui and use custom ui for social login
I am trying to bypass Cognito's hosted UI and have my custom UI for social login, I used Amplify for creating user with username and password, but for user creation using social login documentation says to use Cognito Hosted UI, is there a way to create user pool without using Cognito's Hosted UI.

I tried to build my own but after receiving code from google on redirect I don't know how to create data in Cognito's user pool


问:
Write excels to path with variable in R
I want to write excel files to a folder with the writexl package. I have a list of dfs and a list of names for these dfs. I want to create the excel files automatically with a for loop, something like:

```<code>for (i in 1:length(df_list)) {
 write_xlsx(df_list[[i]],
             "C:/example_path/{name_list[[i]]}.xlsx",
             col_names = FALSE)
}

</code>```

Is there an elegant way? The use of the writexl package is mandatory unfortunately.

Title: Write excels to path with variable in R

Body:
I want to write excel files to a folder with the writexl package. I have a list of dfs and a list of names for these dfs. I want to create the excel files automatically with a for loop, something like:

for (i in 1:length(df_list)) {
 write_xlsx(df_list[[i]],
             "C:/example_path/{name_list[[i]]}.xlsx",
             col_names = FALSE)
}

Is there an elegant way? The use of the writexl package is mandatory unfortunately.


问:
Issue export cognos page with multiple tab to excel 2007
i have a cognos report with a page containing 6 simples table and 3 dynamics cross tables .when exporting to excel only first cell containing a simple table /data IS  exported and not all of the objects ?
Cognos 8/excel 2007

Exporting cognos page to excel 2007
Obtaining all page forme/all object desinging in cognos on Excel


问:
What does bulkCreate return?
I have searched everywhere and I cant get the answer to this. What does bulkCreate operation in sequelize (with postgreSQL) return? I'm getting weird response there so I want to know the exact kind of response with an example please.
My use case is that I insert with bulkCreate using ignoreDuplicates: true param and then want to know which records inserted successfully and which failed.

```<code> const results = await this.model.bulkCreate(records, {
      ignoreDuplicates: true
    });
</code>```

Want to know what the results output.

My output results
Case 1: If id=1 already exists in table of 2 records and id=3 doesnt then I get:

Input:

```<code>[
  {
    "id": "1",
    "brand": "Armani",
    "product_line": "SW06",

  },
  {
    "id": "3",
    "brand": "Gucci",
    "product_line": "ADR35",
  }
]
</code>```

Output:

```<code>[
  {
    "id": "3",
    "brand": "Gucci",
    "product_line": "ADR35",
    "createdAt": "2022-12-25T13:06:07.356Z",
    "updatedAt": "2022-12-25T13:06:07.356Z"
  },
  {
    "id": "3",
    "brand": "Gucci",
    "product_line": "ADR35",
    "createdAt": "2022-12-25T13:06:07.356Z",
    "updatedAt": "2022-12-25T13:06:07.356Z"
  }
]
</code>```

Case 2: If both id=1 and id=3 exists in table then I get:

Input:

```<code>[
  {
    "id": "1",
    "brand": "Armani",
    "product_line": "SW06",

  },
  {
    "id": "3",
    "brand": "Gucci",
    "product_line": "ADR35",
  }
]
</code>```

Output:

```<code>[
  {
    "id": "1",
    "brand": "Armani",
    "product_line": "SW06",
    "createdAt": "2022-12-25T13:48:56.422Z",
    "updatedAt": "2022-12-25T13:48:56.422Z"
  },
  {
    "id": "3",
    "brand": "Gucci",
    "product_line": "ADR35",
    "createdAt": "2022-12-25T13:48:56.422Z",
    "updatedAt": "2022-12-25T13:48:56.422Z"
  }
]
</code>```

Title: What does bulkCreate return?

Body:
I have searched everywhere and I cant get the answer to this. What does bulkCreate operation in sequelize (with postgreSQL) return? I'm getting weird response there so I want to know the exact kind of response with an example please.
My use case is that I insert with bulkCreate using ignoreDuplicates: true param and then want to know which records inserted successfully and which failed.

 const results = await this.model.bulkCreate(records, {
      ignoreDuplicates: true
    });

Want to know what the results output.

My output results
Case 1: If id=1 already exists in table of 2 records and id=3 doesnt then I get:

Input:

[
  {
    "id": "1",
    "brand": "Armani",
    "product_line": "SW06",

  },
  {
    "id": "3",
    "brand": "Gucci",
    "product_line": "ADR35",
  }
]

Output:

[
  {
    "id": "3",
    "brand": "Gucci",
    "product_line": "ADR35",
    "createdAt": "2022-12-25T13:06:07.356Z",
    "updatedAt": "2022-12-25T13:06:07.356Z"
  },
  {
    "id": "3",
    "brand": "Gucci",
    "product_line": "ADR35",
    "createdAt": "2022-12-25T13:06:07.356Z",
    "updatedAt": "2022-12-25T13:06:07.356Z"
  }
]

Case 2: If both id=1 and id=3 exists in table then I get:

Input:

[
  {
    "id": "1",
    "brand": "Armani",
    "product_line": "SW06",

  },
  {
    "id": "3",
    "brand": "Gucci",
    "product_line": "ADR35",
  }
]

Output:

[
  {
    "id": "1",
    "brand": "Armani",
    "product_line": "SW06",
    "createdAt": "2022-12-25T13:48:56.422Z",
    "updatedAt": "2022-12-25T13:48:56.422Z"
  },
  {
    "id": "3",
    "brand": "Gucci",
    "product_line": "ADR35",
    "createdAt": "2022-12-25T13:48:56.422Z",
    "updatedAt": "2022-12-25T13:48:56.422Z"
  }
]