问:
OData Dynamic Model Self-Referencing Navigation Property "Max Level" Expansion
I am developing an OData Web API with dynamic models (no CLR-based types of any kind). Note that this concept is heavily predicated upon the ODataDynamicModel found on GitHub (https://github.com/OData/AspNetCoreOData/tree/main/sample/ODataDynamicModel). Contained within the dynamic model is a self-referencing navigation property named "Items". The OData CSDL is shown below.

```<code><edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
  <edmx:DataServices>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="ns">
      <EntityType Name="Item">
        <Key>
          <PropertyRef Name="ID"/>
        </Key>
        <Property Name="ID" Type="Edm.Int32"/>
        <Property Name="Name" Type="Edm.String"/>
        <NavigationProperty Name="Detail" Type="ns.Detail" ContainsTarget="true"/>
        **<NavigationProperty Name="Items" Type="Collection(ns.Item)" ContainsTarget="true"/>**
      </EntityType>
      <EntityType Name="Detail">
        <Key>
          <PropertyRef Name="ID"/>
        </Key>
        <Property Name="ID" Type="Edm.Int32"/>
        <Property Name="Description" Type="Edm.String"/>
      </EntityType>
      <EntityContainer Name="Default">
        <EntitySet Name="Items" EntityType="ns.Item"/>
        <EntitySet Name="Details" EntityType="ns.Detail"/>
      </EntityContainer>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>
</code>```

For testing purposes, my API is serving up a static data source so as to eliminate unnecessary complexities such as ORM, etc. I am able to query the data source via OData in its entirety when providing an explicit, fully-defined query string as shown below.

[GET]
http://localhost:4527/odata/ns/Items?$expand=Detail,Items($expand=Detail,Items($expand=Detail,Items($expand=Detail,Items($expand=Detail,Items($expand=Detail,Items)))))

Response:

```<code>{
    "@odata.context": "http://localhost:4527/odata/ns/$metadata#Items(Detail(),Items(Detail(),Items(Detail(),Items(Detail(),Items(Detail(),Items(Detail(),Items()))))))",
    "value": [
        {
            "ID": 1,
            "Name": "Item 1",
            "Detail": {
                "ID": 1,
                "Description": "Detail 1"
            },
            "Items": [
                {
                    "ID": 2,
                    "Name": "Item 2",
                    "Detail": {
                        "ID": 2,
                        "Description": "Detail 2"
                    },
                    "Items": [
                        {
                            "ID": 3,
                            "Name": "Item 3",
                            "Detail": {
                                "ID": 3,
                                "Description": "Detail 3"
                            },
                            "Items": [
                                {
                                    "ID": 4,
                                    "Name": "Item 4",
                                    "Detail": {
                                        "ID": 4,
                                        "Description": "Detail 4"
                                    },
                                    "Items": []
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}
</code>```

Retrieval of the same response payload fails when attempting to take advantage of OData's "levels" capabilities as shown below.

[GET]
http://localhost:4527/odata/ns/Items?$expand=Items($levels=10;$expand=Detail),Detail

Response:

```<code>{
    "@odata.context": "http://localhost:4527/odata/ns/$metadata#Items(Items(Detail()),Detail())",
    "value": [
        {
            "ID": 1,
            "Name": "Item 1",
            "Items": [
                {
                    "ID": 2,
                    "Name": "Item 2",
                    "Detail": {
                        "ID": 2,
                        "Description": "Detail 2"
                    }
                }
            ],
            "Detail": {
                "ID": 1,
                "Description": "Detail 1"
            }
        }
    ]
}
</code>```

I have tried many things without success and am currently stumped to say the least. I posted to the discussion board on Git (https://github.com/OData/AspNetCoreOData/discussions/789) but haven't received a response, which is to be expected this time of year. Attached to that discussion is a small zip file containing a working solution demonstrating the current approach. I'm hopeful that someone out there better versed in the ways of OData can point me in the proper direction. Any and all suggestions are appreciated!

Body:
I am developing an OData Web API with dynamic models (no CLR-based types of any kind). Note that this concept is heavily predicated upon the ODataDynamicModel found on GitHub (https://github.com/OData/AspNetCoreOData/tree/main/sample/ODataDynamicModel). Contained within the dynamic model is a self-referencing navigation property named "Items". The OData CSDL is shown below.

<edmx:Edmx xmlns:edmx="http://docs.oasis-open.org/odata/ns/edmx" Version="4.0">
  <edmx:DataServices>
    <Schema xmlns="http://docs.oasis-open.org/odata/ns/edm" Namespace="ns">
      <EntityType Name="Item">
        <Key>
          <PropertyRef Name="ID"/>
        </Key>
        <Property Name="ID" Type="Edm.Int32"/>
        <Property Name="Name" Type="Edm.String"/>
        <NavigationProperty Name="Detail" Type="ns.Detail" ContainsTarget="true"/>
        **<NavigationProperty Name="Items" Type="Collection(ns.Item)" ContainsTarget="true"/>**
      </EntityType>
      <EntityType Name="Detail">
        <Key>
          <PropertyRef Name="ID"/>
        </Key>
        <Property Name="ID" Type="Edm.Int32"/>
        <Property Name="Description" Type="Edm.String"/>
      </EntityType>
      <EntityContainer Name="Default">
        <EntitySet Name="Items" EntityType="ns.Item"/>
        <EntitySet Name="Details" EntityType="ns.Detail"/>
      </EntityContainer>
    </Schema>
  </edmx:DataServices>
</edmx:Edmx>

For testing purposes, my API is serving up a static data source so as to eliminate unnecessary complexities such as ORM, etc. I am able to query the data source via OData in its entirety when providing an explicit, fully-defined query string as shown below.

[GET]
http://localhost:4527/odata/ns/Items?$expand=Detail,Items($expand=Detail,Items($expand=Detail,Items($expand=Detail,Items($expand=Detail,Items($expand=Detail,Items)))))

Response:

{
    "@odata.context": "http://localhost:4527/odata/ns/$metadata#Items(Detail(),Items(Detail(),Items(Detail(),Items(Detail(),Items(Detail(),Items(Detail(),Items()))))))",
    "value": [
        {
            "ID": 1,
            "Name": "Item 1",
            "Detail": {
                "ID": 1,
                "Description": "Detail 1"
            },
            "Items": [
                {
                    "ID": 2,
                    "Name": "Item 2",
                    "Detail": {
                        "ID": 2,
                        "Description": "Detail 2"
                    },
                    "Items": [
                        {
                            "ID": 3,
                            "Name": "Item 3",
                            "Detail": {
                                "ID": 3,
                                "Description": "Detail 3"
                            },
                            "Items": [
                                {
                                    "ID": 4,
                                    "Name": "Item 4",
                                    "Detail": {
                                        "ID": 4,
                                        "Description": "Detail 4"
                                    },
                                    "Items": []
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

Retrieval of the same response payload fails when attempting to take advantage of OData's "levels" capabilities as shown below.

[GET]
http://localhost:4527/odata/ns/Items?$expand=Items($levels=10;$expand=Detail),Detail

Response:

{
    "@odata.context": "http://localhost:4527/odata/ns/$metadata#Items(Items(Detail()),Detail())",
    "value": [
        {
            "ID": 1,
            "Name": "Item 1",
            "Items": [
                {
                    "ID": 2,
                    "Name": "Item 2",
                    "Detail": {
                        "ID": 2,
                        "Description": "Detail 2"
                    }
                }
            ],
            "Detail": {
                "ID": 1,
                "Description": "Detail 1"
            }
        }
    ]
}

I have tried many things without success and am currently stumped to say the least. I posted to the discussion board on Git (https://github.com/OData/AspNetCoreOData/discussions/789) but haven't received a response, which is to be expected this time of year. Attached to that discussion is a small zip file containing a working solution demonstrating the current approach. I'm hopeful that someone out there better versed in the ways of OData can point me in the proper direction. Any and all suggestions are appreciated!


来源: stackexchange

问:
Is it possible to mock a module and all it's submodules in pytest at once?
I am trying to mock a module in pytest and have a lot of functions from that module imported like so:

```<code>from common.util import funct1, funct2, funct3
from common.shared.utils import some_funct
from common.public.utils import some_other_funct
</code>```

So far I have been using

```<code>sys.modules['common.util'] = MagicMock()
sys.modules['common.shared.utils'] = MagicMock()
sys.modules['common.public.utils'] = MagicMock()
</code>```

Is there a way to combine all these imports into one line?

ContentLicense: CC BY-SA 4.0

Body:
I am trying to mock a module in pytest and have a lot of functions from that module imported like so:

from common.util import funct1, funct2, funct3
from common.shared.utils import some_funct
from common.public.utils import some_other_funct

So far I have been using

sys.modules['common.util'] = MagicMock()
sys.modules['common.shared.utils'] = MagicMock()
sys.modules['common.public.utils'] = MagicMock()

Is there a way to combine all these imports into one line?


问:
Remove the rights of the child user after updating the parent
I use mongoose, and I need, in case the owner decided to stop paying for access to a certain brand (or tab, or type), for example, to remove it from a child.

Child Document

```<code>{
    "_id": {
      "$oid": "childId"
    },
    "firstName": "childname",
    "lastName": "childname",
    "email": "childmail@gmail.com",
    "password": "hashpass",
    "avatar": "avatar",
    "active": true,
    "grant": {
        "analytic": {
            "brands": true,
            "competition": true,
            "advanced": true,
            "settings": true
        },
        "entity": {
            "brands": [
                "62b602fab0513b08cbbc58cf",
                "5e2b64350abd833af61c8186"
            ],
            "competitors": [
                {
                    "competitors": [
                        "628cf4763b65341158242c97",
                        "5e2b64350abd833af61c8186",
                        "62226613937930680ce70de7"
                    ]
                },
                {
                    "competitors": [
                        "62226613937930680ce70de7",
                        "628cf4763b65341158242c97",
                        "62b602fab0513b08cbbc58cf"
                    ]
                }
            ],
            "categorys": [
                "5f31a884d318436258f1c1ef",
                "5e2081c80a44092668c29a47",
                "5e20856d0a44092668c29a48",
            ],
            "providers": [
                "5f52869819f2df47af4afafa",
                "5f5a4c51a030d76e5ed555f7",
                "5dc2aff3e820a760dd23f6af",
                "5f59200da030d76e5ed54e21",
            ],
            "types": [
                "structure",
                "point of interest"
            ],
            "limits": []
        },
        "user": {
            "historical_data": true,
            "allowAndUpdate": true
        }
    },
    "pId": {
      "$oid": "63add6ae1cf67918efa856c9"
    },
    "crdAt": {
      "$date": {
        "$numberLong": "1672337405101"
      }
    },
    "updAt": {
      "$date": {
        "$numberLong": "1672337405101"
      }
    },
    "__v": 0
  }
</code>```

Parent Document

```<code>{
  "_id": {
    "$oid": "parentId"
  },
  "firstName": "parentname",
  "lastName": "parentname",
  "email": "parentemail@gmail.com",
  "password": "hashpass",
  "avatar": "pass",
  "active": true,
  "grant": {
    "analytic": {
        "brands": true,
        "competition": false,
        "advanced": true,
        "settings": true
    },
    "entity": {
        "brands": [
            "62b602fab0513b08cbbc58cf",
            "5e2b64350abd833af61c8186"
        ],
        "competitors": [
            {
                "_id": "62b602fab0513b08cbbc58cf",
                "competitors": [
                    "628cf4763b65341158242c97",
                    "5e2b64350abd833af61c8186"
                ]
            },
            {
                "_id": "5e2b64350abd833af61c8186",
                "competitors": [
                    "62226613937930680ce70de7",
                    "628cf4763b65341158242c97",
                    "62b602fab0513b08cbbc58cf"
                ]
            }
        ],
        "categorys": [
            "5f31a884d318436258f1c1ef",
            "5e2081c80a44092668c29a47"
        ],
        "providers": [
            "5f52869819f2df47af4afafa",
            "5f5a4c51a030d76e5ed555f7",
            "5dc2aff3e820a760dd23f6af"
        ],
        "types": [
            "structure",
            "point of interest"
        ],
        "limits": []
    },
    "user": {
        "child_users": true,
        "historical_data": true,
        "allowAndUpdate": true
    }
  },
  "crdAt": {
    "$date": {
      "$numberLong": "1672337070171"
    }
  },
  "updAt": {
    "$date": {
      "$numberLong": "1672337107440"
    }
  },
  "__v": 0
}
</code>```

Both users (child and owner) have their objects with access stored in the database, and we need to subtract the owner object from the child object

the unset function in mongo is powerless here( I've been struggling with this problem for a week now

Body:
I use mongoose, and I need, in case the owner decided to stop paying for access to a certain brand (or tab, or type), for example, to remove it from a child.

Child Document

{
    "_id": {
      "$oid": "childId"
    },
    "firstName": "childname",
    "lastName": "childname",
    "email": "childmail@gmail.com",
    "password": "hashpass",
    "avatar": "avatar",
    "active": true,
    "grant": {
        "analytic": {
            "brands": true,
            "competition": true,
            "advanced": true,
            "settings": true
        },
        "entity": {
            "brands": [
                "62b602fab0513b08cbbc58cf",
                "5e2b64350abd833af61c8186"
            ],
            "competitors": [
                {
                    "competitors": [
                        "628cf4763b65341158242c97",
                        "5e2b64350abd833af61c8186",
                        "62226613937930680ce70de7"
                    ]
                },
                {
                    "competitors": [
                        "62226613937930680ce70de7",
                        "628cf4763b65341158242c97",
                        "62b602fab0513b08cbbc58cf"
                    ]
                }
            ],
            "categorys": [
                "5f31a884d318436258f1c1ef",
                "5e2081c80a44092668c29a47",
                "5e20856d0a44092668c29a48",
            ],
            "providers": [
                "5f52869819f2df47af4afafa",
                "5f5a4c51a030d76e5ed555f7",
                "5dc2aff3e820a760dd23f6af",
                "5f59200da030d76e5ed54e21",
            ],
            "types": [
                "structure",
                "point of interest"
            ],
            "limits": []
        },
        "user": {
            "historical_data": true,
            "allowAndUpdate": true
        }
    },
    "pId": {
      "$oid": "63add6ae1cf67918efa856c9"
    },
    "crdAt": {
      "$date": {
        "$numberLong": "1672337405101"
      }
    },
    "updAt": {
      "$date": {
        "$numberLong": "1672337405101"
      }
    },
    "__v": 0
  }

Parent Document

{
  "_id": {
    "$oid": "parentId"
  },
  "firstName": "parentname",
  "lastName": "parentname",
  "email": "parentemail@gmail.com",
  "password": "hashpass",
  "avatar": "pass",
  "active": true,
  "grant": {
    "analytic": {
        "brands": true,
        "competition": false,
        "advanced": true,
        "settings": true
    },
    "entity": {
        "brands": [
            "62b602fab0513b08cbbc58cf",
            "5e2b64350abd833af61c8186"
        ],
        "competitors": [
            {
                "_id": "62b602fab0513b08cbbc58cf",
                "competitors": [
                    "628cf4763b65341158242c97",
                    "5e2b64350abd833af61c8186"
                ]
            },
            {
                "_id": "5e2b64350abd833af61c8186",
                "competitors": [
                    "62226613937930680ce70de7",
                    "628cf4763b65341158242c97",
                    "62b602fab0513b08cbbc58cf"
                ]
            }
        ],
        "categorys": [
            "5f31a884d318436258f1c1ef",
            "5e2081c80a44092668c29a47"
        ],
        "providers": [
            "5f52869819f2df47af4afafa",
            "5f5a4c51a030d76e5ed555f7",
            "5dc2aff3e820a760dd23f6af"
        ],
        "types": [
            "structure",
            "point of interest"
        ],
        "limits": []
    },
    "user": {
        "child_users": true,
        "historical_data": true,
        "allowAndUpdate": true
    }
  },
  "crdAt": {
    "$date": {
      "$numberLong": "1672337070171"
    }
  },
  "updAt": {
    "$date": {
      "$numberLong": "1672337107440"
    }
  },
  "__v": 0
}

Both users (child and owner) have their objects with access stored in the database, and we need to subtract the owner object from the child object

the unset function in mongo is powerless here( I've been struggling with this problem for a week now


问:
Send messages from a BlockingQueue through a dynamically created web socket using Spring Integration
I have a SpringBoot application that also uses SpringIntegration to dynamically create web sockets upon requests that come from an Angular web application and send messages on that web sockets that are taken from a BlockingQueue.
I want those messages to be pushed on the web socket only when a message is available on the BlockingQueue, so without polling.
At the moment, my code looks like below, but it is very inefficient:

@Service
public class WebSocketPublisherService {

    @Autowired
    private IntegrationFlowContext integrationFlowContext;

    @Bean
    public HandshakeHandler handshakeHandler() {
        return new DefaultHandshakeHandler(new TomcatRequestUpgradeStrategy());
    }

    public void createWebSocket() {
        ServerWebSocketContainer serverWebSocketContainer = new ServerWebSocketContainer("/test")
            .setHandshakeHandler(handshakeHandler())
            .setAllowedOrigins("http://localhost:4200");
        serverWebSocketContainer.setMessageListener(...); // I want messages comming from the web application to be processed
        WebSocketOutboundMessageHandler webSocketOutboundMessageHandler = new WebSocketOutboundMessageHandler(serverWebSocketContainer);
        MethodInvokingMessageSource methodInvokingMessageSource = new MethodInvokingMessageSource();
        methodInvokingMessageSource.setObject(...);
        methodInvokingMessageSource.setMethodName(...);   // this method returns the element from the BlockingQueue, if it exists
        StandardIntegrationFlow standardIntegrationFlow = IntegrationFlow
            .from(methodInvokingMessageSource, polling -> polling.poller(pollerFactory -> pollerFactory.fixedRate(10)))
            .split(new DecorateMessageWithSessionId(serverWebSocketContainer))
            .handle(webSocketOutboundMessageHandler)
            .get();
        IntegrationFlowContext.IntegrationFlowRegistration flowRegistration = integrationFlowContext
            .registration(standardIntegrationFlow)
            .addBean(serverWebSocketContainer)
            .register();
        flowRegistration.start();
    }
}
```

Is there a smarter way of creating an IntegrationFlow using the content of a BlockingQueue (based on subscription and not polling)?

Body:
I have a SpringBoot application that also uses SpringIntegration to dynamically create web sockets upon requests that come from an Angular web application and send messages on that web sockets that are taken from a BlockingQueue.
I want those messages to be pushed on the web socket only when a message is available on the BlockingQueue, so without polling.
At the moment, my code looks like below, but it is very inefficient:

@Service
public class WebSocketPublisherService {

    @Autowired
    private IntegrationFlowContext integrationFlowContext;

    @Bean
    public HandshakeHandler handshakeHandler() {
        return new DefaultHandshakeHandler(new TomcatRequestUpgradeStrategy());
    }

    public void createWebSocket() {
        ServerWebSocketContainer serverWebSocketContainer = new ServerWebSocketContainer("/test")
            .setHandshakeHandler(handshakeHandler())
            .setAllowedOrigins("http://localhost:4200");
        serverWebSocketContainer.setMessageListener(...); // I want messages comming from the web application to be processed
        WebSocketOutboundMessageHandler webSocketOutboundMessageHandler = new WebSocketOutboundMessageHandler(serverWebSocketContainer);
        MethodInvokingMessageSource methodInvokingMessageSource = new MethodInvokingMessageSource();
        methodInvokingMessageSource.setObject(...);
        methodInvokingMessageSource.setMethodName(...);   // this method returns the element from the BlockingQueue, if it exists
        StandardIntegrationFlow standardIntegrationFlow = IntegrationFlow
            .from(methodInvokingMessageSource, polling -> polling.poller(pollerFactory -> pollerFactory.fixedRate(10)))
            .split(new DecorateMessageWithSessionId(serverWebSocketContainer))
            .handle(webSocketOutboundMessageHandler)
            .get();
        IntegrationFlowContext.IntegrationFlowRegistration flowRegistration = integrationFlowContext
            .registration(standardIntegrationFlow)
            .addBean(serverWebSocketContainer)
            .register();
        flowRegistration.start();
    }
}

Is there a smarter way of creating an IntegrationFlow using the content of a BlockingQueue (based on subscription and not polling)?


问:
Should a GitHub repository contain both the virtual environment and the environment.yaml file?
Good Afternoon,

Recently, I've created a project folder that shall be containing a virtual repository for certain libraries. An environment.yaml file can be utilize to set up this virtual repository if any other individual utilizing Conda would like to create it on their own local machine.

For me, to upload the project's folder along with the virtual environment through GitHub, would I need to include in the repository both the virtual environment folder AND the environment.yaml file that creates it?

For example:

The image above is inside the projects directory folder. Within you can see a folder called "front_end", which is the virtual environment and a yaml file called "front_end_venv", which is used to create the "front_end" virtual environment folder.

Would I need to include both files (virtual environment AND the Yaml file the creates it) into the same GitHub repository? The virtual environment folder will be containing some programmable code as well such as a GUI interface.

Thank you


问:
Which SLF4J logging dependency to use in a library
I am writing a tiny Java library and I want to know which of multiple SLF4J libraries to use, if I only want to add logging possibility to library and let end user choose logging framework type:

All I want is to be able to write log.debug() and log.error() across the code which mean to have SLF4J  bindings available.

Which dependency should I add to my library, there are a lot of things popping when one types SLF4J at https://mvnrepository.com


问:
Similarity score with penalty if it doesn't match a specific part
I have been working with KNN, Fuzzy Matching, and Neural networks to do similarity scoring and have run into an interesting problem. We are using it to match drug formulations and I have found that matching them leads to false confidence in specific scenarios:

```<code>User Entered: oral Doxy 100mg tablet per tablet
Highest Similarity (False Positive): Amox 100mg per tablet oral tablet
True Positive:Doxycyline Hyclate 100 mg per tablet oral tablet
</code>```

This is getting matched together because the 2nd part of the terms match, but the amox and doxy don't match. I have tried TF-IDF (with all the different hyper-parameters), CountVectorizer, and even boosting counts, but I have found it very hard to achieve even 75% accuracy.

Are there any known algorithms or maybe techniques to allow me to down-weight similarity if, for example, amox does not match in the 2nd form? I have the ability to identify the drug easily (amox vs doxy), but how to get that downweighting if amox is not in the network.  What I am trying to avoid is a requirement to scan through all formulations every time I try to find a match and create a custom filtering process where.  I was hoping to embed a penalty matrix of some sort into the matching.  The preference is to have a False Negative instead of a False Positive.

Body:
I have been working with KNN, Fuzzy Matching, and Neural networks to do similarity scoring and have run into an interesting problem. We are using it to match drug formulations and I have found that matching them leads to false confidence in specific scenarios:

User Entered: oral Doxy 100mg tablet per tablet
Highest Similarity (False Positive): Amox 100mg per tablet oral tablet
True Positive:Doxycyline Hyclate 100 mg per tablet oral tablet

This is getting matched together because the 2nd part of the terms match, but the amox and doxy don't match. I have tried TF-IDF (with all the different hyper-parameters), CountVectorizer, and even boosting counts, but I have found it very hard to achieve even 75% accuracy.

Are there any known algorithms or maybe techniques to allow me to down-weight similarity if, for example, amox does not match in the 2nd form? I have the ability to identify the drug easily (amox vs doxy), but how to get that downweighting if amox is not in the network.  What I am trying to avoid is a requirement to scan through all formulations every time I try to find a match and create a custom filtering process where.  I was hoping to embed a penalty matrix of some sort into the matching.  The preference is to have a False Negative instead of a False Positive.


问:
Flask Application Port exposure: NGINX config
I have a running flask application which is catering to rest calls by another application using specific port an endpoints.
I want to configure nginx for the application with gunicorn(existing) to tackle DOS and **gunicorn freezing **due to the same.

However I do not want to hide the port. I other words. If we hit the IP:port/ then only we should be able to access the application endpoint, because there are some other applications already running on the ip on some ports which are the calling the application on different port.

Hence I do not want to hit XX.YY.ZZ.AA and get routed to XX.YY.ZZ.AA:5000.
Rather I want to reach XX.YY.ZZ.AA:5000 only if I hit XX.YY.ZZ.AA:5000.

I could not find a way to do the same as I see nginx mostly in context of port masking and reverse proxy.
Please help !!!


问:
Is this layout possible without subgrid and without repeating hardcoded values?
I have the layout in this sandbox. The requirements are that the "Title Text", "More Options" and "Search" areas are fixed at the top of the screen and do not move when scrolling, that "Title Text" and "Search" are aligned together, and that the container height of these two is a controlled hardcoded value (53px). Below the sticky headers there should be two columns of normal content flow, as shown in the sandbox.

I am using grid as such:

```<code>grid-template:
    ". header-main  header-right  ." 53px
    ". header-main  content-right ." auto
    ". content-main content-right ." auto
    / 0.5fr 1fr 1fr 0.5fr;
</code>```

"Title Text" and "More Options" are both grouped under a div which has header-main as its grid area, like this:

```<code><div class="HeaderMain">
    <div class="Wrapper">
      <h2>Title text</h2>
    </div>
    <div>More Options</div>
    <div>More Options</div>
    <div>More Options</div>
    <div>More Options</div>
    <div>More Options</div>
    <div>More Options</div>
  </div>
</code>```

"Search" is under a div that has header-right as its grid area. I give sticky properties to header-right and header-main.

For the final requirement, to have "Title Text" aligned with "Search", I wrap "Title Text" in a Wrapper div, and give it the same height of the row, 53px. Both Wrapper and HeaderRight have display: flex; align-items: center; for vertical alignment.

This works fine, but my issue is that I need to repeat the hardcoded value 53px in two places. Of  course I can put it in a css variable, but I am wondering if there is a cleaner solution.

In this sandbox (firefox only), I solve it using a subgrid, and the 53px manages to appear only once, but support for subgrid is minimal.

Body:
I have the layout in this sandbox. The requirements are that the "Title Text", "More Options" and "Search" areas are fixed at the top of the screen and do not move when scrolling, that "Title Text" and "Search" are aligned together, and that the container height of these two is a controlled hardcoded value (53px). Below the sticky headers there should be two columns of normal content flow, as shown in the sandbox.

I am using grid as such:

grid-template:
    ". header-main  header-right  ." 53px
    ". header-main  content-right ." auto
    ". content-main content-right ." auto
    / 0.5fr 1fr 1fr 0.5fr;

"Title Text" and "More Options" are both grouped under a div which has header-main as its grid area, like this:

Title text

More Options

More Options

More Options

More Options

More Options

More Options

"Search" is under a div that has header-right as its grid area. I give sticky properties to header-right and header-main.

For the final requirement, to have "Title Text" aligned with "Search", I wrap "Title Text" in a Wrapper div, and give it the same height of the row, 53px. Both Wrapper and HeaderRight have display: flex; align-items: center; for vertical alignment.

This works fine, but my issue is that I need to repeat the hardcoded value 53px in two places. Of  course I can put it in a css variable, but I am wondering if there is a cleaner solution.

In this sandbox (firefox only), I solve it using a subgrid, and the 53px manages to appear only once, but support for subgrid is minimal.


问:
Annotation with Custom Callout icon
I'm trying to show a custom icon on rightCalloutAccessoryView

I tried the codes below but it didn't work.

```<code>let iconButton = UIButton(type: .system)
iconButton.setImage(UIImage(named: "test.png"), for: .normal)
pinView?.rightCalloutAccessoryView = iconButton
</code>```

Is it possible to add a custom png icon to Callout button ?

Edit : When I changed the button type with .detailDisclosure it worked.

```<code>let iconButton = UIButton(type: .detailDisclosure)
iconButton.setImage(UIImage(named: "test.png"), for: .normal)
pinView?.rightCalloutAccessoryView = iconButton
</code>```

Title: Annotation with Custom Callout icon

Body:
I'm trying to show a custom icon on rightCalloutAccessoryView

I tried the codes below but it didn't work.

let iconButton = UIButton(type: .system)
iconButton.setImage(UIImage(named: "test.png"), for: .normal)
pinView?.rightCalloutAccessoryView = iconButton

Is it possible to add a custom png icon to Callout button ?

Edit : When I changed the button type with .detailDisclosure it worked.

let iconButton = UIButton(type: .detailDisclosure)
iconButton.setImage(UIImage(named: "test.png"), for: .normal)
pinView?.rightCalloutAccessoryView = iconButton


问:
Is there way to stretch image to the end of the slider (swiper) in opencart 3.0+?
In my website I want to stretch the image to the end of the slider or change these the white vertical bars to orange color ?

The other option is to remove them..

Is there a way to get a solution to this as I have been trying all day to remove the white elements from the sides of the images.


问:
I am facing problem react with Tailwind-css
```<code>

ERROR in ./src/index.css (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-loader/dist/cjs.js!./src/index.css)

Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):

</code>```

please solve this. I am stack for a day

Body:
ERROR in ./src/index.css (./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[1].oneOf[5].use[2]!./node_modules/source-map-loader/dist/cjs.js!./src/index.css)

Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):

please solve this. I am stack for a day


问:
Pause Materialized Views from Refreshing temporarily on Postgres
I have a table in Postgres that needs to have a column data type changed from float to numeric(10,2). However, there are 17 materialized views that have been created on this table by different owners, and I need to make sure that the materialized views are not refreshed while I make the change.

Is there a way to temporarily pause the materialized views from refreshing on Postgres, so that I can make the change to the table without breaking the views?

I am using AWS Aurora Postgresql v9.3


问:
how to create new column with comparison between columns of different dataframes in R?
I'm having some difficulty in R and I don't know how I can do this. I have an excel spreadsheet and I'm developing a script in R, and I'm stuck in a part where I need to do something like a VLOOKUP, but in R, how could I do that?

Objective: I have two dataframes, one called "tb_consolidada" and "tbGEMOR", and both have a column with this name "R2500_PPNCOD", I need you to create a new column in the df "tb_consolidada" and make a comparison between the two columns, and what he finds equal he returns, if not returns empty.

Obstacle: How could it be done, would using Lef_join be ideal? I'll leave a script of how I tried it.

```<code># Grouping tbs
tb_consolidada <- bind_rows(goals1, goals2)
View(tb_consolidated)

# Remove column R1900_CTCCHVCONTA
tb_consolidada$R1900_CTCCHVCONTA <- NULL

#Remove duplicate lines from column PPNCOD
consolidated_tb <- consolidated_tb[!duplicated(consolidated_tb$R2500_PPNCOD), ]

# Sort column from largest to largest (descending order)
tb_consolidada <- tb_consolidada[order(tb_consolidada$R1900_CCSDATLIQ, decreasing = TRUE), ]

#Create tbGEMOR (Last Consolidated tb containing all data)
tbGEMOR<- read.xlsx("C:/Users/AlaxAtaide/Desktop/Metas/Redirecionamento_05122022_26122022v3_enviar.xlsx", sheet = 1)
View(tbGEMOR)

#Creating check column (does it exist?)

VLOOKUP <- left_join(tb_consolidada, tbGEMOR, by='R2500_PPNCOD')
</code>```

Body:
I'm having some difficulty in R and I don't know how I can do this. I have an excel spreadsheet and I'm developing a script in R, and I'm stuck in a part where I need to do something like a VLOOKUP, but in R, how could I do that?

Objective: I have two dataframes, one called "tb_consolidada" and "tbGEMOR", and both have a column with this name "R2500_PPNCOD", I need you to create a new column in the df "tb_consolidada" and make a comparison between the two columns, and what he finds equal he returns, if not returns empty.

Obstacle: How could it be done, would using Lef_join be ideal? I'll leave a script of how I tried it.

# Grouping tbs
tb_consolidada <- bind_rows(goals1, goals2)
View(tb_consolidated)

# Remove column R1900_CTCCHVCONTA
tb_consolidada$R1900_CTCCHVCONTA <- NULL

#Remove duplicate lines from column PPNCOD
consolidated_tb <- consolidated_tb[!duplicated(consolidated_tb$R2500_PPNCOD), ]

# Sort column from largest to largest (descending order)
tb_consolidada <- tb_consolidada[order(tb_consolidada$R1900_CCSDATLIQ, decreasing = TRUE), ]

#Create tbGEMOR (Last Consolidated tb containing all data)
tbGEMOR<- read.xlsx("C:/Users/AlaxAtaide/Desktop/Metas/Redirecionamento_05122022_26122022v3_enviar.xlsx", sheet = 1)
View(tbGEMOR)

#Creating check column (does it exist?)

VLOOKUP <- left_join(tb_consolidada, tbGEMOR, by='R2500_PPNCOD')


问:
Migrating to Azure CLU services from soon to be deprecated LUIS - recognizing a 'gather number' intent
The LUIS way of doing things, we were able to specify a 'pattern' and get the intents with 100% confidence.  And we are trying to get to the same confidence level with the new CLU service.  We migrated to CLU from LUIS - but the 'patterns' data got lost in migration as they are not supported in the CLU services.

We are trying to achieve the same with the new CLU service, with a project that would model a 'gather any number' intent.

Attached is a JSON file of the project the we have been trying out with.  Trying to get the model to recognize the intent with 100% confidence.  But it is not recognizing the intent correctly.

Our goal is to recognize any of the following phrases as a 'gather_number' intent with 100% confidence.
The entity value is recognized with 100% accuracy fine.  But the intent is not as shown in the 'Actual intent confidence' below.

Any thoughts on what could be done for training the model to get to 100% in all scenarios for 'Actual intent confidence'?

With CLU, here are the findings:

Input
Intent
myNumber entity value
Expected Intent Confidence
Actual intent confidence

1
gather_number
1
100%
67.33%

100
gather_number
100
100%
100%

its 100
gather_number
100
100%
100%

its 3212.44
gather_number
3212.44
100%
65.18%

willing to give 383.22
gather_number
383.22
100%
62.24%

dummy text
None
No entities predicted
100%
67.30%

blah
None
No entities predicted
100%
100%

200 may be
None
No entities predicted
100%
76.86%

Here is the exported CLU project JSON:

{
    "projectFileVersion": "2022-10-01-preview",
    "stringIndexType": "Utf16CodeUnit",
    "metadata": {
        "projectKind": "Conversation",
        "settings": {
            "confidenceThreshold": 0
        },
        "projectName": "TestNumbers",
        "multilingual": false,
        "description": "Testing any number",
        "language": "en-us"
    },
    "assets": {
        "projectKind": "Conversation",
        "intents": [
            {
                "category": "None"
            },
            {
                "category": "gather_number"
            }
        ],
        "entities": [
            {
                "category": "mynumber",
                "compositionSetting": "combineComponents",
                "prebuilts": [
                    {
                        "category": "Quantity.Number"
                    }
                ]
            }
        ],
        "utterances": [
            {
                "text": "oh k 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "take 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "100 now 200 later",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "only 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "100 only",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [
                    {
                        "category": "mynumber",
                        "offset": 0,
                        "length": 3
                    }
                ],
                "dataset": "Train"
            },
            {
                "text": "this time 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "no 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "yes 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "for now 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "great 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "its 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "it is 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "ok 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "how about 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "got to pay 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            },
            {
                "text": "my number is 100",
                "language": "en-us",
                "intent": "gather_number",
                "entities": [],
                "dataset": "Train"
            }
        ]
    }
}```


问:
Unable to cast object of type 'System.Management.Automation.PSObject' to type 'System.Array'
Using the SCClient Powershell module, I'm trying to install an individual update from a list of updates in the Software Center.

I can create a variable like this:

$ids = Get-SCCLientPendingUpdate *server* | select-object updateid

and $ids will output something like:

UpdateID
--------
Site_siteid/SUM_446bbb5d-743f-486c-94dc-61c3dce48e75
Site_siteid/SUM_f444ac52-95a6-4a47-95bb-51c2694120fb
Site_siteid/SUM_426ce60a-8e6e-4c8d-ae46-a1329b0b6b2c
```
<p>When I try to run the following:</p>
<p><code>Start-SCClientInstallUpdates *server* -updateid $ids[0]</code></p>
<p>I get an error stating:</p>
```MethodInvocationException: Exception calling "InstallUpdates" with "1" argument(s): "Unable to cast object of type 'System.Management.Automation.PSObject' to type 'System.Array'."
```

Not sure of a good way to deal with this, I was thinking of assigning each updateID to its own variable as a string, but there is no information that I could find to accomplish this and seems a little clunky anyways.  [string]$ids[0] outputs this:

@{UpdateID=Site_siteid/SUM_446bbb5d-743f-486c-94dc-61c3dce48e75}

I'm assuming this is part of the problem, but I can't figure out how to remove the "extra" stuff from it being an array, or how to save the original variable ($ids) differently.  I can reference a variable with -updateid $var if the variable is saved like this:

$var = "Site_siteid/SUM_446bbb5d-743f-486c-94dc-61c3dce48e75"

Maybe I'm going about this wrong or missing something simple I'm not sure, but I can't find this error anywhere online and the few things I tried to convert it to a string seems to still reference the thing as an array, so I don't know what I'm missing.

I've tried:
[string]$ids[0] $ids[0].updateid

setting $ids[0] to its own variable (same error as before)

$idarray = $ids | foreach {"$($_.UpdateID)"} and then using $idarray for the -updateid (same error, unable to cast object...to type 'system.array')

enclosing the variable in quotes ( -updateid "$ids[0]" , "$idarray" , etc.)

Body:
Using the SCClient Powershell module, I'm trying to install an individual update from a list of updates in the Software Center.

I can create a variable like this:

$ids = Get-SCCLientPendingUpdate *server* | select-object updateid

and $ids will output something like:

UpdateID
--------
Site_siteid/SUM_446bbb5d-743f-486c-94dc-61c3dce48e75
Site_siteid/SUM_f444ac52-95a6-4a47-95bb-51c2694120fb
Site_siteid/SUM_426ce60a-8e6e-4c8d-ae46-a1329b0b6b2c

When I try to run the following:

Start-SCClientInstallUpdates *server* -updateid $ids[0]

I get an error stating:

MethodInvocationException: Exception calling "InstallUpdates" with "1" argument(s): "Unable to cast object of type 'System.Management.Automation.PSObject' to type 'System.Array'."

Not sure of a good way to deal with this, I was thinking of assigning each updateID to its own variable as a string, but there is no information that I could find to accomplish this and seems a little clunky anyways.  [string]$ids[0] outputs this:

@{UpdateID=Site_siteid/SUM_446bbb5d-743f-486c-94dc-61c3dce48e75}

I'm assuming this is part of the problem, but I can't figure out how to remove the "extra" stuff from it being an array, or how to save the original variable ($ids) differently.  I can reference a variable with -updateid $var if the variable is saved like this:

$var = "Site_siteid/SUM_446bbb5d-743f-486c-94dc-61c3dce48e75"

Maybe I'm going about this wrong or missing something simple I'm not sure, but I can't find this error anywhere online and the few things I tried to convert it to a string seems to still reference the thing as an array, so I don't know what I'm missing.

I've tried:
[string]$ids[0] $ids[0].updateid

setting $ids[0] to its own variable (same error as before)

$idarray = $ids | foreach {"$($_.UpdateID)"} and then using $idarray for the -updateid (same error, unable to cast object...to type 'system.array')

enclosing the variable in quotes ( -updateid "$ids[0]" , "$idarray" , etc.)


问:
React Native related Question I have asked
How to Access two different state elements in nested flatlist. If mean for outter flatlist there is another element and for inner there is another.

I just asked question


问:
Odoo v8 How to show full size list view in a m2m search
I have a this field in Odoo

```<code>third_check_ids = fields.Many2many('account.third.check', 'third_check_voucher_rel',
'dest_voucher_id', 'third_check_id', 'Third Checks', readonly=True,
states={'draft': [('readonly', False)]})
</code>```

It's being showed just like this

My problem now happens when I need to select the checks from "Add an item"

The list of checks looks like this and I need to see the full list with all the fields. How can achieve this?

This is my XML code

```<code><field name="third_check_ids" string="Third Checks" nolabel="1" colspan="4"
  domain="[('state', '=', 'wallet')]">
      <tree string="Third Checks">
          <field name="number"/>
          <field name="source_partner_id"/>
          <field name="issue_date"/>
          <field name="payment_date"/>
          <field name="bank_id"/>
          <field name="origin"/>
          <field name="amount" sum="Total"/>
          <field name="state" invisible="1"/>
      </tree>
   </field>
</code>```

Body:
I have a this field in Odoo

third_check_ids = fields.Many2many('account.third.check', 'third_check_voucher_rel',
'dest_voucher_id', 'third_check_id', 'Third Checks', readonly=True,
states={'draft': [('readonly', False)]})

It's being showed just like this

My problem now happens when I need to select the checks from "Add an item"

The list of checks looks like this and I need to see the full list with all the fields. How can achieve this?

This is my XML code

<field name="third_check_ids" string="Third Checks" nolabel="1" colspan="4"
  domain="[('state', '=', 'wallet')]">
      <tree string="Third Checks">
          <field name="number"/>
          <field name="source_partner_id"/>
          <field name="issue_date"/>
          <field name="payment_date"/>
          <field name="bank_id"/>
          <field name="origin"/>
          <field name="amount" sum="Total"/>
          <field name="state" invisible="1"/>
      </tree>
   </field>


问:
how to return an image from the clipboard in Maui?
The Clipboard class in MAUI is very thin compared to the similar class in WPF,
It can uses just to return text,
how can you return an image from the clipboard in MAUI?

editor.Text += await Clipboard.Default.GetTextAsync()

Using the Clipboard class I was able to return only text,
Unable to get a picture


问:
why am I unable to open a new activity?
I am making an app and I cannot figure out how to open one activity from another....
I have a button and when clicked, I want it to open another activity, but it is not working.
In my home.kt file, I have:

```<code>val button3 = findViewById<Button>(R.id.button3)
button3.setOnClickListener {
    val Intent = Intent(this, muse_pick_duration::class.java)
    startActivity(Intent)
}
</code>```

My current activity is muse_home and the activity I want to open with button3 is pick_duration. This is how I registered them in my manifest file:

button 3 is the button's id and I want it to open the muse_pick_duration activity.

Does anyone know what's wrong with this?

Title: why am I unable to open a new activity?

Body:
I am making an app and I cannot figure out how to open one activity from another....
I have a button and when clicked, I want it to open another activity, but it is not working.
In my home.kt file, I have:

val button3 = findViewById<Button>(R.id.button3)
button3.setOnClickListener {
    val Intent = Intent(this, muse_pick_duration::class.java)
    startActivity(Intent)
}

My current activity is muse_home and the activity I want to open with button3 is pick_duration. This is how I registered them in my manifest file:

button 3 is the button's id and I want it to open the muse_pick_duration activity.

Does anyone know what's wrong with this?


问:
Why Stateful bean is showing the opposite behavior
I am getting different instances (on clicking Test then going back and repeating) of the Demo. I was expecting the same instance. Can someone explain what I am missing here?

Bean

```<code>@Stateful
@LocalBean
public class Demo {
    public Demo() {
    }
}
</code>```

Service

```<code>@Path("/")
public class Services {
    @EJB
    Demo demo;

    @POST
    @Produces(MediaType.APPLICATION_JSON)
    @Path("Testing")
    public Response testing(){
        return Response.ok(demo.hashCode()).build();
    }
}
</code>```

Body:
I am getting different instances (on clicking Test then going back and repeating) of the Demo. I was expecting the same instance. Can someone explain what I am missing here?

Bean

@Stateful
@LocalBean
public class Demo {
    public Demo() {
    }
}

Service

@Path("/")
public class Services {
    @EJB
    Demo demo;

    @POST
    @Produces(MediaType.APPLICATION_JSON)
    @Path("Testing")
    public Response testing(){
        return Response.ok(demo.hashCode()).build();
    }
}


问:
Adding Node.js server to laradock
I have a simple node.js microservice doing some important asynchronous tasks. I am trying to dockerize one of my laravel apps using laradock now I also want to add that microservice in laradock. I am very new to docker and cant figure out what I have to do.

I have tried adding a separate node.js container. But it's not working.

in my docker-compose.yml I added another service: like

```<code>### NODEJS ##############################################
nodejs:
  build:
    context: ./nodejs
    args:
      - LARADOCK_NODE_VERSION=${NODE_VERSION}
  volumes:
    - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}
  expose:
    - "3000-3010"
  extra_hosts:
    - "dockerhost:${DOCKER_HOST_IP}"
  environment:
    - TZ=${NODE_TZ}
  depends_on:
    - workspace
  networks:
    - frontend
    - backend
</code>```

inside my nodejs folder there is a dockerfile:

```<code>ARG LARADOCK_NODE_VERSION=latest
FROM node:${LARADOCK_NODE_VERSION}-alpine

LABEL maintainer="Huadong Zuo <admin@zuohuadong.cn>"

RUN apk --no-cache add tzdata ca-certificates && npm install pm2@latest -g

WORKDIR /var/www/hotelszone_node_partner

EXPOSE 3000-3010

CMD ["pm2-runtime", "node","hello.js"]
</code>```

my nginx config

```<code>#server {
 #    listen 80;
 #    server_name node.com.co;
 #    return 301 https://node.com.co$request_uri;
 #}

server {

  listen 80;
  listen [::]:80;

  #listen 443;
  #listen [::]:443;

  server_name node_partner_app.test;

  #ssl on;
  #ssl_certificate /var/certs/node.com.co/cert.pem;
  #ssl_certificate_key /var/certs/node.com.co/privkey.pem;
  #ssl_protocols       SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  #ssl_ciphers         HIGH:!aNULL:!MD5;

location / {
    proxy_pass http://node_partner_app.test:3003;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_cache_bypass $http_upgrade;
}

location ~ /\.ht {
    deny all;
}

location /.well-known/acme-challenge/ {
    root /var/www/letsencrypt/;
    log_not_found off;
}

    error_log /var/log/nginx/node.com.co.local_error.log;
    access_log /var/log/nginx/node.com.co.local_access.log;
}
</code>```

I am trying to make my main laravel app send a request to the node app like simple get requests.

Title: Adding Node.js server to laradock

Body:
I have a simple node.js microservice doing some important asynchronous tasks. I am trying to dockerize one of my laravel apps using laradock now I also want to add that microservice in laradock. I am very new to docker and cant figure out what I have to do.

I have tried adding a separate node.js container. But it's not working.

in my docker-compose.yml I added another service: like

### NODEJS ##############################################
nodejs:
  build:
    context: ./nodejs
    args:
      - LARADOCK_NODE_VERSION=${NODE_VERSION}
  volumes:
    - ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}
  expose:
    - "3000-3010"
  extra_hosts:
    - "dockerhost:${DOCKER_HOST_IP}"
  environment:
    - TZ=${NODE_TZ}
  depends_on:
    - workspace
  networks:
    - frontend
    - backend

inside my nodejs folder there is a dockerfile:

ARG LARADOCK_NODE_VERSION=latest
FROM node:${LARADOCK_NODE_VERSION}-alpine

LABEL maintainer="Huadong Zuo <admin@zuohuadong.cn>"

RUN apk --no-cache add tzdata ca-certificates && npm install pm2@latest -g

WORKDIR /var/www/hotelszone_node_partner

EXPOSE 3000-3010

CMD ["pm2-runtime", "node","hello.js"]

my nginx config

#server {
 #    listen 80;
 #    server_name node.com.co;
 #    return 301 https://node.com.co$request_uri;
 #}

server {

  listen 80;
  listen [::]:80;

  #listen 443;
  #listen [::]:443;

  server_name node_partner_app.test;

  #ssl on;
  #ssl_certificate /var/certs/node.com.co/cert.pem;
  #ssl_certificate_key /var/certs/node.com.co/privkey.pem;
  #ssl_protocols       SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  #ssl_ciphers         HIGH:!aNULL:!MD5;

location / {
    proxy_pass http://node_partner_app.test:3003;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_cache_bypass $http_upgrade;
}

location ~ /\.ht {
    deny all;
}

location /.well-known/acme-challenge/ {
    root /var/www/letsencrypt/;
    log_not_found off;
}

    error_log /var/log/nginx/node.com.co.local_error.log;
    access_log /var/log/nginx/node.com.co.local_access.log;
}

I am trying to make my main laravel app send a request to the node app like simple get requests.


问:
How do I timeout (fail) unscheduled DagRuns?
My setup:

There is a scheduled DAG (mother) that triggers and waits for many other unscheduled DAGs (children) using TriggerDagRunOperator + ExternalTaskSensor

What I want to do:

All tasks retry indefinitely until timeout (e.g. retry=99)

ALL tasks need to fail at a specific time (2 pm).

Any clue on what's the best way to do this? Im on 1.10 but I might upgrade.

What I've tried:

sla at DAG level: doesn't work because it doesn't actually fail the DAG, it just throws an alert.

dagrun_timeout at DAG level: only works on the mother DAG. the other DAGs are unscheduled and the dagrun_timeout parameter doesn't work for unscheduled DAGs.

execution_timeout at task level: it's only working for the first task execution, but not for retries. e.g. if i set execution_timeout for 2min, and the tasks takes 2min+, it will fail. But the next retry of this same task will run normally.


问:
AzMan Audit Logs
Good afternoon!

Is there a way to activate an audit trail in AzMan that allows the identification of the changes that were performed in the application (creation/deletion/changes in access rights)?

I tryed to research audit logs for AzMan and notes that there are logs for the monitoring of the access to the tool and to changes in the Security policies, but did not find anything related to the question above.

Thanks in advance!

Title: AzMan Audit Logs


问:
Load and display text file in javascript without user input
I need to pass the name of a file with querystring and use it to load and display tat file. I want to do it without user input.

I have tried the following to automatically fill in an input-file field (which works) but then I want to use tat input to display the text. I have tried calling a separate function to do that but it doesn't work. My code:

```<code><html>
  <head>
    <title>reading file</title>
   </head>
<body>
<input type="file" onchange="previewFile()" />
<input name="Button1" type="button" value="button" onclick="previewFile()"/>
<script>
    const filename = "textfile.txt" // simulate a querystring
    // Get a reference to our file input
    const fileInput = document.querySelector('input[type="file"]');

    // Create a new File object
    const myFile = new File(['Hello World!'], filename, {
        type: 'text/plain',
        lastModified: new Date(),
    });

    // Now let's create a DataTransfer to get a FileList
    const dataTransfer = new DataTransfer();
    dataTransfer.items.add(myFile);
    fileInput.files = dataTransfer.files;
    previewFile();

</script>
<script>
function previewFile() {
  const content = document.querySelector('.content');
  const [file] = document.querySelector('input[type=file]').file;
  const reader = new FileReader();

  if (file) {
    reader.readAsText(file);
  }
}

</script>
  </body>
</html>
</code>```

Body:
I need to pass the name of a file with querystring and use it to load and display tat file. I want to do it without user input.

I have tried the following to automatically fill in an input-file field (which works) but then I want to use tat input to display the text. I have tried calling a separate function to do that but it doesn't work. My code:

    <title>reading file</title>

<input type="file" onchange="previewFile()" />
<input name="Button1" type="button" value="button" onclick="previewFile()"/>


问:
How can I show a placeholder if there are two characters?
How can I show a placeholder "Enter Your Phone Number" if the input has two characters "+1"?

Example without a placeholder:

I'm using the "react-phone-input-2" library where I choose the "countryCodeEditable" option to not remove the country code.

```<code> <PhoneInput
    country={'us'}
    value={this.state.phone}
    onChange={phone => this.setState({ phone })}
    countryCodeEditable={false}
    name={"phone"}
    placeholder={"Enter Your Phone Number"}
   />
</code>```

Body:
How can I show a placeholder "Enter Your Phone Number" if the input has two characters "+1"?

Example without a placeholder:

I'm using the "react-phone-input-2" library where I choose the "countryCodeEditable" option to not remove the country code.

 <PhoneInput
    country={'us'}
    value={this.state.phone}
    onChange={phone => this.setState({ phone })}
    countryCodeEditable={false}
    name={"phone"}
    placeholder={"Enter Your Phone Number"}
   />


问:
C dup2 pipe delay with stdout, how to fix?
I can't figure out how to get rid of a delay, it seems like a buffering delay but I havent had any luck with setvbuf or fflush...

I have a c/c++ program that executes a python script which immediately starts printing to stdout (quite a bit), however there seems to be a huge delay when I try to read that input in my program.  I have tried to include a basic version of what I am doing below.  In the output I see TEST0 immediately and then after quite some time I get a huge dump of prints....  I tried setvbuff but that didnt seem to make a difference.  I think either I am doing something wrong or just not understanding what's happening.

Update: I am running in Linux.
Update2: fixed code typo with multiple forks
Update3: Adding stdout flushes in the python script fixed the problem, no more delays!  Thanks @DavidGrayson

```<code>int pipeFd[2];
pid_t pid;
char buff[PATH_MAX];
std::string path = "/user/bin/python3";
std::string script = "";//use path to python script here
std::string args = ""; //use args for python script here
  pid = fork();
  if( pid == -1)
  {
    printf( "[ERROR] cant fork\n" );
  }
  else if( pid == 0 )
  {
    close( pipeFd[0] );
    dup2( pipeFd[1], STDOUT_FILENO);
    close( pipeFd[1] );
    execl(path.c_str(), "python3", script.c_str(), args.c_str(), (char*)NULL );
    printf( "[ERROR] script execl failed\n" );
    exit(1);
  }
  else
  {
    //setvbuf(stdout, NULL, _IONBF, 0);
    //setvbuf(stdin, NULL, _IONBF, 0);
    printf( "TEST0\n" );
    fflush(stdout);
    //it takes a really long time to see this next print
    read( pipeFd[0], buff, 1 );
    printf( "TEST1:%c\n", buff[0] );
    fflush(stdout);

  }
</code>```

Body:
I can't figure out how to get rid of a delay, it seems like a buffering delay but I havent had any luck with setvbuf or fflush...

I have a c/c++ program that executes a python script which immediately starts printing to stdout (quite a bit), however there seems to be a huge delay when I try to read that input in my program.  I have tried to include a basic version of what I am doing below.  In the output I see TEST0 immediately and then after quite some time I get a huge dump of prints....  I tried setvbuff but that didnt seem to make a difference.  I think either I am doing something wrong or just not understanding what's happening.

Update: I am running in Linux.
Update2: fixed code typo with multiple forks
Update3: Adding stdout flushes in the python script fixed the problem, no more delays!  Thanks @DavidGrayson

int pipeFd[2];
pid_t pid;
char buff[PATH_MAX];
std::string path = "/user/bin/python3";
std::string script = "";//use path to python script here
std::string args = ""; //use args for python script here
  pid = fork();
  if( pid == -1)
  {
    printf( "[ERROR] cant fork\n" );
  }
  else if( pid == 0 )
  {
    close( pipeFd[0] );
    dup2( pipeFd[1], STDOUT_FILENO);
    close( pipeFd[1] );
    execl(path.c_str(), "python3", script.c_str(), args.c_str(), (char*)NULL );
    printf( "[ERROR] script execl failed\n" );
    exit(1);
  }
  else
  {
    //setvbuf(stdout, NULL, _IONBF, 0);
    //setvbuf(stdin, NULL, _IONBF, 0);
    printf( "TEST0\n" );
    fflush(stdout);
    //it takes a really long time to see this next print
    read( pipeFd[0], buff, 1 );
    printf( "TEST1:%c\n", buff[0] );
    fflush(stdout);

  }


问:
r - Error in fda::Data2fd ((a01[1] <= arng[1]) && (arng[2] <= a01[2])) { : missing value where TRUE/FALSE needed
I wrote the following code in R

```<code>library(fda)

n_curves <- 15951
n_points <- 2537

argvals <- matrix(df_l$Time, nrow = n_points, ncol = n_curves)
y_mat <- matrix(df_l$Curve, nrow = n_points, ncol = n_curves)

W.obj <- Data2fd(argvals = argvals, y = y_mat, basisobj = basis, lambda = 0.5)
</code>```

But I'm getting an error

```<code>Error in if ((a01[1] <= arng[1]) && (arng[2] <= a01[2])) { :
  missing value where TRUE/FALSE needed
</code>```

What does it mean, and how do I prevent it?

I'm using a repeated measures data, and I`m trying to do functional data analysis.My data has a lot of missing values(NA). I'm thinking that NA is probably the cause of something.

data:

```<code>> dput(head(df_l, 30))
structure(list(Time = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30), Curve = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 5, 10, 10, 10, 10, 8, 8, 8, 8,
8, 8)), row.names = c(NA, 30L), class = "data.frame")

> dput(head(basis, 5))
list(call = basisfd(type = type, rangeval = rangeval, nbasis = nbasis,
    params = params, dropind = dropind, quadvals = quadvals,
    values = values, basisvalues = basisvalues), type = "bspline",
    rangeval = c(0, 2537), nbasis = 53, params = c(50.74, 101.48,
    152.22, 202.96, 253.7, 304.44, 355.18, 405.92, 456.66, 507.4,
    558.14, 608.88, 659.62, 710.36, 761.1, 811.84, 862.58, 913.32,
    964.06, 1014.8, 1065.54, 1116.28, 1167.02, 1217.76, 1268.5,
    1319.24, 1369.98, 1420.72, 1471.46, 1522.2, 1572.94, 1623.68,
    1674.42, 1725.16, 1775.9, 1826.64, 1877.38, 1928.12, 1978.86,
    2029.6, 2080.34, 2131.08, 2181.82, 2232.56, 2283.3, 2334.04,
    2384.78, 2435.52, 2486.26))
</code>```

Body:
I wrote the following code in R

library(fda)

n_curves <- 15951
n_points <- 2537

argvals <- matrix(df_l$Time, nrow = n_points, ncol = n_curves)
y_mat <- matrix(df_l$Curve, nrow = n_points, ncol = n_curves)

W.obj <- Data2fd(argvals = argvals, y = y_mat, basisobj = basis, lambda = 0.5)

But I'm getting an error

Error in if ((a01[1] <= arng[1]) && (arng[2] <= a01[2])) { :
  missing value where TRUE/FALSE needed

What does it mean, and how do I prevent it?

I'm using a repeated measures data, and I`m trying to do functional data analysis.My data has a lot of missing values(NA). I'm thinking that NA is probably the cause of something.

data:

> dput(head(df_l, 30))
structure(list(Time = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
29, 30), Curve = c(NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, 5, 10, 10, 10, 10, 8, 8, 8, 8,
8, 8)), row.names = c(NA, 30L), class = "data.frame")

> dput(head(basis, 5))
list(call = basisfd(type = type, rangeval = rangeval, nbasis = nbasis,
    params = params, dropind = dropind, quadvals = quadvals,
    values = values, basisvalues = basisvalues), type = "bspline",
    rangeval = c(0, 2537), nbasis = 53, params = c(50.74, 101.48,
    152.22, 202.96, 253.7, 304.44, 355.18, 405.92, 456.66, 507.4,
    558.14, 608.88, 659.62, 710.36, 761.1, 811.84, 862.58, 913.32,
    964.06, 1014.8, 1065.54, 1116.28, 1167.02, 1217.76, 1268.5,
    1319.24, 1369.98, 1420.72, 1471.46, 1522.2, 1572.94, 1623.68,
    1674.42, 1725.16, 1775.9, 1826.64, 1877.38, 1928.12, 1978.86,
    2029.6, 2080.34, 2131.08, 2181.82, 2232.56, 2283.3, 2334.04,
    2384.78, 2435.52, 2486.26))


问:
How to keep ascii art intact when using it inside React projects
I want to use the following art:

```<code>     _.---._    /\\
    ./'       "--`\//
  ./              o \
 /./\  )______   \__ \
./  / /\ \   | \ \  \ \
   / /  \ \  | |\ \  \7
    "     "    "  "        VK
</code>```

In react I am doing the following:

```<code>const x = String.raw`
  _.---._    /\\
  ./'       "--`\//
./              o \
/./\  )______   \__ \
./  / /\ \   | \ \  \ \
 / /  \ \  | |\ \  \7
  "     "    "  "        VK`
</code>```

I have also tried using the  tag but most of those characters are appearing as errors

EDIT:
so this does not get deleted I am explicitly mentioning that I am using some different assets from that website, alot of them do not work when you just copy past because they appear as errors in the ide, I am using VSCode. Yes for some I can just copy paste the thing and its fine, for others it does not work

Body:
I want to use the following art:

     _.---._    /\\
    ./'       "--`\//
  ./              o \
 /./\  )______   \__ \
./  / /\ \   | \ \  \ \
   / /  \ \  | |\ \  \7
    "     "    "  "        VK

In react I am doing the following:

const x = String.raw`
  _.---._    /\\
  ./'       "--`\//
./              o \
/./\  )______   \__ \
./  / /\ \   | \ \  \ \
 / /  \ \  | |\ \  \7
  "     "    "  "        VK`

I have also tried using the  tag but most of those characters are appearing as errors

EDIT:
so this does not get deleted I am explicitly mentioning that I am using some different assets from that website, alot of them do not work when you just copy past because they appear as errors in the ide, I am using VSCode. Yes for some I can just copy paste the thing and its fine, for others it does not work


问:
How to verify the authenticity of packages when using: “sudo apt install [package name here]”
I am specifically trying to install a command in order to burn to a dvd (on tails OS). I am wondering how I can verify terminal commands that I install with sudo apt install. For example I need to be able to use the command growisofs and also genisoimage but it seems like I am just trusting that the download of these two commands is safe, when something could be malicious, so is there a way to verify them?

I noticed when I ran sudo apt install growisofs it said that I only needed the growisofs_7.1-14+b1_amd64.deb package. It also said it was pulling from tor+https://deb.debian.org/debian bullseye/main amd64 growisofs amd64 7.1-14+b1. This made me wonder if there is a debian public key and detached signature of this file or a signed file with sha hashes?

I tried using the debian 11 signing key that would be used to verify a debian11 OS iso but didn't find an .sig or .asc detachted signature files for growisofs_7.1-14+b1_amd64.deb


问:
Prerendering Angular Material Themes?
If we want to prerender our own Angular Material themes such that they can be packaged and delivered via CDN how would be go about this?</p>

Title: Prerendering Angular Material Themes?


问:
org.apache.hadoop.hive.metastore.HiveMetaException: Unknown version specified for initialization: 3.1.0
I finally resolved so many issues, just to run into the following issue. I have absolutely no idea why this error is occurring at the moment. If someone can spot the issue here, please let me know.

```<code>$ schematool -dbType derby -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/apache/apache-hive-3.1.3-bin/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/hadoop-3.3.4/share/hadoop/common/lib/slf4j-reload4j-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:        jdbc:derby:;databaseName=metastore_db;create=true
Metastore Connection Driver :    org.apache.derby.jdbc.EmbeddedDriver
Metastore connection User:       APP
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
Underlying cause: java.sql.SQLException : Failed to start database 'metastore_db' with class loader sun.misc.Launcher$AppClassLoader@6a5fc7f7, see the next exception for details.
SQL Error code: 40000
Use --verbose for detailed stacktrace.
*** schemaTool failed ***
</code>```

With --verbose:

```<code>$ schematool -dbType derby -initSchema --verbose
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/apache/apache-hive-3.1.3-bin/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/hadoop-3.3.4/share/hadoop/common/lib/slf4j-reload4j-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:        jdbc:derby://localhost:1527/metastore_db;create=true
Metastore Connection Driver :    org.apache.derby.jdbc.ClientDriver
Metastore connection User:       APP
Starting metastore schema initialization to 3.1.0
org.apache.hadoop.hive.metastore.HiveMetaException: Unknown version specified for initialization: 3.1.0
org.apache.hadoop.hive.metastore.HiveMetaException: Unknown version specified for initialization: 3.1.0
        at org.apache.hadoop.hive.metastore.MetaStoreSchemaInfo.generateInitFileName(MetaStoreSchemaInfo.java:137)
        at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:585)
        at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:567)
        at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1517)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:323)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:236)
*** schemaTool failed ***
</code>```

Body:
I finally resolved so many issues, just to run into the following issue. I have absolutely no idea why this error is occurring at the moment. If someone can spot the issue here, please let me know.

$ schematool -dbType derby -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/apache/apache-hive-3.1.3-bin/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/hadoop-3.3.4/share/hadoop/common/lib/slf4j-reload4j-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:        jdbc:derby:;databaseName=metastore_db;create=true
Metastore Connection Driver :    org.apache.derby.jdbc.EmbeddedDriver
Metastore connection User:       APP
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
Underlying cause: java.sql.SQLException : Failed to start database 'metastore_db' with class loader sun.misc.Launcher$AppClassLoader@6a5fc7f7, see the next exception for details.
SQL Error code: 40000
Use --verbose for detailed stacktrace.
*** schemaTool failed ***

With --verbose:

$ schematool -dbType derby -initSchema --verbose
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/apache/apache-hive-3.1.3-bin/lib/log4j-slf4j-impl-2.17.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/hadoop-3.3.4/share/hadoop/common/lib/slf4j-reload4j-1.7.36.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:        jdbc:derby://localhost:1527/metastore_db;create=true
Metastore Connection Driver :    org.apache.derby.jdbc.ClientDriver
Metastore connection User:       APP
Starting metastore schema initialization to 3.1.0
org.apache.hadoop.hive.metastore.HiveMetaException: Unknown version specified for initialization: 3.1.0
org.apache.hadoop.hive.metastore.HiveMetaException: Unknown version specified for initialization: 3.1.0
        at org.apache.hadoop.hive.metastore.MetaStoreSchemaInfo.generateInitFileName(MetaStoreSchemaInfo.java:137)
        at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:585)
        at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:567)
        at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1517)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.hadoop.util.RunJar.run(RunJar.java:323)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:236)
*** schemaTool failed ***


问:
Self-signed SLL certificate for Nextcloud Onion: "ERR_SSL_PROTOCOL_ERROR"

Context

After setting up a self-hosted nextcloud server on Ubuntu 22.10 over a tor domain, I created a self-signed SLL certificate using the script below:

Code

This script first

generates the certificate authority (CA) and SSL certificates, and then it adds the CA private key to: "/usr/local/share/ca-certificates/$ca_public_key_filename" and reloads the trusted ca certificates with:

sudo update-ca-certificates
```
<ul>
<li>It also adds the SSL prublic and private key and the full chain certificate into Nextcloud.</li>
<li>The <code>fullchain.pem</code> consists of the SSL certificate, followed by the CA certificate.</li>
</ul>
<pre class="lang-bash prettyprint-override"><code>#!/usr/bin/env bash
# Here is the list of certificates and their description:
# First you create your own certificate authority.
CA_PRIVATE_KEY_FILENAME="ca-key.pem"
CA_PUBLIC_KEY_FILENAME="ca.pem"
# Same file as ca.pem except different file extension and content.
CA_PUBLIC_CERT_FILENAME="ca.crt"

# Then you create a SSL certificate.
SSL_PRIVATE_KEY_FILENAME="cert-key.pem"

# Then create a sign-request (for your own CA to sign your own SSL certificate)
CA_SIGN_SSL_CERT_REQUEST_FILENAME="cert.csr"
SIGNED_DOMAINS_FILENAME="extfile.cnf"

# Then create the signed public SSL cert.
SSL_PUBLIC_KEY_FILENAME="cert.pem"

# Then merge the CA and SLL cert into one.
MERGED_CA_SSL_CERT_FILENAME="fullchain.pem"

setup_tor_ssl() {
  local onion_address="$1"

  # Create domains accepted by certificate.
  local domains
  #domains="DNS:$onion_address,IP:127.0.0.1"
  #domains="DNS:localhost,IP:$onion_address" # IP onion does not work
  #domains="DNS:*.$onion_address" # Does not work.
  #domains="DNS:$onion_address" # Does not work.
  domains="DNS:localhost,DNS:$onion_address" # Works for localhost
  echo "domains=$domains.end_without_space"

  delete_target_files

  # Generate and apply certificate.
  generate_ca_cert "$CA_PRIVATE_KEY_FILENAME" "$CA_PUBLIC_KEY_FILENAME"
  generate_ssl_certificate "$CA_PUBLIC_KEY_FILENAME" "$CA_PRIVATE_KEY_FILENAME" "$CA_SIGN_SSL_CERT_REQUEST_FILENAME" "$SIGNED_DOMAINS_FILENAME" "$SSL_PUBLIC_KEY_FILENAME" "$SSL_PRIVATE_KEY_FILENAME" "$domains"

  verify_certificates "$CA_PUBLIC_KEY_FILENAME" "$SSL_PUBLIC_KEY_FILENAME"

  merge_ca_and_ssl_certs "$SSL_PUBLIC_KEY_FILENAME" "$CA_PUBLIC_KEY_FILENAME" "$MERGED_CA_SSL_CERT_FILENAME"

  install_the_ca_cert_as_a_trusted_root_ca "$CA_PUBLIC_KEY_FILENAME" "$CA_PUBLIC_CERT_FILENAME"

  add_certs_to_nextcloud "$SSL_PUBLIC_KEY_FILENAME" "$SSL_PRIVATE_KEY_FILENAME" "$MERGED_CA_SSL_CERT_FILENAME"
}

generate_ca_cert() {
  local ca_private_key_filename="$1"
  local ca_public_key_filename="$2"

  # Generate RSA
  openssl genrsa -aes256 -out "$ca_private_key_filename" 4096

  # Generate a public CA Cert
  openssl req -new -x509 -sha256 -days 365 -key "$ca_private_key_filename" -out "$ca_public_key_filename"
}

generate_ssl_certificate() {
  local ca_public_key_filename="$1"
  local ca_private_key_filename="$2"
  local ca_sign_ssl_cert_request_filename="$3"
  local signed_domains_filename="$4"
  local ssl_public_key_filename="$5"
  local ssl_private_key_filename="$6"
  local domains="$7"
  # Example supported domains:
  # DNS:your-dns.record,IP:257.10.10.1

  # Create a RSA key
  openssl genrsa -out "$ssl_private_key_filename" 4096

  # Create a Certificate Signing Request (CSR)
  openssl req -new -sha256 -subj "/CN=yourcn" -key "$ssl_private_key_filename" -out "$ca_sign_ssl_cert_request_filename"

  # Create a `extfile` with all the alternative names
  echo "subjectAltName=$domains" >>"$signed_domains_filename"

  # optional
  #echo extendedKeyUsage = serverAuth >> "$ca_sign_ssl_cert_request_filename"

  # Create the public SSL certificate.
  openssl x509 -req -sha256 -days 365 -in "$ca_sign_ssl_cert_request_filename" -CA "$ca_public_key_filename" -CAkey "$ca_private_key_filename" -out "$ssl_public_key_filename" -extfile "$signed_domains_filename" -CAcreateserial
}

verify_certificates() {
  local ca_public_key_filename="$1"
  local ssl_public_key_filename="$2"
  openssl verify -CAfile "$ca_public_key_filename" -verbose "$ssl_public_key_filename"
}

merge_ca_and_ssl_certs() {
  local ssl_public_key_filename="$1"
  local ca_public_key_filename="$2"
  local merged_ca_ssl_cert_filename="$3"

  cat "$ssl_public_key_filename" >"$merged_ca_ssl_cert_filename"
  cat "$ca_public_key_filename" >>"$merged_ca_ssl_cert_filename"
}

install_the_ca_cert_as_a_trusted_root_ca() {
  local ca_public_key_filename="$1"
  local ca_public_cert_filename="$2"

  # The file in the ca-certificates dir must be of extension .crt:
  openssl x509 -outform der -in "$ca_public_key_filename" -out "$ca_public_cert_filename"

  # First remove any old cert if it existed.
  sudo rm "/usr/local/share/ca-certificates/$ca_public_cert_filename"
  sudo update-ca-certificates

  # TODO: Verify target directory exists.
  # On Debian & Derivatives:
  #- Move the CA certificate (`"$ca_private_key_filename"`) into `/usr/local/share/ca-certificates/ca.crt`.
  sudo cp "$ca_public_cert_filename" "/usr/local/share/ca-certificates/$ca_public_cert_filename"

  # TODO: Verify target file exists.

  # TODO: Verify target file MD5sum.

  # Update the Cert Store with:
  sudo update-ca-certificates
}

add_certs_to_nextcloud() {
  local ssl_public_key_filename="$1"
  local ssl_private_key_filename="$2"
  local merged_ca_ssl_cert_filename="$3"

  # First copy the files into nextcloud.
  # Source: https://github.com/nextcloud-snap/nextcloud-snap/issues/256
  # (see nextcloud.enable-https custom -h command).
  #sudo cp ca.pem /var/snap/nextcloud/current/ca.pem
  sudo cp "$ssl_public_key_filename" /var/snap/nextcloud/current/"$ssl_public_key_filename"
  sudo cp "$ssl_private_key_filename" /var/snap/nextcloud/current/"$ssl_private_key_filename"
  sudo cp "$merged_ca_ssl_cert_filename" /var/snap/nextcloud/current/"$merged_ca_ssl_cert_filename"

  # CLI sudo /snap/bin/nextcloud.enable-https custom Says:
  sudo /snap/bin/nextcloud.enable-https custom "/var/snap/nextcloud/current/$ssl_public_key_filename" "/var/snap/nextcloud/current/$ssl_private_key_filename" "/var/snap/nextcloud/current/$merged_ca_ssl_cert_filename"
}

delete_target_files() {
  rm "$CA_PRIVATE_KEY_FILENAME"
  rm "$CA_PUBLIC_CERT_FILENAME"
  rm "$CA_PUBLIC_KEY_FILENAME"
  rm "$SSL_PRIVATE_KEY_FILENAME"
  rm "$CA_SIGN_SSL_CERT_REQUEST_FILENAME"
  rm "$SIGNED_DOMAINS_FILENAME"
  rm "$SSL_PUBLIC_KEY_FILENAME"
  rm "$MERGED_CA_SSL_CERT_FILENAME"
  sudo rm "/usr/local/share/ca-certificates/$CA_PUBLIC_KEY_FILENAME"
  sudo rm "/usr/local/share/ca-certificates/$CA_PUBLIC_CERT_FILENAME"
  sudo rm "/var/snap/nextcloud/current/$SSL_PUBLIC_KEY_FILENAME"
  sudo rm "/var/snap/nextcloud/current/$SSL_PRIVATE_KEY_FILENAME"
  sudo rm "/var/snap/nextcloud/current/$MERGED_CA_SSL_CERT_FILENAME"

}
</code>```

Output

The output of this script can be read as:

$src/main.sh -h
domains=DNS:some_onion.onion,IP:127.0.0.1.end_without_space
rm: cannot remove 'ca.pem': No such file or directory
rm: cannot remove 'cert.csr': No such file or directory
rm: cannot remove 'extfile.cnf': No such file or directory
rm: cannot remove 'cert.pem': No such file or directory
rm: cannot remove 'fullchain.pem': No such file or directory
rm: cannot remove '/usr/local/share/ca-certificates/ca.pem': No such file or directory
Generating RSA private key, 4096 bit long modulus (2 primes)
................................................................................................................................................................................++++
...................................................................................................................................................................................................................................++++
e is 65537 (0x010001)
Enter pass phrase for ca-key.pem:
Verifying - Enter pass phrase for ca-key.pem:
Enter pass phrase for ca-key.pem:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:so
State or Province Name (full name) [Some-State]:state3
Locality Name (eg, city) []:locality3
Organization Name (eg, company) [Internet Widgits Pty Ltd]:org3
Organizational Unit Name (eg, section) []:orgunit3
Common Name (e.g. server FQDN or YOUR name) []:cn3
Email Address []:email3@email.com
Generating RSA private key, 4096 bit long modulus (2 primes)
...................................................................++++
.............................................++++
e is 65537 (0x010001)
Signature ok
subject=CN = yourcn
Getting CA Private Key
Enter pass phrase for ca-key.pem:
cert.pem: OK
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
Processing triggers for ca-certificates-java (20220719) ...
done.
Updating Mono key store
Mono Certificate Store Sync - version 6.8.0.105
Populate Mono certificate store from a concatenated list of certificates.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.

Importing into legacy system store:
I already trust 124, your new list has 124
Import process completed.

Importing into BTLS system store:
I already trust 124, your new list has 124
Import process completed.
Done
done.
Installing custom certificate... done
Restarting apache... done
```
<h2>Error Message</h2>
<p>After running the script successfully, I can manually import the <code>ca.crt</code> into brave at: brave://settings/certificates This ensures https works for https://localhost:81 . However, when I open the tor browser in brave, and visit the <code>some_onion.onion</code> it returns:</p>
<blockquote>
<p>This site can’t provide a secure connection
some_onion.onion sent an invalid response.
ERR_SSL_PROTOCOL_ERROR</p>
</blockquote>
<h2>Question</h2>
<p>How can I ensure the certificate is trusted on both the <code>some_onion.onion</code> link, as well as on localhost?</p>
<h2>Doubt</h2>
<ol start="0">
<li>I am unsure whether:</li>
</ol>
<pre class="lang-bash prettyprint-override"><code>echo "subjectAltName=DNS:some_onion_link.onion"
</code>```

is permitted. for an SSL certificate. I wonder why the tor version of Brave does not show why the certificate is not trusted.

Body:
Context

After setting up a self-hosted nextcloud server on Ubuntu 22.10 over a tor domain, I created a self-signed SLL certificate using the script below:

Code

This script first

generates the certificate authority (CA) and SSL certificates, and then it adds the CA private key to: "/usr/local/share/ca-certificates/$ca_public_key_filename" and reloads the trusted ca certificates with:

sudo update-ca-certificates

It also adds the SSL prublic and private key and the full chain certificate into Nextcloud.

The fullchain.pem consists of the SSL certificate, followed by the CA certificate.

#!/usr/bin/env bash
# Here is the list of certificates and their description:
# First you create your own certificate authority.
CA_PRIVATE_KEY_FILENAME="ca-key.pem"
CA_PUBLIC_KEY_FILENAME="ca.pem"
# Same file as ca.pem except different file extension and content.
CA_PUBLIC_CERT_FILENAME="ca.crt"

# Then you create a SSL certificate.
SSL_PRIVATE_KEY_FILENAME="cert-key.pem"

# Then create a sign-request (for your own CA to sign your own SSL certificate)
CA_SIGN_SSL_CERT_REQUEST_FILENAME="cert.csr"
SIGNED_DOMAINS_FILENAME="extfile.cnf"

# Then create the signed public SSL cert.
SSL_PUBLIC_KEY_FILENAME="cert.pem"

# Then merge the CA and SLL cert into one.
MERGED_CA_SSL_CERT_FILENAME="fullchain.pem"

setup_tor_ssl() {
  local onion_address="$1"

  # Create domains accepted by certificate.
  local domains
  #domains="DNS:$onion_address,IP:127.0.0.1"
  #domains="DNS:localhost,IP:$onion_address" # IP onion does not work
  #domains="DNS:*.$onion_address" # Does not work.
  #domains="DNS:$onion_address" # Does not work.
  domains="DNS:localhost,DNS:$onion_address" # Works for localhost
  echo "domains=$domains.end_without_space"

  delete_target_files

  # Generate and apply certificate.
  generate_ca_cert "$CA_PRIVATE_KEY_FILENAME" "$CA_PUBLIC_KEY_FILENAME"
  generate_ssl_certificate "$CA_PUBLIC_KEY_FILENAME" "$CA_PRIVATE_KEY_FILENAME" "$CA_SIGN_SSL_CERT_REQUEST_FILENAME" "$SIGNED_DOMAINS_FILENAME" "$SSL_PUBLIC_KEY_FILENAME" "$SSL_PRIVATE_KEY_FILENAME" "$domains"

  verify_certificates "$CA_PUBLIC_KEY_FILENAME" "$SSL_PUBLIC_KEY_FILENAME"

  merge_ca_and_ssl_certs "$SSL_PUBLIC_KEY_FILENAME" "$CA_PUBLIC_KEY_FILENAME" "$MERGED_CA_SSL_CERT_FILENAME"

  install_the_ca_cert_as_a_trusted_root_ca "$CA_PUBLIC_KEY_FILENAME" "$CA_PUBLIC_CERT_FILENAME"

  add_certs_to_nextcloud "$SSL_PUBLIC_KEY_FILENAME" "$SSL_PRIVATE_KEY_FILENAME" "$MERGED_CA_SSL_CERT_FILENAME"
}

generate_ca_cert() {
  local ca_private_key_filename="$1"
  local ca_public_key_filename="$2"

  # Generate RSA
  openssl genrsa -aes256 -out "$ca_private_key_filename" 4096

  # Generate a public CA Cert
  openssl req -new -x509 -sha256 -days 365 -key "$ca_private_key_filename" -out "$ca_public_key_filename"
}

generate_ssl_certificate() {
  local ca_public_key_filename="$1"
  local ca_private_key_filename="$2"
  local ca_sign_ssl_cert_request_filename="$3"
  local signed_domains_filename="$4"
  local ssl_public_key_filename="$5"
  local ssl_private_key_filename="$6"
  local domains="$7"
  # Example supported domains:
  # DNS:your-dns.record,IP:257.10.10.1

  # Create a RSA key
  openssl genrsa -out "$ssl_private_key_filename" 4096

  # Create a Certificate Signing Request (CSR)
  openssl req -new -sha256 -subj "/CN=yourcn" -key "$ssl_private_key_filename" -out "$ca_sign_ssl_cert_request_filename"

  # Create a `extfile` with all the alternative names
  echo "subjectAltName=$domains" >>"$signed_domains_filename"

  # optional
  #echo extendedKeyUsage = serverAuth >> "$ca_sign_ssl_cert_request_filename"

  # Create the public SSL certificate.
  openssl x509 -req -sha256 -days 365 -in "$ca_sign_ssl_cert_request_filename" -CA "$ca_public_key_filename" -CAkey "$ca_private_key_filename" -out "$ssl_public_key_filename" -extfile "$signed_domains_filename" -CAcreateserial
}

verify_certificates() {
  local ca_public_key_filename="$1"
  local ssl_public_key_filename="$2"
  openssl verify -CAfile "$ca_public_key_filename" -verbose "$ssl_public_key_filename"
}

merge_ca_and_ssl_certs() {
  local ssl_public_key_filename="$1"
  local ca_public_key_filename="$2"
  local merged_ca_ssl_cert_filename="$3"

  cat "$ssl_public_key_filename" >"$merged_ca_ssl_cert_filename"
  cat "$ca_public_key_filename" >>"$merged_ca_ssl_cert_filename"
}

install_the_ca_cert_as_a_trusted_root_ca() {
  local ca_public_key_filename="$1"
  local ca_public_cert_filename="$2"

  # The file in the ca-certificates dir must be of extension .crt:
  openssl x509 -outform der -in "$ca_public_key_filename" -out "$ca_public_cert_filename"

  # First remove any old cert if it existed.
  sudo rm "/usr/local/share/ca-certificates/$ca_public_cert_filename"
  sudo update-ca-certificates

  # TODO: Verify target directory exists.
  # On Debian & Derivatives:
  #- Move the CA certificate (`"$ca_private_key_filename"`) into `/usr/local/share/ca-certificates/ca.crt`.
  sudo cp "$ca_public_cert_filename" "/usr/local/share/ca-certificates/$ca_public_cert_filename"

  # TODO: Verify target file exists.

  # TODO: Verify target file MD5sum.

  # Update the Cert Store with:
  sudo update-ca-certificates
}

add_certs_to_nextcloud() {
  local ssl_public_key_filename="$1"
  local ssl_private_key_filename="$2"
  local merged_ca_ssl_cert_filename="$3"

  # First copy the files into nextcloud.
  # Source: https://github.com/nextcloud-snap/nextcloud-snap/issues/256
  # (see nextcloud.enable-https custom -h command).
  #sudo cp ca.pem /var/snap/nextcloud/current/ca.pem
  sudo cp "$ssl_public_key_filename" /var/snap/nextcloud/current/"$ssl_public_key_filename"
  sudo cp "$ssl_private_key_filename" /var/snap/nextcloud/current/"$ssl_private_key_filename"
  sudo cp "$merged_ca_ssl_cert_filename" /var/snap/nextcloud/current/"$merged_ca_ssl_cert_filename"

  # CLI sudo /snap/bin/nextcloud.enable-https custom Says:
  sudo /snap/bin/nextcloud.enable-https custom "/var/snap/nextcloud/current/$ssl_public_key_filename" "/var/snap/nextcloud/current/$ssl_private_key_filename" "/var/snap/nextcloud/current/$merged_ca_ssl_cert_filename"
}

delete_target_files() {
  rm "$CA_PRIVATE_KEY_FILENAME"
  rm "$CA_PUBLIC_CERT_FILENAME"
  rm "$CA_PUBLIC_KEY_FILENAME"
  rm "$SSL_PRIVATE_KEY_FILENAME"
  rm "$CA_SIGN_SSL_CERT_REQUEST_FILENAME"
  rm "$SIGNED_DOMAINS_FILENAME"
  rm "$SSL_PUBLIC_KEY_FILENAME"
  rm "$MERGED_CA_SSL_CERT_FILENAME"
  sudo rm "/usr/local/share/ca-certificates/$CA_PUBLIC_KEY_FILENAME"
  sudo rm "/usr/local/share/ca-certificates/$CA_PUBLIC_CERT_FILENAME"
  sudo rm "/var/snap/nextcloud/current/$SSL_PUBLIC_KEY_FILENAME"
  sudo rm "/var/snap/nextcloud/current/$SSL_PRIVATE_KEY_FILENAME"
  sudo rm "/var/snap/nextcloud/current/$MERGED_CA_SSL_CERT_FILENAME"

}

Output

The output of this script can be read as:

$src/main.sh -h
domains=DNS:some_onion.onion,IP:127.0.0.1.end_without_space
rm: cannot remove 'ca.pem': No such file or directory
rm: cannot remove 'cert.csr': No such file or directory
rm: cannot remove 'extfile.cnf': No such file or directory
rm: cannot remove 'cert.pem': No such file or directory
rm: cannot remove 'fullchain.pem': No such file or directory
rm: cannot remove '/usr/local/share/ca-certificates/ca.pem': No such file or directory
Generating RSA private key, 4096 bit long modulus (2 primes)
................................................................................................................................................................................++++
...................................................................................................................................................................................................................................++++
e is 65537 (0x010001)
Enter pass phrase for ca-key.pem:
Verifying - Enter pass phrase for ca-key.pem:
Enter pass phrase for ca-key.pem:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:so
State or Province Name (full name) [Some-State]:state3
Locality Name (eg, city) []:locality3
Organization Name (eg, company) [Internet Widgits Pty Ltd]:org3
Organizational Unit Name (eg, section) []:orgunit3
Common Name (e.g. server FQDN or YOUR name) []:cn3
Email Address []:email3@email.com
Generating RSA private key, 4096 bit long modulus (2 primes)
...................................................................++++
.............................................++++
e is 65537 (0x010001)
Signature ok
subject=CN = yourcn
Getting CA Private Key
Enter pass phrase for ca-key.pem:
cert.pem: OK
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
Processing triggers for ca-certificates-java (20220719) ...
done.
Updating Mono key store
Mono Certificate Store Sync - version 6.8.0.105
Populate Mono certificate store from a concatenated list of certificates.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2008 Novell. BSD licensed.

Importing into legacy system store:
I already trust 124, your new list has 124
Import process completed.

Importing into BTLS system store:
I already trust 124, your new list has 124
Import process completed.
Done
done.
Installing custom certificate... done
Restarting apache... done

Error Message

After running the script successfully, I can manually import the ca.crt into brave at: brave://settings/certificates This ensures https works for https://localhost:81 . However, when I open the tor browser in brave, and visit the some_onion.onion it returns:

This site can’t provide a secure connection
some_onion.onion sent an invalid response.
ERR_SSL_PROTOCOL_ERROR

Question

How can I ensure the certificate is trusted on both the some_onion.onion link, as well as on localhost?

Doubt

I am unsure whether:

echo "subjectAltName=DNS:some_onion_link.onion"

is permitted. for an SSL certificate. I wonder why the tor version of Brave does not show why the certificate is not trusted.