Skip to content

Instantly share code, notes, and snippets.

View vigoo's full-sized avatar

Daniel Vigovszky vigoo

View GitHub Profile
@vigoo
vigoo / prox_3_7.scala
Created November 22, 2019 17:14
prox 3/7
Concurrent[F].start(stream.compile.toVector)
@vigoo
vigoo / prox_3_6.scala
Created November 22, 2019 17:13
prox 3/6
Sync[F].delay {
systemProcess.isAlive
}
@vigoo
vigoo / prox_3_5.scala
Created November 22, 2019 17:13
prox 3/5
private class WrappedProcess[F[_] : Sync, // ...
@vigoo
vigoo / prox_3_4.scala
Created November 22, 2019 17:12
prox 3/4
IO {
systemProcess.isAlive
}
@vigoo
vigoo / prox_3_3.scala
Created November 22, 2019 17:10
prox 3/3
class Process[F[_], Out, Err, OutResult, ErrResult, IRS <: RedirectionState, ORS <: RedirectionState, ERS <: RedirectionState]
(val command: String,
val arguments: List[String],
val workingDirectory: Option[Path],
val inputSource: ProcessInputSource[F],
val outputTarget: ProcessOutputTarget[F, Out, OutResult],
val errorTarget: ProcessErrorTarget[F, Err, ErrResult],
val environmentVariables: Map[String, String],
val removedEnvironmentVariables: Set[String])
extends ProcessNode[Out, Err, IRS, ORS, ERS] {
@vigoo
vigoo / prox_3_2.scala
Created November 22, 2019 17:00
prox 3/2
def apply(process: PN,
dontStartOutput: Boolean = false,
blocker: Blocker)
(implicit
concurrent: Concurrent[F],
contextShift: ContextShift[F]): F[RunningProcesses]
@vigoo
vigoo / prox_3_1.scala
Created November 22, 2019 16:58
prox 3/1
def apply(process: PN, dontStartOutput: Boolean = false, blocker: Blocker)
(implicit contextShift: ContextShift[IO]): IO[RunningProcesses]
@vigoo
vigoo / prox_2_16.scala
Created November 22, 2019 16:49
prox 2/16
val utf8Decode: Sink[ByteString, Future[String]] =
Flow[ByteString]
.reduce(_ ++ _)
.map(_.utf8String)
.toMat(Sink.head)(Keep.right)
@vigoo
vigoo / prox_2_15.scala
Created November 22, 2019 16:49
prox 2/15
val customPipe = Framing.delimiter(
delimiter = ByteString("\n"),
maximumFrameLength = 10000,
allowTruncation = true
).map(_.utf8String)
.map(_.split(' ').toVector)
.map(v => v.map(_ + " !!!").mkString(" "))
.intersperse("\n")
.map(ByteString.apply)
@vigoo
vigoo / prox_2_14.scala
Created November 22, 2019 16:48
prox 2/14
val customPipe: Pipe[IO, Byte, Byte] =
(s: Stream[IO, Byte]) => s
.through(text.utf8Decode)
.through(text.lines)
.map(_.split(' ').toVector)
.map(v => v.map(_ + " !!!").mkString(" "))
.intersperse("\n")
.through(text.utf8Encode)
val proc = Process("echo", List("This is a test string"))