Skip to content

Instantly share code, notes, and snippets.

@xuwei-k
xuwei-k / doctest.md
Last active November 24, 2016 21:40
sbt-doctest でやりたいことまとめ
  • import 文を SettingKeyTaskKey でカスタマイズ可能にしたい
  • 現状は固定
  • やりたかったら、それぞれのテストに明示的に書くか、スコープに入るように、テストが置かれるであろうパッケージオブジェクトに色々置くしか無い?
  • 拡張ポイントをどこにするか問題
  • あくまで個人的意見としては、"sbt pluginの拡張ポイントはできるだけ汎用的" になっているべきだと思う
  • 言い換えると、あとからKeyをあまり増やしたくない。(keyが汎用的すぎて、それを設定するユーザー側が)多少面倒だとしても、少ない汎用的なKeyさえ使えば、とにかくなんでも設定可能
  • 汎用的にするには、やはりKeyは関数になっているべき
  • なので、最初に思いついたのは それぞれのテスト => Import文 という関数のKeyを作る
  • それぞれのテスト とは、現状では ParsedDoctest だろう
  • つまり ParsedDoctest => Seq[String]
val removeIdeaDotSbt = "remove-idea-dot-sbt"
TaskKey[Unit](removeIdeaDotSbt) := {
val f = baseDirectory.value / "project" / "idea.sbt"
assert(f.isFile)
IO.delete(f)
}
commands += Command.command("gen-idea-plugin"){ state =>
val extracted = Project.extract(state)
@gakuzzzz
gakuzzzz / 1_Implicits.scala
Last active April 18, 2021 02:29
Play2 Controller Utilities
package controllers.util
import play.api.mvc.{Result, Controller}
import play.api.data.Form
import scala.util.Either.RightProjection
object Implicits {
implicit def formToEither[A](form: Form[A]): Either[Form[A], A] = form.fold(Left.apply, Right.apply)
@pocketberserker
pocketberserker / gist:bb5059a58ddf182bf5a2
Created July 13, 2014 07:00
Scalaz勉強会 データ構造ひと巡り
@gakuzzzz
gakuzzzz / gist:8d497609012863b3ea50
Last active January 12, 2021 12:50
Scalaz勉強会 主要な型クラスの紹介
@kevinwright
kevinwright / scaladays2014.md
Last active November 16, 2024 17:40
Scaladays 2014 slides

As compiled by Kevin Wright a.k.a @thecoda

(executive producer of the movie, and I didn't even know it... clever huh?)

please, please, please - If you know of any slides/code/whatever not on here, then ping me on twitter or comment this Gist!

This gist will be updated as and when I find new information. So it's probably best not to fork it, or you'll miss the updates!

Monday June 16th

@runarorama
runarorama / gist:a8fab38e473fafa0921d
Last active April 13, 2021 22:28
Compositional application architecture with reasonably priced monads
sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]
@gakuzzzz
gakuzzzz / enum.scala
Last active April 26, 2023 12:26
Enum
trait EnumLike {
type Value
def value: Value
}
trait StringEnumLike extends EnumLike {
type Value = String
}
@tmskst
tmskst / MeasureCyclomaticComplexity.hx
Created May 25, 2014 17:30
CyclomaticComplexity の計測
package ;
import haxe.macro.Context;
import haxe.macro.Expr;
import haxe.macro.Expr.Field;
import haxe.macro.Expr.FieldType;
import haxe.macro.Expr.Function;
import haxe.macro.ExprTools;
using Lambda;
@benmmurphy
benmmurphy / TLSLoggingProvider.java
Last active April 30, 2024 12:11
SSLKEYLOGFILE for java
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.FileSystems;
import java.nio.file.StandardOpenOption;
import java.security.InvalidAlgorithmParameterException;
import java.security.Provider;
import java.security.SecureRandom;