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
scala> @annotation.implicitNotFound("oh no! could not find Foo with ${A} ${B}") trait Foo[A,B] | |
defined trait Foo | |
scala> implicitly[Foo[String, Int]] | |
<console>:12: error: oh no! could not find Foo with String Int | |
implicitly[Foo[String, 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
import bytecask.Bytecask | |
import org.slf4j.{LoggerFactory, Logger} | |
import akka.dispatch.Future | |
import annotation.tailrec | |
import org.slf4j.helpers.{NOPLoggerFactory, SubstituteLoggerFactory} | |
private def tellLoggerToStfu() { | |
@tailrec def impl(i: Int, wait: Long) { | |
Thread.sleep(wait - 1) | |
LoggerFactory.getILoggerFactory() match { |
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 runner = AttributeKey[Runner]("runner") | |
val start = TaskKey[Unit]("start", "start web runner") | |
val stop = TaskKey[Unit]("stop", "stop web runner") | |
trait Startable { | |
def start() | |
def stop() | |
} | |
class Runner { |
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 net.liftweb.json._ | |
val json = """ | |
{"a": "Value"} | |
""" | |
case class ExtractTo(a: String, b: Option[Boolean]) | |
implicit val formats = DefaultFormats | |
println(parse(json).extract[ExtractTo]) | |
} |
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 com.twitter.finagle.builder.ServerBuilder | |
import com.twitter.finagle.http.Http | |
import com.twitter.finagle.{ClientConnection, Service} | |
import com.twitter.util.{Promise, Future} | |
import java.io.{ByteArrayOutputStream, BufferedReader, InputStreamReader} | |
import java.net.{URLDecoder, InetSocketAddress} | |
import java.nio.charset.{Charset => JNIOCharset} | |
import org.jboss.netty.buffer.{ChannelBuffers, ChannelBufferInputStream} | |
import org.jboss.netty.handler.codec.http.{HttpResponseStatus, DefaultHttpResponse, HttpVersion, CookieDecoder, HttpHeaders, HttpResponse => NHttpResponse, HttpRequest => NHttpRequest} | |
import unfiltered.Cookie |
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 annotation.tailrec | |
object SplitList { | |
def split[A](all: List[A], f: (A, A) => Boolean): List[List[A]] = { | |
@tailrec def _split(list: List[A], acc: List[List[A]], current: List[A]): List[List[A]] = list match { | |
case Nil => current match { | |
case Nil => Nil | |
case _ => acc ::: current :: Nil | |
} |
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
require 'java' | |
module Java::scala::collection::Seq | |
def each(&block) | |
foreach &block | |
end | |
include Enumerable | |
end |
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
2010-12-23 15:11:50.204:INFO::Logging to STDERR via org.mortbay.log.StdErrLog | |
2010-12-23 15:11:50.297:INFO::jetty-6.1.26 | |
-> builtin/core_ext/symbol | |
<- builtin/core_ext/symbol - 449ms | |
-> enumerator | |
<- enumerator - 39ms | |
-> java | |
-> java | |
<- java - 0ms | |
-> builtin/javasupport/java |
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
Around do |scenario, block| | |
RSpec::Mocks.setup(self) | |
RSpec::Mocks.teardown | |
block.call | |
RSpec::Mocks.verify | |
end |
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
ruby-1.9.2-p0 > t = Time.now | |
=> 2010-10-27 17:41:00 -0700 | |
ruby-1.9.2-p0 > t.utc? | |
=> false | |
ruby-1.9.2-p0 > t2 = t.utc | |
=> 2010-10-28 00:41:00 UTC | |
ruby-1.9.2-p0 > t | |
=> 2010-10-28 00:41:00 UTC | |
ruby-1.9.2-p0 > t.object_id | |
=> 2154182900 |