Skip to content

Instantly share code, notes, and snippets.

@schrepfler
schrepfler / switchMap.scala
Created August 6, 2024 08:05 — forked from mpilquist/switchMap.scala
FS2 version of switchMap
def switchMap[F[_]: Async, A, B](f: A => Stream[F, B]): Pipe[F, A, B] = {
def go(
outer: ScopedFuture[F, Pull[F, Nothing, (NonEmptyChunk[A], Handle[F, A])]],
inner: ScopedFuture[F, Pull[F, Nothing, (NonEmptyChunk[B], Handle[F, B])]]
): Pull[F, B, Nothing] = {
(outer race inner).pull.flatMap {
case Left(outer) =>
outer.optional.flatMap {
case None =>
inner.pull.flatMap(identity).flatMap { case (hd, tl) => Pull.output(hd) >> tl.echo }
@schrepfler
schrepfler / attributes.rb
Created January 12, 2020 20:20 — forked from lizthegrey/attributes.rb
Hardening SSH with 2fa
default['sshd']['sshd_config']['AuthenticationMethods'] = 'publickey,keyboard-interactive:pam'
default['sshd']['sshd_config']['ChallengeResponseAuthentication'] = 'yes'
default['sshd']['sshd_config']['PasswordAuthentication'] = 'no'