This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REVISION=$1 && | |
BRANCH=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,') && | |
git reset --hard $REVISION && | |
MSG="revert $BRANCH to ${REVISION}" && | |
git merge -s ours @{1} -m "${MSG}" && | |
echo $MSG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats.effect.Concurrent | |
import cats.effect.concurrent.{Deferred, Ref} | |
import cats.implicits._ | |
trait Cache[F[_], K, V] { | |
def getOrUpdate(k: K)(v: F[V]): F[V] | |
def values: F[Map[K, Deferred[F, V]]] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cats.effect._ | |
import cats.effect.concurrent.{Ref, Semaphore} | |
import cats.implicits._ | |
trait SerialRef[F[_], A] { | |
def get: F[A] | |
def modify[B](f: A => F[(A, B)]): F[B] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package akka_streams_test | |
import akka.actor.ActorSystem | |
import akka.stream._ | |
import akka.stream.scaladsl.{Flow, Keep, Sink, Source} | |
import scala.concurrent.Future | |
object ConsistentHashingParallelism extends App { | |
implicit val system = ActorSystem("ConsistentHashingParallelism") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.evolutiongaming.serialization | |
import java.nio.charset.Charset | |
import akka.serialization.SerializerWithStringManifest | |
import scala.util.control.NoStackTrace | |
class BrokenSerializer extends SerializerWithStringManifest { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Maven | |
target | |
# Idea | |
.idea/ | |
*.iml | |
*.ipr | |
#JRebel | |
rebel.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy val dbCache: Option[Cache] = ??? | |
lazy val realCache: scala.concurrent.Future[Cache] = ??? | |
def cache: Option[Cache] = { | |
realCache.value match { | |
case Some(Success(x)) => Some(x) | |
case None => dbCache | |
case Some(Failure(error)) => | |
log.error(error) | |
dbCache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class Coordinates(x: Double, y: Double) | |
object HaversineDistance { | |
def apply(a: Coordinates, b: Coordinates): Double = { | |
val deltaLat = math.toRadians(b.x - a.x) | |
val deltaLong = math.toRadians(b.y - a.y) | |
val x = math.pow(math.sin(deltaLat / 2), 2) + math.cos(math.toRadians(a.x)) * math.cos(math.toRadians(b.x)) * math.pow(math.sin(deltaLong / 2), 2) | |
val greatCircleDistance = 2 * math.atan2(math.sqrt(x), math.sqrt(1 - x)) | |
3958.761 * greatCircleDistance | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazy val flyway = new Flyway { | |
setDataSource(dataSource) | |
} | |
def migrateToLatestDbVersion() { | |
try flyway.migrate() catch { | |
case e: FlywayException if e.getMessage.startsWith("Unable to check whether schema") => | |
flyway.init() | |
flyway.migrate() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project version="4"> | |
<component name="ProjectCodeStyleSettingsManager"> | |
<option name="PER_PROJECT_SETTINGS"> | |
<value> | |
<option name="USE_SAME_INDENTS" value="true" /> | |
<option name="IGNORE_SAME_INDENTS_FOR_LANGUAGES" value="true" /> | |
<option name="OTHER_INDENT_OPTIONS"> | |
<value> | |
<option name="INDENT_SIZE" value="2" /> |
NewerOlder