问:
Any way of telling if a dependency property is being subscribed to?
I have a custom control with a dependency property that is fairly expensive to compute. Therefore I don't want to do so unless someone is actually interested in it.

Does WPF supply any way of seeing if anything is looking at a dependency property?

答:
There are ways to stop a Binding to a DP from taking effect (i.e. before performing your expensive computation), and that is the Validation callback ...

http://msdn.microsoft.com/en-us/library/ms745795.aspx#Validation_Callbacks.


来源: stackexchange

问:
Get the average difference between two values in time period
What I have:
A single table with ids and prices for date and time.

What I want to do:
To get the average difference of price for every id between the first and 15 minute of every day.
Conditions: I also want to use the last available price in 15 minutes if the 15 is missing. For example if 15 is missing, use the price in 14 minutes.

What I did:
My first step was to get the price after 15 minutes of every day for every id.

My code (I did a lot of tests with it, sorry if it doesn't look good and optimised enough) to get the last price(but not last available) in the 15 minutes interval:

```<code>WITH s as (
  SELECT DATE(date_value) as dt, date_value, stock_id sid, open FROM stocks_1min
)

SELECT sid, dt, date_value, s.open as second_price
FROM s

INNER JOIN (
    SELECT q.stock_id, DATE(q.date_value) as dat
    FROM stocks_1min q
    GROUP BY q.stock_id, dat
    ORDER BY q.stock_id ASC
  ) as end_price
           ON s.sid = end_price.stock_id
    AND s.date_value = (SELECT date_value FROM s WHERE s.sid = end_price.stock_id AND s.dt = end_price.dat LIMIT 1) + interval '15 minutes'

ORDER BY sid, dt;
</code>```

What I didn't do:

get the last AVAILABLE price in that interval.

get the first price in that interval and use it in the same query with the last price in the interval

If I got both prices then I can use AVG and Group By to get the needed value.

Expected result (example):
Table:

```<code>|stock_id|open(price)|date_value      |
|1       |10         |01-12-2020 09:31|
|1       |12         |01-12-2020 09:46|
|1       |14         |02-12-2020 09:31|
|1       |20         |02-12-2020 09:46|
|2       |14         |01-12-2020 09:31|
|2       |16         |01-12-2020 09:46|
|2       |2          |02-12-2020 09:31|
|2       |16         |02-12-2020 09:46|
</code>```

Result:

```<code>|stock_id|average_difference|
| 1      | 4                | ((12-10) + (20-14)) / 2 = 4
| 2      | 8                | ((16-14) + (16-2)) / 2 = 8
</code>```

I have never used "Partition By", but maybe here is the place to start with it?
It's my own project, where I want to test some statistical ideas for the stock market.
Thanks in advance!

You can use this link where it's a sample for testing: http://sqlfiddle.com/#!17/83597/1

答:
I continued with the idea from your SQL and tried to get the solution without analytical function which you can if you want to.

SQL: (dbfiddle link)

```<code>WITH
day_min_time AS
(
         SELECT   Min(date_value)  min_time,
                  Date(date_value) dt,
                  stock_id
         FROM     stock_1min
         GROUP BY Date(date_value),
                  stock_id ),
day_max_time AS
(
         SELECT   Max(sd.date_value)  max_time ,
                  Date(sd.date_value) dt,
                  sd.stock_id
         FROM     stock_1min sd
         JOIN     day_min_time dmt
         ON       sd.stock_id = dmt.stock_id
         AND      Date(sd.date_value) = dmt.dt
         WHERE    sd.date_value <= dmt.min_time + interval '15 minutes'
         GROUP BY date(sd.date_value) ,
                  sd.stock_id )
SELECT   round(avg(price_difference)) average_difference,
         stock_id
FROM     (
                    SELECT     max(sd.OPEN)-min(sd.OPEN) price_difference,
                               sd.stock_id ,
                               date(sd.date_value)
                    FROM       stock_1min sd
                    INNER JOIN day_min_time min_dmt
                    ON         min_dmt.stock_id = sd.stock_id
                    AND        date(sd.date_value) = min_dmt.dt
                    INNER JOIN day_max_time max_dmt
                    ON         max_dmt.stock_id = sd.stock_id
                    AND        date(sd.date_value) = max_dmt.dt
                    WHERE      sd.date_value BETWEEN min_dmt.min_time AND        max_dmt.max_time
                    GROUP BY   sd.stock_id ,
                               date(sd.date_value) ) final_inline_view
GROUP BY stock_id;

</code>```

Here are the steps:

Step 1: Minimum recorded time for each day.

```<code>with day_min_time
as
(
 SELECT Min(date_value)  min_time,
       Date(date_value) dt,
       stock_id
FROM   stock_1min
GROUP  BY Date(date_value),
          stock_id
)
</code>```

Step 2: Maximum recorded time for each day which is 15 minutes from minimum recorded time for the day.It is using the CTE from step 1.

```<code>with day_max_time
 as
(
 SELECT   Max(sd.date_value)  max_time ,
         Date(sd.date_value) dt,
         sd.stock_id
FROM     stock_1min sd
JOIN     day_min_time dmt
ON       sd.stock_id = dmt.stock_id
AND      Date(sd.date_value) = dmt.dt
WHERE    sd.date_value <= dmt.min_time + interval '15 minutes'
GROUP BY date(sd.date_value) ,
         sd.stock_id)
</code>```

Step 3: Use the time boundaries obtained from Step 1 and Step 2 to get the maximum  and minimum prices.

```<code>SELECT Max(sd.open) - Min(sd.open) price_difference,
       sd.stock_id,
       DATE(sd.date_value)
FROM   stock_1min sd
       INNER JOIN day_min_time min_dmt
               ON min_dmt.stock_id = sd.stock_id
                  AND DATE(sd.date_value) = min_dmt.dt
       INNER JOIN day_max_time max_dmt
               ON max_dmt.stock_id = sd.stock_id
                  AND DATE(sd.date_value) = max_dmt.dt
WHERE  sd.date_value BETWEEN min_dmt.min_time AND max_dmt.max_time
GROUP  BY sd.stock_id,
          DATE(sd.date_value)
</code>```

Step 4: Get the average difference using the result from step 3:

```<code>SELECT Round(Avg(difference)) average_difference,
       stock_id
FROM   (SELECT Max(sd.open) - Min(sd.open) price_difference,
               sd.stock_id,
               DATE(sd.date_value)
        FROM   stock_1min sd
               INNER JOIN day_min_time min_dmt
                       ON min_dmt.stock_id = sd.stock_id
                          AND DATE(sd.date_value) = min_dmt.dt
               INNER JOIN day_max_time max_dmt
                       ON max_dmt.stock_id = sd.stock_id
                          AND DATE(sd.date_value) = max_dmt.dt
        WHERE  sd.date_value BETWEEN min_dmt.min_time AND max_dmt.max_time
        GROUP  BY sd.stock_id,
                  DATE(sd.date_value)) final_inline_view
GROUP  BY stock_id;
</code>```

ContentLicense: CC BY-SA 4.0

Body:
What I have:
A single table with ids and prices for date and time.

What I want to do:
To get the average difference of price for every id between the first and 15 minute of every day.
Conditions: I also want to use the last available price in 15 minutes if the 15 is missing. For example if 15 is missing, use the price in 14 minutes.

What I did:
My first step was to get the price after 15 minutes of every day for every id.

My code (I did a lot of tests with it, sorry if it doesn't look good and optimised enough) to get the last price(but not last available) in the 15 minutes interval:

WITH s as (
  SELECT DATE(date_value) as dt, date_value, stock_id sid, open FROM stocks_1min
)

SELECT sid, dt, date_value, s.open as second_price
FROM s

INNER JOIN (
    SELECT q.stock_id, DATE(q.date_value) as dat
    FROM stocks_1min q
    GROUP BY q.stock_id, dat
    ORDER BY q.stock_id ASC
  ) as end_price
           ON s.sid = end_price.stock_id
    AND s.date_value = (SELECT date_value FROM s WHERE s.sid = end_price.stock_id AND s.dt = end_price.dat LIMIT 1) + interval '15 minutes'

ORDER BY sid, dt;

What I didn't do:

get the last AVAILABLE price in that interval.

get the first price in that interval and use it in the same query with the last price in the interval

If I got both prices then I can use AVG and Group By to get the needed value.

Expected result (example):
Table:

|stock_id|open(price)|date_value      |
|1       |10         |01-12-2020 09:31|
|1       |12         |01-12-2020 09:46|
|1       |14         |02-12-2020 09:31|
|1       |20         |02-12-2020 09:46|
|2       |14         |01-12-2020 09:31|
|2       |16         |01-12-2020 09:46|
|2       |2          |02-12-2020 09:31|
|2       |16         |02-12-2020 09:46|

Result:

|stock_id|average_difference|
| 1      | 4                | ((12-10) + (20-14)) / 2 = 4
| 2      | 8                | ((16-14) + (16-2)) / 2 = 8

I have never used "Partition By", but maybe here is the place to start with it?
It's my own project, where I want to test some statistical ideas for the stock market.
Thanks in advance!

You can use this link where it's a sample for testing: http://sqlfiddle.com/#!17/83597/1

Body:
I continued with the idea from your SQL and tried to get the solution without analytical function which you can if you want to.

SQL: (dbfiddle link)

WITH
day_min_time AS
(
         SELECT   Min(date_value)  min_time,
                  Date(date_value) dt,
                  stock_id
         FROM     stock_1min
         GROUP BY Date(date_value),
                  stock_id ),
day_max_time AS
(
         SELECT   Max(sd.date_value)  max_time ,
                  Date(sd.date_value) dt,
                  sd.stock_id
         FROM     stock_1min sd
         JOIN     day_min_time dmt
         ON       sd.stock_id = dmt.stock_id
         AND      Date(sd.date_value) = dmt.dt
         WHERE    sd.date_value <= dmt.min_time + interval '15 minutes'
         GROUP BY date(sd.date_value) ,
                  sd.stock_id )
SELECT   round(avg(price_difference)) average_difference,
         stock_id
FROM     (
                    SELECT     max(sd.OPEN)-min(sd.OPEN) price_difference,
                               sd.stock_id ,
                               date(sd.date_value)
                    FROM       stock_1min sd
                    INNER JOIN day_min_time min_dmt
                    ON         min_dmt.stock_id = sd.stock_id
                    AND        date(sd.date_value) = min_dmt.dt
                    INNER JOIN day_max_time max_dmt
                    ON         max_dmt.stock_id = sd.stock_id
                    AND        date(sd.date_value) = max_dmt.dt
                    WHERE      sd.date_value BETWEEN min_dmt.min_time AND        max_dmt.max_time
                    GROUP BY   sd.stock_id ,
                               date(sd.date_value) ) final_inline_view
GROUP BY stock_id;

Here are the steps:

Step 1: Minimum recorded time for each day.

with day_min_time
as
(
 SELECT Min(date_value)  min_time,
       Date(date_value) dt,
       stock_id
FROM   stock_1min
GROUP  BY Date(date_value),
          stock_id
)

Step 2: Maximum recorded time for each day which is 15 minutes from minimum recorded time for the day.It is using the CTE from step 1.

with day_max_time
 as
(
 SELECT   Max(sd.date_value)  max_time ,
         Date(sd.date_value) dt,
         sd.stock_id
FROM     stock_1min sd
JOIN     day_min_time dmt
ON       sd.stock_id = dmt.stock_id
AND      Date(sd.date_value) = dmt.dt
WHERE    sd.date_value <= dmt.min_time + interval '15 minutes'
GROUP BY date(sd.date_value) ,
         sd.stock_id)

Step 3: Use the time boundaries obtained from Step 1 and Step 2 to get the maximum  and minimum prices.

SELECT Max(sd.open) - Min(sd.open) price_difference,
       sd.stock_id,
       DATE(sd.date_value)
FROM   stock_1min sd
       INNER JOIN day_min_time min_dmt
               ON min_dmt.stock_id = sd.stock_id
                  AND DATE(sd.date_value) = min_dmt.dt
       INNER JOIN day_max_time max_dmt
               ON max_dmt.stock_id = sd.stock_id
                  AND DATE(sd.date_value) = max_dmt.dt
WHERE  sd.date_value BETWEEN min_dmt.min_time AND max_dmt.max_time
GROUP  BY sd.stock_id,
          DATE(sd.date_value)

Step 4: Get the average difference using the result from step 3:

SELECT Round(Avg(difference)) average_difference,
       stock_id
FROM   (SELECT Max(sd.open) - Min(sd.open) price_difference,
               sd.stock_id,
               DATE(sd.date_value)
        FROM   stock_1min sd
               INNER JOIN day_min_time min_dmt
                       ON min_dmt.stock_id = sd.stock_id
                          AND DATE(sd.date_value) = min_dmt.dt
               INNER JOIN day_max_time max_dmt
                       ON max_dmt.stock_id = sd.stock_id
                          AND DATE(sd.date_value) = max_dmt.dt
        WHERE  sd.date_value BETWEEN min_dmt.min_time AND max_dmt.max_time
        GROUP  BY sd.stock_id,
                  DATE(sd.date_value)) final_inline_view
GROUP  BY stock_id;


问:
datetuil results in wrong utc offset when using lower case
I'm trying to convert dates into different timezones using dateutil.
I've noticed, that using lower case letters when creating the tz objects is leading to incorrect timezones.

```<code>>>> from datetime import datetime
>>> from dateutil import tz

>>> tz.gettz('utc-6')
tzstr('utc-6')
>>> tz.gettz('UTC-6')
tzstr('UTC-6')
</code>```

Up to this point, everything seems to be correct, however when passing the tzstr into a datetime object, the lower-case tzstr will apply the inverted offset. This happens to both, + and -, for all offsets.

I used %z to show the applied offset, but the issue is affecting all datetime operations.

```<code>>>> datetime.now(tz.gettz('UTC-6')).strftime('%z')
'-0600'

>>> datetime.now(tz.gettz('utc-6')).strftime('%z')
'+0600'
>>> datetime.now(tz.gettz('utc-06')).strftime('%z')
'+0600'
>>>
>>> datetime.now(tz.gettz('utc-8')).strftime('%z')
'+0800'
>>>
</code>```

Is there a big oversight by myself, or is it indeed a bug in the package?
I couldn't find anything in the docs limiting the user input to capitalized UTC+X.

(Python version is tags/v3.9.9:ccb0e6a on Windows and python-dateutil 2.8.2, but occurs as well on Linux with python 2.8.2)

答:
The dateutil library, by default, diverges from POSIX-style time zones, which "use an inverted offset format, so normally GMT+3 would be parsed as an offset 3 hours behind GMT. The tzstr time zone object will parse this as an offset 3 hours ahead of GMT" (dateutil documentation on dateutil.tz.tzstr()).

The library determines when to invert the offset by checking if your timezone abbreviation is either "UTC" or "GMT" (case sensitive), then multiplies the offset by -1. Because the check is case sensitive, the offset for "UTC-6" does properly get offset to -0600 but "utc-6" does not (tzstr source code).

```<code># Here we break the compatibility with the TZ variable handling.
# GMT-3 actually *means* the timezone -3.
if res.stdabbr in ("GMT", "UTC") and not posix_offset:
    res.stdoffset *= -1
</code>```

Regardless of if this was an intentional decision, with the current tzstr implementation, you should uppercase your timezone strings before passing them in to gettz().

Body:
I'm trying to convert dates into different timezones using dateutil.
I've noticed, that using lower case letters when creating the tz objects is leading to incorrect timezones.

>>> from datetime import datetime
>>> from dateutil import tz

>>> tz.gettz('utc-6')
tzstr('utc-6')
>>> tz.gettz('UTC-6')
tzstr('UTC-6')

Up to this point, everything seems to be correct, however when passing the tzstr into a datetime object, the lower-case tzstr will apply the inverted offset. This happens to both, + and -, for all offsets.

I used %z to show the applied offset, but the issue is affecting all datetime operations.

>>> datetime.now(tz.gettz('UTC-6')).strftime('%z')
'-0600'

>>> datetime.now(tz.gettz('utc-6')).strftime('%z')
'+0600'
>>> datetime.now(tz.gettz('utc-06')).strftime('%z')
'+0600'
>>>
>>> datetime.now(tz.gettz('utc-8')).strftime('%z')
'+0800'
>>>

Is there a big oversight by myself, or is it indeed a bug in the package?
I couldn't find anything in the docs limiting the user input to capitalized UTC+X.

(Python version is tags/v3.9.9:ccb0e6a on Windows and python-dateutil 2.8.2, but occurs as well on Linux with python 2.8.2)

Body:
The dateutil library, by default, diverges from POSIX-style time zones, which "use an inverted offset format, so normally GMT+3 would be parsed as an offset 3 hours behind GMT. The tzstr time zone object will parse this as an offset 3 hours ahead of GMT" (dateutil documentation on dateutil.tz.tzstr()).

The library determines when to invert the offset by checking if your timezone abbreviation is either "UTC" or "GMT" (case sensitive), then multiplies the offset by -1. Because the check is case sensitive, the offset for "UTC-6" does properly get offset to -0600 but "utc-6" does not (tzstr source code).

# Here we break the compatibility with the TZ variable handling.
# GMT-3 actually *means* the timezone -3.
if res.stdabbr in ("GMT", "UTC") and not posix_offset:
    res.stdoffset *= -1

Regardless of if this was an intentional decision, with the current tzstr implementation, you should uppercase your timezone strings before passing them in to gettz().


问:
C++ turning string into char and making it unable to compare to another string
```<code>void split_to_array(string sentence, string splitter)
{
    int index = 0;
    int last_index = sentence.find(splitter);

    int array_amount = 0;

    for (int i = 0; i < sentence.size(); i++) {
        cout << sentence[i] << endl;
        if (sentence[i] == splitter) array_amount++;
    }
}

int main()
{

    split_to_array("fdsfds fdsfds vcxvcx fdsafdsa", " ");

}
</code>```

I am trying to get the length of the array by finding the splitter argument in the string, However when I try to compare the index of the string with the splitter I get an error that I cannot compare a char with a string which is the first issue I have. When I try to turn it  into a string by using std::to_string I get a number back instead of the actual string.

答:
```<code>void split_to_array(string sentence, char splitter)
{
    int index = 0;
    int last_index = sentence.find(splitter);

    int array_amount = 0;

    for (int i = 0; i < sentence.size(); i++) {
        cout << sentence[i] << endl;
        if (sentence[i] == splitter) array_amount++;
    }
}

int main()
{

    split_to_array("fdsfds fdsfds vcxvcx fdsafdsa", ' ');

}
</code>```

Maybe do it like this. Eventually you send "splitter" parameter as a char so it is easier to compare. You need to use apostrophe (') for a char when calling a function.

Body:
void split_to_array(string sentence, string splitter)
{
    int index = 0;
    int last_index = sentence.find(splitter);

    int array_amount = 0;

    for (int i = 0; i < sentence.size(); i++) {
        cout << sentence[i] << endl;
        if (sentence[i] == splitter) array_amount++;
    }
}

int main()
{

    split_to_array("fdsfds fdsfds vcxvcx fdsafdsa", " ");

}

I am trying to get the length of the array by finding the splitter argument in the string, However when I try to compare the index of the string with the splitter I get an error that I cannot compare a char with a string which is the first issue I have. When I try to turn it  into a string by using std::to_string I get a number back instead of the actual string.

Body:
void split_to_array(string sentence, char splitter)
{
    int index = 0;
    int last_index = sentence.find(splitter);

    int array_amount = 0;

    for (int i = 0; i < sentence.size(); i++) {
        cout << sentence[i] << endl;
        if (sentence[i] == splitter) array_amount++;
    }
}

int main()
{

    split_to_array("fdsfds fdsfds vcxvcx fdsafdsa", ' ');

}

Maybe do it like this. Eventually you send "splitter" parameter as a char so it is easier to compare. You need to use apostrophe (') for a char when calling a function.


问:
How to print struct variables in console?
How can I print (to the console) the Id, Title, Name, etc. of this struct in Golang?

```<code>type Project struct {
    Id      int64   `json:"project_id"`
    Title   string  `json:"title"`
    Name    string  `json:"name"`
    Data    Data    `json:"data"`
    Commits Commits `json:"commits"`
}
</code>```

答:
A lot of answers for a simple question.  I might as well throw my hat in the ring.

```<code>package main

import "fmt"

type Project struct {
    Id    int64  `json:"project_id"`
    Title string `json:"title"`
    Name  string `json:"name"`
    //Data    Data    `json:"data"`
    //Commits Commits `json:"commits"`
}

var (
    Testy Project
)

func dump_project(foo Project) {
    fmt.Println("== Dump Project Struct ====")
    fmt.Printf("Id: %d\n", foo.Id)
    fmt.Println("Title: ", foo.Title)
    fmt.Printf("Name: %v\n", foo.Name)
}

func main() {
    fmt.Println("hello from go")
    Testy.Id = 3
    Testy.Title = "yo"
    Testy.Name = "my name"
    fmt.Println(Testy)
    dump_project(Testy)
}
</code>```

The output of the various print methods

```<code>hello from go
{3 yo my name}
== Dump Project Struct ====
Id: 3
Title:  yo
Name: my name
</code>```

Body:
How can I print (to the console) the Id, Title, Name, etc. of this struct in Golang?

type Project struct {
    Id      int64   `json:"project_id"`
    Title   string  `json:"title"`
    Name    string  `json:"name"`
    Data    Data    `json:"data"`
    Commits Commits `json:"commits"`
}

Body:
A lot of answers for a simple question.  I might as well throw my hat in the ring.

package main

import "fmt"

type Project struct {
    Id    int64  `json:"project_id"`
    Title string `json:"title"`
    Name  string `json:"name"`
    //Data    Data    `json:"data"`
    //Commits Commits `json:"commits"`
}

var (
    Testy Project
)

func dump_project(foo Project) {
    fmt.Println("== Dump Project Struct ====")
    fmt.Printf("Id: %d\n", foo.Id)
    fmt.Println("Title: ", foo.Title)
    fmt.Printf("Name: %v\n", foo.Name)
}

func main() {
    fmt.Println("hello from go")
    Testy.Id = 3
    Testy.Title = "yo"
    Testy.Name = "my name"
    fmt.Println(Testy)
    dump_project(Testy)
}

The output of the various print methods

hello from go
{3 yo my name}
== Dump Project Struct ====
Id: 3
Title:  yo
Name: my name


问:
How to use validator in vue using setup script, typscript and the composition API
I have the following code example from a tutorial and I try to figure out how to use a validator in a similar way as the example, using the script setup, typescript and the composition API.

```<code>props: {
    image: {
      type: String,
      default: require("@/assets/default-poster.png"),
      validator: propValue => {
        const hasImagesDir = propValue.indexOf("@/assets/") > -1;
        const listOfAvailableExt = [".jpeg", ".jpg", ".png"];
        const isValidExt = listOfAvailableExt.some(ext =>
          propValue.endsWith(ext)
        );
        return hasImagesDir && isValidExt;
      }
    }
  }
</code>```

I know how to declare the type and the default value but I couldn't find a way to use a validator. Is there any function to validate the different properties?

```<code>interface Props {
  image: string
}

const props = withDefaults(defineProps<Props>(), {
  image: require("@/assets/default-poster.png")
});
</code>```

Body:
I have the following code example from a tutorial and I try to figure out how to use a validator in a similar way as the example, using the script setup, typescript and the composition API.

props: {
    image: {
      type: String,
      default: require("@/assets/default-poster.png"),
      validator: propValue => {
        const hasImagesDir = propValue.indexOf("@/assets/") > -1;
        const listOfAvailableExt = [".jpeg", ".jpg", ".png"];
        const isValidExt = listOfAvailableExt.some(ext =>
          propValue.endsWith(ext)
        );
        return hasImagesDir && isValidExt;
      }
    }
  }

I know how to declare the type and the default value but I couldn't find a way to use a validator. Is there any function to validate the different properties?

interface Props {
  image: string
}

const props = withDefaults(defineProps<Props>(), {
  image: require("@/assets/default-poster.png")
});

Body:
In <script setup>, only the function argument of defineProps() supports validator (as of Vue 3.2.31). The function argument has the same type as the props option:

defineProps({
  image: {
    type: String,
    default: require("@/assets/default-poster.png"),
    validator: (propValue: string) => {
      const hasImagesDir = propValue.indexOf("@/assets/") > -1;
      const listOfAvailableExt = [".jpeg", ".jpg", ".png"];
      const isValidExt = listOfAvailableExt.some(ext =>
        propValue.endsWith(ext)
      );
      return hasImagesDir && isValidExt;
    }
  }
})

Note you can't mix the type-only props declaration with the function argument of defineProps(), so any other props would also have to be converted into the option form.

Alternatively, you could implement your own prop validation:

<script setup lang="ts">
interface Props {
  image: string
}

const props = withDefaults(defineProps<Props>(), {
  image: require("@/assets/default-poster.png")
});

if (import.meta.env.DEV /* process.env.NODE_ENV === 'development' */) {
  const isValidImage = (propValue: string) => {
    const hasImagesDir = propValue.indexOf("@/assets/") > -1;
    const listOfAvailableExt = [".jpeg", ".jpg", ".png"];
    const isValidExt = listOfAvailableExt.some(ext =>
      propValue.endsWith(ext)
    );
    return hasImagesDir && isValidExt;
  }

  if (!isValidImage(props.image)) {
    console.warn(`invalid image: ${props.image}`)
  }
}
</script>


问:
How do I provide an informal string representation of a python Class (not instance)
I understand how I can provide an informal representation of an instance of the object, but I am interested in providing an informal string representation of the Class name.

So specifically, I want to override what is returned when I print the Class (__main__.SomeClass).

```<code>>>> class SomeClass:
...   def __str__(self):
...     return 'I am a SomeClass instance.'
...
>>> SomeClass
<class __main__.SomeClass at 0x2ba2f0fd3b30>
>>> print SomeClass
__main__.SomeClass
>>>
>>> x = SomeClass()
>>> x
<__main__.SomeClass instance at 0x2ba2f0ff3f38>
>>> print x
I am a SomeClass instance.
</code>```

答:
You can achieve this with metaclasses.

Observe:

```<code>>>> class MyMeta(type):
...     def __init__(cls, name, bases, dct):
...             super(MyMeta, cls).__init__(name, bases, dct)
...
...     def __repr__(self):
...             return "MyMeta is Cool: " + self.__name__
...
>>> class FooType(metaclass=MyMeta):
...     pass
...
>>> FooType
MyMeta is Cool: FooType
</code>```

ContentLicense: CC BY-SA 3.0

Body:
I understand how I can provide an informal representation of an instance of the object, but I am interested in providing an informal string representation of the Class name.

So specifically, I want to override what is returned when I print the Class (__main__.SomeClass).

>>> class SomeClass:
...   def __str__(self):
...     return 'I am a SomeClass instance.'
...
>>> SomeClass
<class __main__.SomeClass at 0x2ba2f0fd3b30>
>>> print SomeClass
__main__.SomeClass
>>>
>>> x = SomeClass()
>>> x
<__main__.SomeClass instance at 0x2ba2f0ff3f38>
>>> print x
I am a SomeClass instance.

Body:
You can achieve this with metaclasses.

Observe:

>>> class MyMeta(type):
...     def __init__(cls, name, bases, dct):
...             super(MyMeta, cls).__init__(name, bases, dct)
...
...     def __repr__(self):
...             return "MyMeta is Cool: " + self.__name__
...
>>> class FooType(metaclass=MyMeta):
...     pass
...
>>> FooType
MyMeta is Cool: FooType


问:
Why is Linux's pty driver replacing VEOFs with NULs?
It seems that the pty driver on Linux is replacing VEOF characters (^D, \4) with NUL bytes (\0) in the data already written from the master side if the terminal settings are changed with tcsetattr(TCSANOW) to non-canonical mode before reading it on the slave side.

Why is this happening? Does it have any justification or it's simply a bug?

Is there any way to avoid it? -- other than waiting for input from the slave on the master side before writing anything, which is not practical, because on the slave side there may be another program -- the routine of setting the terminal into raw mode which I've simplified here is usually what any shell with line-editing capabilities does.

While having eg \r replaced by \n could be expected (because the ICRNL flag was already applied), I cannot make any rationale for those NUL bytes appearing out of nowhere.

Test case below: it will print foo\x00\x00\x00\x00 on Linux, but foo\x04\x04\x04\x04 on *BSD and foo on Solaris.

#define _XOPEN_SOURCE   600
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdio.h>
#include <termios.h>
#include <err.h>

#ifdef __sun
#include <stropts.h>
#define push_streams(fd)\
        if(ioctl(fd, I_PUSH, "ptem")) err(1, "ioctl(I_PUSH, ptem)");\
        if(ioctl(fd, I_PUSH, "ldterm")) err(1, "ioctl(I_PUSH, ldterm)");
#else
#define push_streams(sd)        /* no need */
#endif

int main(void){
        int mt, st; char *sname;

        /* openpty()-like boilerplate */
        if((mt = posix_openpt(O_RDWR|O_NOCTTY)) == -1) err(1, "posix_openpt");
        if(grantpt(mt)) err(1, "grantpt");
        if(unlockpt(mt)) err(1, "unlockpt");
        if(!(sname = ptsname(mt))) err(1, "ptsname");
        if((st = open(sname, O_RDWR|O_NOCTTY)) == -1) err(1, "open %s", sname);
        push_streams(st);

        /* master */ {
                char test[] = "foo\4\4\4\4";
                if(write(mt, test, sizeof test - 1) < sizeof test - 1)
                        err(1, "write");
        }
        /* slave */ {
                unsigned char buf[512]; int i, r;
                struct termios ts;
                usleep(1000);
                if(tcgetattr(st, &ts)) err(1, "tcgetattr");
                ts.c_lflag &= ~ICANON;
                if(tcsetattr(st, TCSANOW, &ts)) err(1, "tcsetattr");
                if((r = read(st, buf, sizeof buf)) < 0)
                        err(1, "read");
                for(i = 0; i < r; i++)
                        if(isprint(buf[i])) putchar(buf[i]);
                        else printf("\\x%02x", buf[i]);
                putchar('\n');
        }
        return 0;
}
```

答:
This conversion is done by the line discipline driver when the data is written by the master, not when the slave reads the data. The relevant code is:

https://elixir.bootlin.com/linux/latest/source/drivers/tty/n_tty.c#L1344


问:
Routes not properly configured? Not showing H1 tag
New to working with routes in React. I am trying to render my Home page.

Currently, my Home route (/) is showing a blank page despite an H1 tag existing on the page itself. Full reproducible code is as follows:

Home.js

```<code>import React from 'react';

function Home () {
    return (
        <div>
            <h1>Hello World</h1>
        </div>
    );
}

export default Home;
</code>```

App.Js

```<code>import "./App.css";
import Sidebar from "./Components/Sidebar";
import {Route, BrowserRouter as Router} from "react-router-dom";
import Home from "./Components/Home";
import SignUp from "./Components/SignUpPage";

function App() {
  return (
    <Router>
    <div className="App">
      <Sidebar />
    </div>
<Route path="/" component={Home}/>
<Route path="/SignUp" component={SignUp} />
    </Router> //surround app with router, and conditionally display pages based on what the user is on
  );
}

export default App;

</code>```

Am I missing something?

答:
In React router-dom v-6 they changed how you provide the component and more. This is the correct why now:

```<code> import {BrowserRouter as Router, Routes, Route } from "react-router-dom";

 return(
        <Router>
            <Routes>
                <Route path="/" element={<Home/>}/>
            </Routes>
        </Router>
    );
</code>```

Here is a video that show all the changes in the react-router-dom v-6 video.

Body:
New to working with routes in React. I am trying to render my Home page.

Currently, my Home route (/) is showing a blank page despite an H1 tag existing on the page itself. Full reproducible code is as follows:

Home.js

import React from 'react';

function Home () {
    return (

Hello World

    );
}

export default Home;

App.Js

import "./App.css";
import Sidebar from "./Components/Sidebar";
import {Route, BrowserRouter as Router} from "react-router-dom";
import Home from "./Components/Home";
import SignUp from "./Components/SignUpPage";

function App() {
  return (
    <Router>

      <Sidebar />

<Route path="/" component={Home}/>
<Route path="/SignUp" component={SignUp} />
    </Router> //surround app with router, and conditionally display pages based on what the user is on
  );
}

export default App;

Am I missing something?

Body:
In React router-dom v-6 they changed how you provide the component and more. This is the correct why now:

 import {BrowserRouter as Router, Routes, Route } from "react-router-dom";

 return(
        <Router>
            <Routes>
                <Route path="/" element={<Home/>}/>
            </Routes>
        </Router>
    );

Here is a video that show all the changes in the react-router-dom v-6 video.


问:
Cross tabulation of two variables with averages in R?
I have the following social network dataset where participants (ego) were asked who provided social, work, and care support in their lives. Those who provided support (alter) were classified according to their relationship with ego (circle) resulting in the following dataset:

```<code>ego    alter    circle    social    work   care
3400    3403      1         0         0     1
3400    3402      1         0         1     0
3400    3401      1         1         0     0
3500    3504      1         0         0     0
3500    3503      1         0         0     0
3500    3502      1         0         1     1
3500    3501      2         1         0     0
3600    3604      1         0         0     0
3600    3603      3         0         0     1
3600    3602      3         0         1     0
3600    3601      2         1         0     0
3700    3702      1         0         1     1
3700    3703      1         0         0     1
3700    3701      2         1         0     0
…
</code>```

So, for example, in row 1, alter 3403 of social circle 1, did not provide social or work support but provided care support for ego 3400.

My question for you all is: how can I cross tabulate the variable circle with each of the support variables (social, work, and care) and then calculate the averages with ego?

Below is the resulting cross tabulation with totals and percentages, but I need the averages taking into account each ego.

Crosstab result

Body:
I have the following social network dataset where participants (ego) were asked who provided social, work, and care support in their lives. Those who provided support (alter) were classified according to their relationship with ego (circle) resulting in the following dataset:

ego    alter    circle    social    work   care
3400    3403      1         0         0     1
3400    3402      1         0         1     0
3400    3401      1         1         0     0
3500    3504      1         0         0     0
3500    3503      1         0         0     0
3500    3502      1         0         1     1
3500    3501      2         1         0     0
3600    3604      1         0         0     0
3600    3603      3         0         0     1
3600    3602      3         0         1     0
3600    3601      2         1         0     0
3700    3702      1         0         1     1
3700    3703      1         0         0     1
3700    3701      2         1         0     0
…

So, for example, in row 1, alter 3403 of social circle 1, did not provide social or work support but provided care support for ego 3400.

My question for you all is: how can I cross tabulate the variable circle with each of the support variables (social, work, and care) and then calculate the averages with ego?

Below is the resulting cross tabulation with totals and percentages, but I need the averages taking into account each ego.

Crosstab result

Body:
First, reproducible data using dput():

social <- structure(list(ego = c(3400L, 3400L, 3400L, 3500L, 3500L, 3500L,
3500L, 3600L, 3600L, 3600L, 3600L, 3700L, 3700L, 3700L), alter = c(3403L,
3402L, 3401L, 3504L, 3503L, 3502L, 3501L, 3604L, 3603L, 3602L,
3601L, 3702L, 3703L, 3701L), circle = c(1L, 1L, 1L, 1L, 1L, 1L,
2L, 1L, 3L, 3L, 2L, 1L, 1L, 2L), social = c(0L, 0L, 1L, 0L, 0L,
0L, 1L, 0L, 0L, 0L, 1L, 0L, 0L, 1L), work = c(0L, 1L, 0L, 0L,
0L, 1L, 0L, 0L, 0L, 1L, 0L, 1L, 0L, 0L), care = c(1L, 0L, 0L,
0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 1L, 1L, 0L)), class = "data.frame", row.names = c(NA,
-14L))

Now, counts,

(tbl.count <- aggregate(cbind(social, work, care)~circle, social, sum))
#   circle social work care
# 1      1      1    3    4
# 2      2      3    0    0
# 3      3      0    1    1

and means,

(tbl.mean <- aggregate(cbind(social, work, care)~circle, social, mean))
#   circle    social      work      care
# 1      1 0.1111111 0.3333333 0.4444444
# 2      2 1.0000000 0.0000000 0.0000000
# 3      3 0.0000000 0.5000000 0.5000000

and percentages,

(tbl.pct <- aggregate(cbind(social, work, care)~circle, social, function(x) mean(x)*100))
#   circle    social     work     care
# 1      1  11.11111 33.33333 44.44444
# 2      2 100.00000  0.00000  0.00000
# 3      3   0.00000 50.00000 50.00000


问:
Run a script to parse YAML when React app compiles

My Problem

I have a ReactJS website that parses a JSON file (stored in the src folder) to render content. I recently attempted to use a YAML file instead because of YAML's richer abilities (supporting Markdown, for example).

Because React must load and parse YAML asynchronously, this change complicated my codebase and degraded my app's performance (e.g., content flickers).

My Plan

Instead of rewriting my components and slowing down my app, I've written a script to convert my YAML file into a JSON file. This way, I can have the best of both worlds: the richer abilities of YAML and the simple implementation of JSON.

My Question

What's the best way to make React run this script when the app is built? My web host rebuilds my app every time I push a change, so hopefully this can be activated via package.json or similar.

答:
My Solution

I solved the problem using js-yaml. I even found a way to make it work with Fast Refresh.

./src/[PATH]/yaml-convert.js:

```<code>const yaml = require('js-yaml');
const fs = require('fs');

const args = process.argv.slice(2);

switch (args[0]) {
  case 'watch':
    watch();
    break;
  default:
    convert();
}

function watch() {
  fs.watch('./src/[PATH]/myData.yaml', function (event, filename) {
    require('child_process').fork('./src/[PATH]/yaml-convert.js');
  });
}

function convert() {
  try {
    const json = yaml.load(fs.readFileSync('./src/[PATH]/myData.yaml', 'utf8'));
    fs.writeFileSync('./src/[PATH]/myData.json', JSON.stringify(json));
  } catch (e) {
    console.log(e);
  }
}
</code>```

package.json:
(note the -- watch argument and the single & in the dev command)

```<code>...
"scripts": {
  "start": "serve -s build",
  "dev": "npm run yaml-convert -- watch & react-scripts start",
  "build": "npm run yaml-convert && react-scripts build",
  "test": "react-scripts test",
  "eject": "react-scripts eject",
  "yaml-convert": "node ./src/[PATH]/yaml-convert.js"
}
...
</code>```

And to keep git diff tidy...

.gitattributes:

```<code>/src/[PATH]/myData.json -diff
</code>```

Body:
My Solution

I solved the problem using js-yaml. I even found a way to make it work with Fast Refresh.

./src/[PATH]/yaml-convert.js:

const yaml = require('js-yaml');
const fs = require('fs');

const args = process.argv.slice(2);

switch (args[0]) {
  case 'watch':
    watch();
    break;
  default:
    convert();
}

function watch() {
  fs.watch('./src/[PATH]/myData.yaml', function (event, filename) {
    require('child_process').fork('./src/[PATH]/yaml-convert.js');
  });
}

function convert() {
  try {
    const json = yaml.load(fs.readFileSync('./src/[PATH]/myData.yaml', 'utf8'));
    fs.writeFileSync('./src/[PATH]/myData.json', JSON.stringify(json));
  } catch (e) {
    console.log(e);
  }
}

package.json:
(note the -- watch argument and the single & in the dev command)

...
"scripts": {
  "start": "serve -s build",
  "dev": "npm run yaml-convert -- watch & react-scripts start",
  "build": "npm run yaml-convert && react-scripts build",
  "test": "react-scripts test",
  "eject": "react-scripts eject",
  "yaml-convert": "node ./src/[PATH]/yaml-convert.js"
}
...

And to keep git diff tidy...

.gitattributes:

/src/[PATH]/myData.json -diff


问:
Why my button click event handler doesn't get called?
I have created a RadGrid control dynamically on Page_PreInit event and added it to a place holder on the page. my RadGridBuilder class has a Build() method.

My RadGrid has a custom button which is added at the time of ItemCreated event which is called during building the RadGrid (Page_PreInit):

```<code>protected virtual void RdGridItemCreated(object sender, GridItemEventArgs e)
    {
        switch (e.Item.ItemType)
        {
            // other codes
            case GridItemType.CommandItem:
                {
                    var gridCommandItem = e.Item as GridCommandItem;

                    AddPdfButton(gridCommandItem);

                    break;
                }
        }
    }

private void AddPdfButton(GridCommandItem gridCommandItem)
    {
        var pdfButton = CreateExportToPdfButton();

        try
            {
                PageUtil.RegisterPostBackControl(pdfButton);

                // this is the cell which contains the export buttons.
                ((Table) gridCommandItem.Cells[0].Controls[0]).Rows[0].Cells[1].Controls.Add(pdfButton);

            }
            catch
            {
                // LOG the error silently
            }
        }
    }
 private Button CreateExportToPdfButton()
    {
        var result = new Button();
        result.ID = "btnExportToPdf";
        result.Click += ExportToPdfButtonClick;
        result.CssClass = "rgExpPDF";
        result.CommandName = "ExportToPdfCustomCommand";
        result.Attributes["title"] = "Export to Pdf";
        return result;
    }
private void ExportToPdfButtonClick(object sender, EventArgs e)
   {
        // custom code
   }
</code>```

The Pdf icon appears as expected on the RadGrid. When it is clicked, the post back happens (and the RadGrid is regenerated obviously on Page_PreInit again), however, the ExportToPdfButtonClick method is never called.

Why it is not called? how to fix it? it may be related to viewstate and control state?

Thanks

答:
Try binding this event on page_init or page_load as per

ASP.Net: why is my button's click/command events not binding/firing in a repeater?

http://forums.asp.net/t/1129248.aspx/1/10

Body:
I have created a RadGrid control dynamically on Page_PreInit event and added it to a place holder on the page. my RadGridBuilder class has a Build() method.

My RadGrid has a custom button which is added at the time of ItemCreated event which is called during building the RadGrid (Page_PreInit):

protected virtual void RdGridItemCreated(object sender, GridItemEventArgs e)
    {
        switch (e.Item.ItemType)
        {
            // other codes
            case GridItemType.CommandItem:
                {
                    var gridCommandItem = e.Item as GridCommandItem;

                    AddPdfButton(gridCommandItem);

                    break;
                }
        }
    }

private void AddPdfButton(GridCommandItem gridCommandItem)
    {
        var pdfButton = CreateExportToPdfButton();

        try
            {
                PageUtil.RegisterPostBackControl(pdfButton);

                // this is the cell which contains the export buttons.
                ((Table) gridCommandItem.Cells[0].Controls[0]).Rows[0].Cells[1].Controls.Add(pdfButton);

            }
            catch
            {
                // LOG the error silently
            }
        }
    }
 private Button CreateExportToPdfButton()
    {
        var result = new Button();
        result.ID = "btnExportToPdf";
        result.Click += ExportToPdfButtonClick;
        result.CssClass = "rgExpPDF";
        result.CommandName = "ExportToPdfCustomCommand";
        result.Attributes["title"] = "Export to Pdf";
        return result;
    }
private void ExportToPdfButtonClick(object sender, EventArgs e)
   {
        // custom code
   }

The Pdf icon appears as expected on the RadGrid. When it is clicked, the post back happens (and the RadGrid is regenerated obviously on Page_PreInit again), however, the ExportToPdfButtonClick method is never called.

Why it is not called? how to fix it? it may be related to viewstate and control state?

Thanks


问:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pictureResource'
Im working on a school project and decided to work with spring. I set it up myself for the first time myself and cant run it propperly now.

Im following this tutorial https://www.youtube.com/watch?v=Gx4iBLKLVHk and I did everything exactly the same. Atleast I think so. If someone needs more Information about the Project please contact me.

Thank you very much for your time.

My Model:

```<code>package ch.M306_LB.gallery.model;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

public class Picture {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(nullable = false, updatable = false)
    private Long id;
    private String description;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}
</code>```

My Service

```<code>package ch.M306_LB.gallery.service;

import ch.M306_LB.gallery.exception.UserNotFoundException;
import ch.M306_LB.gallery.model.Picture;
import ch.M306_LB.gallery.repo.PictureRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PictureService {
    private final PictureRepo pictureRepo;

    @Autowired
    public PictureService(PictureRepo pictureRepo) {
        this.pictureRepo = pictureRepo;
    }

    public Picture addPicture(Picture picture){
        return pictureRepo.save(picture);
    }

    public List<Picture> findAllPictures(){
        return pictureRepo.findAll();
    }

    public Picture updatePicture(Picture picture){
        return pictureRepo.save(picture);
    }

    public Picture findPictureById(Long id){
        return pictureRepo.findPictureById(id)
                .orElseThrow(() -> new UserNotFoundException("User by id " + id + " was not found"));
    }

    public void deletePicture(Long id){
        pictureRepo.deletePictureById(id);
    }
}
</code>```

My Repo:

```<code>package ch.M306_LB.gallery.repo;

import ch.M306_LB.gallery.model.Picture;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;

public interface PictureRepo extends JpaRepository<Picture, Long> {
    void deletePictureById(Long id);

    Optional<Picture> findPictureById(Long id);
}
</code>```

My Resource:

```<code>    package ch.M306_LB.gallery;

import ch.M306_LB.gallery.model.Picture;
import ch.M306_LB.gallery.service.PictureService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/picture")
public class PictureResource {
    private final PictureService pictureService;

    public PictureResource(PictureService pictureService) {
        this.pictureService = pictureService;
    }

    @GetMapping("/all")
    public ResponseEntity<List<Picture>> getAllPictures(){
        List<Picture> pictures = pictureService.findAllPictures();
        return new ResponseEntity<>(pictures, HttpStatus.OK);
    }

    @GetMapping("/find{id}")
    public ResponseEntity<Picture> getPictureById(@PathVariable("id") Long id){
        Picture picture = pictureService.findPictureById(id);
        return new ResponseEntity<>(picture, HttpStatus.OK);
    }

    @PostMapping("/add")
    public ResponseEntity<Picture> addPicture(@RequestBody Picture picture){
        Picture newPicture = pictureService.addPicture(picture);
        return new ResponseEntity<>(newPicture, HttpStatus.CREATED);
    }

    @PutMapping("/update")
    public ResponseEntity<Picture> updatePicture(@RequestBody Picture picture){
        Picture updatePicture = pictureService.updatePicture(picture);
        return new ResponseEntity<>(updatePicture, HttpStatus.OK);
    }

    @DeleteMapping("/delete/{id}")
    public ResponseEntity<?> deletePicture(@PathVariable("id") Long id){
        pictureService.deletePicture(id);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}
</code>```

Error Log:

```<code>Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-13 23:48:27.596 ERROR 11656 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pictureResource' defined in file [C:\Users\david\Desktop\BZZ\Workspace\Modul 152\LB\gallery\target\classes\ch\M306_LB\gallery\PictureResource.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pictureService' defined in file [C:\Users\david\Desktop\BZZ\Workspace\Modul 152\LB\gallery\target\classes\ch\M306_LB\gallery\service\PictureService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pictureRepo' defined in ch.M306_LB.gallery.repo.PictureRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class ch.M306_LB.gallery.model.Picture
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.6.3.jar:2.6.3]
    at ch.M306_LB.gallery.GalleryApplication.main(GalleryApplication.java:10) ~[classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pictureService' defined in file [C:\Users\david\Desktop\BZZ\Workspace\Modul 152\LB\gallery\target\classes\ch\M306_LB\gallery\service\PictureService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pictureRepo' defined in ch.M306_LB.gallery.repo.PictureRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class ch.M306_LB.gallery.model.Picture
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 19 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pictureRepo' defined in ch.M306_LB.gallery.repo.PictureRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class ch.M306_LB.gallery.model.Picture
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 33 common frames omitted
Caused by: java.lang.IllegalArgumentException: Not a managed type: class ch.M306_LB.gallery.model.Picture
    at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:582) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
    at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:85) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
    at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:75) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:232) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:181) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:164) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:75) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:324) ~[spring-data-commons-2.6.1.jar:2.6.1]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:322) ~[spring-data-commons-2.6.1.jar:2.6.1]
    at org.springframework.data.util.Lazy.getNullable(Lazy.java:230) ~[spring-data-commons-2.6.1.jar:2.6.1]
    at org.springframework.data.util.Lazy.get(Lazy.java:114) ~[spring-data-commons-2.6.1.jar:2.6.1]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:328) ~[spring-data-commons-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:144) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 44 common frames omitted

Process finished with exit code 1
</code>```

答:
I think you model class needs an entity annotation:</p>
```<code>@Entity
public class Picture {
</code>```

Body:
Im working on a school project and decided to work with spring. I set it up myself for the first time myself and cant run it propperly now.

Im following this tutorial https://www.youtube.com/watch?v=Gx4iBLKLVHk and I did everything exactly the same. Atleast I think so. If someone needs more Information about the Project please contact me.

Thank you very much for your time.

My Model:

package ch.M306_LB.gallery.model;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

public class Picture {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(nullable = false, updatable = false)
    private Long id;
    private String description;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }
}

My Service

package ch.M306_LB.gallery.service;

import ch.M306_LB.gallery.exception.UserNotFoundException;
import ch.M306_LB.gallery.model.Picture;
import ch.M306_LB.gallery.repo.PictureRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PictureService {
    private final PictureRepo pictureRepo;

    @Autowired
    public PictureService(PictureRepo pictureRepo) {
        this.pictureRepo = pictureRepo;
    }

    public Picture addPicture(Picture picture){
        return pictureRepo.save(picture);
    }

    public List<Picture> findAllPictures(){
        return pictureRepo.findAll();
    }

    public Picture updatePicture(Picture picture){
        return pictureRepo.save(picture);
    }

    public Picture findPictureById(Long id){
        return pictureRepo.findPictureById(id)
                .orElseThrow(() -> new UserNotFoundException("User by id " + id + " was not found"));
    }

    public void deletePicture(Long id){
        pictureRepo.deletePictureById(id);
    }
}

My Repo:

package ch.M306_LB.gallery.repo;

import ch.M306_LB.gallery.model.Picture;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.Optional;

public interface PictureRepo extends JpaRepository<Picture, Long> {
    void deletePictureById(Long id);

    Optional<Picture> findPictureById(Long id);
}

My Resource:

    package ch.M306_LB.gallery;

import ch.M306_LB.gallery.model.Picture;
import ch.M306_LB.gallery.service.PictureService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/picture")
public class PictureResource {
    private final PictureService pictureService;

    public PictureResource(PictureService pictureService) {
        this.pictureService = pictureService;
    }

    @GetMapping("/all")
    public ResponseEntity<List<Picture>> getAllPictures(){
        List<Picture> pictures = pictureService.findAllPictures();
        return new ResponseEntity<>(pictures, HttpStatus.OK);
    }

    @GetMapping("/find{id}")
    public ResponseEntity<Picture> getPictureById(@PathVariable("id") Long id){
        Picture picture = pictureService.findPictureById(id);
        return new ResponseEntity<>(picture, HttpStatus.OK);
    }

    @PostMapping("/add")
    public ResponseEntity<Picture> addPicture(@RequestBody Picture picture){
        Picture newPicture = pictureService.addPicture(picture);
        return new ResponseEntity<>(newPicture, HttpStatus.CREATED);
    }

    @PutMapping("/update")
    public ResponseEntity<Picture> updatePicture(@RequestBody Picture picture){
        Picture updatePicture = pictureService.updatePicture(picture);
        return new ResponseEntity<>(updatePicture, HttpStatus.OK);
    }

    @DeleteMapping("/delete/{id}")
    public ResponseEntity<?> deletePicture(@PathVariable("id") Long id){
        pictureService.deletePicture(id);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}

Error Log:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-13 23:48:27.596 ERROR 11656 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pictureResource' defined in file [C:\Users\david\Desktop\BZZ\Workspace\Modul 152\LB\gallery\target\classes\ch\M306_LB\gallery\PictureResource.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pictureService' defined in file [C:\Users\david\Desktop\BZZ\Workspace\Modul 152\LB\gallery\target\classes\ch\M306_LB\gallery\service\PictureService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pictureRepo' defined in ch.M306_LB.gallery.repo.PictureRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class ch.M306_LB.gallery.model.Picture
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.6.3.jar:2.6.3]
    at ch.M306_LB.gallery.GalleryApplication.main(GalleryApplication.java:10) ~[classes/:na]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'pictureService' defined in file [C:\Users\david\Desktop\BZZ\Workspace\Modul 152\LB\gallery\target\classes\ch\M306_LB\gallery\service\PictureService.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pictureRepo' defined in ch.M306_LB.gallery.repo.PictureRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class ch.M306_LB.gallery.model.Picture
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:229) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1372) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 19 common frames omitted
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'pictureRepo' defined in ch.M306_LB.gallery.repo.PictureRepo defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class ch.M306_LB.gallery.model.Picture
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1804) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:620) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1389) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1309) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 33 common frames omitted
Caused by: java.lang.IllegalArgumentException: Not a managed type: class ch.M306_LB.gallery.model.Picture
    at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:582) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
    at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:85) ~[hibernate-core-5.6.4.Final.jar:5.6.4.Final]
    at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:75) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:232) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:181) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:164) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:75) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:324) ~[spring-data-commons-2.6.1.jar:2.6.1]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:322) ~[spring-data-commons-2.6.1.jar:2.6.1]
    at org.springframework.data.util.Lazy.getNullable(Lazy.java:230) ~[spring-data-commons-2.6.1.jar:2.6.1]
    at org.springframework.data.util.Lazy.get(Lazy.java:114) ~[spring-data-commons-2.6.1.jar:2.6.1]
    at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:328) ~[spring-data-commons-2.6.1.jar:2.6.1]
    at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:144) ~[spring-data-jpa-2.6.1.jar:2.6.1]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1863) ~[spring-beans-5.3.15.jar:5.3.15]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800) ~[spring-beans-5.3.15.jar:5.3.15]
    ... 44 common frames omitted

Process finished with exit code 1

Body:
I think you model class needs an entity annotation:

@Entity
public class Picture {


问:
nginx ssl reverse proxy for wordpress docker wont load resources and css
recently i configured wordpress site with docker and it runs on port 8080 and then i configured nginx reverse proxy on host and it was totally fine.. but sooner after i added ssl site wont load itz css and i can not find the error</p>
```<code>    server {
  server_name mysite.com; # change this

  # global gzip on
#  gzip on;
#  gzip_min_length 10240;
#  gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
#  gzip_disable "MSIE [1-6]\.";

 # add_header Cache-Control public;

  location / {
    proxy_pass http://127.0.0.1:8080; # change this
    proxy_buffering on;
    proxy_buffers 12 12k;
    proxy_redirect off;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
  }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    if ($host = mysite.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

  listen 80;
  server_name mysite.com;
    return 404; # managed by Certbot
}

</code>```

答:
List your docker containers to get your instance name

```<code>sudo docker ps -a
</code>```

Access the wp-config.php on docker instance.

```<code># Access your instance files
sudo docker exec -i -t instance_name bash

# Install nano to edit files
apt install nano

nano wp-config.php
</code>```

Add following at top of wp-config.php

```<code>define('FORCE_SSL_ADMIN', true);

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false){
    $_SERVER['HTTPS'] = 'on';
    $_SERVER['SERVER_PORT'] = 443;
}
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
    $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}
</code>```

Add following at end of wp-config.php. Repalce example.com with your domain name

```<code>define('WP_HOME','https://example.com/');
define('WP_SITEURL','https://exampe.com/');
</code>```

In your nginx file ie /etc/nginx/sites-enabled/example.com, Ensure you have added proxy_set_header X-Forwarded-Proto https;

```<code>server {

    root /var/www/example.com;

    index index.html index.htm index.nginx-debian.html;

    server_name example.com www.example.com;

    location / {
            proxy_pass http://localhost:8000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header X-Forwarded-Proto https;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mazclan.otherside.co.ke/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mazclan.otherside.co.ke/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = www.mazclan.otherside.co.ke) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = mazclan.otherside.co.ke) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    server_name mazclan.otherside.co.ke www.mazclan.otherside.co.ke;
    listen 80;
    return 404; # managed by Certbot

}
</code>```

Now restart you docker instance

```<code>sudo docker restart instance_name
</code>```

Body:
recently i configured wordpress site with docker and it runs on port 8080 and then i configured nginx reverse proxy on host and it was totally fine.. but sooner after i added ssl site wont load itz css and i can not find the error

    server {
  server_name mysite.com; # change this

  # global gzip on
#  gzip on;
#  gzip_min_length 10240;
#  gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml;
#  gzip_disable "MSIE [1-6]\.";

 # add_header Cache-Control public;

  location / {
    proxy_pass http://127.0.0.1:8080; # change this
    proxy_buffering on;
    proxy_buffers 12 12k;
    proxy_redirect off;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
  }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

server {
    if ($host = mysite.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

  listen 80;
  server_name mysite.com;
    return 404; # managed by Certbot
}

Body:
List your docker containers to get your instance name

sudo docker ps -a

Access the wp-config.php on docker instance.

# Access your instance files
sudo docker exec -i -t instance_name bash

# Install nano to edit files
apt install nano

nano wp-config.php

Add following at top of wp-config.php

define('FORCE_SSL_ADMIN', true);

if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false){
    $_SERVER['HTTPS'] = 'on';
    $_SERVER['SERVER_PORT'] = 443;
}
if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
    $_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
}

Add following at end of wp-config.php. Repalce example.com with your domain name

define('WP_HOME','https://example.com/');
define('WP_SITEURL','https://exampe.com/');

In your nginx file ie /etc/nginx/sites-enabled/example.com, Ensure you have added proxy_set_header X-Forwarded-Proto https;

server {

    root /var/www/example.com;

    index index.html index.htm index.nginx-debian.html;

    server_name example.com www.example.com;

    location / {
            proxy_pass http://localhost:8000;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection 'upgrade';
            proxy_set_header Host $host;
            proxy_cache_bypass $http_upgrade;
            proxy_set_header X-Forwarded-Proto https;
    }

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/mazclan.otherside.co.ke/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/mazclan.otherside.co.ke/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = www.mazclan.otherside.co.ke) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    if ($host = mazclan.otherside.co.ke) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    server_name mazclan.otherside.co.ke www.mazclan.otherside.co.ke;
    listen 80;
    return 404; # managed by Certbot

}

Now restart you docker instance

sudo docker restart instance_name


问:
AWS docker image python lambda unable to access /tmp folder files
I have downloaded a file from s3 and stored to /tmp folder.

File1:(inside lambda_handler)

```<code>    print("connecting to s3 bucket")
    bucket_db_name = os.environ['BUCKET_DB']
    s3 = boto3.client('s3',
        aws_access_key_id=ACCESS_KEY,
        aws_secret_access_key=SECRET_KEY)

    print("Getting ready to download 'data.h5s' file to local")
    s3.download_file(bucket_db_name, 'data.h5s', '/tmp/data.h5s')
    print("file download complete")
</code>```

i am trying to access the same from another function.But it throws OSError.
File 2 present as part of docker image file ,

```<code>try:
    with pd.HDFStore('/tmp/data.h5s', 'r') as h5s:
        old_data = h5s['data']
        h5s.close()
except EnvironmentError as e:
    print ('dB file problem. \nError:',e)
</code>```

答:
Create the 'tmp' folder in your project and add the next line to your Dockerfile</p>
```<code>ADD tmp ${LAMBDA_TASK_ROOT}/tmp
</code>```

Body:
I have downloaded a file from s3 and stored to /tmp folder.

File1:(inside lambda_handler)

    print("connecting to s3 bucket")
    bucket_db_name = os.environ['BUCKET_DB']
    s3 = boto3.client('s3',
        aws_access_key_id=ACCESS_KEY,
        aws_secret_access_key=SECRET_KEY)

    print("Getting ready to download 'data.h5s' file to local")
    s3.download_file(bucket_db_name, 'data.h5s', '/tmp/data.h5s')
    print("file download complete")

i am trying to access the same from another function.But it throws OSError.
File 2 present as part of docker image file ,

try:
    with pd.HDFStore('/tmp/data.h5s', 'r') as h5s:
        old_data = h5s['data']
        h5s.close()
except EnvironmentError as e:
    print ('dB file problem. \nError:',e)

Body:
Create the 'tmp' folder in your project and add the next line to your Dockerfile

ADD tmp ${LAMBDA_TASK_ROOT}/tmp


问:
Pass parent attribute in metaclass
The metaclass is defined as below:

```<code>class MyMeta(type):
    def __new__(metacls, name, bases, namespace, **kwargs):
        # uses attribute a,b,c,d
        a = namespace["a"]
        b = namespace["b"]
        c = namespace["c"]
        d = namespace["d"]
        ...
        return super().__new__(metacls, name, bases, namespace, **kwargs)
</code>```

This metaclass uses attributes a, b, c, d.
Now classes can be created with this metaclass as:

```<code>class A(metaclass=MyMeta):
    a = "etc/dev"
    b = 2
    c = "c"
    d = "d"

class B(metaclass=MyMeta):
    a = "etc/dev/null"
    b = 2
    c = "c"
    d = "d"
</code>```

The attribute a is variable for each class.
I want to extract the constant attributes in a base class to avoid duplication:

```<code>class BaseClass:
    b = 2
    c = "c"
    d = "d"
</code>```

and create classes using the metaclass as:

```<code>class A(BaseClass, metaclass=MyMeta):
    a = "/etc/dev"

class B(BaseClass, metaclass=MyMeta):
    a = "/etc/dev/null"
</code>```

The metaclass complains that it can not find attribute b from parent class.

```<code>test_mode = namespace["b"]
KeyError: 'b'
</code>```

Is there a way to pass attributes from parent to a child metaclass ?

Constraint: Can not update the MyMeta metaclass as it's been borrowed/imported it from an existing library.

答:
No, you can't do what you want without changing the metaclass's behavior.

The problem is that the namespace argument that MyMeta.__new__ is looking in contains only the values defined in the class statement for the new class. It doesn't contain anything inherited, since the class and it's bases haven't been combined yet (that's what MyMeta.__new__ does when it calls super().__new__ at the bottom of its implementation, after it has done its thing with the a/b/c variables).

Title: Pass parent attribute in metaclass

Body:
The metaclass is defined as below:

class MyMeta(type):
    def __new__(metacls, name, bases, namespace, **kwargs):
        # uses attribute a,b,c,d
        a = namespace["a"]
        b = namespace["b"]
        c = namespace["c"]
        d = namespace["d"]
        ...
        return super().__new__(metacls, name, bases, namespace, **kwargs)

This metaclass uses attributes a, b, c, d.
Now classes can be created with this metaclass as:

class A(metaclass=MyMeta):
    a = "etc/dev"
    b = 2
    c = "c"
    d = "d"

class B(metaclass=MyMeta):
    a = "etc/dev/null"
    b = 2
    c = "c"
    d = "d"

The attribute a is variable for each class.
I want to extract the constant attributes in a base class to avoid duplication:

class BaseClass:
    b = 2
    c = "c"
    d = "d"

and create classes using the metaclass as:

class A(BaseClass, metaclass=MyMeta):
    a = "/etc/dev"

class B(BaseClass, metaclass=MyMeta):
    a = "/etc/dev/null"

The metaclass complains that it can not find attribute b from parent class.

test_mode = namespace["b"]
KeyError: 'b'

Is there a way to pass attributes from parent to a child metaclass ?

Constraint: Can not update the MyMeta metaclass as it's been borrowed/imported it from an existing library.


问:
Why replace in this code approves float numbers as numeric . I have tried floats without replace and I am getting message that it is not a number
```<code>#user inputs a number
number = input("Enter number: ")
# 1) changes dot and creates a new string,2) verifies is it a number
if(not number.replace(".","").isnumeric()):
    print("Sorry number is not numeric")
</code>```

Generally replace changes old value with a new one.

答:
```<code>number = input("Enter number: ")
if(not number.replace(".","").isnumeric()):
    print("Sorry number is not numeric")
</code>```

Replace here change dot, creates a new string and makes isnumeric() to be True for float numbers.

Body:
#user inputs a number
number = input("Enter number: ")
# 1) changes dot and creates a new string,2) verifies is it a number
if(not number.replace(".","").isnumeric()):
    print("Sorry number is not numeric")

Generally replace changes old value with a new one.

Body:
number = input("Enter number: ")
if(not number.replace(".","").isnumeric()):
    print("Sorry number is not numeric")

Replace here change dot, creates a new string and makes isnumeric() to be True for float numbers.


问:
Query large volume of data for web page display
I am new to Oracle (know some basic SQL), but the task is somehow assigned to me.

My task is to optimize a query. It joins some large tables (query is time consuming) and returns the result to a webpage (paging can be used).

My question is what direction should I look into? It would be better if links can be provided.

Here is some details:

Optimized methods taken

```<code>index on dayNum, timeNum, entityID columns
</code>```

Number of rows:

time_seq:  100,000

indicator_set: 50,000,000

tity amount: 1,000

Query:

```<code>select *
  from time_seq seq,
       (
        select entityID,
               dayNum,
               timeNum,
               sum(ind1) sum_ind1,
               avg(ind2) avg_ind2,
               max(ind3) max_ind3
          from indicator_set
         group by entityID, dayNum, timeNum
         -- the dayNum timeNum are grouped to the time sequence standard
         -- in time_seq table
        ) sum
where seq.entityID=sum.entityID
  and seq.dayNum=sum.dayNum
  and seq.timeNum=sum.timeNum
</code>```

Table time_seq

```<code>entityID, dayNum, timeNum
--------------------------------
object1, 20110818, 220000
object1, 20110818, 223000
object1, 20100818, 230000
object1, 20110819, 220000
object1, 20110819, 223000
object1, 20100819, 230000
object2, 20110818, 220000
object2, 20110818, 223000
object2, 20100818, 230000
object2, 20110819, 220000
object2, 20110819, 223000
object2, 20100819, 230000
</code>```

Table indicator_set

```<code>entityID, dayNum, timeNUm, ind1, ind2, ind3
--------------------------------------------
object1, 20110818, 220000, 23,34,23
object1, 20110818, 220500, 23,54,543
object1, 20110818, 220530, 23,54,543
object1, 20110818, 220610, 23,54,543
object1, 20110818, 222900, 23,54,543
...
</code>```

PS: sorry I didn't provide exact format/detail of the table and query. Just too complicated.

cheers~

答:
You can create a materialized view based on your query:

```<code>create materialized view mv as
select entityID,
               dayNum,
               timeNum,
               sum(ind1) sum_ind1,
               avg(ind2) avg_ind2,
               max(ind3) max_ind3
          from indicator_set
         group by entityID, dayNum, timeNum;
</code>```

This table would be smaller. You can create your indexes also in this materialized view. Your select would be something like this:

```<code>select *
  from time_seq seq,
      mv sum
where seq.entityID=sum.entityID
  and seq.dayNum=sum.dayNum
  and seq.timeNum=sum.timeNum;
</code>```

Your materialized view could be refresehed in fast mode, normal, etc... If you want some more intormation, take a look:
http://download.oracle.com/docs/cd/B13789_01/server.101/b10759/statements_6002.htm

http://orafaq.com/wiki/Oracle_Materialized_Views

Body:
I am new to Oracle (know some basic SQL), but the task is somehow assigned to me.

My task is to optimize a query. It joins some large tables (query is time consuming) and returns the result to a webpage (paging can be used).

My question is what direction should I look into? It would be better if links can be provided.

Here is some details:

Optimized methods taken

index on dayNum, timeNum, entityID columns

Number of rows:

time_seq:  100,000

indicator_set: 50,000,000

tity amount: 1,000

Query:

select *
  from time_seq seq,
       (
        select entityID,
               dayNum,
               timeNum,
               sum(ind1) sum_ind1,
               avg(ind2) avg_ind2,
               max(ind3) max_ind3
          from indicator_set
         group by entityID, dayNum, timeNum
         -- the dayNum timeNum are grouped to the time sequence standard
         -- in time_seq table
        ) sum
where seq.entityID=sum.entityID
  and seq.dayNum=sum.dayNum
  and seq.timeNum=sum.timeNum

Table time_seq

entityID, dayNum, timeNum
--------------------------------
object1, 20110818, 220000
object1, 20110818, 223000
object1, 20100818, 230000
object1, 20110819, 220000
object1, 20110819, 223000
object1, 20100819, 230000
object2, 20110818, 220000
object2, 20110818, 223000
object2, 20100818, 230000
object2, 20110819, 220000
object2, 20110819, 223000
object2, 20100819, 230000

Table indicator_set

entityID, dayNum, timeNUm, ind1, ind2, ind3
--------------------------------------------
object1, 20110818, 220000, 23,34,23
object1, 20110818, 220500, 23,54,543
object1, 20110818, 220530, 23,54,543
object1, 20110818, 220610, 23,54,543
object1, 20110818, 222900, 23,54,543
...

PS: sorry I didn't provide exact format/detail of the table and query. Just too complicated.

cheers~

Body:
You can create a materialized view based on your query:

create materialized view mv as
select entityID,
               dayNum,
               timeNum,
               sum(ind1) sum_ind1,
               avg(ind2) avg_ind2,
               max(ind3) max_ind3
          from indicator_set
         group by entityID, dayNum, timeNum;

This table would be smaller. You can create your indexes also in this materialized view. Your select would be something like this:

select *
  from time_seq seq,
      mv sum
where seq.entityID=sum.entityID
  and seq.dayNum=sum.dayNum
  and seq.timeNum=sum.timeNum;

Your materialized view could be refresehed in fast mode, normal, etc... If you want some more intormation, take a look:
http://download.oracle.com/docs/cd/B13789_01/server.101/b10759/statements_6002.htm

http://orafaq.com/wiki/Oracle_Materialized_Views