问:
problem cluster runtime 4.3 standalone disconnect - Mule Runtime Standalone
I have a problem with one of the servers in a unicast cluster, for a few days a server had been disconnected on the Anypoint Platform, I explain the architecture a bit, we have 2 servers with Mule Runtime 4.3 both on AWS, the server the primary is running fine with no problem but the secondary server fails I don't know why i checked the log on the damaged server but I can't see anything to help me I put a small log below hope you can help me or give me some advice on how to get the right trace.</p>
```<code>INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Mule cluster setup properties >>>
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Cluster id: 12611154
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Cluster node id: 2
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Discovery SPI is not enabled.
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Reading backup data: false
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Multicast to discover cluster nodes disabled
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: TCP/IP to discover cluster nodes enabled
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: TCP/IP time to connect 20 seconds
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: TCP/IP discovery members:
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger:  - 0.0.0.19
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger:  - 0.0.0.12
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Using port 5701 for inbound connections
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Inbound request port autoincrement is enabled
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Using random port for outobund connections
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: No network interface restriction. Using all available interfaces
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Message backup count: 1
INFO  2022-12-07 18:38:22,723 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Quorum enabled: false
INFO  2022-12-07 18:38:22,723 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Quorum size: 0
INFO  2022-12-07 18:38:22,723 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Mule cluster setup properties <<<
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.hazelcast.internal.networking.nio.SelectorOptimizer (file:/C:/MuleRuntime-Dev/mule/lib/opt/hazelcast-3.12.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
WARNING: Please consider reporting this to the maintainers of com.hazelcast.internal.networking.nio.SelectorOptimizer
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
DEBUG 2022-12-07 18:43:31,509 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager: Node failed to start!
java.lang.IllegalStateException: Node failed to start!
    at com.hazelcast.instance.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:138) ~[hazelcast-3.12.jar:3.12]
    at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:228) ~[hazelcast-3.12.jar:3.12]
    at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:207) ~[hazelcast-3.12.jar:3.12]
    at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:157) ~[hazelcast-3.12.jar:3.12]
    at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:57) ~[hazelcast-3.12.jar:3.12]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.configureServerMode(HazelcastClusterManager.java:167) ~[mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.<init>(HazelcastClusterManager.java:114) ~[mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.createManager(HazelcastClusterManager.java:223) ~[mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.lambda$0(HazelcastClusterManager.java:263) ~[mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.create(HazelcastClusterManager.java:275) [mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.create(HazelcastClusterManager.java:263) [mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterCoreExtension.createHazelcastManager(HazelcastClusterCoreExtension.java:152) [mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterCoreExtension.initialise(HazelcastClusterCoreExtension.java:129) [mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at org.mule.runtime.module.launcher.coreextension.DefaultMuleCoreExtensionManagerServer.initializeCoreExtensions(DefaultMuleCoreExtensionManagerServer.java:178) [mule-module-launcher-4.3.0-20210119.jar:4.3.0-20210119]
    at org.mule.runtime.module.launcher.coreextension.DefaultMuleCoreExtensionManagerServer.initialise(DefaultMuleCoreExtensionManagerServer.java:91) [mule-module-launcher-4.3.0-20210119.jar:4.3.0-20210119]
    at org.mule.runtime.module.launcher.MuleContainer.start(MuleContainer.java:249) [mule-module-launcher-4.3.0-20210119.jar:4.3.0-20210119]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    at org.mule.runtime.module.reboot.internal.MuleContainerWrapper.start(MuleContainerWrapper.java:49) [mule-module-boot-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at org.tanukisoftware.wrapper.WrapperManager$11.run(WrapperManager.java:4514) [wrapper-3.5.45.jar:3.5.45]
ERROR 2022-12-07 18:43:31,525 [WrapperListener_start_runner] [processor: ; event: ] org.mule.runtime.module.launcher.MuleContainer:
********************************************************************************
Message               : Invalid cluster configuration: Node failed to start!
Element               : org.mule.runtime.module.launcher.coreextension.DefaultMuleCoreExtensionManagerServer@3c67d3c4 @ app
Element DSL           : (None)
Error type            : (None)
FlowStack             : (None)

  (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

ERROR 2022-12-07 18:43:31,525 [WrapperListener_start_runner] [processor: ; event: ] org.mule.runtime.module.launcher.MuleContainer:
********************************************************************************
* A Fatal error has occurred while the server was running:                     *
* Invalid cluster configuration: Node failed to start!                         *
* (java.lang.RuntimeException)                                                 *
*                                                                              *
* The error is fatal, the system will shutdown                                 *
********************************************************************************
<-- Wrapper Stopped
</code>```

Body:
I have a problem with one of the servers in a unicast cluster, for a few days a server had been disconnected on the Anypoint Platform, I explain the architecture a bit, we have 2 servers with Mule Runtime 4.3 both on AWS, the server the primary is running fine with no problem but the secondary server fails I don't know why i checked the log on the damaged server but I can't see anything to help me I put a small log below hope you can help me or give me some advice on how to get the right trace.

INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Mule cluster setup properties >>>
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Cluster id: 12611154
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Cluster node id: 2
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Discovery SPI is not enabled.
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Reading backup data: false
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Multicast to discover cluster nodes disabled
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: TCP/IP to discover cluster nodes enabled
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: TCP/IP time to connect 20 seconds
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: TCP/IP discovery members:
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger:  - 0.0.0.19
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger:  - 0.0.0.12
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Using port 5701 for inbound connections
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Inbound request port autoincrement is enabled
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Using random port for outobund connections
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: No network interface restriction. Using all available interfaces
INFO  2022-12-07 18:38:22,707 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Message backup count: 1
INFO  2022-12-07 18:38:22,723 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Quorum enabled: false
INFO  2022-12-07 18:38:22,723 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Quorum size: 0
INFO  2022-12-07 18:38:22,723 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.config.ClusterConfigLogger: Mule cluster setup properties <<<
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.hazelcast.internal.networking.nio.SelectorOptimizer (file:/C:/MuleRuntime-Dev/mule/lib/opt/hazelcast-3.12.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
WARNING: Please consider reporting this to the maintainers of com.hazelcast.internal.networking.nio.SelectorOptimizer
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
DEBUG 2022-12-07 18:43:31,509 [WrapperListener_start_runner] [processor: ; event: ] com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager: Node failed to start!
java.lang.IllegalStateException: Node failed to start!
    at com.hazelcast.instance.HazelcastInstanceImpl.<init>(HazelcastInstanceImpl.java:138) ~[hazelcast-3.12.jar:3.12]
    at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:228) ~[hazelcast-3.12.jar:3.12]
    at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:207) ~[hazelcast-3.12.jar:3.12]
    at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:157) ~[hazelcast-3.12.jar:3.12]
    at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:57) ~[hazelcast-3.12.jar:3.12]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.configureServerMode(HazelcastClusterManager.java:167) ~[mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.<init>(HazelcastClusterManager.java:114) ~[mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.createManager(HazelcastClusterManager.java:223) ~[mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.lambda$0(HazelcastClusterManager.java:263) ~[mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.create(HazelcastClusterManager.java:275) [mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterManager.create(HazelcastClusterManager.java:263) [mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterCoreExtension.createHazelcastManager(HazelcastClusterCoreExtension.java:152) [mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at com.mulesoft.mule.runtime.module.cluster.internal.HazelcastClusterCoreExtension.initialise(HazelcastClusterCoreExtension.java:129) [mule-module-cluster-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at org.mule.runtime.module.launcher.coreextension.DefaultMuleCoreExtensionManagerServer.initializeCoreExtensions(DefaultMuleCoreExtensionManagerServer.java:178) [mule-module-launcher-4.3.0-20210119.jar:4.3.0-20210119]
    at org.mule.runtime.module.launcher.coreextension.DefaultMuleCoreExtensionManagerServer.initialise(DefaultMuleCoreExtensionManagerServer.java:91) [mule-module-launcher-4.3.0-20210119.jar:4.3.0-20210119]
    at org.mule.runtime.module.launcher.MuleContainer.start(MuleContainer.java:249) [mule-module-launcher-4.3.0-20210119.jar:4.3.0-20210119]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
    at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:566) ~[?:?]
    at org.mule.runtime.module.reboot.internal.MuleContainerWrapper.start(MuleContainerWrapper.java:49) [mule-module-boot-ee-4.3.0-20210119.jar:4.3.0-20210119]
    at org.tanukisoftware.wrapper.WrapperManager$11.run(WrapperManager.java:4514) [wrapper-3.5.45.jar:3.5.45]
ERROR 2022-12-07 18:43:31,525 [WrapperListener_start_runner] [processor: ; event: ] org.mule.runtime.module.launcher.MuleContainer:
********************************************************************************
Message               : Invalid cluster configuration: Node failed to start!
Element               : org.mule.runtime.module.launcher.coreextension.DefaultMuleCoreExtensionManagerServer@3c67d3c4 @ app
Element DSL           : (None)
Error type            : (None)
FlowStack             : (None)

  (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

ERROR 2022-12-07 18:43:31,525 [WrapperListener_start_runner] [processor: ; event: ] org.mule.runtime.module.launcher.MuleContainer:
********************************************************************************
* A Fatal error has occurred while the server was running:                     *
* Invalid cluster configuration: Node failed to start!                         *
* (java.lang.RuntimeException)                                                 *
*                                                                              *
* The error is fatal, the system will shutdown                                 *
********************************************************************************
<-- Wrapper Stopped


来源: stackexchange

问:
Replace string with a value
I have a C# string as shown below. I need to give a value to {0}. How can I do it?

```<code>var valueActions = @"{
    ""Name"": {0},
}";
</code>```

At the end what I need to see is:

```<code>{
    Name: James,
}
</code>```

ContentLicense: CC BY-SA 4.0

Title: Replace string with a value

Body:
I have a C# string as shown below. I need to give a value to {0}. How can I do it?

var valueActions = @"{
    ""Name"": {0},
}";

At the end what I need to see is:

{
    Name: James,
}


问:
in Squeryl can i use string interpolation in where clause?
I have a question lets say i have a record in this form:

```<code>case class BlahInfoRecord(
 id: Long,
 lvl: Int, /*possible values 1,2,3,4*/
 id1: Long,
 id2: Long,
 id3: Long,
 id4: Long,
 parentId: Long
)
</code>```

and in schema I have

```<code>object blahSchema extends Schema {
  implicit object blahRecordKed extends KeyedEntityDef[BlahInfoRecord, Long] {
  def getId(ptInfo: BlahInfoRecord): Long = ptInfo.id
  def idPropertyName: String = "id"
  def isPersisted(blahInfo: BlahInfoRecord): Boolean = blahInfo.id > 0
}

val blahRecords: Table[BlahInfoRecord] =
    table[BlahInfoRecord]("blah_info")
}
</code>```

I want to add method expansion like so:

```<code>def expansion(blahInfo: BlahInfoRecord): Query[BlahInfoRecord] = {
  from(blahRecords)(b => where(s"b.id${blahInfo.lvl} === ${blahInfo.id}") // essentially to get all records where id with index lvl is equal to a record id for example if i have blahRecord with lvl = 3 then i want this to translate to id3 === <id>
}
</code>```

is it possible?

Body:
I have a question lets say i have a record in this form:

case class BlahInfoRecord(
 id: Long,
 lvl: Int, /*possible values 1,2,3,4*/
 id1: Long,
 id2: Long,
 id3: Long,
 id4: Long,
 parentId: Long
)

and in schema I have

object blahSchema extends Schema {
  implicit object blahRecordKed extends KeyedEntityDef[BlahInfoRecord, Long] {
  def getId(ptInfo: BlahInfoRecord): Long = ptInfo.id
  def idPropertyName: String = "id"
  def isPersisted(blahInfo: BlahInfoRecord): Boolean = blahInfo.id > 0
}

val blahRecords: Table[BlahInfoRecord] =
    table[BlahInfoRecord]("blah_info")
}

I want to add method expansion like so:

def expansion(blahInfo: BlahInfoRecord): Query[BlahInfoRecord] = {
  from(blahRecords)(b => where(s"b.id${blahInfo.lvl} === ${blahInfo.id}") // essentially to get all records where id with index lvl is equal to a record id for example if i have blahRecord with lvl = 3 then i want this to translate to id3 === <id>
}

is it possible?


问:
javascript countdown chrome extension issue
I created a countdown chrome extension using javascript. The code runs perfectly fine, but I noticed once I close the popup, the timer stops and resets. I need help in figuring out how I can make the timer run in the background even while the popup is closed.

Javascript code:

```<code>const myStart = document.querySelector("#myBtn1");
const myReset = document.getElementById("myBtn2");
const myPause = document.getElementById("myBtn3");
const myResume = document.getElementById("myBtn4");

myStart.addEventListener("click", function() {
 var getNum = document.getElementById("myInpt").value;
  var myTime = getNum;
  console.log(myTime)
  var timer = setInterval (() =>{
    document.querySelector('#myVal').innerHTML = myTime;
    myTime--;
    console.log(myTime)
    if (myTime < -1) {
   document.querySelector('#myVal').innerHTML = "done";
   alert("done")
   clearInterval(timer)
  }
  }, 1000)

  myReset.addEventListener("click", function() {
    var resetBtn = clearInterval(timer)
    document.querySelector('#myVal').innerHTML = "0000";
  })
  myPause.addEventListener("click", function() {
    document.getElementById("myBtn3").innerHTML = "pause"
    clearInterval(timer)
    })
    myResume.addEventListener("click", function() {
    timer = setInterval (() =>{
      document.querySelector('#myVal').innerHTML = myTime;
      myTime--;
      if (myTime < -1) {
        document.querySelector('#myVal').innerHTML = "done";
        clearInterval(timer)
       }
    }, 1000)
})

})

</code>```

The countdown works perfectly fine, but once the pop up closes, the countdown resets.

Body:
I created a countdown chrome extension using javascript. The code runs perfectly fine, but I noticed once I close the popup, the timer stops and resets. I need help in figuring out how I can make the timer run in the background even while the popup is closed.

Javascript code:

const myStart = document.querySelector("#myBtn1");
const myReset = document.getElementById("myBtn2");
const myPause = document.getElementById("myBtn3");
const myResume = document.getElementById("myBtn4");

myStart.addEventListener("click", function() {
 var getNum = document.getElementById("myInpt").value;
  var myTime = getNum;
  console.log(myTime)
  var timer = setInterval (() =>{
    document.querySelector('#myVal').innerHTML = myTime;
    myTime--;
    console.log(myTime)
    if (myTime < -1) {
   document.querySelector('#myVal').innerHTML = "done";
   alert("done")
   clearInterval(timer)
  }
  }, 1000)

  myReset.addEventListener("click", function() {
    var resetBtn = clearInterval(timer)
    document.querySelector('#myVal').innerHTML = "0000";
  })
  myPause.addEventListener("click", function() {
    document.getElementById("myBtn3").innerHTML = "pause"
    clearInterval(timer)
    })
    myResume.addEventListener("click", function() {
    timer = setInterval (() =>{
      document.querySelector('#myVal').innerHTML = myTime;
      myTime--;
      if (myTime < -1) {
        document.querySelector('#myVal').innerHTML = "done";
        clearInterval(timer)
       }
    }, 1000)
})

})

The countdown works perfectly fine, but once the pop up closes, the countdown resets.


问:
Corner widgets overlap the tab in QTabWidget
I have added some widgets into the corner in a QTabWidget using setCornerWidget(), but there are still some problems.

The corner widgets overlap the tab. How can I set some margin to keep them away from tabs?

The corner widgets stay at the bottom of tab bar. What can I do to center them vertically in the tab bar?

main.py:

```<code>import sys
from PySide6.QtWidgets import *
from classes.tab import Tab

app = QApplication(sys.argv)
screen = Tab()
screen.show()
sys.exit(app.exec_())
</code>```

tab.py (just put this in a folder called classes):

```<code>from PySide6.QtCore import *
from PySide6.QtWidgets import *
from interfaces.tab_ui import Ui_tabWidgetForm
from interfaces.c_widget_ui import Ui_Form

class CornerWidget(QWidget, Ui_Form):

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(self)

class Tab(QWidget, Ui_tabWidgetForm):

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(self)

        label1 = QLabel("Widget in tab 1.")
        label2 = QLabel("Widget in tab 2.")
        label3 = QLabel("Widget in tab 3.")
        label4 = QLabel("Widget in tab 4.")
        self.tabWidget.addTab(label1, "Tab 1")
        self.tabWidget.addTab(label2, "Tab 2")
        self.tabWidget.addTab(label3, "Tab 3")
        self.tabWidget.addTab(label4, "Tab 4")

        cornerWidget = CornerWidget()
        self.tabWidget.setCornerWidget(cornerWidget, Qt.TopRightCorner)
</code>```

c_widget_ui.py (just put this in a folder called interfaces):

```<code>from PySide6.QtCore import *
from PySide6.QtWidgets import *

class Ui_Form(object):

    def setupUi(self, Form):
        if not Form.objectName():
            Form.setObjectName(u"Form")
        Form.resize(237, 30)
        Form.setMinimumSize(QSize(100, 30))
        Form.setMaximumSize(QSize(237, 30))
        self.horizontalLayout = QHBoxLayout(Form)
        self.horizontalLayout.setSpacing(0)
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.widget = QWidget(Form)
        self.widget.setObjectName(u"widget")
        self.horizontalLayout_2 = QHBoxLayout(self.widget)
        self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
        self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.pushButton = QPushButton(self.widget)
        self.pushButton.setObjectName(u"pushButton")

        self.horizontalLayout_2.addWidget(self.pushButton)

        self.pushButton_2 = QPushButton(self.widget)
        self.pushButton_2.setObjectName(u"pushButton_2")

        self.horizontalLayout_2.addWidget(self.pushButton_2)

        self.pushButton_3 = QPushButton(self.widget)
        self.pushButton_3.setObjectName(u"pushButton_3")

        self.horizontalLayout_2.addWidget(self.pushButton_3)

        self.horizontalLayout.addWidget(self.widget)

        self.retranslateUi(Form)

        QMetaObject.connectSlotsByName(Form)

    # setupUi

    def retranslateUi(self, Form):
        Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None))
        self.pushButton.setText(
            QCoreApplication.translate("Form", u"PushButton", None))
        self.pushButton_2.setText(
            QCoreApplication.translate("Form", u"PushButton", None))
        self.pushButton_3.setText(
            QCoreApplication.translate("Form", u"PushButton", None))

    # retranslateUi
</code>```

tab_ui.py (just put this in a folder called interfaces):

```<code>from PySide6.QtCore import *
from PySide6.QtWidgets import *

class Ui_tabWidgetForm(object):

    def setupUi(self, tabWidgetForm):
        if not tabWidgetForm.objectName():
            tabWidgetForm.setObjectName(u"tabWidgetForm")
        tabWidgetForm.resize(662, 599)
        tabWidgetForm.setStyleSheet(u"QWidget{\n"
                                    "   background-color: rgb(205, 203, 201);\n"
                                    "   color: rgb(38, 38, 38);\n"
                                    "}")
        self.verticalLayout = QVBoxLayout(tabWidgetForm)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.layout = QWidget(tabWidgetForm)
        self.layout.setObjectName(u"layout")
        self.verticalLayout_3 = QVBoxLayout(self.layout)
        self.verticalLayout_3.setSpacing(0)
        self.verticalLayout_3.setObjectName(u"verticalLayout_3")
        self.verticalLayout_3.setContentsMargins(0, 4, 0, 0)
        self.tabWidget = QTabWidget(self.layout)
        self.tabWidget.setObjectName(u"tabWidget")
        self.tabWidget.setStyleSheet(
            u"QTabWidget::tab-bar {\n"
            "   left: 8px;\n"
            "}\n"
            "\n"
            "QTabBar::tab {\n"
            "   border-top-left-radius: 5px;\n"
            "   border-top-right-radius: 5px;\n"
            "   width: 35ex;\n"
            "   padding: 8px;\n"
            "}\n"
            "\n"
            "QTabBar::tab:selected {\n"
            "   background: rgb(247, 245, 243);\n"
            "   margin-bottom: -1px;\n"
            "   margin-left: 2px;\n"
            "   margin-right: 2px;\n"
            "   border-bottom: 1px solid rgb(247, 245, 243);\n"
            "}\n"
            "\n"
            "QTabBar::tab:!selected {\n"
            "   background: rgba(247, 245, 243, 80);\n"
            "   border-radius: 8px;\n"
            "   padding: 4px;\n"
            "   border-top: 4px solid rgb(205, 203, 201);\n"
            "   border-bottom: 4px solid rgb(205, 203, 201);\n"
            "   border-left: 2px solid rgb(205, 203, 201);\n"
            "   border-right: 2px solid rgb(205, 203, 201);\n"
            "}\n"
            "\n"
            "QTabWidget::pane {\n"
            "   border: 3px solid rgb(247, 245, 243);\n"
            "}\n"
            "\n"
            "QTabBar::scroller {\n"
            "    width: 40px;\n"
            "}\n"
            "\n"
            "QTabBar QToolButton {\n"
            "   background-color: rgb(243, 242, 241);\n"
            "   border: 1px solid rgb(138, 136, 134);\n"
            "}\n"
            "\n"
            "QTabBar QToolButton:hover{\n"
            "   background-color: rgb(225, 22"
            "3, 221);\n"
            "}\n"
            "\n"
            "QTabBar QToolButton:pressed{\n"
            "   background-color: rgb(210, 208, 206);\n"
            "}\n"
            "")
        self.tabWidget.setTabShape(QTabWidget.Rounded)
        self.tabWidget.setElideMode(Qt.ElideRight)
        self.tabWidget.setUsesScrollButtons(True)
        self.tabWidget.setTabsClosable(True)
        self.tabWidget.setMovable(True)

        self.verticalLayout_3.addWidget(self.tabWidget)

        self.verticalLayout.addWidget(self.layout)

        self.retranslateUi(tabWidgetForm)

        self.tabWidget.setCurrentIndex(-1)

        QMetaObject.connectSlotsByName(tabWidgetForm)

    # setupUi

    def retranslateUi(self, tabWidgetForm):
        tabWidgetForm.setWindowTitle(
            QCoreApplication.translate("tabWidgetForm", u"Form", None))

    # retranslateUi
</code>```

Body:
I have added some widgets into the corner in a QTabWidget using setCornerWidget(), but there are still some problems.

The corner widgets overlap the tab. How can I set some margin to keep them away from tabs?

The corner widgets stay at the bottom of tab bar. What can I do to center them vertically in the tab bar?

main.py:

import sys
from PySide6.QtWidgets import *
from classes.tab import Tab

app = QApplication(sys.argv)
screen = Tab()
screen.show()
sys.exit(app.exec_())

tab.py (just put this in a folder called classes):

from PySide6.QtCore import *
from PySide6.QtWidgets import *
from interfaces.tab_ui import Ui_tabWidgetForm
from interfaces.c_widget_ui import Ui_Form

class CornerWidget(QWidget, Ui_Form):

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(self)

class Tab(QWidget, Ui_tabWidgetForm):

    def __init__(self, parent=None):
        super().__init__(parent)
        self.setupUi(self)

        label1 = QLabel("Widget in tab 1.")
        label2 = QLabel("Widget in tab 2.")
        label3 = QLabel("Widget in tab 3.")
        label4 = QLabel("Widget in tab 4.")
        self.tabWidget.addTab(label1, "Tab 1")
        self.tabWidget.addTab(label2, "Tab 2")
        self.tabWidget.addTab(label3, "Tab 3")
        self.tabWidget.addTab(label4, "Tab 4")

        cornerWidget = CornerWidget()
        self.tabWidget.setCornerWidget(cornerWidget, Qt.TopRightCorner)

c_widget_ui.py (just put this in a folder called interfaces):

from PySide6.QtCore import *
from PySide6.QtWidgets import *

class Ui_Form(object):

    def setupUi(self, Form):
        if not Form.objectName():
            Form.setObjectName(u"Form")
        Form.resize(237, 30)
        Form.setMinimumSize(QSize(100, 30))
        Form.setMaximumSize(QSize(237, 30))
        self.horizontalLayout = QHBoxLayout(Form)
        self.horizontalLayout.setSpacing(0)
        self.horizontalLayout.setObjectName(u"horizontalLayout")
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.widget = QWidget(Form)
        self.widget.setObjectName(u"widget")
        self.horizontalLayout_2 = QHBoxLayout(self.widget)
        self.horizontalLayout_2.setObjectName(u"horizontalLayout_2")
        self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.pushButton = QPushButton(self.widget)
        self.pushButton.setObjectName(u"pushButton")

        self.horizontalLayout_2.addWidget(self.pushButton)

        self.pushButton_2 = QPushButton(self.widget)
        self.pushButton_2.setObjectName(u"pushButton_2")

        self.horizontalLayout_2.addWidget(self.pushButton_2)

        self.pushButton_3 = QPushButton(self.widget)
        self.pushButton_3.setObjectName(u"pushButton_3")

        self.horizontalLayout_2.addWidget(self.pushButton_3)

        self.horizontalLayout.addWidget(self.widget)

        self.retranslateUi(Form)

        QMetaObject.connectSlotsByName(Form)

    # setupUi

    def retranslateUi(self, Form):
        Form.setWindowTitle(QCoreApplication.translate("Form", u"Form", None))
        self.pushButton.setText(
            QCoreApplication.translate("Form", u"PushButton", None))
        self.pushButton_2.setText(
            QCoreApplication.translate("Form", u"PushButton", None))
        self.pushButton_3.setText(
            QCoreApplication.translate("Form", u"PushButton", None))

    # retranslateUi

tab_ui.py (just put this in a folder called interfaces):

from PySide6.QtCore import *
from PySide6.QtWidgets import *

class Ui_tabWidgetForm(object):

    def setupUi(self, tabWidgetForm):
        if not tabWidgetForm.objectName():
            tabWidgetForm.setObjectName(u"tabWidgetForm")
        tabWidgetForm.resize(662, 599)
        tabWidgetForm.setStyleSheet(u"QWidget{\n"
                                    "   background-color: rgb(205, 203, 201);\n"
                                    "   color: rgb(38, 38, 38);\n"
                                    "}")
        self.verticalLayout = QVBoxLayout(tabWidgetForm)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setObjectName(u"verticalLayout")
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.layout = QWidget(tabWidgetForm)
        self.layout.setObjectName(u"layout")
        self.verticalLayout_3 = QVBoxLayout(self.layout)
        self.verticalLayout_3.setSpacing(0)
        self.verticalLayout_3.setObjectName(u"verticalLayout_3")
        self.verticalLayout_3.setContentsMargins(0, 4, 0, 0)
        self.tabWidget = QTabWidget(self.layout)
        self.tabWidget.setObjectName(u"tabWidget")
        self.tabWidget.setStyleSheet(
            u"QTabWidget::tab-bar {\n"
            "   left: 8px;\n"
            "}\n"
            "\n"
            "QTabBar::tab {\n"
            "   border-top-left-radius: 5px;\n"
            "   border-top-right-radius: 5px;\n"
            "   width: 35ex;\n"
            "   padding: 8px;\n"
            "}\n"
            "\n"
            "QTabBar::tab:selected {\n"
            "   background: rgb(247, 245, 243);\n"
            "   margin-bottom: -1px;\n"
            "   margin-left: 2px;\n"
            "   margin-right: 2px;\n"
            "   border-bottom: 1px solid rgb(247, 245, 243);\n"
            "}\n"
            "\n"
            "QTabBar::tab:!selected {\n"
            "   background: rgba(247, 245, 243, 80);\n"
            "   border-radius: 8px;\n"
            "   padding: 4px;\n"
            "   border-top: 4px solid rgb(205, 203, 201);\n"
            "   border-bottom: 4px solid rgb(205, 203, 201);\n"
            "   border-left: 2px solid rgb(205, 203, 201);\n"
            "   border-right: 2px solid rgb(205, 203, 201);\n"
            "}\n"
            "\n"
            "QTabWidget::pane {\n"
            "   border: 3px solid rgb(247, 245, 243);\n"
            "}\n"
            "\n"
            "QTabBar::scroller {\n"
            "    width: 40px;\n"
            "}\n"
            "\n"
            "QTabBar QToolButton {\n"
            "   background-color: rgb(243, 242, 241);\n"
            "   border: 1px solid rgb(138, 136, 134);\n"
            "}\n"
            "\n"
            "QTabBar QToolButton:hover{\n"
            "   background-color: rgb(225, 22"
            "3, 221);\n"
            "}\n"
            "\n"
            "QTabBar QToolButton:pressed{\n"
            "   background-color: rgb(210, 208, 206);\n"
            "}\n"
            "")
        self.tabWidget.setTabShape(QTabWidget.Rounded)
        self.tabWidget.setElideMode(Qt.ElideRight)
        self.tabWidget.setUsesScrollButtons(True)
        self.tabWidget.setTabsClosable(True)
        self.tabWidget.setMovable(True)

        self.verticalLayout_3.addWidget(self.tabWidget)

        self.verticalLayout.addWidget(self.layout)

        self.retranslateUi(tabWidgetForm)

        self.tabWidget.setCurrentIndex(-1)

        QMetaObject.connectSlotsByName(tabWidgetForm)

    # setupUi

    def retranslateUi(self, tabWidgetForm):
        tabWidgetForm.setWindowTitle(
            QCoreApplication.translate("tabWidgetForm", u"Form", None))

    # retranslateUi


问:
Open SSH tunnel during PostGIS Docker build
How to open an SSH tunnel during the build process of PostGIS container build?

I need to SSH tunnel to database, so I can create dump, then restore in container.

With other docker containers, I usually create a startup.sh then run from Dockerfile.  However, to run startup scripts in PostGIS container we need to add the script to /docker-entrypoint-initdb.d folder.

The problem with this is, the script runs as user postgres with a user id of 999.  I need to run as root with userid of 0 to execute ssh commands.

 Instructions run from the Dockerfile execute under the root user, but again once the scripts are run from /docker-entrypoint-initdb.d, they are run under the postgres user.

 If I run docker exec -it postgis_container bash, I am in bash as the root user and I can execute all the commands I need.  However, I do not want to do this.  I want to just execute docker-compose up and allow the docker compose configurations, the Dockerfile and possible any startup script to do the rest.

I know I can install OpenSSH and run tunnel from Dockerfile but connecting to a server the first time brings up the known_host prompt.  I can user ssh-keyscan -H some_server >> /root/.ssh/known_hosts or even make a volume from the host machine of my ~/.ssh folder, that containers working a known_host file but the error I get is:

Dockerfile

```<code>RUN echo "Install OpenSSH \n" \
&& apt-get -y update \
&& apt-get install -y openssh-client \
&& echo "Config SSH \n" \
&& mkdir /root/.ssh && touch /root/.ssh/id_rsa-dev \
&& chmod 700 /root/.ssh/id_rsa-dev \
&& touch /root/.ssh/known_hosts \
&& touch /root/.ssh/config \
&& ssh-keyscan -H some_server.com >> /root/.ssh/known_hosts \
&& echo "Tunnel to DB \n" \
&& ssh -N -L 9001:some_other_server.com:5432 some_user@some_server.com -i /root/.ssh/id_rsa-dev & \
&& echo "Setup for dump and restore \n" \
&& cd /root/dump \
&& date_today=$(date +%F) \
&& echo "Createing dump file from dev db name = dev_db_$date_today.sql" \
&& export PGPASSWORD=${DEV_DB_PASSWORD} \
&& pg_dump -Fc -v -U dbuser -d dev_db -p 9001 -h 0.0.0.0 > ./dev_db_$date_today.sql \
&& export PGPASSWORD=$POSTGRES_PASSWORD \
&& echo "Restoring db" \
&& pg_restore -Fc -v -U dbuser -d dev_db_docker_local ./dev_db_$date_today.sql
</code>```

Error from output

```<code>0.335 Warning: Permanently added the ECDSA host key for IP address ‘111.222.333.444’ to the list of known hosts.
#0 0.418 Authorized uses only. All activity may be monitored and reported.
#0 0.418 Load key "/root/.ssh/id_rsa-dev": invalid format
#0 0.418 some_user@some_server.com: Permission denied (publickey).
</code>```

However, again, if I run docker exec -it postgis_container bash, then execute the exact same commands, I am able to open the ssh tunnel, dump and restore.

startup.sh

```<code>#!/usr/bin/env bash
cho "Install OpenSSH
apt-get -y update
apt-get install -y openssh-client
echo "Config SSH
mkdir /root/.ssh && touch /root/.ssh/id_rsa-dev
chmod 700 /root/.ssh/id_rsa-dev
touch /root/.ssh/known_hosts
touch /root/.ssh/config
ssh-keyscan -H some_server.com >> /root/.ssh/known_hosts
echo "Tunnel to DB
ssh -N -L 9001:some_other_server.com:5432 some_user@some_server.com -i /root/.ssh/id_rsa-dev &
echo "Setup for dump and restore
cd /root/dump
date_today=$(date +%F)
echo "Createing dump file from dev db name = dev_db_$date_today.sql"
export PGPASSWORD=${DEV_DB_PASSWORD}
pg_dump -Fc -v -U dbuser -d dev_db -p 9001 -h 0.0.0.0 > ./dev_db_$date_today.sql
export PGPASSWORD=$POSTGRES_PASSWORD
echo "Restoring db"
pg_restore -Fc -v -U dbuser -d dev_db_docker_local ./dev_db_$date_today.sql
</code>```

I would prefer to be able to run my startup.sh script from /docker-entrypoint-initdb.d folder as a root user.  But If I can not, then would like to be able to added all the steps to Dockerfile

Any help would be greatly appreciated.

Note:

I asked a question here.

I was trying to find out how to get my startup script to run as root, but realized the question did not give enough context so I created this post.  I mention this because setting user root or 0, wether in the Dockerfile or the docker-compose.yml does not solve my problem.

If I try to run startup.sh from /docker-entrypoint-initdbd:

sudo is not available.  su is available, but I do not know root password. gosu is available but when I used that it give an error along the lines of operation not permitted.

Update 1:

Seems like this is an issue.  The postgres docker github says you can not run as root from /docker-entrypoint-initdb.d.

https://github.com/docker-library/postgres/issues/973

But something seems weird about that.  I figure there has got to be a way around this.  Or maybe some best practice that address this use case.  I imagine I am not the only one who has run into an issue like this.

Update 2:

I just realized running the commands in Dockerfile will not work because postgres would not have been started yet.  And I need to run psql after I open the tunnel.  So I have to run from /docker-entrypoint-initdb.d folder or figure out some way to get startup.sh to run after postgis container finishes its default start up processes.

Appearently this was not a problem a few years ago, but I believe there was a move to stop the use of root access during the build start up process in the /docker-entrypoint-initdb.d for security reasons.  But there was no suggested work around.

Body:
How to open an SSH tunnel during the build process of PostGIS container build?

I need to SSH tunnel to database, so I can create dump, then restore in container.

With other docker containers, I usually create a startup.sh then run from Dockerfile.  However, to run startup scripts in PostGIS container we need to add the script to /docker-entrypoint-initdb.d folder.

The problem with this is, the script runs as user postgres with a user id of 999.  I need to run as root with userid of 0 to execute ssh commands.

 Instructions run from the Dockerfile execute under the root user, but again once the scripts are run from /docker-entrypoint-initdb.d, they are run under the postgres user.

 If I run docker exec -it postgis_container bash, I am in bash as the root user and I can execute all the commands I need.  However, I do not want to do this.  I want to just execute docker-compose up and allow the docker compose configurations, the Dockerfile and possible any startup script to do the rest.

I know I can install OpenSSH and run tunnel from Dockerfile but connecting to a server the first time brings up the known_host prompt.  I can user ssh-keyscan -H some_server >> /root/.ssh/known_hosts or even make a volume from the host machine of my ~/.ssh folder, that containers working a known_host file but the error I get is:

Dockerfile

RUN echo "Install OpenSSH \n" \
&& apt-get -y update \
&& apt-get install -y openssh-client \
&& echo "Config SSH \n" \
&& mkdir /root/.ssh && touch /root/.ssh/id_rsa-dev \
&& chmod 700 /root/.ssh/id_rsa-dev \
&& touch /root/.ssh/known_hosts \
&& touch /root/.ssh/config \
&& ssh-keyscan -H some_server.com >> /root/.ssh/known_hosts \
&& echo "Tunnel to DB \n" \
&& ssh -N -L 9001:some_other_server.com:5432 some_user@some_server.com -i /root/.ssh/id_rsa-dev & \
&& echo "Setup for dump and restore \n" \
&& cd /root/dump \
&& date_today=$(date +%F) \
&& echo "Createing dump file from dev db name = dev_db_$date_today.sql" \
&& export PGPASSWORD=${DEV_DB_PASSWORD} \
&& pg_dump -Fc -v -U dbuser -d dev_db -p 9001 -h 0.0.0.0 > ./dev_db_$date_today.sql \
&& export PGPASSWORD=$POSTGRES_PASSWORD \
&& echo "Restoring db" \
&& pg_restore -Fc -v -U dbuser -d dev_db_docker_local ./dev_db_$date_today.sql

Error from output

0.335 Warning: Permanently added the ECDSA host key for IP address ‘111.222.333.444’ to the list of known hosts.
#0 0.418 Authorized uses only. All activity may be monitored and reported.
#0 0.418 Load key "/root/.ssh/id_rsa-dev": invalid format
#0 0.418 some_user@some_server.com: Permission denied (publickey).

However, again, if I run docker exec -it postgis_container bash, then execute the exact same commands, I am able to open the ssh tunnel, dump and restore.

startup.sh

#!/usr/bin/env bash
cho "Install OpenSSH
apt-get -y update
apt-get install -y openssh-client
echo "Config SSH
mkdir /root/.ssh && touch /root/.ssh/id_rsa-dev
chmod 700 /root/.ssh/id_rsa-dev
touch /root/.ssh/known_hosts
touch /root/.ssh/config
ssh-keyscan -H some_server.com >> /root/.ssh/known_hosts
echo "Tunnel to DB
ssh -N -L 9001:some_other_server.com:5432 some_user@some_server.com -i /root/.ssh/id_rsa-dev &
echo "Setup for dump and restore
cd /root/dump
date_today=$(date +%F)
echo "Createing dump file from dev db name = dev_db_$date_today.sql"
export PGPASSWORD=${DEV_DB_PASSWORD}
pg_dump -Fc -v -U dbuser -d dev_db -p 9001 -h 0.0.0.0 > ./dev_db_$date_today.sql
export PGPASSWORD=$POSTGRES_PASSWORD
echo "Restoring db"
pg_restore -Fc -v -U dbuser -d dev_db_docker_local ./dev_db_$date_today.sql

I would prefer to be able to run my startup.sh script from /docker-entrypoint-initdb.d folder as a root user.  But If I can not, then would like to be able to added all the steps to Dockerfile

Any help would be greatly appreciated.

Note:

I asked a question here.

I was trying to find out how to get my startup script to run as root, but realized the question did not give enough context so I created this post.  I mention this because setting user root or 0, wether in the Dockerfile or the docker-compose.yml does not solve my problem.

If I try to run startup.sh from /docker-entrypoint-initdbd:

sudo is not available.  su is available, but I do not know root password. gosu is available but when I used that it give an error along the lines of operation not permitted.

Update 1:

Seems like this is an issue.  The postgres docker github says you can not run as root from /docker-entrypoint-initdb.d.

https://github.com/docker-library/postgres/issues/973

But something seems weird about that.  I figure there has got to be a way around this.  Or maybe some best practice that address this use case.  I imagine I am not the only one who has run into an issue like this.

Update 2:

I just realized running the commands in Dockerfile will not work because postgres would not have been started yet.  And I need to run psql after I open the tunnel.  So I have to run from /docker-entrypoint-initdb.d folder or figure out some way to get startup.sh to run after postgis container finishes its default start up processes.

Appearently this was not a problem a few years ago, but I believe there was a move to stop the use of root access during the build start up process in the /docker-entrypoint-initdb.d for security reasons.  But there was no suggested work around.


问:
ofstream fails to open existing file
While working with the OpenXcom app, I noticed that at some point the app stopped updating the options.cfg file.  I tracked this issue down to a failure creating an ofstream object for the options.cfg file in the Options::save() method.  A search uncovered no explanation for my issue.  The only solution I could find was to delete the options.cfg file and let the program recreate it with the default settings.

I have recreated what appears to be a similar issue with a very simple C++ program (modeled on the first few lines of the Options::save() method in the OpenXcom project):

```<code>#include <iostream>
#include <fstream>

void check(const std::string& filename)
{
    std::ofstream stream(filename.c_str());

    if (!stream) {
        std::cout << "FAIL " << filename << std::endl;
    }
    else {
        std::cout << "PASS " << filename << std::endl;
    }
}

int main()
{
    check("options1.cfg");
    check("options2.cfg");
}
</code>```

Using this test program, I created the following test case using the Command Prompt:

Create a directory containing only the test program.

Run the test program to create two empty .cfg files.

Run the test program again to verify that the program can still work with both .cfg files.

Delete options2.cfg

Copy options1.cfg to options2.cfg

Run the test program again.  Now the program can no longer create an ofstream object for the options2.cfg file.

Here is Command Prompt listing for the test case (which I have edited a bit to remove extraneous information):

C:\...\test>dir

12/19/2022  09:10 AM            27,648 ofstream-test.exe

C:\Users\jwlent\Documents\test>ofstream-test.exe
PASS options1.cfg
PASS options2.cfg

C:\...\test>dir

12/19/2022  09:10 AM            27,648 ofstream-test.exe
12/19/2022  02:39 PM                 0 options1.cfg
12/19/2022  02:39 PM                 0 options2.cfg

C:\...\test>ofstream-test.exe
PASS options1.cfg
PASS options2.cfg

C:\....\test>del options2.cfg

C:\....\test>copy options1.cfg options2.cfg
        1 file(s) copied.

C:\...\test>dir

12/19/2022  09:10 AM            27,648 ofstream-test.exe
12/19/2022  02:39 PM                 0 options1.cfg
12/19/2022  02:39 PM                 0 options2.cfg

C:\....\test>ofstream-test.exe
PASS options1.cfg
FAIL options2.cfg
```
<p>Other things I noted:</p>
<ul>
<li>Closing the Command Prompt console and creating a new one did not change the result (i.e. allow the test program to create an <code>ofstream</code> object for the <code>options2.cfg</code> file).</li>
<li>Closing the Command Prompt console and creating a new one with Admin authority did not change the result.</li>
<li>A restart of my laptop did clear the issue.  Since a restart clears the issue, that would indicate that there is nothing wrong with the file permissions.</li>
<li>There are several other ways to create this issue.  For example, manually creating the files using any editor.</li>
<li>I used VS 2022 on a Win 10 laptop to create the test program.</li>
</ul>
<p>Can anyone explain what may be going on?   Especially if there is a way to modify the test program to work around this issue in a way that can be applied to the <code>Options::save()</code> file in the OpenXcom project.</p>
<p>A few more observations:</p>
<ul>
<li>The problem can persist for many hours (overnight).</li>
<li>While the problem persists, Python has no problem writing to the file from the same Command Prompt.</li>
</ul>
<p>Here is the slightly edited Command Prompt output.</p>
```C:\...\test>ofstream-test.exe
PASS options1.cfg
FAIL options2.cfg

C:\...\test>python
Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)] on win32
>>> f = open("options2.cfg", "w")
>>> f.write("overwrite")
>>> f.close()
>>> exit()

C:\...\test>ofstream-test.exe
PASS options1.cfg
FAIL options2.cfg

C:\...\test>more options2.cfg
 overwrite
```

Here is what Process Monitor recorded for the C++ program and then Python trying to open the file for write:

46:23.0 ofstream-test.exe   22396   CreateFile   C:\Users\jwlent\Documents\test\options2.cfg   ACCESS DENIED   Desired Access: Generic Write, Read Attributes, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0

46:39.9 python.exe           3000   CreateFile   C:\Users\jwlent\Documents\test\options2.cfg   SUCCESS         Desired Access: Generic Write, Read Attributes, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0, OpenResult: Overwritten

Title: ofstream fails to open existing file

Body:
While working with the OpenXcom app, I noticed that at some point the app stopped updating the options.cfg file.  I tracked this issue down to a failure creating an ofstream object for the options.cfg file in the Options::save() method.  A search uncovered no explanation for my issue.  The only solution I could find was to delete the options.cfg file and let the program recreate it with the default settings.

I have recreated what appears to be a similar issue with a very simple C++ program (modeled on the first few lines of the Options::save() method in the OpenXcom project):

#include <iostream>
#include <fstream>

void check(const std::string& filename)
{
    std::ofstream stream(filename.c_str());

    if (!stream) {
        std::cout << "FAIL " << filename << std::endl;
    }
    else {
        std::cout << "PASS " << filename << std::endl;
    }
}

int main()
{
    check("options1.cfg");
    check("options2.cfg");
}

Using this test program, I created the following test case using the Command Prompt:

Create a directory containing only the test program.

Run the test program to create two empty .cfg files.

Run the test program again to verify that the program can still work with both .cfg files.

Delete options2.cfg

Copy options1.cfg to options2.cfg

Run the test program again.  Now the program can no longer create an ofstream object for the options2.cfg file.

Here is Command Prompt listing for the test case (which I have edited a bit to remove extraneous information):

C:\...\test>dir

12/19/2022  09:10 AM            27,648 ofstream-test.exe

C:\Users\jwlent\Documents\test>ofstream-test.exe
PASS options1.cfg
PASS options2.cfg

C:\...\test>dir

12/19/2022  09:10 AM            27,648 ofstream-test.exe
12/19/2022  02:39 PM                 0 options1.cfg
12/19/2022  02:39 PM                 0 options2.cfg

C:\...\test>ofstream-test.exe
PASS options1.cfg
PASS options2.cfg

C:\....\test>del options2.cfg

C:\....\test>copy options1.cfg options2.cfg
        1 file(s) copied.

C:\...\test>dir

12/19/2022  09:10 AM            27,648 ofstream-test.exe
12/19/2022  02:39 PM                 0 options1.cfg
12/19/2022  02:39 PM                 0 options2.cfg

C:\....\test>ofstream-test.exe
PASS options1.cfg
FAIL options2.cfg

Other things I noted:

Closing the Command Prompt console and creating a new one did not change the result (i.e. allow the test program to create an ofstream object for the options2.cfg file).

Closing the Command Prompt console and creating a new one with Admin authority did not change the result.

A restart of my laptop did clear the issue.  Since a restart clears the issue, that would indicate that there is nothing wrong with the file permissions.

There are several other ways to create this issue.  For example, manually creating the files using any editor.

I used VS 2022 on a Win 10 laptop to create the test program.

Can anyone explain what may be going on?   Especially if there is a way to modify the test program to work around this issue in a way that can be applied to the Options::save() file in the OpenXcom project.

A few more observations:

The problem can persist for many hours (overnight).

While the problem persists, Python has no problem writing to the file from the same Command Prompt.

Here is the slightly edited Command Prompt output.

C:\...\test>ofstream-test.exe
PASS options1.cfg
FAIL options2.cfg

C:\...\test>python
Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)] on win32
>>> f = open("options2.cfg", "w")
>>> f.write("overwrite")
>>> f.close()
>>> exit()

C:\...\test>ofstream-test.exe
PASS options1.cfg
FAIL options2.cfg

C:\...\test>more options2.cfg
 overwrite

Here is what Process Monitor recorded for the C++ program and then Python trying to open the file for write:

46:23.0 ofstream-test.exe   22396   CreateFile   C:\Users\jwlent\Documents\test\options2.cfg   ACCESS DENIED   Desired Access: Generic Write, Read Attributes, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0

46:39.9 python.exe           3000   CreateFile   C:\Users\jwlent\Documents\test\options2.cfg   SUCCESS         Desired Access: Generic Write, Read Attributes, Disposition: OverwriteIf, Options: Synchronous IO Non-Alert, Non-Directory File, Attributes: N, ShareMode: Read, Write, AllocationSize: 0, OpenResult: Overwritten


问:
django: aggregation of aggregation with subquery: cannot compute - Avg is an aggregate
I've been scouting & testing for quite some time now and I'm unable to get anything working with MariaDB.

My models:

```<code>class SequenceCompletion(SequenceMixin, models.Model):
    pass

class Play(SequenceMixin, models.Model):
    puzzle = models.ForeignKey(
        'puzzles.Puzzle', on_delete=models.CASCADE, related_name='plays')
    rating = models.IntegerField(default=-1)
    completion = models.ForeignKey(SequenceCompletion, blank=True,
                                   null=True, on_delete=models.SET_NULL, related_name='plays')
</code>```

I have a subquery:

```<code>rating_average_by_puzzle_from_completion_plays = Play.objects.filter(completion_id=OuterRef('id')).values('puzzle_id').order_by('puzzle_id').annotate(puzzle_rating_average=Avg('rating')).values('puzzle_rating_average')
</code>```

where the ratings of all plays corresponding to a given completion are averaged per puzzle_id

Afterwards, I'm trying, for each completion, to average the puzzle_rating_average corresponding to each puzzle_id:

if I do annotate, I end up with :

```<code>SequenceCompletion.objects.annotate(rating_avg_from_completion_plays=Subquery(rating_average_by_puzzle_from_completion_plays.annotate(result=Avg('puzzle_rating_average')).order_by().values('result')))

django.core.exceptions.FieldError: Cannot compute Avg('puzzle_rating_average'): 'puzzle_rating_average' is an aggregate
</code>```

if I do aggregate, I end up with :

```<code>SequenceCompletion.objects.annotate(rating_avg_from_completion_plays=Subquery(rating_average_by_puzzle_from_completion_plays.aggregate(result=Avg('puzzle_rating_average')).order_by().values('result')))

ValueError: This queryset contains a reference to an outer query and may only be used in a subquery.
</code>```

the same if I add completion_id to the subquery:

```<code>rating_average_by_puzzle_from_completion_plays = Play.objects.filter(completion_id=OuterRef('id')).values('puzzle_id').order_by('puzzle_id').annotate(puzzle_rating_average=Avg('rating')).values('puzzle_rating_average','completion_id')
</code>```

I tried as well:

```<code>SequenceCompletion.objects.annotate(rating_avg_from_completion_plays=Avg(Subquery(rating_average_by_puzzle_from_completion_plays)))
</code>```

and I end up with:

```<code>MySQLdb._exceptions.OperationalError: (1242, 'Subquery returns more than 1 row'
</code>```

Nothing I could find on the documentation or in any post would work, so I'll appreciate any help

Body:
I've been scouting & testing for quite some time now and I'm unable to get anything working with MariaDB.

My models:

class SequenceCompletion(SequenceMixin, models.Model):
    pass

class Play(SequenceMixin, models.Model):
    puzzle = models.ForeignKey(
        'puzzles.Puzzle', on_delete=models.CASCADE, related_name='plays')
    rating = models.IntegerField(default=-1)
    completion = models.ForeignKey(SequenceCompletion, blank=True,
                                   null=True, on_delete=models.SET_NULL, related_name='plays')

I have a subquery:

rating_average_by_puzzle_from_completion_plays = Play.objects.filter(completion_id=OuterRef('id')).values('puzzle_id').order_by('puzzle_id').annotate(puzzle_rating_average=Avg('rating')).values('puzzle_rating_average')

where the ratings of all plays corresponding to a given completion are averaged per puzzle_id

Afterwards, I'm trying, for each completion, to average the puzzle_rating_average corresponding to each puzzle_id:

if I do annotate, I end up with :

SequenceCompletion.objects.annotate(rating_avg_from_completion_plays=Subquery(rating_average_by_puzzle_from_completion_plays.annotate(result=Avg('puzzle_rating_average')).order_by().values('result')))

django.core.exceptions.FieldError: Cannot compute Avg('puzzle_rating_average'): 'puzzle_rating_average' is an aggregate

if I do aggregate, I end up with :

SequenceCompletion.objects.annotate(rating_avg_from_completion_plays=Subquery(rating_average_by_puzzle_from_completion_plays.aggregate(result=Avg('puzzle_rating_average')).order_by().values('result')))

ValueError: This queryset contains a reference to an outer query and may only be used in a subquery.

the same if I add completion_id to the subquery:

rating_average_by_puzzle_from_completion_plays = Play.objects.filter(completion_id=OuterRef('id')).values('puzzle_id').order_by('puzzle_id').annotate(puzzle_rating_average=Avg('rating')).values('puzzle_rating_average','completion_id')

I tried as well:

SequenceCompletion.objects.annotate(rating_avg_from_completion_plays=Avg(Subquery(rating_average_by_puzzle_from_completion_plays)))

and I end up with:

MySQLdb._exceptions.OperationalError: (1242, 'Subquery returns more than 1 row'

Nothing I could find on the documentation or in any post would work, so I'll appreciate any help


问:
mongo-express can't connect to MongoDB
I have a problem my mongo-express container can't connect to the MongoDB container. Although I didn't change my code, I changed the version of the image container by downloading the latest version. And this is the log file from the mongo-express container.

```<code>(node:7) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring
engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Could not connect to database using connectionString: mongodb://admin:password@mongodb:27017/"
(node:7) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [mongodb:27017] on first connect [MongoNetworkTimeoutError: connection timed out
    at connectionFailureError (/node_modules/mongodb/lib/core/connection/connect.js:362:14)
    at Socket.<anonymous> (/node_modules/mongodb/lib/core/connection/connect.js:330:16)
    at Object.onceWrapper (events.js:420:28)
    at Socket.emit (events.js:314:20)
    at Socket._onTimeout (net.js:483:8)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)]
    at Pool.<anonymous> (/node_modules/mongodb/lib/core/topologies/server.js:441:11)
    at Pool.emit (events.js:314:20)
    at /node_modules/mongodb/lib/core/connection/pool.js:564:14
    at /node_modules/mongodb/lib/core/connection/pool.js:1000:11
    at /node_modules/mongodb/lib/core/connection/connect.js:32:7
    at callback (/node_modules/mongodb/lib/core/connection/connect.js:300:5)
    at Socket.<anonymous> (/node_modules/mongodb/lib/core/connection/connect.js:330:7)
    at Object.onceWrapper (events.js:420:28)
    at Socket.emit (events.js:314:20)
    at Socket._onTimeout (net.js:483:8)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
(node:7) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:7) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
</code>```

I tried to connect mongo-express to MongoDB and every 10 seconds mongo-express restarted.

Title: mongo-express can't connect to MongoDB

Body:
I have a problem my mongo-express container can't connect to the MongoDB container. Although I didn't change my code, I changed the version of the image container by downloading the latest version. And this is the log file from the mongo-express container.

(node:7) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring
engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Could not connect to database using connectionString: mongodb://admin:password@mongodb:27017/"
(node:7) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [mongodb:27017] on first connect [MongoNetworkTimeoutError: connection timed out
    at connectionFailureError (/node_modules/mongodb/lib/core/connection/connect.js:362:14)
    at Socket.<anonymous> (/node_modules/mongodb/lib/core/connection/connect.js:330:16)
    at Object.onceWrapper (events.js:420:28)
    at Socket.emit (events.js:314:20)
    at Socket._onTimeout (net.js:483:8)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)]
    at Pool.<anonymous> (/node_modules/mongodb/lib/core/topologies/server.js:441:11)
    at Pool.emit (events.js:314:20)
    at /node_modules/mongodb/lib/core/connection/pool.js:564:14
    at /node_modules/mongodb/lib/core/connection/pool.js:1000:11
    at /node_modules/mongodb/lib/core/connection/connect.js:32:7
    at callback (/node_modules/mongodb/lib/core/connection/connect.js:300:5)
    at Socket.<anonymous> (/node_modules/mongodb/lib/core/connection/connect.js:330:7)
    at Object.onceWrapper (events.js:420:28)
    at Socket.emit (events.js:314:20)
    at Socket._onTimeout (net.js:483:8)
    at listOnTimeout (internal/timers.js:554:17)
    at processTimers (internal/timers.js:497:7)
(node:7) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:7) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I tried to connect mongo-express to MongoDB and every 10 seconds mongo-express restarted.


问:
Validate OneSignalNotificationExtension.appex Command ValidateEmbeddedBinary failed with a nonzero exit code
I have a react native app. I integrated one signal into android and ios separately.
There is no problem in android side.
After i am setting ios sdk, i am getting error while get archive for testfligt.

Error text:

.) Validate OneSignalNotificationExtension.appex
..) Command ValidateEmbeddedBinary failed with a nonzero exit code.
Before installing OneSignalNotificationExtension

I was able to get archive successfully. I think the problem is inside OneSignalNotificationExtension.

I use m1 macbook air and my ios is version 11.0.


问:
ID = None script doesn't return ID from List
I am new to Python. A script was made for parsing Flashscore via request. It takes data from the first page for all games for tomorrow.
`

```<code>import json
import requests
from datetime import datetime

headers = {"x-fsign": "SW9D1eZo"}

def main():
    feed = 'f_1_1_1_en_1'
    url = f'https://d.flashscore.com/x/feed/{feed}'
    response = requests.get(url=url, headers=headers)
    data = response.text.split('¬')

    data_list = [{}]

    for item in data:
        key = item.split('÷')[0]
        value = item.split('÷')[-1]

        if '~' in key:
            data_list.append({key: value})
        else:
            data_list[-1].update({key: value})

    for game in data_list:
        if 'AA' in list(game.keys())[0]:
            id = game.get("AA")
            date = datetime.fromtimestamp(int(game.get("AD")))
            team_1 = game.get("AE")
            team_2 = game.get("AF")
            score = f'{game.get("AG")} : {game.get("AH")}'

            print(id, date, team_1, team_2, score, sep=' ')

            #print(json.dumps(data_list, ensure_ascii=False, indent=2))
</code>```

`

But then, I need to go into each game to get the H2H stats, get the average number of goals scored in the last 5 Home and Away games. And here I just can’t understand and do how I can pull out the ID of each game so that the page with H2H opens. On Selenium, I was able to do this, but nothing happens with request.

Please can you advise me and help me to do.
Thank you all in advance for your help and participation.

Body:
I am new to Python. A script was made for parsing Flashscore via request. It takes data from the first page for all games for tomorrow.
`

import json
import requests
from datetime import datetime

headers = {"x-fsign": "SW9D1eZo"}

def main():
    feed = 'f_1_1_1_en_1'
    url = f'https://d.flashscore.com/x/feed/{feed}'
    response = requests.get(url=url, headers=headers)
    data = response.text.split('¬')

    data_list = [{}]

    for item in data:
        key = item.split('÷')[0]
        value = item.split('÷')[-1]

        if '~' in key:
            data_list.append({key: value})
        else:
            data_list[-1].update({key: value})

    for game in data_list:
        if 'AA' in list(game.keys())[0]:
            id = game.get("AA")
            date = datetime.fromtimestamp(int(game.get("AD")))
            team_1 = game.get("AE")
            team_2 = game.get("AF")
            score = f'{game.get("AG")} : {game.get("AH")}'

            print(id, date, team_1, team_2, score, sep=' ')

            #print(json.dumps(data_list, ensure_ascii=False, indent=2))

`

But then, I need to go into each game to get the H2H stats, get the average number of goals scored in the last 5 Home and Away games. And here I just can’t understand and do how I can pull out the ID of each game so that the page with H2H opens. On Selenium, I was able to do this, but nothing happens with request.

Please can you advise me and help me to do.
Thank you all in advance for your help and participation.


问:
Why is pandas-profiling report not working in kaggle
I'm trying to run this code in kaggle for EDA.  As you can see everything seems correct but I don't see an option to open an html file.  How would I access the file that I just created?


问:
Auto scale an Image in Unity only when screen boundaries touches the image

Example

The square is a screen and the diamond is an image

Example

In words

I want my image to be located always at the same point of the screen with any resolution and the image resizes only if the image touches the boundaries of the screen and it always resizes with constant propotions of its width and height (say 16:9) (I have a grid drawed on the image and I need to keep cells of it squared).

Summary

I need to resize the image only if the screen size is smaller in width or height than the image is, else never the image never scales.

What I've tried

For the ideal resolution I took 16:9 and I needed to scale my image, as I described above.
I've tried to use any combination of anchors, and the best one I've got is

use Canvas scaler of the canvas with the image with Scale with screen size checked and

Match width or height equals 1

make anchors of the image located in the center of the image. And everything's good except if the width of the image touches the screen left or right boundaries it does not scale.

Otherwise, if I use Match width or height equals 0 the image does not scale if it touches the screen's upper or lower boundaries.

And, finally, if Match width or height equals 0.5, or other between 0 and 1, the image scales always, but I needed to scale it only if it touches the screen boundaries.


问:
How to Alphanumerically Iterate Through Folders While Accounting for Decimals? (Python3.10)
Is there some way to alphanumerically sort through the folders inside of a given directory path while accounting for the decimals as well? (I'm currently using Python3.10 and am on Windows 11).

I'm making a program that when given a directory path containing folders in it, will iterate through each of those folders and iterate through each of the .jpgs in those folders. Each of those .jpgs are to be renamed starting from i, where i = 1 and up until the last .jpg that is founded. However, I am having issues with iterating through each of those folders alphanumerically (I believe that's the term?).

I have technically iterated through the folders alphanumerically like in Example 1.

Example 1 (Correct): Ch 1, Ch 2, Ch 3, Ch 10, Ch 11

Example 2 (Incorrect): Ch 1, Ch 10, Ch 11, Ch 2, Ch 3

But I say technically because I've done so using key=len in the for loop in the code provided below. And (I believe) that only sorts things by the character length. Thus, it does not account for decimals such as in Example 4. I got key=len from this post.

Example 3 (Correct): Ch 1, Ch 2, Ch 2.5, Ch 8, Ch 10, Ch. 21.5, Ch 234

Example 4 (Incorrect): Ch 1, Ch 2, Ch 8, Ch 10, Ch 2.5, Ch 234, Ch. 21.5

```<code>    def fnSortThroughFiles(self):
        #Prompts file dialog for user to choose a directory path
        chosenPath = filedialog.askdirectory()

        i = 0
        #For all the files in a sorted list containing each directory path in chosenPath
        for file in sorted(os.listdir(chosenPath), key=len):
            i = i+1
            #prints name of the folder
            print( str(i) + ". " + file)
            #Make a for loop that iterates through a concatenation of chosenPath and file to rename .jpgs and move them all into one single folder rather than being in separate folders.
        #Outputs the total amount of files (in this case folder) founded inside of chosenPath (not the files inside of chosenPath's files)
        print("\nA total of " + str(i) + " items are in the directory " + chosenPath)

</code>```

Here are some pictures I've attached if needed.

Output with incorrect sorting

Visual Aid 1: User's Chosen Path

Visual Aid 2: Folders to be iterated in User's Chosen Path

Visual Aid 3: Files to be iterated and renamed accordingly

Body:
Is there some way to alphanumerically sort through the folders inside of a given directory path while accounting for the decimals as well? (I'm currently using Python3.10 and am on Windows 11).

I'm making a program that when given a directory path containing folders in it, will iterate through each of those folders and iterate through each of the .jpgs in those folders. Each of those .jpgs are to be renamed starting from i, where i = 1 and up until the last .jpg that is founded. However, I am having issues with iterating through each of those folders alphanumerically (I believe that's the term?).

I have technically iterated through the folders alphanumerically like in Example 1.

Example 1 (Correct): Ch 1, Ch 2, Ch 3, Ch 10, Ch 11

Example 2 (Incorrect): Ch 1, Ch 10, Ch 11, Ch 2, Ch 3

But I say technically because I've done so using key=len in the for loop in the code provided below. And (I believe) that only sorts things by the character length. Thus, it does not account for decimals such as in Example 4. I got key=len from this post.

Example 3 (Correct): Ch 1, Ch 2, Ch 2.5, Ch 8, Ch 10, Ch. 21.5, Ch 234

Example 4 (Incorrect): Ch 1, Ch 2, Ch 8, Ch 10, Ch 2.5, Ch 234, Ch. 21.5

    def fnSortThroughFiles(self):
        #Prompts file dialog for user to choose a directory path
        chosenPath = filedialog.askdirectory()

        i = 0
        #For all the files in a sorted list containing each directory path in chosenPath
        for file in sorted(os.listdir(chosenPath), key=len):
            i = i+1
            #prints name of the folder
            print( str(i) + ". " + file)
            #Make a for loop that iterates through a concatenation of chosenPath and file to rename .jpgs and move them all into one single folder rather than being in separate folders.
        #Outputs the total amount of files (in this case folder) founded inside of chosenPath (not the files inside of chosenPath's files)
        print("\nA total of " + str(i) + " items are in the directory " + chosenPath)

Here are some pictures I've attached if needed.

Output with incorrect sorting

Visual Aid 1: User's Chosen Path

Visual Aid 2: Folders to be iterated in User's Chosen Path

Visual Aid 3: Files to be iterated and renamed accordingly


问:
How can we resolve 'certificate verify failed' error?
I am trying to run this simple script on my company laptop.

```<code>from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="ryan_data")
location = geolocator.geocode("175 5th Avenue NYC")
print(location.address)
</code>```

When I run that code I get this error message.

```<code>GeocoderUnavailable: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /search?q=175+5th+Avenue+NYC&format=json&limit=1 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))
</code>```

If I run the exact code on my personal laptop, everything works totally fine. I think there is some kind of VPN issue or maybe firewall issue, on the corporate laptop. I Googled the error and found a couple things on this topic, but not much really. I feel like there should be an easy work-around, but after Googling this and trying a couple ideas, I am still stuck! Has anyone here encountered this issue and resolved it? If so, please do share your thoughts!

Body:
I am trying to run this simple script on my company laptop.

from geopy.geocoders import Nominatim
geolocator = Nominatim(user_agent="ryan_data")
location = geolocator.geocode("175 5th Avenue NYC")
print(location.address)

When I run that code I get this error message.

GeocoderUnavailable: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /search?q=175+5th+Avenue+NYC&format=json&limit=1 (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))

If I run the exact code on my personal laptop, everything works totally fine. I think there is some kind of VPN issue or maybe firewall issue, on the corporate laptop. I Googled the error and found a couple things on this topic, but not much really. I feel like there should be an easy work-around, but after Googling this and trying a couple ideas, I am still stuck! Has anyone here encountered this issue and resolved it? If so, please do share your thoughts!


问:
Can't use string literal "s" with a string in C++
I am trying to write a simple C++ program that would just print string "Hello" with a string literal s. However, for some reason I can't. This is my code:

```<code>#include <iostream>
#include <string>

using namespace std;

int main() {
    string hello_word = "Hello!"s;
    cout << hello_word << endl;
    return 0;
}
</code>```

This is the error code:

```<code>test.cpp:7:33: error: expected ';' at end of declaration
    string hello_word = "Hello!"s;
                                ^
                                ;
1 error generated.
</code>```

I've tried inserting using namespace std::string_literals but nothing still works.

Body:
I am trying to write a simple C++ program that would just print string "Hello" with a string literal s. However, for some reason I can't. This is my code:

#include <iostream>
#include <string>

using namespace std;

int main() {
    string hello_word = "Hello!"s;
    cout << hello_word << endl;
    return 0;
}

This is the error code:

test.cpp:7:33: error: expected ';' at end of declaration
    string hello_word = "Hello!"s;
                                ^
                                ;
1 error generated.

I've tried inserting using namespace std::string_literals but nothing still works.


问:
How do I find out the current role of the user?
I create a role and a user:

```<code>create user FUser identified by '123';
CREATE ROLE 'admin';
GRANT 'admin' TO FUser;
</code>```

I know there is a function CURRENT_ROLE().
If I log into the database as FUser and when I call this function, the role is displayed correctly.

But now I need to create a function (as root user) inside which will be used CURRENT_ROLE().

Now if i log in as FUser again and call my function, I will get a NONE response. I.e., the root user role. How can this be fixed so that there is the right role, and not the role of the root user, where the function was created

Body:
I create a role and a user:

create user FUser identified by '123';
CREATE ROLE 'admin';
GRANT 'admin' TO FUser;

I know there is a function CURRENT_ROLE().
If I log into the database as FUser and when I call this function, the role is displayed correctly.

But now I need to create a function (as root user) inside which will be used CURRENT_ROLE().

Now if i log in as FUser again and call my function, I will get a NONE response. I.e., the root user role. How can this be fixed so that there is the right role, and not the role of the root user, where the function was created


问:
Woocommerce rounding totals and tax still gives a wrong impression to the client
A Regular price of a product is 46.875 but the figure displayed is 55 on the client view because of Rounding per Line ( UNCHECKED : Round tax at subtotal level, instead of rounding per line) and depends on the Decimals Set in this case Zero (0).

When a Client takes Quantity of 2 the Subtotal is 109 instead of 110. For the client expects 110 instead of 109.

Here is the Math:

```<code>46.875 x 0.16(VAT) = 7.5 then Add 46.875 = 54.375 (x2 (Quantity) = 108.75 => rounded subtotal is 109)
</code>```

Even if we change the regular price 46.875 to 47. We get the same.

```<code>47   x   0.16(VAT) = 7.52 then Add 47 = 54.52    (x2 (Quantity) = 109.04 => rounded subtotal 109)
</code>```

My Question or idea is, can i Round the items Subtotal before multiplying by Quantity so that i have something like this:

```<code>46.875 x 0.16(VAT) = 7.5 then Add 46.875 = ROUNDED SUBTOTAL 55 instead of 54.375 (x2 (Quantity) = 110 => rounded subtotal is 110)
</code>```

or

```<code>47   x   0.16(VAT) = 7.52 then Add 47 = 54.52 ROUND TO 55    (x2 (Quantity) = 110 => rounded subtotal 110)
</code>```

The solution though makes the client pay the extra decimals added to the rounding and it becomes more if the quantity increases. (55 - 54.52 = 0.48 X Quantity Increase).
This Increase were not taxed as well.

So my last solution to this part is on receipting and invoice or order , I can calculate how much VAT is in the total 110 and send to Quickbooks online the total as 110 and tax as 0.16 of 110 instead of 109.
This means the tax i calculated earlier was just to factor in Tax in the price to the client and the increase in rounding is a markup by the seller or considered by the seller within their mark up.

The last generation of new tax amount at the receipting/order level is just to make sure we tax the Total.

Sounds crazy but i think its a win win for everyone.

SO, i would really like to try this by rounding subtotal before multiplying by Quantity and generating new Tax amount at totals when receipting/invoicing so that the client sees accurate tax from totals.

If you have a different idea, i would really like to try.

Thanks :)

Body:
A Regular price of a product is 46.875 but the figure displayed is 55 on the client view because of Rounding per Line ( UNCHECKED : Round tax at subtotal level, instead of rounding per line) and depends on the Decimals Set in this case Zero (0).

When a Client takes Quantity of 2 the Subtotal is 109 instead of 110. For the client expects 110 instead of 109.

Here is the Math:

46.875 x 0.16(VAT) = 7.5 then Add 46.875 = 54.375 (x2 (Quantity) = 108.75 => rounded subtotal is 109)

Even if we change the regular price 46.875 to 47. We get the same.

47   x   0.16(VAT) = 7.52 then Add 47 = 54.52    (x2 (Quantity) = 109.04 => rounded subtotal 109)

My Question or idea is, can i Round the items Subtotal before multiplying by Quantity so that i have something like this:

46.875 x 0.16(VAT) = 7.5 then Add 46.875 = ROUNDED SUBTOTAL 55 instead of 54.375 (x2 (Quantity) = 110 => rounded subtotal is 110)

or

47   x   0.16(VAT) = 7.52 then Add 47 = 54.52 ROUND TO 55    (x2 (Quantity) = 110 => rounded subtotal 110)

The solution though makes the client pay the extra decimals added to the rounding and it becomes more if the quantity increases. (55 - 54.52 = 0.48 X Quantity Increase).
This Increase were not taxed as well.

So my last solution to this part is on receipting and invoice or order , I can calculate how much VAT is in the total 110 and send to Quickbooks online the total as 110 and tax as 0.16 of 110 instead of 109.
This means the tax i calculated earlier was just to factor in Tax in the price to the client and the increase in rounding is a markup by the seller or considered by the seller within their mark up.

The last generation of new tax amount at the receipting/order level is just to make sure we tax the Total.

Sounds crazy but i think its a win win for everyone.

SO, i would really like to try this by rounding subtotal before multiplying by Quantity and generating new Tax amount at totals when receipting/invoicing so that the client sees accurate tax from totals.

If you have a different idea, i would really like to try.

Thanks :)


问:
Error in pluck: object not found -- trying to create loop to scrape data from multiple PDFs with uniform formatting
Thanks to other articles on this website, I managed to put together a script that will do the following:

Collect PDF file names from directory and put into a list.

Start a data frame using target data from the first PDF in the directory.

Use loop function to add rows to the original data frame containing the same target data (pulling from the same section of the PDF).

My first two steps work (code below)

```<code>file_names <- list.files(pattern = "*.pdf")
</code>```
```<code>df <-
  extract_tables(
    file = "firstlastname.pdf",
    method = "decide",
    output = "data.frame"
  ) %>%
  pluck(2) %>%
  t() %>%
  as.data.frame() %>%
  slice(2) %>%
  select(1:3) %>%
  rename("inst" = "V1",
         "date" = "V2",
         "field" = "V3")
</code>```

but my final step throws the following error:
"Error in pluck(., 2) : object 'tmp' not found"

```<code>for (i in file_names)
{
  new <-
    extract_tables(
      file = i,
      method = "decide",
      output = "data.frame"
      ) %>%
    pluck(2) %>%
    t() %>%
    as.data.frame() %>%
    slice(2) %>%
    select(1:3) %>%
    rename("inst" = "V1",
           "date" = "V2",
           "field" = "V3") %>%
    df[nrow(df) + 1, ] <- new
}
</code>```

I am confused because I actually made it all the way through successfully a couple times, but I tried it again after closing RStudio and coming back, and it just won't work anymore. I'm a complete beginner just trying to automate my secretary job a little bit, but I'm probably in way over my head. All I can do is Google things, copy and paste code, and try to understand what everything means and how it comes together.

Unfortunately I can't provide my data files because they contain people's personal information, but the final result is supposed to look like a table with about 50 rows and 3 columns. I did take a photo the first time it worked, though:

successful data frame

Thank you for reading. Any tips would be much appreciated!

Body:
Thanks to other articles on this website, I managed to put together a script that will do the following:

Collect PDF file names from directory and put into a list.

Start a data frame using target data from the first PDF in the directory.

Use loop function to add rows to the original data frame containing the same target data (pulling from the same section of the PDF).

My first two steps work (code below)

file_names <- list.files(pattern = "*.pdf")

df <-
  extract_tables(
    file = "firstlastname.pdf",
    method = "decide",
    output = "data.frame"
  ) %>%
  pluck(2) %>%
  t() %>%
  as.data.frame() %>%
  slice(2) %>%
  select(1:3) %>%
  rename("inst" = "V1",
         "date" = "V2",
         "field" = "V3")

but my final step throws the following error:
"Error in pluck(., 2) : object 'tmp' not found"

for (i in file_names)
{
  new <-
    extract_tables(
      file = i,
      method = "decide",
      output = "data.frame"
      ) %>%
    pluck(2) %>%
    t() %>%
    as.data.frame() %>%
    slice(2) %>%
    select(1:3) %>%
    rename("inst" = "V1",
           "date" = "V2",
           "field" = "V3") %>%
    df[nrow(df) + 1, ] <- new
}

I am confused because I actually made it all the way through successfully a couple times, but I tried it again after closing RStudio and coming back, and it just won't work anymore. I'm a complete beginner just trying to automate my secretary job a little bit, but I'm probably in way over my head. All I can do is Google things, copy and paste code, and try to understand what everything means and how it comes together.

Unfortunately I can't provide my data files because they contain people's personal information, but the final result is supposed to look like a table with about 50 rows and 3 columns. I did take a photo the first time it worked, though:

successful data frame

Thank you for reading. Any tips would be much appreciated!


问:
I am developing an android mobile app using WebView. My site uses bootstrap 5 and I'm in the process of converting it to a mobile app
My site is responsive on all media by displaying it in a browser. When I load it in the android webview the display is distorted. I found that there are class bootstrap 5 which work badly. Its classes are position classes.
such as: .position-relative, .position-static and .position-absolute.
The css of its class does not work with the android webview.
Does anyone have an idea for the webview to take positional css into account.

```<code>Exemple css :
</code>```

.position-static

```<code>position: static !important;
</code>```

.position-relative

```<code>position: relative !important;
</code>```

.position-absolute

```<code>position: absolute !important;
</code>```

Example HTML:

```<code><div class="row g-0 border rounded overflow-hidden flex-md-row mb-2 shadow-sm h-md-250 position-relative">
    <div class="col-auto d-lg-block">
        <a href="/ad-categories/21" hreflang="zxx"><img loading="lazy" src="/sites/default/files/styles/thumbnail/public/2022-10/sauce%20pistache.jpg ?itok=RcWqSOZN" width="100" height="100" alt="" typeof="foaf:Image" class="img-fluid image-style-thumbnail">
</a>

        <div class="label-top shadow-sm">
            <i class="fa fa-star" aria-hidden="true"></i>
        </div>
    </div>
    <div class="col d-flex flex-column position-static small">
        <div class="d-flex bd-highlight">
            <div class="flex-fill bd-highlight">
                <h5 class="card-title small "><span class="field field--name-title field--type-string field--label-hidden">MAÏTE DEHYDRATED SAUCES</span>
                </h5>
            </div>
        </div>
        <div class="d-flex bd-highlight departure-date">
            <div class="flex-fill bd-highlight text-muted small">
                <p class="card-text address"><i class="fa fa-map-o text-info"></i> Abidjan,CI</p>
            </div>
            <div class="flex-fill bd-highlight small">
                <span class="badge rounded-pill bg-success border border-light text-light fw-bold">
                    Premium
                    <span class="visually-hidden">New alerts</span>
                </span>
            </div>
        </div>
        <div class="d-flex bd-highlight">
            <div class="flex-fill bd-highlight text-muted small">

                <div class="field field--name-field-categories field--type-entity-reference field--label-hidden field__item"><div class="contextual-region term-categories-icon d-flex justify-content -start" about="/taxonomy/term/4">

                        <div class="field field--name-field-icon field--type-fontawesome-icon field--label-hidden field__item"><div class="fontawesome-icons">
                                <div class="fontawesome-icon">
                                    <i class="fas fa-beer food-drink" data-fa-transform="" data-fa-mask="" style="--fa-primary-color: #000000; --fa-secondary-color : #000000; food-drink"></i>
                                </div>

                            </div>
                        </div>
                        <a class="link" href="/ad-categories?categories_id=4">
                            <div class="field field--name-name field--type-string field--label-hidden field__item">Food & drink</div>
                        </a>
                    </div></div>

            </div>
            <div class="flex-fill bd-highlight text-muted small">
                <span class="align-middle"><i class="fa fa-map-marker"></i> Abidjan</span>
            </div>
        </div>
    </div>
</div>
</code>```

Body:
My site is responsive on all media by displaying it in a browser. When I load it in the android webview the display is distorted. I found that there are class bootstrap 5 which work badly. Its classes are position classes.
such as: .position-relative, .position-static and .position-absolute.
The css of its class does not work with the android webview.
Does anyone have an idea for the webview to take positional css into account.

Exemple css :

.position-static

position: static !important;

.position-relative

position: relative !important;

.position-absolute

position: absolute !important;

Example HTML:

MAÏTE DEHYDRATED SAUCES

 Abidjan,CI

                    Premium
                    New alerts

Food & drink

                 Abidjan


问:
convert stringUri to hierarchicalUri Android
I converted hierarchicalUri to string using toString() method.
Now when I'm parsing the string back to Uri using Uri.parse() method it's returning me a "stringUri" which is unacceptable for setImageURI() method.

How can I parse string to hierarchicalUri from stringUri

I tried to parsing a string back to Uri using Uri.parse() method it's returning me a "stringUri" I was expecting ImageView setImageURI() method accept stringUri


问:
Specifying Micronaut Lambda application profile
According to the AWS Lambda documentation, one can pass environment variables when creating a Lambda.

If Lambda is implemented as a spring boot application, setting the SPRING_PROFILES_ACTIVE variable will activate the specified profile.

How can we emulate the same behavior when Lambda is implemented as a Micronaut application?