Skip to content

Instantly share code, notes, and snippets.

Takuya Fujimura tlync

Block or report user

Report or block tlync

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pre-push
#!/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 Aug 29, 2015
2014/10/16 社内LT - 人を恨むな仕組みを恨め
View gist:852be00dcab8a4a5d237

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


人を恨むな仕組みを恨め


@tlync
tlync / pre-push
Created Oct 16, 2014
pre-push kuso edition
View pre-push
#!/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
View applicatino-logger.xml
<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 Feb 8, 2018
Scala Advent Calendar 2013 12/11 の記事で利用した Transparent IO Context パターンのコード
View transparent-context.scala
// Transparent IO Context pattern using implicit parameter
// ---
// domain
// ---
// base (サンプルなのでほぼただの Marker Trait)
trait Entity
// 永続化に利用するセッションを保持するただのコンテナ
View ddd-dip.scala
// 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 Dec 28, 2015
ドメイン層を特有のトランザクション管理の概念から独立させる為の Transparent context pattern (適当)
View gist:7576585
// 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 Dec 28, 2015
Isolate domain models from transaction management. version 2
View gist:7560473
// dummy session classes for sample codes
final class AnormSession {
def anormMethod = {
println("anorm")
}
def start = {}
def commit = {}
}
@tlync
tlync / nyankoro.scala
Created Nov 20, 2013
Isolate domain models from transaction management
View nyankoro.scala
// dummy session classes for sample codes
final class AnormSession {
def anormMethod = {
println("anorm")
}
def start = {}
def commit = {}
}
@tlync
tlync / gist:6841791
Created Oct 5, 2013
Single field json serialization using Play's JSON
View gist:6841791
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))
You can’t perform that action at this time.