Skip to content

Instantly share code, notes, and snippets.

@AitorATuin
AitorATuin / AsyncDirective.scala
Created June 1, 2014 13:57
Jetty Async Plans with Directives Support for Unfiltered
import unfiltered.response._
import unfiltered.request._
import unfiltered.filter._
import unfiltered.directives._
import Directive._
import scala.concurrent.Future
import scala.util.Try
import javax.servlet.http.{HttpServletResponse, HttpServletRequest}
object AsyncDirective {
@AitorATuin
AitorATuin / gist:61d9d5c024cf781cbacd
Last active August 29, 2015 14:26 — forked from runarorama/gist:a8fab38e473fafa0921d
Compositional application architecture with reasonably priced monads
sealed trait Interact[A]
case class Ask(prompt: String)
extends Interact[String]
case class Tell(msg: String)
extends Interact[Unit]
trait Monad[M[_]] {
def pure[A](a: A): M[A]
@AitorATuin
AitorATuin / Server.scala
Last active January 22, 2016 19:54 — forked from YoEight/Server.scala
Chunk encoded response using Unfiltered, Netty and Scalaz-Stream
package deiko
import java.nio.charset.Charset
import java.util.concurrent.CancellationException
import org.jboss.netty.buffer.ChannelBuffers
import org.jboss.netty.channel.{ Channel, ChannelFuture, ChannelFutureListener }
import org.jboss.netty.handler.codec.http.{ DefaultHttpChunk, HttpChunk }
import scalaz.stream.{ Process, process1, processes }
import scalaz.concurrent.Task
import Process.{ Process1, Sink }
@AitorATuin
AitorATuin / test1.lua
Created August 7, 2016 10:34
luv bug?
require('luv')

Previously, I played with a way of piping output from SBT into a file that would be truncated on each compile session: https://gist.github.com/nkpart/5923908 . After that, I used cfile to load up the errors in that file.

However, as is so often the case, it turns out most of the plumbing is already there in SBT and VIM and a great solution is trivial.

When SBT runs, it logs each tasks' output into target/streams/<task>. We can use the output stream from compile as the input to cfile, without any of that haskell scripting nonsense!

:cfile ./target/streams/compile/compile/\$global/out

The only other part you need is a nice errorformat value. This setting tells vim how to pull errors out of the parameter to cfile. The one from Derek Wyatt's vim-scala project works: