Skip to content

Instantly share code, notes, and snippets.

View joost-de-vries's full-sized avatar

Joost de Vries joost-de-vries

View GitHub Profile
@joost-de-vries
joost-de-vries / pretty-print.scala
Last active March 7, 2017 22:07 — forked from carymrobbins/pretty-print.scala
Pretty print Scala case classes and other data structures.
/**
* Pretty prints a Scala value similar to its source represention.
* Particularly useful for case classes.
* @param a - The value to pretty print.
* @param indentSize - Number of spaces for each indent.
* @param maxElementWidth - Largest element size before wrapping.
* @param depth - Initial depth to pretty print indents.
* @return
*/
object PrettyPrint {
@joost-de-vries
joost-de-vries / scalap.sbt
Last active August 29, 2015 14:15 — forked from xuwei-k/scalap.sbt
run scalap for your project from sbt
scalaVersion := "2.11.4"
libraryDependencies += "org.scala-lang" % "scalap" % scalaVersion.value
InputKey[Unit]("scalap") := {
import complete.DefaultParsers._
val classes = spaceDelimited("<class names>").parsed
val pathSeparator = java.lang.System.getProperty("path.separator")
val classpath = "-classpath" :: (fullClasspath in Compile).value.map(_.data).mkString(pathSeparator) :: Nil
val args = "-verbose" :: classpath ::: classes.toList
@joost-de-vries
joost-de-vries / foldfun.sc
Last active August 29, 2015 14:02 — forked from headinthebox/gist:37c76829253388fd88e3
Erik Meijers foldleft implementation using foldright rewritten in Scala
object foldfun {
def foldr[A, B](f: A => B => B)(b: B)(s: Seq[A]): B = s match {
case Nil => b
case a :: as =>
f(a)(foldr(f)(b)(as))
} //> foldr: [A, B](f: A => (B => B))(b: B)(s: Seq[A])B
foldr { a: String => b: Int => a.toInt * b.toInt }(7)(Seq("1", "2", "3"))
//> res0: Int = 42
#!/bin/bash
#
# =========================================================================
# Copyright 2014 Rado Buransky, Dominion Marine Media
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0