Skip to content

Instantly share code, notes, and snippets.

Chris Lewis chrislewis

Block or report user

Report or block chrislewis

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View meetup_message_oauth_example.php
* This is a simple example of using PHP's OAuth extension to send a message
* to another member. It assumes you have already recieved the necessary
* authorization from the user and stored the token for reuse.
* See for an
* example of how to fetch a valid token for a given member, with her
* authorization, using your consumer key and secret.
View MapIsFold.scala
CanBuildFrom is easily abused such that the ubiquitous higher order function
map can be repurposed as fold. This is not good; this example demonstrates
a design flaw, not a strength.
import scala.language.postfixOps
import scala.collection.generic
chrislewis / Foo.scala
Last active Aug 29, 2015
Not so sealed
View Foo.scala
sealed trait Foo
case class Bar(x: Int) extends Foo
case class Baz(name: String) extends Foo
object Foo {
def show(f: Foo) =
f match {
case Bar(x) => x.toString // Quux, a subtype of Bar in a different file, will be matched as a Bar
case Baz(name) => name
chrislewis /
Created Mar 13, 2014
Testing parameter limits of java 8 lambdas. 255 turns out to be the limit for both the number of type parameters and arguments in lambda expressions.
class Lambda255 {
chrislewis / gist:4409778
Created Dec 29, 2012
A Reader Either monad transformer for java.util.Properties with Scalaz7
View gist:4409778
* This is a rendition of Scalaz7 provides the
* Reader and we take it a step further by constructing and using a Reader Either
* monad transformer with pure error handling, instead of the original impure Reader
* monad that would throw exceptions on parse errors.
import scalaz._
import Scalaz._
import java.util.Properties
chrislewis /
Created Oct 12, 2012
Andrew's market-making bot in perl
use JSON;
use IO::Socket;
my $pid=$$;
my $user = "marketmaker";
my $pass = "liquidity";
my $host = "";
my $port = "10000";
chrislewis / gist:3416494
Created Aug 21, 2012
reader monad for java.util.Properties example
View gist:3416494
/* Start by creating a reader for some fake yet conceivable type for executing SQL queries. */
val dbReader: Reader[Properties, JdbcExecutor] =
for {
driver <- read[String]("db.driver")
uri <- read[String]("db.uri")
user <- read[String]("db.username")
password <- read[String]("db.password")
name <- read[String]("")
minCons <- read[Int]("db.pool.minConnections")
View gist:2919454
package com.example.foobie
import unfiltered.jetty.Http
import unfiltered.response._
import unfiltered.request._
trait Resolver[A] {
type B
chrislewis / comprehensible.scala
Created Mar 11, 2012
general type and implicit conversion to add support for using a general Bind instance in a for comprehension
View comprehensible.scala
trait Bind[M[_]] {
def fmap[A, B](ma: M[A], f: A => B): M[B]
def bind[A, B](ma: M[A], f: A => M[B]): M[B]
trait Monad[M[_]] extends Bind[M]{
def unit[A](a: => A): M[A]
chrislewis / interpreter.scala
Created Mar 10, 2012
quick interpreter for nescala
View interpreter.scala
package necsala.embedded
import{Global, Settings}
import{AbstractFile, VirtualDirectory}
import java.util.jar.JarFile
You can’t perform that action at this time.