Skip to content

Instantly share code, notes, and snippets.

View LeifWarner's full-sized avatar

Leif Warner LeifWarner

  • Janrain
  • Portland, Oregon
View GitHub Profile
@andyscott
andyscott / gist:6361691
Last active December 21, 2015 20:29
sequencing List[Future[A \/ B]]
type FutureEither[A, B] = EitherT[Future, A, B]
implicit class SequenceOverFutureEither[F[_], A, B](v: F[FutureEither[A, B]])(implicit F0: Traverse[F]) {
def sequenceR() = v.sequence[({ type λ[R] = FutureEither[A, R] })#λ, B]
}
@alivesay
alivesay / gist:6034533
Created July 19, 2013 01:59
minimal python to extract json value from stdin
import json
import sys
if __name__ == "__main__":
data = json.loads(sys.stdin.read())
print data[sys.argv[1]]
@runarorama
runarorama / Scalaz Google Code page
Created April 22, 2013 16:31
Scalaz Google Code page
<b>The source for Scalaz is now hosted on !GitHub - http://github.com/scalaz/scalaz</b>
Scalaz is a library written in the [http://scala-lang.org/ Scala Programming Language]. The intention of Scalaz is to include general functions that are not currently available in the core Scala API. The scalaz-core module depends only on [http://www.scala-lang.org/docu/files/api/index.html the core Scala API] and the core Java 2 Standard Edition API. Scalaz is released under a BSD open source licence making it compatible with the licence of the Scala project.
[http://code.google.com/p/scalaz/wiki/Scalaz6 Scalaz 6.0.4] was released in January 2012, targeting Scala 2.8.1, 2.9.0.1, 2.9.1 and 2.10.0-M1. [http://scala-tools.org/repo-releases/org/scalaz/scalaz-full_2.9.1/6.0.4/scalaz-full_2.9.1-6.0.4.jar Full download for 2.9.1]
[Scalaz7 Scalaz 7] is currently being developed. This is a rewrite to address the challenges posed by type class inheritance. The first release of this series is expected in April 2012.
== Community
@aloiscochard
aloiscochard / qsbt.sh
Last active March 5, 2018 21:34
QuickSBT - Launch SBT with support for generating /tmp/sbt.quickfix file for Vim
#!/usr/bin/env bash
############
# QuickSBT #
############
# Launch SBT with support for generating /tmp/sbt.quickfix file for Vim
# http://github.com/aloiscochard / https://gist.github.com/4698501
# Error format for SBT, and shortcut to open SBT quickfix file :
object PdxleifMonoid {
trait Monoid[A] {
def op(a1: A, a2: A): A
def id: A
}
def XorMonoid[A]: Monoid[Option[A]] =
new Monoid[Option[A]] {
def op(a1: Option[A], a2: Option[A]) =
(a1, a2) match {
#!/usr/bin/env ruby
#
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156)
#
# ## Advisory
#
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion
#
# ## Caveats
#
sealed trait KeyValueStore[+A] {
def map[B](f: A => B): KeyValueStore[B] =
this match {
case Put(k, v, q) => Put(k, v, f compose q)
case Get(k, q) => Get(k, f compose q)
case Del(k, q) => Del(k, f compose q)
}
}
case class Put[A](k: String, v: String, q: Option[String] => A) extends KeyValueStore[A]
case class Get[A](k: String, q: Option[String] => A) extends KeyValueStore[A]
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)
}
@stonegao
stonegao / HttpServer.scala
Created June 14, 2012 02:53 — forked from soheilhy/HttpServer.scala
Routing based on HTTP method in Finagle
import com.twitter.finagle.http.path._
import com.twitter.finagle.http.service.RoutingService
import com.twitter.finagle.http.{Request, Response, RichHttp, Http}
import com.twitter.finagle.{Service, SimpleFilter}
import org.jboss.netty.handler.codec.http._
import org.jboss.netty.handler.codec.http.HttpResponseStatus._
import org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1
import org.jboss.netty.buffer.ChannelBuffers.copiedBuffer
import org.jboss.netty.util.CharsetUtil.UTF_8
import com.twitter.util.Future
@gseitz
gseitz / gist:2306504
Created April 4, 2012 23:20
polyparse.scala
scala> val pair = for {
| _ <- token(char('{'))
| id <- token(ident)
| _ <- token(char(':'))
| v <- integer
| _ <- token(char('}'))
| } yield id -> v
obj: scalaz.parse.huttonmeijer.Parser[(List[Char], Int)] = scalaz.parse.huttonmeijer.Parser$$anon$2@234e7730
scala> pair("{ foo : 17 }".toList)