Skip to content

Instantly share code, notes, and snippets.

View tototoshi's full-sized avatar

Toshiyuki Takahashi tototoshi

View GitHub Profile
@tototoshi
tototoshi / build.sbt
Last active January 4, 2016 03:09
ガラパゴス化するbuild.sbt
libraryDependencies ++= Seq(
jdbc,
cache,
"org.scalikejdbc" %% "scalikejdbc" % "[1.7,)", // by scalikejdbc organization (@seratch, .....)
"org.scalikejdbc" %% "scalikejdbc-interpolation" % "[1.7,)", // by scalikejdbc organization
"org.scalikejdbc" %% "scalikejdbc-play-plugin" % "[1.7,)", // by scalikejdbc organization
"com.github.tototoshi" %% "play-flyway" % "1.0.1", // by me
"com.github.mumoshu" %% "play2-memcached" % "0.3.0.2", // by @mumoshu
"com.github.nscala-time" %% "nscala-time" % "0.6.0", // by nscala-time organization (@kmizu, @xuwei_k ...)
"jp.t2v" %% "play2-auth" % "0.11.0", // by @gakuzzzz
@tototoshi
tototoshi / H2BrowserLauncher.scala
Created November 30, 2013 17:24
Open h2-browser with Skinny TaskLauncher
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
object TaskLancher extends skinny.task.TaskLauncher {
register("h2-browser", (params) => {
val f = Future {
org.h2.tools.Server.main()
}
f.onFailure { case e => e.printStackTrace() }
@tototoshi
tototoshi / anata_to_java.alpaca
Created November 30, 2013 14:36
あなたとJAVA
#!/usr/bin/env alpaca
visit("http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html")
click("input[type=radio]")
click(partialLink("macosx-x64.dmg"))
@tototoshi
tototoshi / slick_change.scala
Created September 12, 2013 05:58
The difference of Slick's API between 1.x and 2.0.0-M2
/* 1.0.0 */
import scala.slick.driver.PostgresDriver.simple._
case class Task(id: Int, name: String)
object Task extends Table[Task]("task") {
def id = column[Int]("id")
def name = column[String]("name")
def * = id ~ name <> (Task.apply _, Task.unapply _)
}
@tototoshi
tototoshi / Build.scala
Last active December 22, 2015 12:39
Retrieve request token asynchronously
import sbt._
import sbt.Keys._
object ScalaoauthasyncBuild extends Build {
lazy val scalaoauthasync = Project(
id = "scala-oauth-async",
base = file("."),
settings = Project.defaultSettings ++ Seq(
name := "scala-oauth-async",
val m1 = Map(1 -> 2, 2 -> 5, 3 -> 1)
val m2 = Map(2 -> 4, 3 -> 3, 4 -> 3)
def toMultiMap[A, B](m1: Map[A, B], m2: Map[A, B]): Map[A, Set[B]] =
(m1.toSeq ++ m2.toSeq).groupBy(_._1).mapValues(_.map(_._2).toSet)
/*
scala> toMultiMap(m1, m2).mapValues(_.max)
res0: scala.collection.immutable.Map[Int,Int] = Map(2 -> 5, 4 -> 3, 1 -> 2, 3 -> 3)
*/
@tototoshi
tototoshi / a.scala
Created April 2, 2013 14:10
specs2 contain only
"foo" in {
List(2, 4, 3, 5) must contain(2, 4, 3).only
}
@tototoshi
tototoshi / a.scala
Created March 31, 2013 07:27
play.api.Configuration. Is it a bug?
FakeApplication(
additionalConfiguration = Map(
"foo" -> List("bar", "baz").asJava
)
)
@tototoshi
tototoshi / a.sh
Created March 29, 2013 02:36
canything べんりです
ssh $(cat ~/.ssh/config | grep ^Host | perl -pe 's/Host\s+//' | canything)
@tototoshi
tototoshi / build.sbt
Created March 10, 2013 03:29
Modularizing Language Features sucks.
scalacOptions <<= scalaVersion.map { sv =>
if (sv.startsWith("2.10")) {
Seq(
"-deprecation",
"-language:dynamics",
"-language:postfixOps",
"-language:reflectiveCalls",
"-language:implicitConversions",
"-language:higherKinds",
"-language:existentials",