How to use printf with std::string

C++23 Update We now finally have std::print as a way to use std::format for output directly: #include <print> #include <string> int main() { // … std::print(“Follow this command: {}”, myString); // … } This combines the best of both approaches. Original Answer It’s compiling because printf isn’t type safe, since it uses variable arguments in … Read more

XPath with namespace in Java

Short answer: use XPath local-name(). Like this: xPathFactory.newXPath().compile(“//*[local-name()=’requestURL’]/text()”); will return /CAMERA/Streaming/status Or you can implement a NamespaceContext that maps namespaces names and URIs and set it on the XPath object before querying. Take a look at this blog article, Update: the article is down, you can see it on webarchive Solution 1 sample: XPath xpath … Read more

Namespace “stucked” as Terminating, How I removed it

Assuming you’ve already tried to force-delete resources like: Pods stuck at terminating status, and your at your wits’ end trying to recover the namespace… You can force-delete the namespace (perhaps leaving dangling resources): ( NAMESPACE=your-rogue-namespace kubectl proxy & kubectl get namespace $NAMESPACE -o json |jq ‘.spec = {“finalizers”:[]}’ >temp.json curl -k -H “Content-Type: application/json” -X … Read more

Is anyone actually using css namespaces?

They cover completely different use cases. CSS namespaces are for applying CSS to XML documents that mix elements from different XML namespaces. e.g. so you can target <foo:p> and <bar:p> without confusion. SMACSS covers techniques for writing robust CSS that doesn’t interfere with other parts of the page. e.g. so that .title in your address … Read more

Declaring a namespace as a friend of a class

No, it’s not possible befriend a namespace. If nothing else, it would constitute a “security breach,” as namespaces can be extended anywhere. So anyone could add an arbitrary function to the namespace and access the class’s non-public data. The closest you can get is the solution you propose, making those functions static members of a … Read more

understanding the javascript global namespace and closures

Is there a god (i.e. a parent) object? Yes. More technically, it’s the global object that all these primitives are members of; it just happens that in the browser, the window object is the global object. > window.String === String; true Why is it bad idea to have vars/functions on a global level? Because if … Read more