Skip to content

Instantly share code, notes, and snippets.

View seratch's full-sized avatar

Kazuhiro Sera seratch

View GitHub Profile
@seratch
seratch / prettyprint.scala
Created October 22, 2012 10:39
XML PrettyPrinter in Scala
import scala.xml._
val xml: Elem = XML.load("./input.xml")
val formatted: String = new PrettyPrinter(80, 2).format(xml)
@seratch
seratch / ideas.md
Created October 18, 2012 12:27
Ideas for developer contest
  • Play の WebSocket で何か
  • Akka を使った何か
  • ディスク IO に関した何か
  • Play scaffold sbt plugin
  • DSL をつくる?
  • giter8 で何か
  • Play の javascriptRouter
  • クローラシステム
  • Node.js のサンプルを移植
  • AWS と連携
@seratch
seratch / developer-contest-ja.md
Created October 18, 2012 10:41
Developer Contest: Japanese Translation

NOTE: The following is a Japanese translation for the guidelines of Typesafe Developer Contest.

http://typesafe.com/resources/developer-contest

Typesafe 社は、Scala、Akka または Play(もしくはそのすべて!)を使ったプログラミングのデモンストレーションとなる、素晴らしいアプリケーションを求めています。

このようなアプリケーションの例として提供できる、誇れるプログラムがありますか?もしあれば、あなたのエントリを心よりお待ちしております。

Martin Odersky が JAX Java Ambassador Award で獲得した賞金をこのコンテストに寄付しました。

@seratch
seratch / config.yml
Created October 11, 2012 10:19
CDPStudyGroup S3 example
access_key_id: xxx
secret_access_key: yyy
@seratch
seratch / SQLRunner.scala
Created October 3, 2012 15:28
sbt dbconsole?
case class SQLRunner(sql: String) {
def run(): Seq[Map[Symbol, Any]] = {
try {
SQL(sql).map(_.toSymbolMap()).list.apply()
} catch { case e: java.sql.SQLException =>
val result = SQL(sql).execute.apply()
Seq(Map('RESULT -> result))
}
}
}
@seratch
seratch / Tx.scala
Created September 29, 2012 00:36
Play20 Transactional Action sample
trait Tx { self: Controller =>
def localTx[A](action: Action[A]) = LocalTxActionDecorator[A](action)
}
case class LocalTxActionDecorator[A](action: Action[A]) extends Action[A] {
def parser: BodyParser[A] = action.parser
override def apply() = DB localTx { implicit s => action.apply() }
@seratch
seratch / build.sbt
Created September 27, 2012 05:35
My first JGit sample in Scala
// http://www.eclipse.org/jgit/download/
resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
libraryDependencies += "org.eclipse.jgit" % "org.eclipse.jgit" % "[2.1,)"
@seratch
seratch / config.ru
Created September 11, 2012 05:18
Redirect Rack app
def redirect(arg)
new_host = 'new.example.com'
uri = arg["REQUEST_URI"]
[
302,
{'content-type' => 'text/plain', 'location' => "http://#{new_host}#{uri}"},
"http://#{new_host}#{uri}".chars
]
end
run method(:redirect)
@seratch
seratch / build.sbt
Created September 11, 2012 02:58
ScalikeJDBC Left Join Query Example
libraryDependencies ++= Seq(
"com.github.seratch" %% "scalikejdbc" % "[1.3,)",
"org.slf4j" % "slf4j-simple" % "1.6.4",
"org.hsqldb" % "hsqldb" % "[2,)"
)
@seratch
seratch / scala.pl
Created August 31, 2012 03:49
scala.pl
#!/usr/bin/env perl
use strict;
use warnings;
package Seq;
sub apply {
my ($class, @seq) = @_;
bless { seq => \@seq }, $class;