Scala Environment

Showcase

case class Hello(i: Int, s0: String)
defined class Hello
Hello(3, "Hello Scala!")
res1: Hello = Hello(3, "Hello Scala!")

Graphics

Plotly

import $ivy.`org.plotly-scala::plotly-almond:0.7.0`
import plotly._, plotly.element._, plotly.layout._, plotly.Almond._

val trace1 = Scatter(
  Seq(1, 2, 3, 4),
  Seq(10, 15, 13, 17)
)

val trace2 = Scatter(
  Seq(1, 2, 3, 4),
  Seq(16, 5, 11, 9)
)

val data = Seq(trace1, trace2)

plot(data)

Vegas

import $ivy.`org.vegas-viz::vegas:0.3.11`

import vegas._
import vegas.data.External._

Vegas("A simple bar chart with embedded data.").
  withData(Seq(
    Map("a" -> "A", "b" -> 28), Map("a" -> "B", "b" -> 55), 
    Map("a" -> "C", "b" -> 43), Map("a" -> "D", "b" -> 91), 
    Map("a" -> "E", "b" -> 81), Map("a" -> "F", "b" -> 53),
    Map("a" -> "G", "b" -> 19), Map("a" -> "H", "b" -> 87), 
    Map("a" -> "I", "b" -> 52)
  )).
  encodeX("a", Ordinal).
  encodeY("b", Quantitative).
  mark(Bar).
  show

Setup

Java & Scala

apt-get -qq update
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends \
  openjdk-8-jdk-headless
java -version
mkdir -p /tmp/scalas
cd /tmp/scalas
for scala in $SCALA_VERSION $SCALA_EX_VERSIONS; do
  FILENAME="scala-${scala}.tgz"
  FILEURL="https://downloads.lightbend.com/scala/${scala}/$FILENAME"

  wget --progress=dot:mega $FILEURL
done

tar -cf /results/scalas.tar scala-*.tgz
rm -r /tmp/scalas
scalas.tar
mkdir -p /opt/scalas
cd /opt/scalas
tar -xf 
scalas.tar
for scala in scala-*.tgz; do tar -zxf $scala done ln -sf scala-${SCALA_VERSION} default rm scala-*.tgz
ls -l /opt/scalas

Install Coursier.

curl -Lo /opt/scalas/default/bin/coursier https://git.io/coursier-cli
chmod +x /opt/scalas/default/bin/coursier
mkdir -p /opt/scalas/coursier
scala -version

Almond

Install Jupyter.

pip install --upgrade jupyter jupyter_client

Install the Almond Jupyter kernel for all Scala versions.

cd /tmp
almond_inst () {
  coursier bootstrap -r jitpack -i user -o almond \
    -I user:sh.almond:scala-kernel-api_$1:$2 \
    sh.almond:scala-kernel_$1:$2
  ./almond --install --id $3 --display-name "Scala $1"
  rm almond
}
almond_inst 2.13.0  0.7.0 scala213
almond_inst 2.12.8  0.7.0 scala212
almond_inst 2.11.12 0.6.0 scala211

Check.

du -hsx /
jupyter kernelspec list