Skip to content

Instantly share code, notes, and snippets.

View michaelahlers's full-sized avatar

Michael Ahlers michaelahlers

View GitHub Profile
import scalaz.PLens._
import scalaz.Lens._
import scalaz._
case class Name(given: Option[String] = None, family: Option[String] = None)
val givenL: Name @> Option[String] = lensg(a => v => a.copy(given = v), _.given)
val familyL: Name @> Option[String] = lensg(a => v => a.copy(family = v), _.family)
case class Contact(name: Option[Name] = None)
@michaelahlers
michaelahlers / keybase.md
Last active April 2, 2017 21:25
Keybase Proof

Keybase

I hereby claim:

  • I am michaelahlers on github.
  • I am michaelahlers (https://keybase.io/michaelahlers) on keybase.
  • I have a public key ASDxnGn9BcucjilpJv6GW8GVTmYa1Tb7dPtHwA6fsGymMwo

Proof

@michaelahlers
michaelahlers / idea.vmoptions
Last active April 21, 2017 18:23
Helpful IntelliJ IDEA settings for coping with egregiously-large SBT projects.
# See https://intellij-support.jetbrains.com/hc/en-us/articles/206544859-Mac-OS-specific-configuration-of-the-JVM-options for detials.
-server
-Xms2g
-Xmx2g
-XX:NewRatio=3
-Xss16m
-XX:+UseConcMarkSweepGC
-XX:+CMSParallelRemarkEnabled
-XX:ConcGCThreads=4
@michaelahlers
michaelahlers / Embedded.scala
Last active May 4, 2018 20:23
Neo4j Impermanent Database with Bolt Connector
import org.neo4j.driver.v1._
import org.neo4j.graphdb.factory.GraphDatabaseSettings
import org.neo4j.helpers.ListenSocketAddress._
import org.neo4j.kernel.configuration.BoltConnector.EncryptionLevel._
import org.neo4j.kernel.configuration.Connector.ConnectorType._
import org.neo4j.kernel.configuration.Settings.{ FALSE, TRUE }
import org.neo4j.kernel.configuration._
import org.neo4j.test._
import org.scalatest._
@michaelahlers
michaelahlers / EntityReferenceSpec.scala
Last active November 13, 2018 12:56
Illustrates why inheritance produces unexpected behavior when an entity may also service as a reference.
import org.scalamock.scalatest._
import org.scalatest._
import scala.language.implicitConversions
class EntityReferenceSpec extends WordSpec with MockFactory {
"An entity" that {
"is also a reference" when {
@michaelahlers
michaelahlers / fight.md
Last active April 2, 2019 19:12
Pyramid Generator Challenge!
@michaelahlers
michaelahlers / glacier-bulk-restore.sh
Last active April 4, 2019 16:27
Bulk restore-request of objects in S3.
#!/bin/bash
BUCKET_NAME="my-bucket"
KEY_PREFIX="my-key-prefix"
DAYS = "10"
aws s3 ls --recursive "s3://$BUCKET_NAME/$KEY_PREFIX" |\
awk '{$1=$2=$3=""; print $0}' |\
sed 's/^[[:space:]]*//g' |\
tr '\n' '\0' |\
@michaelahlers
michaelahlers / concatenate-movies.sh
Last active July 7, 2021 21:54
Don't escape single quotes around paths
#!/bin/bash
IN_FILE="*.mp4"
OUT_FILE="output.mp4"
ffmpeg \
-safe 0 \
-f concat \
-i <(for file in $IN_FILE; do echo "file '$(pwd)/$file'"; done) \
-c copy \
@michaelahlers
michaelahlers / appveyor.yml
Last active October 2, 2021 16:00
AppVeyor Configuration for SBT with (macOS, Linux, Windows) × JDK
version: '{build}'
skip_branch_with_pr: true
platform:
- x64
image:
- macOS
- Ubuntu
trait JavaApi {
def isAuthenticated: Boolean
}
sealed trait IsAuthenticated
object IsAuthenticated {
def unapply(x: JavaApi): Option[IsAuthenticated] =
if (x.isAuthenticated) Some(Yes)
else Some(No)
}