问:
iOS: How to adjust uikit row height based on height of dynamic embedded swiftui view?
I'm working on a legacy app and trying to embed a swiftUI view inside a UIKit UITableView. The SwiftUI view is a LazyHGrid with a number of items based on a user's number of accounts. The idea is to display the first 1-3 items (if there are any), and a "More" button, which, when tapped, displays the rest of the items.

The SwiftUI piece is working correctly, and initially the tableView displays it correctly, like so:
three tiles working correctly. However, when I tap the "More" button, the other items pop in, but the row height in the table doesn't adjust, so they just overlap the other content in the table, like so: tiles overlapping other content.

Here's the host function that controls the swiftUI view:

```<code>func host(_ view: Content, parent: UIViewController) {
        hostingController.rootView = view
        hostingController.view.invalidateIntrinsicContentSize()

        let requiresControllerMove = hostingController.parent != parent

        if requiresControllerMove {
            // remove old parent if exists
            removeHostingControllerFromParent()
            parent.addChild(hostingController)
        }

        if !contentView.subviews.contains(hostingController.view) {
            contentView.addSubview(hostingController.view)

            hostingController.view.translatesAutoresizingMaskIntoConstraints = false
            hostingController.view.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true
            hostingController.view.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true
            hostingController.view.leadingAnchor.constraint(equalTo: contentView.leadingAnchor).isActive = true
            hostingController.view.trailingAnchor.constraint(equalTo: contentView.trailingAnchor).isActive = true
        }

        if requiresControllerMove {
            hostingController.didMove(toParent: parent)
        }
    }
</code>```

I register the cell in the viewDidLoad in the UIKit controller:

```<code>self.tableView.register(SwiftUIHostTableViewCell<BillingTileGridView>.self, forCellReuseIdentifier: "BillingTileGridViewCell")
</code>```

(This code was already present in the viewDidLoad):

```<code>  self.tableView.estimatedRowHeight = 60
  self.tableView.rowHeight = UITableView.automaticDimension
</code>```

And then I create the cell like so in the tableView cellForRowAt function:

```<code>
if let cell = tableView.dequeueReusableCell(withIdentifier: cellReuseID, for: indexPath) as? SwiftUIHostTableViewCell<BillingTileGridView> {
                let view = BillingTileGridView(viewModel: BillingTileGridViewModel(), adjustHeight: {
                })
                cell.host(view, parent: self)
                return cell
            }

</code>```

I tried using a callback to re-load the table height for the button action, like this:

```<code>                let view = BillingTileGridView(viewModel: BillingTileGridViewModel(), adjustHeight: {
                    tableView.beginUpdates()
                    tableView.endUpdates()
                })
</code>```

like I'd seen in questions like this one, Swift: How to reload row height in UITableViewCell without reloading data, but it didn't seem to do anything. Do I just need to calculate the height manually based on how many rows I have, and set the height explicitly to that?

Body:
I'm working on a legacy app and trying to embed a swiftUI view inside a UIKit UITableView. The SwiftUI view is a LazyHGrid with a number of items based on a user's number of accounts. The idea is to display the first 1-3 items (if there are any), and a "More" button, which, when tapped, displays the rest of the items.

The SwiftUI piece is working correctly, and initially the tableView displays it correctly, like so:
three tiles working correctly. However, when I tap the "More" button, the other items pop in, but the row height in the table doesn't adjust, so they just overlap the other content in the table, like so: tiles overlapping other content.

Here's the host function that controls the swiftUI view:

func host(_ view: Content, parent: UIViewController) {
        hostingController.rootView = view
        hostingController.view.invalidateIntrinsicContentSize()

        let requiresControllerMove = hostingController.parent != parent

        if requiresControllerMove {
            // remove old parent if exists
            removeHostingControllerFromParent()
            parent.addChild(hostingController)
        }

        if !contentView.subviews.contains(hostingController.view) {
            contentView.addSubview(hostingController.view)

            hostingController.view.translatesAutoresizingMaskIntoConstraints = false
            hostingController.view.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true
            hostingController.view.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true
            hostingController.view.leadingAnchor.constraint(equalTo: contentView.leadingAnchor).isActive = true
            hostingController.view.trailingAnchor.constraint(equalTo: contentView.trailingAnchor).isActive = true
        }

        if requiresControllerMove {
            hostingController.didMove(toParent: parent)
        }
    }

I register the cell in the viewDidLoad in the UIKit controller:

self.tableView.register(SwiftUIHostTableViewCell<BillingTileGridView>.self, forCellReuseIdentifier: "BillingTileGridViewCell")

(This code was already present in the viewDidLoad):

  self.tableView.estimatedRowHeight = 60
  self.tableView.rowHeight = UITableView.automaticDimension

And then I create the cell like so in the tableView cellForRowAt function:

if let cell = tableView.dequeueReusableCell(withIdentifier: cellReuseID, for: indexPath) as? SwiftUIHostTableViewCell<BillingTileGridView> {
                let view = BillingTileGridView(viewModel: BillingTileGridViewModel(), adjustHeight: {
                })
                cell.host(view, parent: self)
                return cell
            }

I tried using a callback to re-load the table height for the button action, like this:

                let view = BillingTileGridView(viewModel: BillingTileGridViewModel(), adjustHeight: {
                    tableView.beginUpdates()
                    tableView.endUpdates()
                })

like I'd seen in questions like this one, Swift: How to reload row height in UITableViewCell without reloading data, but it didn't seem to do anything. Do I just need to calculate the height manually based on how many rows I have, and set the height explicitly to that?


来源: stackexchange

问:
java.net.ProtocolException: Server redirected too many times (20) when publishing to Azure Devops
I am attempting to publish an artifact to an Azure devops feed, self hosted. I have successfully published a normal maven project to the feed without issue. When i attempt to use sbt to publish a scala package I get this error.

```<code>[error] java.net.ProtocolException: Server redirected too many  times (20)
[error]         at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error]         at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
[error]         at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error]         at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
[error]         at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:2048)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:2043)
[error]         at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:2042)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1609)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)
[error]         at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224)
[error]         at org.apache.ivy.util.url.BasicURLHandler.upload(BasicURLHandler.java:288)
[error]         at org.apache.ivy.util.url.URLHandlerDispatcher.upload(URLHandlerDispatcher.java:82)
[error]         at org.apache.ivy.util.FileUtil.copy(FileUtil.java:150)
[error]         at org.apache.ivy.plugins.repository.url.URLRepository.put(URLRepository.java:84)
[error]         at sbt.internal.librarymanagement.ConvertResolver$LocalIfFileRepo.put(ConvertResolver.scala:368)
[error]         at org.apache.ivy.plugins.repository.AbstractRepository.put(AbstractRepository.java:130)
[error]         at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put(ConvertResolver.scala:118)
[error]         at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put$(ConvertResolver.scala:105)
[error]         at sbt.internal.librarymanagement.ConvertResolver$$anonfun$defaultConvert$lzycompute$1$PluginCapableResolver$1.put(ConvertResolver.scala:165)
[error]         at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(RepositoryResolver.java:216)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$5(IvyActions.scala:504)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at scala.util.Try$.apply(Try.scala:213)
[error]         at sbt.internal.librarymanagement.IvyUtil$.retryWithBackoff(IvyUtil.scala:22)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$4(IvyActions.scala:503)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$4$adapted(IvyActions.scala:501)
[error]         at scala.collection.Iterator.foreach(Iterator.scala:943)
[error]         at scala.collection.Iterator.foreach$(Iterator.scala:943)
[error]         at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
[error]         at scala.collection.IterableLike.foreach(IterableLike.scala:74)
[error]         at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
[error]         at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
[error]         at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:501)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$3(IvyActions.scala:143)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:157)
[error]         at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:150)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1(IvyActions.scala:143)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1$adapted(IvyActions.scala:133)
[error]         at sbt.internal.librarymanagement.IvySbt$Module.$anonfun$withModule$1(Ivy.scala:245)
[error]         at sbt.internal.librarymanagement.IvySbt.$anonfun$withIvy$1(Ivy.scala:209)
[error]         at sbt.internal.librarymanagement.IvySbt.sbt$internal$librarymanagement$IvySbt$$action$1(Ivy.scala:72)
[error]         at sbt.internal.librarymanagement.IvySbt$$anon$1.call(Ivy.scala:82)
[error]         at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:113)
[error]         at xsbt.boot.Locks$GlobalLock.withChannelRetries$1(Locks.scala:91)
[error]         at xsbt.boot.Locks$GlobalLock.$anonfun$withFileLock$1(Locks.scala:119)
[error]         at xsbt.boot.Using$.withResource(Using.scala:12)
[error]         at xsbt.boot.Using$.apply(Using.scala:9)
[error]         at xsbt.boot.Locks$GlobalLock.withFileLock(Locks.scala:119)
[error]         at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:71)
[error]         at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:59)
[error]         at xsbt.boot.Locks$.apply0(Locks.scala:47)
[error]         at xsbt.boot.Locks$.apply(Locks.scala:36)
[error]         at sbt.internal.librarymanagement.IvySbt.withDefaultLogger(Ivy.scala:82)
[error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:203)
[error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:200)
[error]         at sbt.internal.librarymanagement.IvySbt$Module.withModule(Ivy.scala:244)

[error]         at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:133)
[error]         at sbt.Classpaths$.$anonfun$publishTask$4(Defaults.scala:3553)
[error]         at sbt.Classpaths$.$anonfun$publishTask$4$adapted(Defaults.scala:3546)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error]         at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error]         at sbt.Execute.work(Execute.scala:291)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error]         at java.base/java.lang.Thread.run(Thread.java:833)
[error] Caused by: java.net.ProtocolException: Server redirected too many  times (20)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:2005)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)
[error]         at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:529)
[error]         at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:308)
[error]         at org.apache.ivy.util.url.BasicURLHandler.upload(BasicURLHandler.java:284)
[error]         at org.apache.ivy.util.url.URLHandlerDispatcher.upload(URLHandlerDispatcher.java:82)
[error]         at org.apache.ivy.util.FileUtil.copy(FileUtil.java:150)
[error]         at org.apache.ivy.plugins.repository.url.URLRepository.put(URLRepository.java:84)
[error]         at sbt.internal.librarymanagement.ConvertResolver$LocalIfFileRepo.put(ConvertResolver.scala:368)
[error]         at org.apache.ivy.plugins.repository.AbstractRepository.put(AbstractRepository.java:130)
[error]         at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put(ConvertResolver.scala:118)
[error]         at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put$(ConvertResolver.scala:105)
[error]         at sbt.internal.librarymanagement.ConvertResolver$$anonfun$defaultConvert$lzycompute$1$PluginCapableResolver$1.put(ConvertResolver.scala:165)
[error]         at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(RepositoryResolver.java:216)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$5(IvyActions.scala:504)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at scala.util.Try$.apply(Try.scala:213)
[error]         at sbt.internal.librarymanagement.IvyUtil$.retryWithBackoff(IvyUtil.scala:22)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$4(IvyActions.scala:503)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$4$adapted(IvyActions.scala:501)
[error]         at scala.collection.Iterator.foreach(Iterator.scala:943)
[error]         at scala.collection.Iterator.foreach$(Iterator.scala:943)
[error]         at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
[error]         at scala.collection.IterableLike.foreach(IterableLike.scala:74)
[error]         at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
[error]         at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
[error]         at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:501)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$3(IvyActions.scala:143)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:157)
[error]         at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:150)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1(IvyActions.scala:143)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1$adapted(IvyActions.scala:133)
[error]         at sbt.internal.librarymanagement.IvySbt$Module.$anonfun$withModule$1(Ivy.scala:245)
[error]         at sbt.internal.librarymanagement.IvySbt.$anonfun$withIvy$1(Ivy.scala:209)
[error]         at sbt.internal.librarymanagement.IvySbt.sbt$internal$librarymanagement$IvySbt$$action$1(Ivy.scala:72)
[error]         at sbt.internal.librarymanagement.IvySbt$$anon$1.call(Ivy.scala:82)
[error]         at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:113)
[error]         at xsbt.boot.Locks$GlobalLock.withChannelRetries$1(Locks.scala:91)
[error]         at xsbt.boot.Locks$GlobalLock.$anonfun$withFileLock$1(Locks.scala:119)
[error]         at xsbt.boot.Using$.withResource(Using.scala:12)
[error]         at xsbt.boot.Using$.apply(Using.scala:9)
[error]         at xsbt.boot.Locks$GlobalLock.withFileLock(Locks.scala:119)
[error]         at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:71)
[error]         at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:59)
[error]         at xsbt.boot.Locks$.apply0(Locks.scala:47)
[error]         at xsbt.boot.Locks$.apply(Locks.scala:36)
[error]         at sbt.internal.librarymanagement.IvySbt.withDefaultLogger(Ivy.scala:82)
[error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:203)
[error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:200)
[error]         at sbt.internal.librarymanagement.IvySbt$Module.withModule(Ivy.scala:244)
[error]         at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:133)
[error]         at sbt.Classpaths$.$anonfun$publishTask$4(Defaults.scala:3553)
[error]         at sbt.Classpaths$.$anonfun$publishTask$4$adapted(Defaults.scala:3546)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error]         at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error]         at sbt.Execute.work(Execute.scala:291)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error]         at java.base/java.lang.Thread.run(Thread.java:833)
[error] (publish) java.net.ProtocolException: Server redirected too many  times (20)
</code>```

build.sbt

```<code>ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "2.13.10"
ThisBuild / versionScheme := Some("early-semver")

lazy val root = (project in file("."))
  .settings(
    name := "untitled",
    publishMavenStyle := true,
    publishTo := Some("XXX" at "https://XXX/XXX/_packaging/tsmaven/maven/v1"),
    credentials += Credentials (Path.userHome / ".sbt" / "azureArtifactsFeed.credentials")
)
</code>```

azureArtifactsFeed.credentials

```<code>realm=
host=XXX
user=[USERNAME]
password=[TOKEN]
</code>```

Any help is appreciated.

sbt publish

expected a publish to maven feed

got error

ContentLicense: CC BY-SA 4.0

Body:
I am attempting to publish an artifact to an Azure devops feed, self hosted. I have successfully published a normal maven project to the feed without issue. When i attempt to use sbt to publish a scala package I get this error.

[error] java.net.ProtocolException: Server redirected too many  times (20)
[error]         at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
[error]         at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
[error]         at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
[error]         at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
[error]         at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:2048)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:2043)
[error]         at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:2042)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1609)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)
[error]         at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:224)
[error]         at org.apache.ivy.util.url.BasicURLHandler.upload(BasicURLHandler.java:288)
[error]         at org.apache.ivy.util.url.URLHandlerDispatcher.upload(URLHandlerDispatcher.java:82)
[error]         at org.apache.ivy.util.FileUtil.copy(FileUtil.java:150)
[error]         at org.apache.ivy.plugins.repository.url.URLRepository.put(URLRepository.java:84)
[error]         at sbt.internal.librarymanagement.ConvertResolver$LocalIfFileRepo.put(ConvertResolver.scala:368)
[error]         at org.apache.ivy.plugins.repository.AbstractRepository.put(AbstractRepository.java:130)
[error]         at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put(ConvertResolver.scala:118)
[error]         at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put$(ConvertResolver.scala:105)
[error]         at sbt.internal.librarymanagement.ConvertResolver$$anonfun$defaultConvert$lzycompute$1$PluginCapableResolver$1.put(ConvertResolver.scala:165)
[error]         at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(RepositoryResolver.java:216)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$5(IvyActions.scala:504)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at scala.util.Try$.apply(Try.scala:213)
[error]         at sbt.internal.librarymanagement.IvyUtil$.retryWithBackoff(IvyUtil.scala:22)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$4(IvyActions.scala:503)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$4$adapted(IvyActions.scala:501)
[error]         at scala.collection.Iterator.foreach(Iterator.scala:943)
[error]         at scala.collection.Iterator.foreach$(Iterator.scala:943)
[error]         at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
[error]         at scala.collection.IterableLike.foreach(IterableLike.scala:74)
[error]         at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
[error]         at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
[error]         at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:501)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$3(IvyActions.scala:143)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:157)
[error]         at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:150)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1(IvyActions.scala:143)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1$adapted(IvyActions.scala:133)
[error]         at sbt.internal.librarymanagement.IvySbt$Module.$anonfun$withModule$1(Ivy.scala:245)
[error]         at sbt.internal.librarymanagement.IvySbt.$anonfun$withIvy$1(Ivy.scala:209)
[error]         at sbt.internal.librarymanagement.IvySbt.sbt$internal$librarymanagement$IvySbt$$action$1(Ivy.scala:72)
[error]         at sbt.internal.librarymanagement.IvySbt$$anon$1.call(Ivy.scala:82)
[error]         at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:113)
[error]         at xsbt.boot.Locks$GlobalLock.withChannelRetries$1(Locks.scala:91)
[error]         at xsbt.boot.Locks$GlobalLock.$anonfun$withFileLock$1(Locks.scala:119)
[error]         at xsbt.boot.Using$.withResource(Using.scala:12)
[error]         at xsbt.boot.Using$.apply(Using.scala:9)
[error]         at xsbt.boot.Locks$GlobalLock.withFileLock(Locks.scala:119)
[error]         at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:71)
[error]         at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:59)
[error]         at xsbt.boot.Locks$.apply0(Locks.scala:47)
[error]         at xsbt.boot.Locks$.apply(Locks.scala:36)
[error]         at sbt.internal.librarymanagement.IvySbt.withDefaultLogger(Ivy.scala:82)
[error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:203)
[error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:200)
[error]         at sbt.internal.librarymanagement.IvySbt$Module.withModule(Ivy.scala:244)

[error]         at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:133)
[error]         at sbt.Classpaths$.$anonfun$publishTask$4(Defaults.scala:3553)
[error]         at sbt.Classpaths$.$anonfun$publishTask$4$adapted(Defaults.scala:3546)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error]         at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error]         at sbt.Execute.work(Execute.scala:291)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error]         at java.base/java.lang.Thread.run(Thread.java:833)
[error] Caused by: java.net.ProtocolException: Server redirected too many  times (20)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:2005)
[error]         at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)
[error]         at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:529)
[error]         at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:308)
[error]         at org.apache.ivy.util.url.BasicURLHandler.upload(BasicURLHandler.java:284)
[error]         at org.apache.ivy.util.url.URLHandlerDispatcher.upload(URLHandlerDispatcher.java:82)
[error]         at org.apache.ivy.util.FileUtil.copy(FileUtil.java:150)
[error]         at org.apache.ivy.plugins.repository.url.URLRepository.put(URLRepository.java:84)
[error]         at sbt.internal.librarymanagement.ConvertResolver$LocalIfFileRepo.put(ConvertResolver.scala:368)
[error]         at org.apache.ivy.plugins.repository.AbstractRepository.put(AbstractRepository.java:130)
[error]         at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put(ConvertResolver.scala:118)
[error]         at sbt.internal.librarymanagement.ConvertResolver$ChecksumFriendlyURLResolver.put$(ConvertResolver.scala:105)
[error]         at sbt.internal.librarymanagement.ConvertResolver$$anonfun$defaultConvert$lzycompute$1$PluginCapableResolver$1.put(ConvertResolver.scala:165)
[error]         at org.apache.ivy.plugins.resolver.RepositoryResolver.publish(RepositoryResolver.java:216)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$5(IvyActions.scala:504)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at scala.util.Try$.apply(Try.scala:213)
[error]         at sbt.internal.librarymanagement.IvyUtil$.retryWithBackoff(IvyUtil.scala:22)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$4(IvyActions.scala:503)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$4$adapted(IvyActions.scala:501)
[error]         at scala.collection.Iterator.foreach(Iterator.scala:943)
[error]         at scala.collection.Iterator.foreach$(Iterator.scala:943)
[error]         at scala.collection.AbstractIterator.foreach(Iterator.scala:1431)
[error]         at scala.collection.IterableLike.foreach(IterableLike.scala:74)
[error]         at scala.collection.IterableLike.foreach$(IterableLike.scala:73)
[error]         at scala.collection.AbstractIterable.foreach(Iterable.scala:56)
[error]         at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:501)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$3(IvyActions.scala:143)
[error]         at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error]         at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:157)
[error]         at sbt.internal.librarymanagement.IvyActions$.withChecksums(IvyActions.scala:150)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1(IvyActions.scala:143)
[error]         at sbt.internal.librarymanagement.IvyActions$.$anonfun$publish$1$adapted(IvyActions.scala:133)
[error]         at sbt.internal.librarymanagement.IvySbt$Module.$anonfun$withModule$1(Ivy.scala:245)
[error]         at sbt.internal.librarymanagement.IvySbt.$anonfun$withIvy$1(Ivy.scala:209)
[error]         at sbt.internal.librarymanagement.IvySbt.sbt$internal$librarymanagement$IvySbt$$action$1(Ivy.scala:72)
[error]         at sbt.internal.librarymanagement.IvySbt$$anon$1.call(Ivy.scala:82)
[error]         at xsbt.boot.Locks$GlobalLock.withChannel$1(Locks.scala:113)
[error]         at xsbt.boot.Locks$GlobalLock.withChannelRetries$1(Locks.scala:91)
[error]         at xsbt.boot.Locks$GlobalLock.$anonfun$withFileLock$1(Locks.scala:119)
[error]         at xsbt.boot.Using$.withResource(Using.scala:12)
[error]         at xsbt.boot.Using$.apply(Using.scala:9)
[error]         at xsbt.boot.Locks$GlobalLock.withFileLock(Locks.scala:119)
[error]         at xsbt.boot.Locks$GlobalLock.ignoringDeadlockAvoided(Locks.scala:71)
[error]         at xsbt.boot.Locks$GlobalLock.withLock(Locks.scala:59)
[error]         at xsbt.boot.Locks$.apply0(Locks.scala:47)
[error]         at xsbt.boot.Locks$.apply(Locks.scala:36)
[error]         at sbt.internal.librarymanagement.IvySbt.withDefaultLogger(Ivy.scala:82)
[error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:203)
[error]         at sbt.internal.librarymanagement.IvySbt.withIvy(Ivy.scala:200)
[error]         at sbt.internal.librarymanagement.IvySbt$Module.withModule(Ivy.scala:244)
[error]         at sbt.internal.librarymanagement.IvyActions$.publish(IvyActions.scala:133)
[error]         at sbt.Classpaths$.$anonfun$publishTask$4(Defaults.scala:3553)
[error]         at sbt.Classpaths$.$anonfun$publishTask$4$adapted(Defaults.scala:3546)
[error]         at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error]         at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error]         at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error]         at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error]         at sbt.Execute.work(Execute.scala:291)
[error]         at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error]         at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error]         at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error]         at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error]         at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error]         at java.base/java.lang.Thread.run(Thread.java:833)
[error] (publish) java.net.ProtocolException: Server redirected too many  times (20)

build.sbt

ThisBuild / version := "0.1.0-SNAPSHOT"
ThisBuild / scalaVersion := "2.13.10"
ThisBuild / versionScheme := Some("early-semver")

lazy val root = (project in file("."))
  .settings(
    name := "untitled",
    publishMavenStyle := true,
    publishTo := Some("XXX" at "https://XXX/XXX/_packaging/tsmaven/maven/v1"),
    credentials += Credentials (Path.userHome / ".sbt" / "azureArtifactsFeed.credentials")
)

azureArtifactsFeed.credentials

realm=
host=XXX
user=[USERNAME]
password=[TOKEN]

Any help is appreciated.

sbt publish

expected a publish to maven feed

got error


问:
Model.predict first output of the prediction always stays on 1.0
I try to do model.predict and the result of the first class is always 1.0 causing the prediction to be in its favour and always goes for this class even though its another class. How can i fix it, see picture underneath

enter image description here


问:
How to use GitTools GitVersion for Release Branches
I am trying to use GitTools GitVersion to semantically tag my different branches in an azure devops pipeline. I have seen a lot of demos that show how to tag only the main/master branch, but I will have different versions of my software and would like to keep the versions organized as branches, rather than creating an entirely new code repo for every version/release. So my branches might look like:

main

release/2.0.0

release/3.0.0

I am wondering how to configure GitTools GitVersion on each branch so that a PR on that branch will update the relevant version number? So far I can only get it to work on main and find the documentation to not be very helpful on this specific topic.

Here is the GitVersion.yml file I have set up for the main branch, so far I have tried setting up the same file in each release branch but with the relevant source-branches names for the release branches and this does not work

```<code>mode: Mainline
branches:
  feature:
    regex: ^feature?[/-]
    source-branches: ['main', 'master']
    tag: feat-{BranchName}
  fix:
    regex: ^bugFix(es)?[/-]
    source-branches: ['main', 'master']
    tag: bugfix-{BranchName}
ignore:
  sha: []
merge-message-formats: {}
</code>```

Here is my yml pipeline file:

```<code>trigger:
- main
- releases/*
pool: Dev-AWSAgentPool

jobs:
- job: BuildAndTest

  steps:
    - checkout: self
      fetchDepth: 0
      clean: true

    - task: UseDotNet@2
      inputs:
        packageType: 'sdk'
        version: '5.0.x'

    - task: gitversion/setup@0
      displayName: Install GitVersion
      inputs:
        versionSpec: '5.6.6'

    - task: gitversion/execute@0
      displayName: Determine Version
      inputs:
        useConfigFile: true
        configFilePath: '.azuredevops/Pipelines/GitVersion.yml'

    - script: echo current version is $(GitVersion.SemVer)
      displayName: Display current version

    - task: Bash@3
      displayName: "Update build number"
      inputs:
        targetType: inline
        script: echo "##vso[build.updatebuildnumber]$(SemVer)"
</code>```

Body:
I am trying to use GitTools GitVersion to semantically tag my different branches in an azure devops pipeline. I have seen a lot of demos that show how to tag only the main/master branch, but I will have different versions of my software and would like to keep the versions organized as branches, rather than creating an entirely new code repo for every version/release. So my branches might look like:

main

release/2.0.0

release/3.0.0

I am wondering how to configure GitTools GitVersion on each branch so that a PR on that branch will update the relevant version number? So far I can only get it to work on main and find the documentation to not be very helpful on this specific topic.

Here is the GitVersion.yml file I have set up for the main branch, so far I have tried setting up the same file in each release branch but with the relevant source-branches names for the release branches and this does not work

mode: Mainline
branches:
  feature:
    regex: ^feature?[/-]
    source-branches: ['main', 'master']
    tag: feat-{BranchName}
  fix:
    regex: ^bugFix(es)?[/-]
    source-branches: ['main', 'master']
    tag: bugfix-{BranchName}
ignore:
  sha: []
merge-message-formats: {}

Here is my yml pipeline file:

trigger:
- main
- releases/*
pool: Dev-AWSAgentPool

jobs:
- job: BuildAndTest

  steps:
    - checkout: self
      fetchDepth: 0
      clean: true

    - task: UseDotNet@2
      inputs:
        packageType: 'sdk'
        version: '5.0.x'

    - task: gitversion/setup@0
      displayName: Install GitVersion
      inputs:
        versionSpec: '5.6.6'

    - task: gitversion/execute@0
      displayName: Determine Version
      inputs:
        useConfigFile: true
        configFilePath: '.azuredevops/Pipelines/GitVersion.yml'

    - script: echo current version is $(GitVersion.SemVer)
      displayName: Display current version

    - task: Bash@3
      displayName: "Update build number"
      inputs:
        targetType: inline
        script: echo "##vso[build.updatebuildnumber]$(SemVer)"


问:
How to recall a jsPsychHtmlButtonResponse?
I am trying to design a game for an experiment. The game involves recognizing emotions and clicking a button to respond. Now I am onto the next stage of the experiment where participants get a response for the button they clicked (ex. Incorrect, Correct etc.)

I have used the same method to recall jsPsychHtmlKeyboardResponse but I am not sure how to do it for buttons.

Here is code so far. I have attempted  to save the button response (ex.'High Happy') under the timeline Variable as corrext_response. I don't think that's right but I am not sure how else to do it.

enter image description here
enter image description here


问:
JS-created dropdown with bootstrap/HTML is not being recognised by an onchange trigger?
Have tied myself in some knots here - so would welcome any thoughts on how to untie them. Am using js and bootstrap to create a specifically formatted dropdown. This function is called on an if statement and works successfully:

```<code>
      function updateMFin2() {
      document.getElementById('containermFin2').innerHTML = '';

      var values = arrmPlayer.slice(4, 8); //Just an array with 4 string elements in it

      var m_fin2List = values.map(function(r){ return '<option>' + r + '</option>\n'; }).join('');

      var divx2 = document.createElement("m_fin2");
      divx2.innerHTML =
          '<div class="input-group">\n' +
          '<label class="input-group-text">F2</label>\n' +
          '<select class="form-select form-select-sm" id="m_fin2">\n' +
          "<option selected>Men's Finalist #2</option>\n" +
          m_fin2List +
          '</select>\n' +
          '<input class="input-group-text" disabled id="drawfin2" class="validate" type="text"  style="width:60px;" value="-" aria-label="readonly input example" readonly>\n' +
          '</div>\n';

      document.getElementById("containermFin2").appendChild(divx2);
      }

</code>```

Then using an onchange for m_fin2 I want to call another function which does something e.g.

```<code>
   document.getElementById("m_fin2").addEventListener("change",getmFBH);

   function getmFBH(evt){
    //do something
   }

</code>```

The good news is that this is working insofar as the dropdowns are being created dynamically from the user-determined 'values' - however (possibly because of the way I am scripting the dropdowns in the div container?) the onchange doesn't work.

Have tried various approaches, including trying to shrink down the amount of HTML included in the divx2.innerHTML (would like this to be as little as possible and just focus on the 'option' list - however I couldn't get that to work either). Advice gratefully received on solving the problem or recommending the best practice way to do this and still have the bootstrap formatting work.

Body:
Have tied myself in some knots here - so would welcome any thoughts on how to untie them. Am using js and bootstrap to create a specifically formatted dropdown. This function is called on an if statement and works successfully:

      function updateMFin2() {
      document.getElementById('containermFin2').innerHTML = '';

      var values = arrmPlayer.slice(4, 8); //Just an array with 4 string elements in it

      var m_fin2List = values.map(function(r){ return '<option>' + r + '</option>\n'; }).join('');

      var divx2 = document.createElement("m_fin2");
      divx2.innerHTML =
          '
\n' +
          'F2\n' +
          '<select class="form-select form-select-sm" id="m_fin2">\n' +
          "<option selected>Men's Finalist #2</option>\n" +
          m_fin2List +
          '</select>\n' +
          '<input class="input-group-text" disabled id="drawfin2" class="validate" type="text"  style="width:60px;" value="-" aria-label="readonly input example" readonly>\n' +
          '
\n';

      document.getElementById("containermFin2").appendChild(divx2);
      }

Then using an onchange for m_fin2 I want to call another function which does something e.g.

   document.getElementById("m_fin2").addEventListener("change",getmFBH);

   function getmFBH(evt){
    //do something
   }

The good news is that this is working insofar as the dropdowns are being created dynamically from the user-determined 'values' - however (possibly because of the way I am scripting the dropdowns in the div container?) the onchange doesn't work.

Have tried various approaches, including trying to shrink down the amount of HTML included in the divx2.innerHTML (would like this to be as little as possible and just focus on the 'option' list - however I couldn't get that to work either). Advice gratefully received on solving the problem or recommending the best practice way to do this and still have the bootstrap formatting work.


问:
Wordpress Ajax Load More Posts - How to Load by Category
It all works well and good for the main index.php file but it doesn't work in the archive.php file. It merely loads the latest posts.

This goes in Functions.php:

```<code>function bsubash_load_more_scripts() {
    wp_enqueue_script('jquery');
    wp_register_script( 'loadmore_script', get_stylesheet_directory_uri() . '/js/ajax.js', array('jquery') );
    wp_localize_script( 'loadmore_script', 'loadmore_params', array(
        'ajaxurl' => admin_url('admin-ajax.php'),
    ) );

    wp_enqueue_script( 'loadmore_script' );
}

add_action( 'wp_enqueue_scripts','bsubash_load_more_scripts' );

function bsubash_loadmore_ajax_handler(){
    $type = $_POST['type'];
    $category = isset($_POST['category']) ? $_POST['category']: '';
    $args['paged'] = $_POST['page'] + 1;
    $args['post_status'] = 'publish';
    $args['posts_per_page'] =  $_POST['limit'];
    if($type == 'archive'){
        $args['category_name'] = $category;
    }
    query_posts( $args );
    if( have_posts() ) :
        while(have_posts()): the_post();
//write your single post card
            the_title();
the_excerpt();
    endwhile;
    endif;
    die;
}
add_action('wp_ajax_loadmore','bsubash_loadmore_ajax_handler');
add_action('wp_ajax_nopriv_loadmore','bsubash_loadmore_ajax_handler');
</code>```

This goes in the index.php template:

```<code><div class="latest_posts_wrapper">
   <?php
      $paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
      $latests = new WP_Query(array(
        'post_type' => 'post',
        'posts_per_page' => 3,
        'paged' => $paged
      ));

      while($latests->have_posts()): $latests->the_post();
        //put the post card here
      the_title();
      the_excerpt
      endwhile;
      ?>
</div>
<script>
   var limit = 3,
       page = 1,
       type = 'latest',
       category = '',
       max_pages_latest = <?php echo $latests->max_num_pages ?>
</script>
<?php if ( $latests->max_num_pages > 1 ){
   echo '<div class="load_more text-center">
                    <a href="#" class="btn btn-circle btn-inverse btn-load-more">More Article</a>
                </div>';
        }else{?>
<article>
   <h1>Sorry...</h1>
   <p><?php _e('Sorry, No Posts Available !'); ?></p>
</article>
<?php }
   wp_reset_query();
   ?>

</code>```

And this is a separate .js file:

```<code>jQuery(function($) {
    $('.btn-load-more').click(function(e) {
        e.preventDefault();
        var button = $(this),
            data = {
                'action': 'loadmore',
                'limit': limit,
                'page': page,
                'type': type,
                'category': category
            };

        $.ajax({
            url: loadmore_params.ajaxurl,
            data: data,
            type: 'POST',
            beforeSend: function(xhr) {
                button.text('Loading...'); // change the button text, you can also add a preloader image
            },
            success: function(data) {
                if (data) {
$(".latest_posts_wrapper").append(data);
                    page++;
                    button.text('More Articles');
                    if (page == max_pages_latest)
                        button.remove(); // if last page, remove the button
                } else {
                    button.remove(); // if no data, remove the button as well
                }
            }
        });
    });

});
</code>```

Any thoughts on what I need to do to specify the category for archive.php even if I need to have slightly different code for that page?

Body:
It all works well and good for the main index.php file but it doesn't work in the archive.php file. It merely loads the latest posts.

This goes in Functions.php:

function bsubash_load_more_scripts() {
    wp_enqueue_script('jquery');
    wp_register_script( 'loadmore_script', get_stylesheet_directory_uri() . '/js/ajax.js', array('jquery') );
    wp_localize_script( 'loadmore_script', 'loadmore_params', array(
        'ajaxurl' => admin_url('admin-ajax.php'),
    ) );

    wp_enqueue_script( 'loadmore_script' );
}

add_action( 'wp_enqueue_scripts','bsubash_load_more_scripts' );

function bsubash_loadmore_ajax_handler(){
    $type = $_POST['type'];
    $category = isset($_POST['category']) ? $_POST['category']: '';
    $args['paged'] = $_POST['page'] + 1;
    $args['post_status'] = 'publish';
    $args['posts_per_page'] =  $_POST['limit'];
    if($type == 'archive'){
        $args['category_name'] = $category;
    }
    query_posts( $args );
    if( have_posts() ) :
        while(have_posts()): the_post();
//write your single post card
            the_title();
the_excerpt();
    endwhile;
    endif;
    die;
}
add_action('wp_ajax_loadmore','bsubash_loadmore_ajax_handler');
add_action('wp_ajax_nopriv_loadmore','bsubash_loadmore_ajax_handler');

This goes in the index.php template:

   <?php
      $paged = ( get_query_var('page') ) ? get_query_var('page') : 1;
      $latests = new WP_Query(array(
        'post_type' => 'post',
        'posts_per_page' => 3,
        'paged' => $paged
      ));

      while($latests->have_posts()): $latests->the_post();
        //put the post card here
      the_title();
      the_excerpt
      endwhile;
      ?>

<?php if ( $latests->max_num_pages > 1 ){
   echo '

                    More Article

';
        }else{?>

Sorry...

<?php _e('Sorry, No Posts Available !'); ?>

<?php }
   wp_reset_query();
   ?>

And this is a separate .js file:

jQuery(function($) {
    $('.btn-load-more').click(function(e) {
        e.preventDefault();
        var button = $(this),
            data = {
                'action': 'loadmore',
                'limit': limit,
                'page': page,
                'type': type,
                'category': category
            };

        $.ajax({
            url: loadmore_params.ajaxurl,
            data: data,
            type: 'POST',
            beforeSend: function(xhr) {
                button.text('Loading...'); // change the button text, you can also add a preloader image
            },
            success: function(data) {
                if (data) {
$(".latest_posts_wrapper").append(data);
                    page++;
                    button.text('More Articles');
                    if (page == max_pages_latest)
                        button.remove(); // if last page, remove the button
                } else {
                    button.remove(); // if no data, remove the button as well
                }
            }
        });
    });

});

Any thoughts on what I need to do to specify the category for archive.php even if I need to have slightly different code for that page?


问:
EXCEPTION_STACK_OVERFLOW Unreal Engine 5.1
Made a simple clicker on widgets. I saved the project, made an archive, after I go into the project, but it crashes with an error

Unhandled Exception: EXCEPTION_STACK_OVERFLOW

UnrealEditor_CoreUObject!<lambda_e2fcebb0769fb73f1f7185c23a2b6a0e>::operator()() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3221]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImportInner() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3429]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImport() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:2953]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImportInner() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3457]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImport() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:2953]
UnrealEditor_CoreUObject!FLinkerLoad::CreateExport() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:4661]
UnrealEditor_CoreUObject!FLinkerLoad::CreateExportAndPreload() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3779]
UnrealEditor_CoreUObject!FLinkerLoad::LoadAllObjects() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3956]
UnrealEditor_CoreUObject!LoadPackageInternal() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1682]
UnrealEditor_CoreUObject!<lambda_e2fcebb0769fb73f1f7185c23a2b6a0e>::operator()() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3301]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImportInner() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3429]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImport() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:2953]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImportInner() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3457]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImport() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:2953]
UnrealEditor_CoreUObject!FLinkerLoad::CreateExport() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:4661]
UnrealEditor_CoreUObject!FLinkerLoad::CreateExportAndPreload() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3779]
UnrealEditor_CoreUObject!FLinkerLoad::LoadAllObjects() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3956]
UnrealEditor_CoreUObject!LoadPackageInternal() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\UObjectGlobals.cpp:1682]
UnrealEditor_CoreUObject!<lambda_e2fcebb0769fb73f1f7185c23a2b6a0e>::operator()() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3301]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImportInner() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3429]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImport() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:2953]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImportInner() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:3457]
UnrealEditor_CoreUObject!FLinkerLoad::VerifyImport() [D:\build++UE5\Sync\Engine\Source\Runtime\CoreUObject\Private\UObject\LinkerLoad.cpp:2953]

I don't understand what could be the problem


问:
Splash Connection refused on target localhost URL
I am trying to render JS with Splash, it works with normal URLs like https://google.com, etc but it does not work for URLs having addresses like http://localhost:8002/report.

Error:

```<code>{"error": 502, "type": "RenderError", "description": "Error rendering page", "info": {"type": "Network", "code": 1, "text": "Connection refused", "url": "https://localhost:8002/"}}
</code>```

I.e:
curl 'http://127.0.0.1:8050/render.html?url=https://localhost:8002'

Body:
I am trying to render JS with Splash, it works with normal URLs like https://google.com, etc but it does not work for URLs having addresses like http://localhost:8002/report.

Error:

{"error": 502, "type": "RenderError", "description": "Error rendering page", "info": {"type": "Network", "code": 1, "text": "Connection refused", "url": "https://localhost:8002/"}}

I.e:
curl 'http://127.0.0.1:8050/render.html?url=https://localhost:8002'


问:
How to copy ALE hover message to clipboard on vim?
Is there a way to grab / yank / copy the ALE hover message to a vim register? Having the message on clipboard would be useful for quickly searching the warning or error message elsewhere. It appears that the usual :redir or :let @* will not work since the hover message is not an output of a vim command per se.


问:
How to fix 'Error in normalizePath(conda, winslash = "/", mustWork = TRUE) ' when using reticulate package in R

Background

I had some python code in a .py file stored in an R studio project. I was successfully using R studio (version 2022.7.1.554) and the reticulate package (verson 1.26) to write and run the python code. I was using anaconda3 rather than miniconda and all was well. Then I decided to "see what happens" when I open the .py file in VS Code. I think I created a new virtual environment for the project but I'm not really sure, it was a few days ago and my first time using VS code. A few days later I tried running the .py file in R Studio again but I keep getting errors. However, reticulate works fine in other R projects.

Errors and Things I've Tried

This is the error I get:

```<code>>reticulate::repl_python()
Error in normalizePath(conda, winslash = "/", mustWork = TRUE) :
  path[1]="/Users/myname/opt/anaconda3/lib/python3.9/site-packages/conda/conda": No such file or directory

</code>```

So I tried to change the coda environment and the python path

```<code>#first getting the conda environments
> conda_list()
    name                                                      python
1 .conda /Users/myname/Desktop/mesa_prisoners/.conda/bin/python
2   base                 /Users/myname/opt/anaconda3/bin/python

#then setting the conda environments
> use_condaenv(".conda")
Error in normalizePath(conda, winslash = "/", mustWork = TRUE) :
  path[1]="/Users/myname/opt/anaconda3/lib/python3.9/site-packages/conda/conda": No such file or directory

> use_condaenv("base")
Warning message:
The request to `use_python("/Users/myname/opt/anaconda3/bin/python")` will be ignored because the environment variable RETICULATE_PYTHON is set to "/Users/myname/Desktop/mesa_prisoners/.conda/bin/python"

> use_python("/Users/myname/opt/anaconda3/bin/python")
Warning message:
The request to `use_python("/Users/myname/opt/anaconda3/bin/python")` will be ignored because the environment variable RETICULATE_PYTHON is set to "/Users/myname/Desktop/mesa_prisoners/.conda/bin/python"
</code>```

But it doesn't work. I'm new to python so I'm pretty lost here.

Body:
Background

I had some python code in a .py file stored in an R studio project. I was successfully using R studio (version 2022.7.1.554) and the reticulate package (verson 1.26) to write and run the python code. I was using anaconda3 rather than miniconda and all was well. Then I decided to "see what happens" when I open the .py file in VS Code. I think I created a new virtual environment for the project but I'm not really sure, it was a few days ago and my first time using VS code. A few days later I tried running the .py file in R Studio again but I keep getting errors. However, reticulate works fine in other R projects.

Errors and Things I've Tried

This is the error I get:

>reticulate::repl_python()
Error in normalizePath(conda, winslash = "/", mustWork = TRUE) :
  path[1]="/Users/myname/opt/anaconda3/lib/python3.9/site-packages/conda/conda": No such file or directory

So I tried to change the coda environment and the python path

#first getting the conda environments
> conda_list()
    name                                                      python
1 .conda /Users/myname/Desktop/mesa_prisoners/.conda/bin/python
2   base                 /Users/myname/opt/anaconda3/bin/python

#then setting the conda environments
> use_condaenv(".conda")
Error in normalizePath(conda, winslash = "/", mustWork = TRUE) :
  path[1]="/Users/myname/opt/anaconda3/lib/python3.9/site-packages/conda/conda": No such file or directory

> use_condaenv("base")
Warning message:
The request to `use_python("/Users/myname/opt/anaconda3/bin/python")` will be ignored because the environment variable RETICULATE_PYTHON is set to "/Users/myname/Desktop/mesa_prisoners/.conda/bin/python"

> use_python("/Users/myname/opt/anaconda3/bin/python")
Warning message:
The request to `use_python("/Users/myname/opt/anaconda3/bin/python")` will be ignored because the environment variable RETICULATE_PYTHON is set to "/Users/myname/Desktop/mesa_prisoners/.conda/bin/python"

But it doesn't work. I'm new to python so I'm pretty lost here.


问:
Is there a Way to have a Maximum Amount of Elements on a Screen?
I have 4 boxes and want only 3 of them to be on the screen at a time. At the moment, I am using a flex-wrap to move the one that does not fit to the bottom, but the way I want it is for whatever element that does not fit to move to the end of the last element on the right, off the screen. Is this possible to do and if so how can I do it?

.bioSlider {
    position: relative;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.box {
    position: relative;
    display: inline-block;
    width: 360px;
    padding: 10px;
}

.slideImage {
    position: relative;
    height: 300px;
}

.slideImage img {
    object-fit: cover;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
}

.overlay {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background-color: #000000;
    opacity: 0;
    transition: 0.8s ease-in-out;
}

.detailBox {
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    padding: 20px;
    background-color: #e8e8e8;
}

.slideImage > .overlay:hover {
    opacity: 50%;
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><div> <!-- Cadet Slider -->
        <ul class = 'bioSlider'>
            <li class = 'cadetOne'>
                <div class = 'box'>
                    <div class = 'slideImage'>
                        <img src = '/Images/Red_Card.png' alt = 'Img A'>
                        <div class = 'overlay'>
                        </div>
                    </div>
                    <div class = 'detailBox'>Detail A</div>
                </div>
            </li>

            <li class = 'cadetOne'>
                <div class = 'box'>
                    <div class = 'slideImage'>
                        <img src = '/Images/Yellow_Card.png' alt = 'Img B'>
                        <div class = 'overlay'>
                        </div>
                    </div>
                    <div class = 'detailBox'>Detail B</div>
                </div>
            </li>

            <li class = 'cadetOne'>
                <div class = 'box'>
                    <div class = 'slideImage'>
                        <img src = '/Images/Blue_Card.png' alt = 'Img C'>
                        <div class = 'overlay'>
                        </div>
                    </div>
                    <div class = 'detailBox'>Detail C</div>
                </div>
            </li>

            <li class = 'cadetOne'>
                <div class = 'box'>
                    <div class = 'slideImage'>
                        <img src = '/Images/Green_Card.png' alt = 'Img D'>
                        <div class = 'overlay'>
                        </div>
                    </div>
                    <div class = 'detailBox'>Detail D</div>
                </div>
            </li>
        </ul>
    </div></code>```

Body:
I have 4 boxes and want only 3 of them to be on the screen at a time. At the moment, I am using a flex-wrap to move the one that does not fit to the bottom, but the way I want it is for whatever element that does not fit to move to the end of the last element on the right, off the screen. Is this possible to do and if so how can I do it?

.bioSlider {
    position: relative;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.box {
    position: relative;
    display: inline-block;
    width: 360px;
    padding: 10px;
}

.slideImage {
    position: relative;
    height: 300px;
}

.slideImage img {
    object-fit: cover;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
}

.overlay {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background-color: #000000;
    opacity: 0;
    transition: 0.8s ease-in-out;
}

.detailBox {
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    width: 100%;
    padding: 20px;
    background-color: #e8e8e8;
}

.slideImage > .overlay:hover {
    opacity: 50%;
}

Detail A

Detail B

Detail C

Detail D


问:
Using multiple sets of credentials with GCP API calls
I have a long running process that subscribes to Pub/Sub topic A and publishes to Pub/Sub topic B. The process uses two distinct sets of credentials: one that allows it to subscribe to A and one to publish to B. These credentials are JSON files with credentials to two different service acccounts.

The process flow looks something like this:

```<code>from google.cloud import pubsub_v1

# create publisher
project_id  = "my-project-id"
subscr_id_A = "subscribe-A"
topic_id_B  = "topic-B"

# create subscriber
subscriber        = pubsub_v1.SubscriberClient()
subscription_path = subscriber.subscription_path(project_id, subscr_id_A)

# create publisher
publisher_options = pubsub_v1.types.PublisherOptions(enable_message_ordering=True)
publisher         = pubsub_v1.PublisherClient(publisher_options=publisher_options)
topic_path        = publisher.topic_path(project_id, topic_id_B)

while (True):
    response = subscriber.pull(subscription_path)
    # ... other things ...

    future = publisher.publish(topic_path, data)
</code>```

In simpler contexts I usually set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of my service account credentials file. As already noted I have two credentials file.

I am looking for Google documentation (or some tests that someone has carried out) that answers this question:
Do I need to set the environment variable GOOGLE_APPLICATION_CREDENTIALS before every pull and publish? Or is it sufficient to set it only before the SubscriberClient and PublisherClient create?

Body:
I have a long running process that subscribes to Pub/Sub topic A and publishes to Pub/Sub topic B. The process uses two distinct sets of credentials: one that allows it to subscribe to A and one to publish to B. These credentials are JSON files with credentials to two different service acccounts.

The process flow looks something like this:

from google.cloud import pubsub_v1

# create publisher
project_id  = "my-project-id"
subscr_id_A = "subscribe-A"
topic_id_B  = "topic-B"

# create subscriber
subscriber        = pubsub_v1.SubscriberClient()
subscription_path = subscriber.subscription_path(project_id, subscr_id_A)

# create publisher
publisher_options = pubsub_v1.types.PublisherOptions(enable_message_ordering=True)
publisher         = pubsub_v1.PublisherClient(publisher_options=publisher_options)
topic_path        = publisher.topic_path(project_id, topic_id_B)

while (True):
    response = subscriber.pull(subscription_path)
    # ... other things ...

    future = publisher.publish(topic_path, data)

In simpler contexts I usually set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the path of my service account credentials file. As already noted I have two credentials file.

I am looking for Google documentation (or some tests that someone has carried out) that answers this question:
Do I need to set the environment variable GOOGLE_APPLICATION_CREDENTIALS before every pull and publish? Or is it sufficient to set it only before the SubscriberClient and PublisherClient create?


问:
ValueError: could not convert string to float: b' Using CNN U-NET model- tif format files
I'm running the following tensorflow script for CNN in google colab:

```<code>def process_path(image_path, mask_path):
    imag = tf.io.read_file(image_path)
    imag = tf.image.decode_png(imag, channels=3)
    imag = tf.image.convert_image_dtype(imag, tf.float32)

    mask = tf.io.read_file(mask_path)
    mask = tf.image.decode_png(mask, channels=3)
    mask = tf.math.reduce_max(mask, axis=-1, keepdims=True)
    return imag, mask

def preprocess(image, mask):
    input_image = tf.image.resize(image, (96, 128), method='nearest')
    input_mask = tf.image.resize(mask, (96, 128), method='nearest')

    # input_image = input_image / 255.
    input_image = tf.cast(input_image, tf.float32) / 255.0

    print(input_image.dtype)
    print(input_mask.dtype)
    return input_image, input_mask

image_ds = image_mask_ds.map(process_path)
processed_image_ds = image_ds.map(preprocess)
</code>```
```<code>from PIL import Image

def display(display_list):
    plt.figure(figsize=(15, 15))

    title = ['Input Image', 'True Mask', 'Predicted Mask']

    for i in range(len(display_list)):
        plt.subplot(1, len(display_list), i+1)
        plt.title(title[i])
        print("display_list",display_list)
        plt.imshow(tf.keras.preprocessing.image.array_to_img(display_list[i]))

        print("display_list",display_list[i])
        plt.axis('off')

    plt.show()

for image, mask in image_mask_ds.take(1):

    sample_image, sample_mask = image, mask
    # print(mask.shape)
display([sample_image, sample_mask])
</code>```

However I got the errors like (image attached):

ValueError: could not convert string to float: b'./DRIVE/training/images/40_training.tif'

```<code>    222     raise ImportError('Could not import PIL.Image. '
    223                       'The use of `array_to_img` requires PIL.')
--> 224   x = np.asarray(x, dtype=dtype)
    225   if x.ndim != 3:
    226     raise ValueError('Expected image array to have rank 3 (single image). '

ValueError: could not convert string to float: b'./DRIVE/training/images/40_training.tif'
</code>```

I'm confused by these:

display_list [<tf.Tensor: shape=(), dtype=string, numpy=b'./DRIVE/training/images/40_training.tif'>, <tf.Tensor: shape=(), dtype=string, numpy=b'./DRIVE/training/mask/22_training_mask.gif'>]

I have successfully installed Pillow

  raise ImportError('Could not import PIL.Image. '   'The use ofarray_to_imgrequires PIL.')

Can anyone explain about this? where I made a mistake. Thank you.

Body:
I'm running the following tensorflow script for CNN in google colab:

def process_path(image_path, mask_path):
    imag = tf.io.read_file(image_path)
    imag = tf.image.decode_png(imag, channels=3)
    imag = tf.image.convert_image_dtype(imag, tf.float32)

    mask = tf.io.read_file(mask_path)
    mask = tf.image.decode_png(mask, channels=3)
    mask = tf.math.reduce_max(mask, axis=-1, keepdims=True)
    return imag, mask

def preprocess(image, mask):
    input_image = tf.image.resize(image, (96, 128), method='nearest')
    input_mask = tf.image.resize(mask, (96, 128), method='nearest')

    # input_image = input_image / 255.
    input_image = tf.cast(input_image, tf.float32) / 255.0

    print(input_image.dtype)
    print(input_mask.dtype)
    return input_image, input_mask

image_ds = image_mask_ds.map(process_path)
processed_image_ds = image_ds.map(preprocess)

from PIL import Image

def display(display_list):
    plt.figure(figsize=(15, 15))

    title = ['Input Image', 'True Mask', 'Predicted Mask']

    for i in range(len(display_list)):
        plt.subplot(1, len(display_list), i+1)
        plt.title(title[i])
        print("display_list",display_list)
        plt.imshow(tf.keras.preprocessing.image.array_to_img(display_list[i]))

        print("display_list",display_list[i])
        plt.axis('off')

    plt.show()

for image, mask in image_mask_ds.take(1):

    sample_image, sample_mask = image, mask
    # print(mask.shape)
display([sample_image, sample_mask])

However I got the errors like (image attached):

ValueError: could not convert string to float: b'./DRIVE/training/images/40_training.tif'

    222     raise ImportError('Could not import PIL.Image. '
    223                       'The use of `array_to_img` requires PIL.')
--> 224   x = np.asarray(x, dtype=dtype)
    225   if x.ndim != 3:
    226     raise ValueError('Expected image array to have rank 3 (single image). '

ValueError: could not convert string to float: b'./DRIVE/training/images/40_training.tif'

I'm confused by these:

display_list [<tf.Tensor: shape=(), dtype=string, numpy=b'./DRIVE/training/images/40_training.tif'>, <tf.Tensor: shape=(), dtype=string, numpy=b'./DRIVE/training/mask/22_training_mask.gif'>]

I have successfully installed Pillow

  raise ImportError('Could not import PIL.Image. '   'The use ofarray_to_imgrequires PIL.')

Can anyone explain about this? where I made a mistake. Thank you.


问:
How to Invoke a the same SOAP API using Oracle SOA Suite from BPEL with differents URLs (address locations)
I've a case where a system is being upgraded. Not all customers are migrated to the upgraded version.
Currenlty I have an invokation in my BPEL that calls the olds system. I want to be able to call the upgraded system only if the customer calling my process is migrated to the upgraded system (for this condition i have a lookup db).

I tried to import the wsdls from the upgreaded system to the same bpel and add a new invokation, but when i want to deploy the services it gives an error in build:

Error: Global Type declaration/definition of name '{http://XXXXX/product}GetProductComponentOutputProductComponentIntf' are duplicated at the following locations:
...
...

Is there a way to keep one invokation and change the URL which is calling at runtime?


问:
How can I prevent an out of memory error in Github Actions?
I'm working on a project that uses the repo2docker Github Actions workflow: https://github.com/jupyterhub/repo2docker-action

However, the required packages have grown and on mamba env update, the runner crashes, due to what I believe is an out of memory error. Image shown below:

Does anyone have suggestions for workarounds, shortcuts, etc? Thanks!

I've looked into the action itself, and registered for a free enterprise trial to get larger runners as a temporary workaround, but I'm looking for a long term fix.

Note: This question was also posted on the Jupyter Community Discourse Forum here.


问:
Best way to update 10k rows based on ID
We have a table clients (1m rows)

```<code>CREATE TABLE `clients` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `client_id` bigint NOT NULL,
  `external_id` bigint DEFAULT NULL,
  `status` tinyint NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `clients_3_index` (`status`,`client_id`,`external_id`),
) ENGINE=InnoDB AUTO_INCREMENT=717651
</code>```

On the backend, we regularly request an API that returns a list of external_ids. The list contains around 10k external_ids. If an external_id is new, we insert it as a new row to the table clients with status 1.

If an external_id disappeared from the list, we have to change its status to 0. Meaning, any external_id that is not in that list needs to be updated to status 0 in case it still has status 1. What is the best way to do that?

We currently do it like this

```<code>UPDATE clients SET status = 0 WHERE status = 1 AND client_id = 2 AND external_id NOT IN (12540726, 12540725, 12540720, 12540719, 12540717, 12540716, 12540712, 12540711, 12540706, ...)
</code>```

The NOT IN contains the 10k items from the API response.
It is running around 180s (which is way too long)

```<code>SELECT * FROM clients WHERE status = 1 AND client_id = 2 AND external_id NOT IN (12540726, 12540725, 12540720, 12540719, 12540717, 12540716, 12540712, 12540711, 12540706, ...)
</code>```

This is running 0.01s

Why is the SELECT so much faster than the UPDATE? The query is updating between 0 to 100 rows, which should not take that long. Is there a better way to do it?

Our MySQL Version is 8.0.28

edit:
One alternative approach would be letting the backend handle the logic. So each time we have to update:

SELECT external_id FROM clients WHERE client_id = 2 AND status = 1

Letting the backend compare the list of 10k external_ids with the result from the query above. Any external_id that is in the query but not in the list needs to be updated in the next step

UPDATE clients SET status = 0 WHERE client_id = 2 AND external_id IN (123, 456, 789, ...)
As we now know which external_ids have to be updated, we can UPDATE these external_ids specifically instead of updating all external_ids NOT IN the main list

Would this be a better approach?

Title: Best way to update 10k rows based on ID

Body:
We have a table clients (1m rows)

CREATE TABLE `clients` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `client_id` bigint NOT NULL,
  `external_id` bigint DEFAULT NULL,
  `status` tinyint NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `clients_3_index` (`status`,`client_id`,`external_id`),
) ENGINE=InnoDB AUTO_INCREMENT=717651

On the backend, we regularly request an API that returns a list of external_ids. The list contains around 10k external_ids. If an external_id is new, we insert it as a new row to the table clients with status 1.

If an external_id disappeared from the list, we have to change its status to 0. Meaning, any external_id that is not in that list needs to be updated to status 0 in case it still has status 1. What is the best way to do that?

We currently do it like this

UPDATE clients SET status = 0 WHERE status = 1 AND client_id = 2 AND external_id NOT IN (12540726, 12540725, 12540720, 12540719, 12540717, 12540716, 12540712, 12540711, 12540706, ...)

The NOT IN contains the 10k items from the API response.
It is running around 180s (which is way too long)

SELECT * FROM clients WHERE status = 1 AND client_id = 2 AND external_id NOT IN (12540726, 12540725, 12540720, 12540719, 12540717, 12540716, 12540712, 12540711, 12540706, ...)

This is running 0.01s

Why is the SELECT so much faster than the UPDATE? The query is updating between 0 to 100 rows, which should not take that long. Is there a better way to do it?

Our MySQL Version is 8.0.28

edit:
One alternative approach would be letting the backend handle the logic. So each time we have to update:

SELECT external_id FROM clients WHERE client_id = 2 AND status = 1

Letting the backend compare the list of 10k external_ids with the result from the query above. Any external_id that is in the query but not in the list needs to be updated in the next step

UPDATE clients SET status = 0 WHERE client_id = 2 AND external_id IN (123, 456, 789, ...)
As we now know which external_ids have to be updated, we can UPDATE these external_ids specifically instead of updating all external_ids NOT IN the main list

Would this be a better approach?


问:
Operand type clash: image is incompatible with xml Error
I am getting the below error 'Operand type clash: image is incompatible with xml' , when i follow the exact same instructions as below

Store XML File into MS SQL DB using Python

Here is my code

```<code>import pyodbc
#import xlrd
import xml.etree.ElementTree as ET
import os
from lxml import etree

os.chdir("C:/Users/tasks/xml_Parsing")

print("Connecting..")
# Establish a connection between Python and SQL Server
driver= '{ODBC Driver 17 for SQL Server}'

cnxn = pyodbc.connect(
    Trusted_Connection='Yes',
    Driver='{ODBC Driver 17 for SQL Server}',
    Server='10.x.x.xxx',
    Database='Out'
)

# Get XMLFile
XMLFilePath = open('00A1222H001.xml')
x = etree.parse(XMLFilePath)
#print(x)

with open("00A1222H001.xml", "wb") as f:
    f.write(etree.tostring(x))

    #print(x)

cursor = cnxn.cursor()

InsertQuery = """INSERT INTO dbo.Xml_test (XBRLFile) values(?)"""

# Assign values from each row
values = etree.tostring(x) # Updated Code line

#print(values)

# Execute SQL Insert Query
cursor.execute(InsertQuery, values)

# Commit the transaction
cnxn.commit()

# Close the database connection
cnxn.close()
</code>```

My error

Kindly help me. This is my first time to deal with xml files.

Body:
I am getting the below error 'Operand type clash: image is incompatible with xml' , when i follow the exact same instructions as below

Store XML File into MS SQL DB using Python

Here is my code

import pyodbc
#import xlrd
import xml.etree.ElementTree as ET
import os
from lxml import etree

os.chdir("C:/Users/tasks/xml_Parsing")

print("Connecting..")
# Establish a connection between Python and SQL Server
driver= '{ODBC Driver 17 for SQL Server}'

cnxn = pyodbc.connect(
    Trusted_Connection='Yes',
    Driver='{ODBC Driver 17 for SQL Server}',
    Server='10.x.x.xxx',
    Database='Out'
)

# Get XMLFile
XMLFilePath = open('00A1222H001.xml')
x = etree.parse(XMLFilePath)
#print(x)

with open("00A1222H001.xml", "wb") as f:
    f.write(etree.tostring(x))

    #print(x)

cursor = cnxn.cursor()

InsertQuery = """INSERT INTO dbo.Xml_test (XBRLFile) values(?)"""

# Assign values from each row
values = etree.tostring(x) # Updated Code line

#print(values)

# Execute SQL Insert Query
cursor.execute(InsertQuery, values)

# Commit the transaction
cnxn.commit()

# Close the database connection
cnxn.close()

My error

Kindly help me. This is my first time to deal with xml files.


问:
Terminal error for WHILE loop when trying to print an incrementing variable until the user input is matched
Im using this python3 for this code:

```<code>N = int(input("Input:"))
count = 1
while (count<=N):
    count = count=+1
print(count)
</code>```

But it keeps giving me nothing, just a white vertical, blinking dash right under the input

I want it to increment and print until it reaches the specified inputted value
Ive tried reversing the less than sign and ive tried nesting the print but it gives me an infinite loop.
Im sorry for such a silly question but in a beginner and cant seem to figure it out.

Body:
Im using this python3 for this code:

N = int(input("Input:"))
count = 1
while (count<=N):
    count = count=+1
print(count)

But it keeps giving me nothing, just a white vertical, blinking dash right under the input

I want it to increment and print until it reaches the specified inputted value
Ive tried reversing the less than sign and ive tried nesting the print but it gives me an infinite loop.
Im sorry for such a silly question but in a beginner and cant seem to figure it out.


问:
vstest task cannot find any tests when using google test executable in azure devops
I have been trying to run tests using the vstest@2 task within azure devops pipelines and there are never any tests found when using the google test executable. I do have the test assembly specified to google test and Nuget restores google test in an earlier pipeline task.

Here is a snippet of my yaml

```<code>- task : VSBuild@1
  displayName: 'VSbuild'
  inputs :
    solution : '$(solution)'
    platform : '$(buildPlatform)'
    configuration : ${{parameters.buildconfiguration}}

- task: VSTest@2
  inputs:
    searchFolder:  '$(System.DefaultWorkingDirectory)/<ProjectRepo>'
    resultsFolder: '$(System.DefaultWorkingDirectory)/TestResults'
    testAssemblyVer2: |
      **\UnitTesting.exe
    codeCoverageEnabled: true
    pathtoCustomTestAdapters: '$(System.DefaultWorkingDirectory)/GoogleTestAdapter'
    platform: '$(buildPlatform)'
    configuration: ${{parameters.buildconfiguration}}
</code>```

UnitTesting.exe is the google test executable that is generated using the vsbuild@1 task just before.

Below is the output from the vstest task.

```<code>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe "@D:\a\_temp\c4zmbclzr0a.tmp"
Microsoft (R) Test Execution Command Line Tool Version 16.11.0
Copyright (c) Microsoft Corporation.  All rights reserved.
vstest.console.exe "D:\a\1\s\<project repo>\UnitTesting.exe"
/Settings:"D:\a\_temp\2kvnbwgfz0c.tmp.runsettings"
/EnableCodeCoverage
/Logger:"trx"
/TestAdapterPath:"D:\a\1\s\<project repo>\GoogleTestAdapter"
Starting test execution, please wait...
2.391
A total of 1 test files matched the specified pattern.
No settings file provided through env variable GTA_FALLBACK_SETTINGS
Warning: Using default settings.
Google Test Adapter: Test execution starting...
Found 0 tests in executable D:\a\1\s\<project repo>\UnitTesting.exe
##[error]Test discovery was cancelled after 30s for executable 'D:\a\1\s\<project repo>\UnitTesting.exe'
Google Test execution completed, overall duration: 00:00:31.6375081.
##[error]================
##[error]The following warnings and errors occured during test execution (enable debug mode for more information):
##[error]Test discovery was cancelled after 30s for executable 'D:\a\1\s\<project repo>\UnitTesting.exe'
No test is available in D:\a\1\s\<project repo>\UnitTesting.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
Results File: D:\a\1\s\TestResults\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19_22_25_03.trx
Attachments:
  D:\a\1\s\TestResults\e27d838c-1572-409c-886c-741d2b1a6e51\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19.22_24_28.coverage
##[error]Test Run Failed.
Vstest.console.exe exited with code 1.
**************** Completed test execution *********************
Test results files: D:\a\1\s\TestResults\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19_22_25_03.trx
No Result Found to Publish 'D:\a\1\s\TestResults\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19_22_25_03.trx'.
Created test run: 1381422
Publishing test results: 0
Publishing test results to test run '1381422'.
TestResults To Publish 0, Test run id:1381422
Published test results: 0
Publishing Attachments: 2
Execution Result Code 1 is non zero, checking for failed results
Completed TestExecution Model...
##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
##[error]Error: The process 'D:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.210.0\Modules\DTAExecutionHost.exe' failed with exit code 1
##[error]Vstest failed with error. Check logs for failures. There might be failed tests.
Finishing: VSTest

</code>```

I know I can use the command line task and run the google test executable and publish pipeline results from there, but I want to be able to use code coverage with the vstest task.

Edit for comments:
When I run the following task just before the VSTest task I get output of all my tests.

```<code>- task: CmdLine@2
  inputs:
    script: '"<project repo output directory>/UnitTesting.exe" --gtest_list_tests'
</code>```

Body:
I have been trying to run tests using the vstest@2 task within azure devops pipelines and there are never any tests found when using the google test executable. I do have the test assembly specified to google test and Nuget restores google test in an earlier pipeline task.

Here is a snippet of my yaml

- task : VSBuild@1
  displayName: 'VSbuild'
  inputs :
    solution : '$(solution)'
    platform : '$(buildPlatform)'
    configuration : ${{parameters.buildconfiguration}}

- task: VSTest@2
  inputs:
    searchFolder:  '$(System.DefaultWorkingDirectory)/<ProjectRepo>'
    resultsFolder: '$(System.DefaultWorkingDirectory)/TestResults'
    testAssemblyVer2: |
      **\UnitTesting.exe
    codeCoverageEnabled: true
    pathtoCustomTestAdapters: '$(System.DefaultWorkingDirectory)/GoogleTestAdapter'
    platform: '$(buildPlatform)'
    configuration: ${{parameters.buildconfiguration}}

UnitTesting.exe is the google test executable that is generated using the vsbuild@1 task just before.

Below is the output from the vstest task.

C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\Extensions\TestPlatform\vstest.console.exe "@D:\a\_temp\c4zmbclzr0a.tmp"
Microsoft (R) Test Execution Command Line Tool Version 16.11.0
Copyright (c) Microsoft Corporation.  All rights reserved.
vstest.console.exe "D:\a\1\s\<project repo>\UnitTesting.exe"
/Settings:"D:\a\_temp\2kvnbwgfz0c.tmp.runsettings"
/EnableCodeCoverage
/Logger:"trx"
/TestAdapterPath:"D:\a\1\s\<project repo>\GoogleTestAdapter"
Starting test execution, please wait...
2.391
A total of 1 test files matched the specified pattern.
No settings file provided through env variable GTA_FALLBACK_SETTINGS
Warning: Using default settings.
Google Test Adapter: Test execution starting...
Found 0 tests in executable D:\a\1\s\<project repo>\UnitTesting.exe
##[error]Test discovery was cancelled after 30s for executable 'D:\a\1\s\<project repo>\UnitTesting.exe'
Google Test execution completed, overall duration: 00:00:31.6375081.
##[error]================
##[error]The following warnings and errors occured during test execution (enable debug mode for more information):
##[error]Test discovery was cancelled after 30s for executable 'D:\a\1\s\<project repo>\UnitTesting.exe'
No test is available in D:\a\1\s\<project repo>\UnitTesting.exe. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
Results File: D:\a\1\s\TestResults\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19_22_25_03.trx
Attachments:
  D:\a\1\s\TestResults\e27d838c-1572-409c-886c-741d2b1a6e51\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19.22_24_28.coverage
##[error]Test Run Failed.
Vstest.console.exe exited with code 1.
**************** Completed test execution *********************
Test results files: D:\a\1\s\TestResults\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19_22_25_03.trx
No Result Found to Publish 'D:\a\1\s\TestResults\VssAdministrator_WIN-CVJL4F2UTMJ_2022-12-19_22_25_03.trx'.
Created test run: 1381422
Publishing test results: 0
Publishing test results to test run '1381422'.
TestResults To Publish 0, Test run id:1381422
Published test results: 0
Publishing Attachments: 2
Execution Result Code 1 is non zero, checking for failed results
Completed TestExecution Model...
##[warning]Vstest failed with error. Check logs for failures. There might be failed tests.
##[error]Error: The process 'D:\a\_tasks\VSTest_ef087383-ee5e-42c7-9a53-ab56c98420f9\2.210.0\Modules\DTAExecutionHost.exe' failed with exit code 1
##[error]Vstest failed with error. Check logs for failures. There might be failed tests.
Finishing: VSTest

I know I can use the command line task and run the google test executable and publish pipeline results from there, but I want to be able to use code coverage with the vstest task.

Edit for comments:
When I run the following task just before the VSTest task I get output of all my tests.

- task: CmdLine@2
  inputs:
    script: '"<project repo output directory>/UnitTesting.exe" --gtest_list_tests'


问:
Python script doesn't open new chrome tab but gives off no error
i've been trying to debug my code for a while now, it's supposed to open a new chrome url as "about:blank" but does nothing. i'm pretty sure its some simple fix like implementing an argument but i can't find anything at all, also i'm using anaconda3 3.9.13 since it comes with a bunch of modules

(this is only a part of the code)

```<code># Setup for chrome
urL = 'https://www.google.com'
chrome_path = "C:/Program Files/Google/Chrome/Application/chrome.exe %s"
webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chrome_path))
webbrowser.get('chrome').open_new_tab(urL)

# Open the new tab
Url2 = 'about:blank'
Url3 = 'https://python.org' # Debug url
webbrowser.get('chrome').open_new_tab(Url2)

# Use JavaScript to set the background image of the page
javascript = f"document.body.style.backgroundImage = 'url(\"File://{os.getcwd()}/image.jpg\")';"
webbrowser.get('chrome').open("javascript:" + javascript)
print(os.getcwd()) # Debug thing for directory
</code>```

i have tried a bunch of things such as changing url, printing arguments etc but nothing seems wrong, it just wont open anything. before, it used to only open google.com but windows would give me an "You'll need a new app to open this about link" error

Body:
i've been trying to debug my code for a while now, it's supposed to open a new chrome url as "about:blank" but does nothing. i'm pretty sure its some simple fix like implementing an argument but i can't find anything at all, also i'm using anaconda3 3.9.13 since it comes with a bunch of modules

(this is only a part of the code)

# Setup for chrome
urL = 'https://www.google.com'
chrome_path = "C:/Program Files/Google/Chrome/Application/chrome.exe %s"
webbrowser.register('chrome', None, webbrowser.BackgroundBrowser(chrome_path))
webbrowser.get('chrome').open_new_tab(urL)

# Open the new tab
Url2 = 'about:blank'
Url3 = 'https://python.org' # Debug url
webbrowser.get('chrome').open_new_tab(Url2)

# Use JavaScript to set the background image of the page
javascript = f"document.body.style.backgroundImage = 'url(\"File://{os.getcwd()}/image.jpg\")';"
webbrowser.get('chrome').open("javascript:" + javascript)
print(os.getcwd()) # Debug thing for directory

i have tried a bunch of things such as changing url, printing arguments etc but nothing seems wrong, it just wont open anything. before, it used to only open google.com but windows would give me an "You'll need a new app to open this about link" error


问:
Nginx possibly removing dot (".") from URL path before forwardslash
I have defined a reverse proxy like this:

```<code>    server {
        listen       443 ssl;
        server_name  testing.com;
        ssl_certificate      "C:/nginx/testing.crt";
        ssl_certificate_key  "C:/nginx/testing.key";
        location / {
            proxy_pass  "http://127.0.0.1:8888/";
        }
    }
</code>```

The reverse proxy works as intended. Now that we got that out of the way:

I have a case where i need to pass parameters in the URL and some of the parameters sometimes end with a dot (.) like this "https://testing.com/param1./param2/param3/param4."
But for some reason the URL that is received at the server looks like this "127.0.0.1:8888/param1/param2/param3/param4"

If i call the server directly like this "127.0.0.1:8888/param1./param2/param3/param4.", the parameters are correct. My guess is that nginx modifies the URL. Maybe the issues lies somewhere else...

I am on Windows 10. The server is a Go (golang) server that uses only built in libraries. I have setup self signed certificates and edited my hosts file (never had issues with those).

ALSO - my friend who is also working on this project has no issues even tho we have identical nginx setups, but the only difference is that he is on Linux.

Body:
I have defined a reverse proxy like this:

    server {
        listen       443 ssl;
        server_name  testing.com;
        ssl_certificate      "C:/nginx/testing.crt";
        ssl_certificate_key  "C:/nginx/testing.key";
        location / {
            proxy_pass  "http://127.0.0.1:8888/";
        }
    }

The reverse proxy works as intended. Now that we got that out of the way:

I have a case where i need to pass parameters in the URL and some of the parameters sometimes end with a dot (.) like this "https://testing.com/param1./param2/param3/param4."
But for some reason the URL that is received at the server looks like this "127.0.0.1:8888/param1/param2/param3/param4"

If i call the server directly like this "127.0.0.1:8888/param1./param2/param3/param4.", the parameters are correct. My guess is that nginx modifies the URL. Maybe the issues lies somewhere else...

I am on Windows 10. The server is a Go (golang) server that uses only built in libraries. I have setup self signed certificates and edited my hosts file (never had issues with those).

ALSO - my friend who is also working on this project has no issues even tho we have identical nginx setups, but the only difference is that he is on Linux.