当尝试使用以下命令推送到 git 时git push,我突然收到以下错误消息:
fatal: unable to access 'https://bitbucket.org/mopla-solutions/mopla-server.git/': HTTP/2 stream 5 was not closed cleanly before end of the underlying stream
我尝试了各种 SO 答案和其他网站中推荐的以下内容:
git config --global http.version HTTP/1.1和git config --global http.postBuffer 524288000但到目前为止,没有任何帮助。还有其他方法可以调试这个问题吗?
更新: Bitbucket 已经解决了这个问题 - 现在一切正常。
一般来说,我在查找如何在"内部"monad中编写tailrecursive函数时遇到问题.这是一个简单的例子:
这是我写的一个小示例应用程序,以更好地理解Scala中的FP.首先,提示用户进入由7名玩家组成的团队.此函数以递归方式读取输入:
import cats.effect.{ExitCode, IO, IOApp}
import cats.implicits._
case class Player (name: String)
case class Team (players: List[Player])
/**
* Reads a team of 7 players from the command line.
* @return
*/
def readTeam: IO[Team] = {
def go(team: Team): IO[Team] = { // here I'd like to add @tailrec
if(team.players.size >= 7){
IO(println("Enough players!!")) >>= (_ => IO(team))
} else {
for {
player <- readPlayer
team <- go(Team(team.players :+ player))
} yield team
}
}
go(Team(Nil))
} …Run Code Online (Sandbox Code Playgroud) 是否有可能在build.sbt文件中使用外部库?
我想写这样的东西:
import scala.io.Source
import io.circe._ // not possible
version := myTask
lazy val myTask: String = {
val filename = "version.txt"
Source.fromFile(filename).getLines.mkString(", ")
// do some json parsing using the circe library
// ...
}
Run Code Online (Sandbox Code Playgroud) 我已经用谷歌搜索了很多小时以找到解决方案,但在表格单元格中垂直对齐文本似乎非常困难。我很困惑为什么他们使水平对齐变得容易,而垂直对齐却那么困难。
<TableCell colSpan={2} align='center' vertical-align='top' >
<Typography variant="h5" gutterBottom >
Task
</Typography>
</TableCell>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用cats-effect以纯粹的功能方式获取一些基本文件IO(写入/读取)。遵循本教程之后,下面就是我读取文件的内容:
private def readFile(): IO[String] = for {
lines <- bufferedReader(new File(filePath)).use(readAllLines)
} yield lines.mkString
def bufferedReader(f: File): Resource[IO, BufferedReader] =
Resource.make {
IO(new BufferedReader(new FileReader(f)))
} { fileReader =>
IO(fileReader.close()).handleErrorWith(_ => IO.unit)
}
Run Code Online (Sandbox Code Playgroud)
现在在handleErrorWith函数中,我可以记录发生的任何错误,但是如何为它添加适当的错误处理(例如,返回Resource[IO, Either[CouldNotReadFileError, BufferedReader]])?
我在WPF应用程序中使用剪贴板时遇到问题:我的代码如下所示:
var msg = "sample message for the clipboard";
Clipboard.Clear();
Clipboard.SetText(msg);
Run Code Online (Sandbox Code Playgroud)
但只有"\ t\t\t\r \n"才会存储在我的剪贴板中.这是在我的应用程序中使用剪贴板的唯一代码,它被调用.
*编辑:发现错误.我使用上面的代码在DataGridRow中进行复制粘贴操作.这适用于:
private void OnCopyingRowClipboardContent(object sender, DataGridRowClipboardEventArgs e)
{
var msg = "sample"
e.ClipboardRowContent.Clear();
e.ClipboardRowContent.Add(new DataGridClipboardCellContent(e.Item, (sender as DataGrid).Columns[0], msg));
}
Run Code Online (Sandbox Code Playgroud)
我想问题是它在我的Clipboard.SetText(..)之后自动尝试从我的DataGrid中复制出来并再次覆盖我的文本.
这是我的 proto 文件的样子:
option java_package = "com.test.report";
message ClientRecord
{
optional string cust_id = 1;
optional double tx_bytes = 2;
optional double rx_bytes = 3;
optional string source_id = 4;
optional string dest_id = 5;
}
message ClientRecords
{
repeated ClientRecord record = 1;
}
Run Code Online (Sandbox Code Playgroud)
我能够在 python 中编写 protobuf 生成器/解码器,但是如何在 Scala/Java 中编写它。谁能帮我在 Scala 中为我的示例编写一个生成器?
给定以下案例类别LogMessage:
import io.circe.{Decoder, Encoder}
import io.circe.generic.semiauto.{deriveDecoder, deriveEncoder}
import enumeratum.{CirceEnum, Enum, EnumEntry}
import io.circe.syntax._
sealed trait LogLevel extends EnumEntry
object LogLevel extends Enum[LogLevel] with CirceEnum[LogLevel] {
val values = findValues
case object Warning extends LogLevel
case object Error extends LogLevel
case object Info extends LogLevel
case object Success extends LogLevel
}
object LogMessage {
implicit val logMessageDecoder: Decoder[LogMessage] = deriveDecoder[LogMessage]
implicit val logMessageEncoder: Encoder[LogMessage] = deriveEncoder[LogMessage]
}
case class LogMessage(level: LogLevel, text: String, args: List[String], date: Long)
Run Code Online (Sandbox Code Playgroud)
case class …Run Code Online (Sandbox Code Playgroud) 在我目前正在编写的应用程序中,我在IOApp中使用了cat -effect 的IO monad。
如果从命令行参数“debug”开始,我会将我的程序流委派到一个调试循环中,该循环等待用户输入并执行各种与调试相关的方法。一旦开发者在enter没有任何输入的情况下按下,应用程序将退出调试循环并退出 main 方法,从而关闭应用程序。
此应用程序的主要方法大致如下所示:
import scala.concurrent.{ExecutionContext, ExecutionContextExecutor}
import cats.effect.{ExitCode, IO, IOApp}
import cats.implicits._
object Main extends IOApp {
val BlockingFileIO: ExecutionContextExecutor = ExecutionContext.fromExecutor(blockingIOCachedThreadPool)
def run(args: List[String]): IO[ExitCode] = for {
_ <- IO { println ("Running with args: " + args.mkString(","))}
debug = args.contains("debug")
// do all kinds of other stuff like initializing a webserver, file IO etc.
// ...
_ <- if(debug) debugLoop else IO.unit
} yield …Run Code Online (Sandbox Code Playgroud) 尝试将org.ajoberstar.grgit插件添加到我的 gradle 构建中时,出现以下错误:
Plugin [id: 'org.ajoberstar.grgit', version: '2.3.0'] was not found in any of
the following sources:
- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Plugin Repositories (could not resolve plugin artifact
'org.ajoberstar.grgit:org.ajoberstar.grgit.gradle.plugin:2.3.0')
Searched in the following repositories:
Gradle Central Plugin Repository
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
import org.ajoberstar.grgit.*
buildscript {
dependencies {
classpath 'org.ajoberstar:grgit:2.3.0'
}
}
plugins {
id "org.sonarqube" version "2.6"
id "idea"
id "org.ajoberstar.grgit" version "2.3.0"
}
// ...
Run Code Online (Sandbox Code Playgroud)
关于如何解决这个问题的任何想法?我可以以某种方式手动下载插件并将其放入缓存中吗?
scala ×6
cats-effect ×2
java ×2
scala-cats ×2
.net ×1
bitbucket ×1
c# ×1
circe ×1
clipboard ×1
git ×1
gradle ×1
io ×1
json ×1
material-ui ×1
monads ×1
sbt ×1
unit-testing ×1
wpf ×1