Skip to content

Instantly share code, notes, and snippets.

View LeifWarner's full-sized avatar

Leif Warner LeifWarner

  • Janrain
  • Portland, Oregon
View GitHub Profile
@LeifWarner
LeifWarner / JavaSig.hs
Created April 8, 2013 04:18
Read Java method signatures from haskell
{-# LANGUAGE OverloadedStrings, FlexibleContexts #-}
import Control.Monad.Exception
import qualified Data.ByteString.Lazy as B
import Data.ByteString.Lazy.Char8 (pack)
import System.Environment (getArgs)
import JVM.ClassFile
import JVM.Assembler
import JVM.Builder
// defined on List[A], theoretically
def filterM[M](p: A=>M[A]): M[A] = for {
flg <- p(this.head)
ys <- this.tail.filterM(p)
} yield if (flg) this.head :: ys else ys
@LeifWarner
LeifWarner / concurrently.hs
Created July 6, 2013 17:55
Run two IO actions concurrently. Seems to run the second one first, for me.
{-# OPTIONS_GHC -F -pgmF she #-}
import Control.Applicative
import Control.Concurrent.Async
action = (| Concurrently getLine ++ Concurrently getLine |)
main = putStrLn =<< runConcurrently action
package com.example
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.webapp.WebAppContext
import org.scalatra.servlet.MultipartConfig
object Main {
def main(args: Array[String]) {
val port = 8080
val server = new Server(port)
object Foo {
val jedis = new Jedis("localhost")
val t1 = jedis.multi
t1.hgetAll("bp2local:backplane_server_config")
val t2 = jedis.multi
t2.get("v2_last_id")
t2.exec
}