Skip to content

Instantly share code, notes, and snippets.

View kolemannix's full-sized avatar

Koleman Nix kolemannix

  • patterndata.ai
  • Richmond, VA
View GitHub Profile
@kolemannix
kolemannix / CoordinateGen.scala
Last active March 9, 2017 18:43
ScalaCheck Polymorphic Generators for Latitude and Longitude
import org.scalacheck.Gen._
def latitudeGen[T](implicit num: Numeric[T], c: Choose[T]): Gen[T] = {
import num._
val min = fromInt(-90)
val max = fromInt(90)
Gen.sized(n => c.choose(min, max))
}
def longitudeGen[T](implicit num: Numeric[T], c: Choose[T]): Gen[T] = {
@kolemannix
kolemannix / TaggedPlayJsonExample.scala
Last active November 15, 2016 13:58
Dynamically sanitizing Strings (XSS concerns) based on type tags
import scalaz.{ @@, Tag }
import org.apache.commons.lang.StringEscapeUtils
import org.joda.time.DateTime
import play.api.libs.json._
trait DomRenderable
def RenderableString(s: String): String @@ DomRenderable = Tag[String, DomRenderable](s)