Skip to content

Instantly share code, notes, and snippets.

View LeifWarner's full-sized avatar

Leif Warner LeifWarner

  • Janrain
  • Portland, Oregon
View GitHub Profile
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
}
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)
@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
// 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 / 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
class Hello { throw new Exception("broke") }
@LeifWarner
LeifWarner / gist:5042799
Created February 26, 2013 22:15
Bundler on 1.6.7 requires jruby-openssl gem, these days?
Successfully installed bundler-1.3.0
1 gem installed
JRuby limited openssl loaded. http://jruby.org/openssl
gem install jruby-openssl for full support.
The source :rubygems is deprecated because HTTP requests are insecure.
Please change your source to 'https://rubygems.org' if possible, or 'http://rubygems.org' if not.
Unfortunately, a fatal error has occurred. Please see the Bundler
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
LoadError: OpenSSL::SSL requires the jruby-openssl gem
(root) at /scratch/jenkins/workspace/engage-master/engage/jruby-1.6.7/lib/ruby/site_ruby/shared/jruby/openssl/autoloads/ssl.rb:8
@LeifWarner
LeifWarner / NPE.scala
Created December 28, 2012 01:42
NPE in compiler
Caused by: java.lang.NullPointerException: null
at scala.tools.nsc.Global.globalError(Global.scala:145)
at scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:122)
at scala.tools.nsc.symtab.SymbolLoaders$SymbolLoader.complete(SymbolLoaders.scala:85)
at scala.tools.nsc.symtab.Symbols$Symbol.info(Symbols.scala:730)
at scala.tools.nsc.symtab.Definitions$definitions$.init(Definitions.scala:810)
at scala.tools.nsc.Global$Run.<init>(Global.scala:697)
at scala.tools.nsc.interactive.Global$TyperRun.<init>(Global.scala:1036)
at scala.tools.nsc.interactive.Global.newTyperRun(Global.scala:1059)
at scala.tools.nsc.interactive.Global.<init>(Global.scala:191)
@LeifWarner
LeifWarner / gist:4158545
Created November 28, 2012 01:49
idris.PKGBUILD
# Maintainer: Leif Warner <abimelech@gmail.com>
pkgname=idris
pkgver=0.9.5.1
pkgrel=1
pkgdesc="Functional Programming Language with Dependent Types"
url="http://hackage.haskell.org/package/${_hkgname}"
license=('custom:BSD3')
arch=('i686' 'x86_64')
makedepends=('ghc' 'haskell-cabal' 'haskell-binary' 'haskell-bytestring' 'haskell-containers' 'haskell-directory' 'haskell-filepath' 'haskell-haskeline' 'haskell-mtl' 'haskell-parsec' 'haskell-pretty' 'haskell-process' 'haskell-transformers')
depends=('gmp')
@LeifWarner
LeifWarner / build.sbt
Created November 5, 2012 22:38
Getting started w/ akka
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies += "com.typesafe.akka" % "akka-actor" % "2.0.3"