Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
commits=`git log @{u}..`
if [ -z "$commits" ]; then
exit 0
fi
COLOR_MAIN="\x1B[01;91m"
COLOR_SUB="\x1B[01;90m"
COLOR_PASS="\x1B[32m"
@tlync
tlync / gist:852be00dcab8a4a5d237
Last active August 29, 2015 14:07
2014/10/16 社内LT - 人を恨むな仕組みを恨め

%title: %author: Takuya Fujimura (@tlync) %date: 2014-10-16


人を恨むな仕組みを恨め


@tlync
tlync / pre-push
Created October 16, 2014 08:38
pre-push kuso edition
#!/bin/sh
CMD="sbt test" # Command that runs your tests
# Check if we actually have commits to push
#commits=`git log @{u}..`
#if [ -z "$commits" ]; then
# exit 0
#fi
echo
read -p "…もちろん、ちゃんとテストしたよな?" -n 0 -r < /dev/tty
<configuration>
<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />
<!-- console -->
<appender name="STDOUT1" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%coloredLevel %gray%date{HH:mm:ss.SSS} [%gray(%thread)] - %replace(%replace(%message){'\n','\\n'}){'\t',' '}, %replace(%replace(%xException{5}){'\n','\\n'}){'\t',' '}%n%nopex</pattern>
</encoder>
</appender>
@tlync
tlync / transparent-context.scala
Last active February 8, 2018 06:36
Scala Advent Calendar 2013 12/11 の記事で利用した Transparent IO Context パターンのコード
// Transparent IO Context pattern using implicit parameter
// ---
// domain
// ---
// base (サンプルなのでほぼただの Marker Trait)
trait Entity
// 永続化に利用するセッションを保持するただのコンテナ
// base (サンプルなのでただの marker trait)
trait Entity
trait Repository
// domain layer
case class User(id: Int, name: String) extends Entity
trait Users extends Repository {
def find(id: Int): Option[User]
}
@tlync
tlync / gist:7576585
Last active December 28, 2015 23:09
ドメイン層を特有のトランザクション管理の概念から独立させる為の Transparent context pattern (適当)
// domain layer
trait Entity
trait Repo
case class Context[T](session: T)
trait TransparentContext[T] {
implicit def c2s(implicit ctx: Context[T]) = ctx.session
implicit def s2c(implicit session: T) = Context(session)
}
@tlync
tlync / gist:7560473
Last active December 28, 2015 20:49
Isolate domain models from transaction management. version 2
// dummy session classes for sample codes
final class AnormSession {
def anormMethod = {
println("anorm")
}
def start = {}
def commit = {}
}
@tlync
tlync / nyankoro.scala
Created November 20, 2013 05:32
Isolate domain models from transaction management
// dummy session classes for sample codes
final class AnormSession {
def anormMethod = {
println("anorm")
}
def start = {}
def commit = {}
}
@tlync
tlync / gist:6841791
Created October 5, 2013 14:45
Single field json serialization using Play's JSON
import play.api.libs.json._
import play.api.libs.functional.syntax._
object Main {
implicit val jsonFormat =
(__ \ "v").write[String].contramap((fb: FizzBuzz) => fb.v)
def main(args: Array[String]) {
print(Json.toJson(FizzBuzz.Fizz))
print(Json.toJson(FizzBuzz.Buzz))