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
--- play-2.1.0.orig/play-2.1.0/framework/src/play/src/main/scala/play/api/mvc/ContentTypes.scala 2013-02-05 09:51:23.000000000 +0900 | |
+++ play-2.1.0/framework/src/play/src/main/scala/play/api/mvc/ContentTypes.scala 2013-08-31 12:58:01.000000000 +0900 | |
@@ -277,7 +277,7 @@ | |
*/ | |
def tolerantText(maxLength: Int): BodyParser[String] = BodyParser("text, maxLength=" + maxLength) { request => | |
Traversable.takeUpTo[Array[Byte]](maxLength) | |
- .transform(Iteratee.consume[Array[Byte]]().map(c => new String(c, request.charset.getOrElse("utf-8")))) | |
+ .transform(Iteratee.consume[Array[Byte]]().map(c => new String(c, request.charset.getOrElse("Shift_JIS/*utf-8*/")))) | |
.flatMap(Iteratee.eofOrElse(Results.EntityTooLarge)) | |
} |
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
diff -ru play-2.2.1 2/framework/project/plugins.sbt play-2.2.1/framework/project/plugins.sbt | |
--- play-2.2.1 2/framework/project/plugins.sbt 2013-10-30 16:44:48.000000000 +0900 | |
+++ play-2.2.1/framework/project/plugins.sbt 2013-11-08 02:13:56.000000000 +0900 | |
@@ -6,6 +6,8 @@ | |
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.0") | |
+addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.1.0") | |
+ | |
libraryDependencies <+= sbtVersion { sv => |
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 check = { | |
val cond1 = (_: String) => if (1==2) Left("cond1") else Right("not matched") | |
val cond2 = (_: String) => if (2==2) Left("cond2") else Right("not matched") | |
val cond3 = (_: String) => if (3==2) Left("cond3") else Right("not matched") | |
val condList = List(cond1, cond2, cond3) | |
condList.reduce(_.flatMap) | |
} |
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 StreamT extends StreamTInstances { | |
// 略 | |
def unfoldM[M[_],A,B](start: B)(f: B => M[Option[(A,B)]])(implicit M: Functor[M]): StreamT[M,A] = | |
StreamT[M,A](M.map(f(start)) { | |
case Some((a, b)) => Yield(a, unfoldM(b)(f)) | |
case None => Done | |
}) |
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
val failable: Int => Option[Int] = { | |
(n: Int) => | |
n match { | |
case n if 0 until 100 contains n => Some(n + 1) | |
case otherwise => None | |
} | |
} |
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 scalaz.std.stream._ | |
import scalaz.syntax.id._ | |
unfold(0)(failable(_).map(_.squared)).force // => Stream(1, 2, 3, 4, 5, ..., 99, 100) | |
unfold(0)(failable(_).map(n => (s"n=${n}", n))).force // => Stream("n=1", "n=2", ... "n=100") |
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
#include <stdio.h> | |
/* 定数定義 */ | |
#define CHAR_ZERO 0x30 | |
#define CHAR_ONE 0x31 | |
#define CHAR_NINE 0x39 | |
#define CHAR_NULL 0x00 | |
/* cが0から9までのcharのとき真 */ | |
int isZeroToNine(char c) { |
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
pointer = default | |
! shift_r -> @ | |
clear Shift | |
add Shift = Shift_L | |
!remove Shift = Shift_R | |
keycode 62 = at |
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 controllers | |
import play.api._ | |
import play.api.mvc._ | |
import play.api.data._ | |
object Application extends Controller { | |
def hoge = Action(parse.tolerantText) { request ⇒ // 生の文字列で受け取る。 | |
// 修正したリクエストでimplicit宣言する。 | |
// あたかも最初からパースされたフォームデータが渡されたような状態にする。 |
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 momijikawa.exercisezmq | |
import scala.concurrent.ExecutionContext | |
object Main extends App { | |
import akka.actor._ | |
import akka.zeromq._ | |
import akka.util.ByteString | |
import concurrent.duration._ | |
import collection.immutable.Seq |
OlderNewer