Skip to content

Instantly share code, notes, and snippets.

View ahjohannessen's full-sized avatar

Alex Henning Johannessen ahjohannessen

View GitHub Profile
@ahjohannessen
ahjohannessen / update-oem-vmware.sh
Last active July 15, 2021 15:46 — forked from neilmayhew/update-oem-vmware.sh
Update a Flatcar installation on VMWare to use the latest OEM content
#!/usr/bin/env bash
# Update a Flatcar installation on VMWare to use the latest OEM content
#
# Copyright 2020, Neil Mayhew <[email protected]>
# LICENSE: MIT
set -ex
shopt -s extglob nullglob
@ahjohannessen
ahjohannessen / Ex.scala
Created October 29, 2018 16:23 — forked from SystemFw/Ex.scala
Get instances of a typeclass `TC[_]` for all cases of a Coproduct [shapeless]
import shapeless._
@annotation.implicitNotFound("Make sure all cases of ${C} have an instance of ${TC}")
trait CopTCs[C <: Coproduct, TC[_]] {
type Out <: HList
def result: Out
}
object CopTCs {
type Aux[C <: Coproduct, TC[_], O <: HList] = CopTCs[C, TC] { type Out = O }
def apply[C <: Coproduct, TC[_]](implicit ev: CopTCs[C, TC]) = ev
import cats.{ ApplicativeError, MonadError }
import cats.data.{ Kleisli, OptionT }
import cats.effect.Sync
import cats.effect.concurrent.Ref
import cats.syntax.all._
import io.circe.generic.auto._
import io.circe.syntax._
import org.http4s._
import org.http4s.circe.CirceEntityDecoder._
import org.http4s.circe._
@ahjohannessen
ahjohannessen / amm.sc
Created September 21, 2018 15:33 — forked from MarkRBM/amm.sc
Dynamic Transactors
interp.configureCompiler(_.settings.YpartialUnification.value = true)
import $ivy.`org.tpolecat::doobie-core:0.5.3`
import cats._
import cats.effect._
import cats.implicits._
import doobie._
import doobie.implicits._
@ahjohannessen
ahjohannessen / Foo.scala
Created September 21, 2018 15:30 — forked from ChristopherDavenport/Foo.scala
ConnectionIO Final Tagless Example
import doobie._
import doobie.implicits._
// Something for FunctionK ~>
trait Foo[F[_]]{
def getFoo: F[Bar]
}
@ahjohannessen
ahjohannessen / RequiredFields.scala
Created August 22, 2018 19:21 — forked from afiore/RequiredFields.scala
Filtering non-optional fields using shapeless
import shapeless._
import shapeless.labelled._
trait Required[A] {
def isRequired: Boolean
}
object Required {
implicit def optIsRequired[A]: Required[Option[A]] = new Required[Option[A]] {
override def isRequired = false
}

Advanced Functional Programming with Scala - Notes

Copyright © 2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
#!/bin/bash
set -e
JAVA_HOME=${1-text}
[ $# -eq 0 ] && { echo "Usage: sudo $0 \$(/usr/libexec/java_home -v '1.8*')" ; exit 1; }
KEYSTORE=$JAVA_HOME/jre/lib/security/cacerts
wget https://letsencrypt.org/certs/letsencryptauthorityx1.der
wget https://letsencrypt.org/certs/letsencryptauthorityx2.der
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using EventStore.ClientAPI;
using EventStore.ClientAPI.Embedded;
@ahjohannessen
ahjohannessen / Flowz.scala
Last active August 29, 2015 14:27 — forked from DomBlack/Flowz.scala
Generic Akka stream operations for carrying extra information around operations
import akka.stream.scaladsl.Flow
import scala.concurrent.{ ExecutionContext, Future }
import scalaz._
import scalaz.std.scalaFuture.futureInstance // IntelliJ lies
/**
* Flowz provides Akka Stream Flow like methods for monadic types.
*
* You can define the `M` type and the input type, and let the compiler infer the output