Please see https://gist.github.com/nafg/6ecce298a0a20f1e4a259cdae5634060 instead
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
val generateInstallInstructions = taskKey[Unit]("Generate install instructions in README.md") | |
generateInstallInstructions := { | |
val info = Def.task((projectID.value, description.value, (publish / skip).value)).all(ScopeFilter(inAnyProject)).value | |
val lines = | |
for ((moduleId, descr, noPublish) <- info.sortBy(_._1.name) if !noPublish) yield { | |
"// " + descr + "\n" + | |
s"""libraryDependencies += "${moduleId.organization}" %%% "${moduleId.name}" % "${moduleId.revision}"""" | |
} |
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 scala.language.experimental.macros | |
import scala.reflect.ClassTag | |
import io.circe.{Decoder, Encoder, Json} | |
import magnolia._ | |
class ParamEncoder[T](val underlying: Encoder[T]) extends AnyVal | |
trait ParamEncoderLowPriority { | |
type Typeclass[T] = ParamEncoder[T] |
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 scala.util.{Failure, Success} | |
import $ivy.`io.circe::circe-core:0.12.3` | |
import $ivy.`io.circe::circe-generic:0.12.3` | |
import $ivy.`io.circe::circe-parser:0.12.3` | |
import io.circe.{Decoder, Encoder} | |
import io.circe.generic.auto._ | |
import io.circe.syntax._ | |
import io.circe.parser | |
import requests.BaseSession |
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
class SomeClass { | |
private def get(url: String): Future[Option[String]] = | |
for { | |
serviceResponse <- sendGetRequest(url) | |
} yield maybeBody(url, serviceResponse) | |
private def maybeBody(url: String, response: HttpResponse[String]): String = | |
if (response.is2xx) Some(response.body) | |
else None |
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
object Main extends App { | |
case class Coord(row: Int, col: Int) | |
case class Line(coords: Seq[Coord]) | |
sealed abstract class Dir(val sign: Int, val horizontal: Boolean) { | |
def first(sign: Int) = (0 until 4).maxBy(_ * sign) | |
def last(sign: Int) = (0 until 4).minBy(_ * sign) | |
def lines = | |
for(i <- first(sign) to last(sign) by -sign) | |
yield Line( |
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
#!/bin/bash | |
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do | |
echo "Waiting for other software managers to finish..." | |
sleep 10 | |
done | |
/usr/bin/apt-get "$@" |
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
version: "3.2" | |
services: | |
selenium: | |
image: selenium/standalone-chrome | |
ports: | |
- "4444:4444" |
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
#!/usr/bin/fish | |
set instance $argv[1] | |
set key $argv[2] | |
set tmpdir (mktemp -d) | |
set file $tmpdir/(string replace _ . $key) | |
gcloud compute instances describe $instance --format="value(metadata.$key)" > $file |
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 java.io.{FileReader, Reader} | |
import scala.concurrent.Await | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.duration.Duration | |
import slick.jdbc.PostgresProfile.api._ | |
import slick.jdbc.PostgresProfile.columnTypes | |
import slick.jdbc.meta.MPrimaryKey |