Skip to content

Instantly share code, notes, and snippets.

View jdegoes's full-sized avatar

John A. De Goes jdegoes

View GitHub Profile
object Util {
def BenchmarkCycles = 100000000
def time[Z](label: String)(f: => Z): Z = {
val startTime = System.currentTimeMillis
val result = f
val endTime = System.currentTimeMillis
object Util {
def BenchmarkCycles = 100000000
def time[Z](label: String)(f: => Z): Z = {
val startTime = System.currentTimeMillis
val result = f
val endTime = System.currentTimeMillis
@jdegoes
jdegoes / Scala.tmLanguage
Created May 10, 2011 22:48
Scala syntax file for Sublime Text 2.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>fileTypes</key>
<array>
<string>scala</string>
</array>
<key>foldingStartMarker</key>
<string>/\*\*|\{\s*$</string>
// Does NOT work
aToB >>> bToC
// Does NOT work
aToB.`>>>`(bToC)(ActorMCategory[M](monad))
// WORKS
mab[({type λ[α, β]=ActorM[M, α, β]})#λ, A, B](aToB) >>> bToC
// WORKS
@jdegoes
jdegoes / gist:1197019
Created September 6, 2011 08:56
Scalaz & Scale Type System Puzzle
// Does NOT work
aToB >>> bToC
// Does NOT work
aToB.`>>>`(bToC)(ActorMCategory[M](monad))
// WORKS
mab[({type λ[α, β]=ActorM[M, α, β]})#λ, A, B](aToB) >>> bToC
// WORKS
@jdegoes
jdegoes / BindSemigroup.scala
Created December 18, 2011 19:02
BindSemigroup
implicit def BindSemigroup[M[_], A](implicit bind: Bind[M]): Semigroup[M[A]] = new Semigroup[M[A]] {
def append(v1: M[A], v2: => M[A]): M[A] = bind.bind(v1)((a: A) => v2)
}
@jdegoes
jdegoes / DT.js
Created May 25, 2012 16:29
JavaScript code samples
// [output, nextDT]
DT = function(f) {
this.f = f;
}
DT.prototype.send =
function(input) {
return this.f(input);
}
DT.prototype.sendMany =
function(inputs) {
@jdegoes
jdegoes / DataScienceInScala.scala
Created February 8, 2013 15:11
Example code for the Creating a Data Science Platform in Scala talk.
object BenchmarkCommon {
import scala.util.Random
val DatasetSize = 10000
val Iterations = 10000
val ArrayPoolSize = 1000
val ArrayPool = {
def randomArray(): Array[Int] = {
val array = new Array[Int](DatasetSize)
@jdegoes
jdegoes / iso8601.g4
Created June 24, 2013 20:40
ISO8601 ANTLR4
dateFullyear : Digit{4};
dateMonth : Digit{2};
dateMday : Digit{2};
timeHour : Digit{2};
timeMinute : Digit{2};
timeSecond: Digit{2};
timeSecfrac : '.' Digit{1,};
timeNumOffset : ('+' | '-') timeHour ':' timeMinute;
timeOffset: 'Z' | timeNumOffset;
partialTime : timeHour ':' timeMinute ':' timeSecond timeSecfrac?;
@jdegoes
jdegoes / ejson.g4
Last active December 18, 2015 22:18
ANTLR4 EJSON Grammar
ejsonValue
: (ejsonLiteral
| ejsonUnorderedMap
| ejsonOrderedMap
| ejsonSet
| ejsonArray
| ejsonNumber
| ejsonString) ejsonMetadata?;
ejsonMetadata : '@' ejsonValue;