Skip to content

Instantly share code, notes, and snippets.


Malcolm Greaves malcolmgreaves

View GitHub Profile
View scalaConcurrentPatterns.scala
import scala.concurrent._
import scala.concurrent.duration._
import scala.util.Random
import java.util.{Timer, TimerTask}
object Util {
sealed trait BaseResponse
case class Response1(res: Int) extends BaseResponse
case class Response2(res: String) extends BaseResponse
View gist:d07099a8fe378311fd79
import scala.collection.mutable
* Bounded priority queue trait that is intended to be mixed into instances of
* scala.collection.mutable.PriorityQueue. By default PriorityQueue instances in
* Scala are unbounded. This trait modifies the original PriorityQueue's
* enqueue methods such that we only retain the top K elements.
* The top K elements are defined by an implicit Ordering[A].
* @author Ryan LeCompte (
View MapReduceTypeClasses.scala
package mapreduce
* This is an attempt to find a minimal set of type classes that describe the map-reduce programming model
* (the underlying model of Google map/reduce, Hadoop, Spark and others)
* The idea is to have:
* 1) lawful types that fully constrain correctness
* 2) a minimal set of laws (i.e. we can't remove any laws,
* 3) able to fully express existing map/reduce in terms of these types
import kafka.admin.CreateTopicCommand;
import kafka.producer.KeyedMessage;
import kafka.producer.Producer;
import kafka.producer.ProducerConfig;
import kafka.server.KafkaConfig;
import kafka.server.KafkaServer;
import kafka.utils.*;
import kafka.utils.TestUtils;
import kafka.utils.TestZKUtils;
import kafka.zk.EmbeddedZookeeper;
View FreeMacros.scala
import scala.language.experimental.macros
import scala.reflect.macros.whitebox
class FreeMacros(val c: whitebox.Context) {
import c.universe._
def smartName(name: String): String = (
name.toList match {
case h :: t => h.toLower :: t
case Nil => Nil
malcolmgreaves / gist:c5edd777aa25b8aee7f6
Last active Aug 29, 2015 — forked from agibsonccc/gist:241034a329bd1e12fa70
Scala API for ND4J, high-performance, n-dimensional matrix library for the JVM
View gist:c5edd777aa25b8aee7f6
package org.deeplearning4j.learn
import java.util.Arrays
import org.nd4j.api.linalg.DSL._
import org.nd4j.linalg.api.ndarray.INDArray
import org.nd4j.linalg.factory.Nd4j
import org.nd4j.linalg.indexing.{NDArrayIndex, BooleanIndexing}
import org.nd4j.linalg.indexing.conditions.Conditions
import org.nd4j.linalg.indexing.functions.Value
View ammonite-shapeless
> runMain ammonite.repl.Repl
[info] Running ammonite.repl.Repl
Loading Ammonite Repl...
@ load.ivy("com.chuusai" %% "shapeless" % "2.1.0")
@ import shapeless._
import shapeless._
@ 1 :: "lol" :: List(1, 2, 3) :: HNil
"""A stripped-down MLP example, using Theano.
Based on the tutorial here:
This example trims away some complexities, and makes it easier to see how Theano works.
Design changes:
* Model compiled in a distinct function, so that symbolic variables are not in run-time scope.
* No classes. Network shown by chained function calls.
malcolmgreaves / Tree.scala
Last active Aug 26, 2015 — forked from dholbrook/Tree.scala
Scala binary tree
View Tree.scala
* D Holbrook
* Code Club: PO1
* (*) Define a binary tree data structure and related fundamental operations.
* Use whichever language features are the best fit (this will depend on the language you have selected). The following operations should be supported:
* Constructors
malcolmgreaves / Client example
Created Oct 6, 2015 — forked from rklaehn/Client example
akka http file server
View Client example
package akkahttptest
import akka.http.Http
import{Sink, Source}
import akka.http.model._
object TestClient extends App {