Skip to content

Instantly share code, notes, and snippets.

View kmizu's full-sized avatar

Kota Mizushima kmizu

View GitHub Profile
import language.experimental.macros
import language.implicitConversions
import scala.reflect.macros.Context
import scala.reflect.runtime.universe.Tree
class ReflectiveClosure[A, B](val tree: Tree, fn: Function1[A, B]) extends Function1[A, B] {
def apply(x: A) = fn(x)
}
object ReflectiveClosure {
@kmizu
kmizu / Auth.scala
Created January 8, 2013 06:00 — forked from teamon/Auth.scala
package controllers
import lib._
import play.api.mvc._
import play.api.libs.json._
object Auth extends Controller {
val GITHUB = new OAuth2[GithubUser](OAuth2Settings(
@kmizu
kmizu / .sbt
Created January 5, 2013 17:29 — forked from gseitz/.sbt
## Note: the system property `sbt.global.base` was introduced in 0.10.1
## sbt-0.10.0 still uses the default global directory in ~/.sbt
gseitz@QBallz ~/.sbt % find . -name '*target*' -prune -o -print
.
./0.10.1
./0.10.1/plugins
./0.10.1/plugins/build.sbt
./0.10.1/plugins/project
@kmizu
kmizu / play_2_assets_pipeline.scala
Created December 7, 2012 05:55 — forked from eboto/play_2_assets_pipeline.scala
Play 2 Assets pipeline
package assetproviders {
import play.api.mvc.Action
import play.api.mvc.Controller
import play.api.mvc.AnyContent
import play.api.mvc.Call
/**
* This simple interface is meant to mimic the existing interface in Play 2.0
* for the Assets controller it provides. By implementing this it is possible
* to mix and combine various AssetProviders to create a custom Asset controller
@kmizu
kmizu / 1.scala
Created October 16, 2012 13:10 — forked from tototoshi/1.scala
(implicit conversions + method values) cause strange problem
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.
7.0_03).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import scala.collection.immutable.StringLike
import scala.collection.immutable.StringLike
scala> "a".format(_)
res0: Any* => String = <function1>
@kmizu
kmizu / README.md
Created September 8, 2012 02:55 — forked from xuwei-k/README.md
Scala language page pdf all download script

Scala公式ページの論文一覧のページのhtmlをパースして、自動でpdfのファイルっぽいものを全部ダウンロードするだけのものです

@kmizu
kmizu / hexToStr.scala
Created April 14, 2012 07:54 — forked from rirakkumya/hexToStr.scala
16進文字列をAscii文字列に変換 (再帰を使わないバージョン)
def hexToStr(s:String):String = {
s.grouped(2).map{xx => Integer.parseInt(xx, 16).toChar}.mkString("")
}
val target = 'a' to 'z' mkString
val hexTarget = target map {"%02x" format _.toInt} mkString
assert(target == hexToStr(hexTarget))
@kmizu
kmizu / gist:1876800
Last active December 22, 2019 00:05 — forked from gakuzzzz/gist:1865400
Scala環境構築

Scala 開発環境構築手順

前提条件

  • JDKがinstall済みであること
  • java コマンドに環境変数Pathが通っていること
@kmizu
kmizu / gist:1876796
Created February 21, 2012 14:32 — forked from gakuzzzz/gist:1865400
Scala環境構築

Scala 開発環境構築手順

前提条件

  • JDKがinstall済みであること
  • java コマンドに環境変数Pathが通っていること
@kmizu
kmizu / Eith.scala
Created December 14, 2011 13:20 — forked from makotan/gist:1476310
Either[L,Either[L,R]]のように多段になる場合にRだけを取得する (改変版)
def eith[R](arg: Either[Throwable, R] ) : R = {
/* Right(o:Either[Throwable, R]) パターンは
* erasureのせいで警告が出る点に注意 */
arg match {
case Left(e) => throw e
case Right(o:Either[Throwable, R]) => eith(o)
case Right(o:R) => o
}
}
println(eith(Right(1)))