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.example | |
import org.slf4j.LoggerFactory | |
trait BaseLogger { | |
private val classNameLogger = LoggerFactory.getLogger(classOf[BaseLogger]) | |
private val thisLogger = LoggerFactory.getLogger(this.getClass) |
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 sbt._ | |
import Keys._ | |
/** | |
* テストをいい感じに分割して実行します。 | |
* 分割にはテストクラス名のCRC32チェックサムを使っています。 | |
* 例えば3分割したい時は | |
* | |
* > sbt 'splitTest 3 1' | |
* > sbt 'splitTest 3 2' |
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.example | |
import shapeless._ | |
import shapeless.labelled.FieldType | |
trait Show[A] { | |
def show(a: A): String | |
} | |
object Show { |
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
scala> import scala.collection.immutable.SortedSet | |
import scala.collection.immutable.SortedSet | |
scala> case class Hoge(i: Int) | |
defined class Hoge | |
scala> SortedSet(1, 2, 3, 4, 5) | |
res0: scala.collection.immutable.SortedSet[Int] = TreeSet(1, 2, 3, 4, 5) | |
scala> SortedSet(1, 2, 3, 4, 5).map(Hoge.apply) |
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.example | |
import java.time.LocalDateTime | |
@ToString | |
case class UserName( | |
firs: String, | |
last: String | |
) |
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 | |
dir=${1:?directory is not specified} | |
subproject=$2 | |
cd $dir | |
tmpfile=$(mktemp "project/$$.sbt") | |
clean() { | |
rm -f $tmpfile |
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 models | |
import javax.inject.{Inject, Provider, Singleton} | |
import play.api.inject.{ApplicationLifecycle, Binding, Module} | |
import play.api.{Configuration, Environment, Logger} | |
import scalikejdbc.config.TypesafeConfigReader | |
import scalikejdbc.{Commons2ConnectionPoolFactory, ConnectionPool} | |
import scala.concurrent.{ExecutionContext, Future} |
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.concurrent.Future | |
// def successful[T](result: T): Future[T] を使った場合 | |
// result を評価する時点でブロックされるので | |
// a b c の順に表示される | |
println("a") | |
val f1 = Future.successful { Thread.sleep(1000); println("b") } | |
println("c") | |
// def apply[T](body: ⇒ T)(implicit execctx: ExecutionContext): Future[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
case class User(id: Int, name: String) | |
object Test { | |
import scalacache._ | |
import memoization._ | |
import redis._ | |
implicit val scalaCache = ScalaCache(RedisCache("localhost", 6379)) |
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
example=# CREATE TABLE tstest (ts1 timestamp, ts2 timestamp with time zone); | |
CREATE TABLE | |
example=# \d tstest; | |
Table "public.tstest" | |
Column | Type | Modifiers | |
--------+-----------------------------+----------- | |
ts1 | timestamp without time zone | | |
ts2 | timestamp with time zone | | |
example=# INSERT INTO tstest VALUES (current_timestamp, current_timestamp); |
NewerOlder