This file contains hidden or 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
val dict = Map( | |
"AAA" -> "BBB", | |
"BBB" -> "CCC", | |
"CCC" -> "DDD" | |
) | |
// Optionで返す場合 | |
for { | |
bbb <- dict.get("AAA") | |
ccc <- dict.get(bbb) | |
ddd <- dict.get(ccc) |
This file contains hidden or 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
% schema2rst -c schema2rst.yml -o schema.rst | |
Traceback (most recent call last): | |
File "~/.python/2.7.5/site-packages//schema2rst", line 8, in <module> | |
load_entry_point('schema2rst==0.9.0', 'console_scripts', 'schema2rst')() | |
File "~/src/Sphinx/schema2rst-0.9.0-py2.7.egg/schema2rst/commands/rst.py", line 51, in main | |
engine.dispose() | |
NameError: global name 'engine' is not defined |
This file contains hidden or 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.Function2; | |
import scala.Predef.; | |
import scala.Serializable; | |
import scala.runtime.AbstractFunction2; | |
import scala.runtime.BoxesRunTime; | |
public final class Main$ | |
{ | |
public static final MODULE$; |
This file contains hidden or 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
kkismd 6月 30 11:08 | |
フォーマットの決まったXMLをパースしてcase classに格納したいとき、 | |
標準のscala.xmlだけで下記のようにやってみてるのですが、 | |
https://gist.github.com/kkismd/87e073fadfa63423308a | |
このへんを省力化してくれるライブラリはありますか? | |
JSON -> case classはいろいろ見つかるんですがXMLは探しかたが悪いのか見つかりませんでした。 | |
mather 6月 30 12:08 | |
scalaxbでしょうか。 |
This file contains hidden or 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 play.api.libs.functional.Applicative | |
type ESTR[A] = Either[String,A] | |
implicit def applicativeEither: Applicative[ESTR] = new Applicative[ESTR] { | |
override def apply[A, B](mf: ESTR[A => B], ma: ESTR[A]): ESTR[B] = mf.right.flatMap(f => ma.right.map(f)) | |
override def pure[A](a: A): ESTR[A] = Right(a) |
This file contains hidden or 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 Example { | |
import scala.xml._ | |
import scala.util.control.Exception._ | |
def str(node: Node, key: String): Option[String] = (node \\ key).headOption.map(_.text) | |
def int(node: Node, key: String): Option[Int] = allCatch opt { str(node, key).map(_.toInt).get } | |
case class Person(name: String, age: Int) |
This file contains hidden or 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 models | |
import scalikejdbc._ | |
import skinny.orm.{SkinnyCRUDMapper, SkinnyRecord} | |
case class Example( id: Long, name: Option[String] = None ) extends SkinnyRecord[Example] { | |
def skinnyCRUDMapper = Example | |
} | |
object Example extends SkinnyCRUDMapper[Example] { |
This file contains hidden or 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
#! /bin/env ruby | |
class Option | |
end | |
class Some < Option | |
include Enumerable | |
def initialize(a) | |
@a = a |
This file contains hidden or 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
kkismd 31 minutes前 | |
コードを直しながらsbt shellの中でtestを繰り返し実行していると、そのうち | |
java.lang.OutOfMemoryError: PermGen space | |
が出て落ちることが多いのですが、これはクラスローダーまわりになにかリークが起こってるんでしょうか? | |
xuwei-k 30 minutes前 | |
はい | |
(もしメモリの設定を変えてなかったら)設定を増やしましょう | |
あとは、コンパイルじゃなくtestのほうが原因なら、testは必ずforkして実行するとか |
This file contains hidden or 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 mystate | |
import scalaz._ | |
import Scalaz._ | |
case class RandGen(seed: Long) { | |
def nextInt: (RandGen, Int) = { | |
val newSeed = (seed * 0x5DEECE66DL + 0xBL) & 0xFFFFFFFFFFFFL | |
val nextGen = RandGen(newSeed) | |
val n = (newSeed >>> 16).toInt |