Skip to content

Instantly share code, notes, and snippets.

View imeredith's full-sized avatar

Ivan Meredith imeredith

View GitHub Profile
<configuration>
<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date - [%level] - from %logger in %thread %n%message%n%xException%n</pattern>
</encoder>
</appender>
val stuff = "stuff" + someString match {
case "" => ""
case s => " " + s
}
[info] bar.json (2.0B)
[info] smart 0.2 ms
[info] jackson 1.6 ms
[info] jawn 0.6 ms
[info] bla2.json (41.9K)
[info] smart 6.4 ms
[info] jackson 13.8 ms
[info] jawn 12.8 ms
[info] bla25.json (1.8M)
[info] smart 117.2 ms
if ( cond ) {
if (cond) {
"a"
} else {
"b"
}
} else if (cond) {
"c"
} else {
if (cond) {
def forMonth(account: String, month: Timestamp) = {
val eom = add30Days(month)
for {
b <- Build if b.account === account && b.start_time > month && b.start_time < eom
} yield b
}
implicit val PromiseInstance = new Monad[Promise] {
def point[A](a: => A) = Promise.pure(a)
def bind[A, B](fa: Promise[A])(f: A => Promise[B]) = fa.flatMap(f)
}
@imeredith
imeredith / openid.scala
Created November 16, 2012 02:30
Play2 OpenId4Java
package controllers
import play.api.mvc.Action
import play.api.mvc.Controller
import play.api.mvc.AsyncResult
import views.html.index
import play.api.libs.openid.OpenID
import play.api.libs.concurrent.Redeemed
import play.api.libs.concurrent.Thrown
import play.api._
val q = (for {
b <- Build if b.account === account && b.start_time > som && b.start_time < eom
} yield b).groupBy(_.instance_size).map {
case (a, q) => (a, q.map(_.minutes).sum)
}
16:06 ~/haskell/yesog $ cabal install unix-time
Resolving dependencies...
Configuring unix-time-0.1.5...
Failed to install unix-time-0.1.5
cabal: Error: some packages failed to install:
unix-time-0.1.5 failed during the configure step. The exception was:
ExitFailure 127
searching for ghc in path.
found ghc at /usr/bin/ghc
("/usr/bin/ghc",["--numeric-version"])
/usr/bin/ghc is version 7.4.1
looking for tool "ghc-pkg" near compiler in /usr/bin
found ghc-pkg in /usr/bin/ghc-pkg
("/usr/bin/ghc-pkg",["--version"])
/usr/bin/ghc-pkg is version 7.4.1
("/usr/bin/ghc",["--supported-languages"])
("/usr/bin/ghc",["--info"])