- Web系
- Scalatra Sinatraのようなフレームワーク https://github.com/scalatra/scalatra
- Scalate テンプレートエンジン。言語を選べる http://scalate.fusesource.org/
- Play! framework 2.0 プロダクト自体がScalaで実装されている。 http://www.playframework.org/2.0
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 mapreduce | |
import akka.actor.Actor | |
import akka.actor.ActorRef | |
import scala.collection.mutable.ListBuffer | |
import scala.concurrent.ops._ | |
import scala.io.Source | |
import scala.annotation.tailrec | |
import scala.io.Codec | |
import scala.xml.XML |
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
object Loan { | |
def using[A <: { def close() }, B](resource: A)(func: A => B): Either[Exception, B] = | |
try { | |
Right(func(resource)) | |
} catch { | |
case e: Exception => Left(e) | |
} finally { | |
if (resource != null) resource.close() | |
} |
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
object Loan { | |
def using[A <: { def close() }, B](resource: A)(func: A => B): B = | |
try { | |
func(resource) | |
} finally { | |
if (resource != null) resource.close() | |
} | |
} |
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
jp.sf.amateras.scala.sbt_0.0.3.201112241216.jar | |
でプロジェクトを新規作成して、Update Dependency を実行したらNullPointerExceptionが発生した。 | |
libraryDependencies ++= Seq( | |
"junit" % "junit" % "4.8.1" % "test" | |
) | |
などと追記してもDependencyが追加されていない模様。 |
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
def connect = { | |
log("connect") { // connect start | |
// ... 何かの処理 ... | |
log("login") { // connect : login start | |
// ... 何かの処理 ... | |
} // connect : login end | |
// ... 何かの処理 ... | |
} // connect end | |
} |
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 EntityNotFoundException(message: Option[String] = None, cause: Option[Throwable] = None) | |
extends Exception(message.orNull, cause.orNull) |
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 base | |
import scalaz._ | |
import Scalaz._ | |
/** | |
* エンティティを表すトレイト。 | |
* | |
* @author j5ik2o | |
*/ |
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
// サブタスクの作業時間を計算する | |
def subTasksTimeSpent(target) { | |
long result = 0 | |
subTasks = target.getSubTaskObjects() | |
for(subTask in subTasks){ | |
result += (subTask.getTimeSpent() == null ? 0 : subTask.getTimeSpent().floatValue()) | |
} | |
return result | |
} | |
// 初期見積もりが登録されている場合 |
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.util.DynamicVariable | |
import scala.collection.immutable | |
import grizzled.slf4j.Logging | |
trait LoggingEx extends Logging { | |
private val msgs = new DynamicVariable[Seq[String]](immutable.Queue.empty) | |
private def withScope[T](msg: String, logger: (=> Any, => Throwable) => Unit, f: => T): T = { | |
val newMsgs = msgs.value :+ msg |