Skip to content

Instantly share code, notes, and snippets.

View tototoshi's full-sized avatar

Toshiyuki Takahashi tototoshi

View GitHub Profile
@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",
@tototoshi
tototoshi / Build.scala
Created February 15, 2013 03:19
こんな感じで watchSources に含めないファイルのパターンをどっかで設定したい
import sbt._,Keys._
import PlayProject._
object Build extends sbt.Build {
val appName = "hoge"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq (
)
@tototoshi
tototoshi / Application.scala
Last active December 12, 2015 07:48
[play_ja:504]
package controllers
import play.api._
import play.api.mvc._
object Application extends Controller {
def index = Action {
Ok(views.html.index())
}
@tototoshi
tototoshi / rownum.sql
Created December 26, 2012 01:14
Grouped LIMIT in PostgreSQL: show the first N rows for each group
-- http://stackoverflow.com/questions/1124603/grouped-limit-in-postgresql-show-the-first-n-rows-for-each-group
-- http://www.postgresql.jp/document/9.2/html/tutorial-window.html
CREATE TABLE empsalary (
depname varchar(10) not null
, empno integer not null
, salary integer not null
);
INSERT INTO empsalary (depname, empno, salary) VALUES ('develop', 11, 5200);
@tototoshi
tototoshi / withDefaultValue.scala
Created December 18, 2012 15:41
Default value of scala.collection.mutable.Map will be invalid after converted to scala.collection.immutable.Map
scala> scala.collection.mutable.Map.empty[Int, Int].withDefaultValue(0)
res0: scala.collection.mutable.Map[Int,Int] = Map()
scala> res0(1)
res1: Int = 0
scala> res0.toMap
res2: scala.collection.immutable.Map[Int,Int] = Map()
scala> res2(1)
@tototoshi
tototoshi / break_continue.scala
Created December 17, 2012 15:34
break, continue in scala
#!/bin/sh
exec scala "$0" "$@"
!#
import util.control.Breaks
val continue = new Breaks
Breaks.breakable {
scala> "a".format(_)
res0: Any* => String = <function1>
scala> "a".format(_: String)
res1: String => String = <function1>
scala> "a".format(_: String, _: String)
res2: (String, String) => String = <function2>
scala> "a".format(_: String, _: String, _: Int)
res3: (String, String, Int) => String = <function3>