Skip to content

Instantly share code, notes, and snippets.

View edgarchan's full-sized avatar

Edgar Chan edgarchan

View GitHub Profile
@edgarchan
edgarchan / implicit conversion
Created July 25, 2013 03:36
manual import of implicit conversion
class PostgreSQLTest extends TestVerticle with VertxScalaHelpers {
import org.vertx.scala.core._
import org.vertx.scala.core.eventbus.EventBus._
...
}
@edgarchan
edgarchan / gist:5905937
Last active December 19, 2015 05:39
trait delegator
trait Delegator[T]{
protected def internal:T
}
trait ReadStream[T <: JReadStream[T]] extends ExceptionSupport[T] { self: Delegator[T] =>
trait WriteStream[T <: JWriteStream[T]] extends ExceptionSupport[T] { self: Delegator[T] =>
class AsyncFile(protected val internal: JAsyncFile) extends Delegator[JAsyncFile] with ReadStream[JAsyncFile] with WriteStream[JAsyncFile]
@edgarchan
edgarchan / gist:5898296
Created July 1, 2013 04:10
Message type class
object MTypes {
import org.vertx.scala.core.FunctionConverters._
trait MessageLike[T]{
def reply(payload: T, handler: Message[T] => Unit)(implicit jmessage:JMessage[T]):Unit
}
object MessageLike{
@edgarchan
edgarchan / gist:5897738
Last active December 19, 2015 04:29
after scalariform
@Test
def pumpFileTest() {
val fs = vertx.newFileSystem
val from = fileDir + "/foo.tmp"
val to = fileDir + "/bar.tmp"
val content = TestUtils.generateRandomBuffer(10000)
fs.writeFile(from, content, () => {
fs.open(from, ares1 => {
assertEquals(true, Option(ares1.cause).isEmpty)