Skip to content

Instantly share code, notes, and snippets.

@shadaj
Last active October 3, 2022 20:56

Revisions

  1. shadaj revised this gist Aug 20, 2019. No changes.
  2. shadaj revised this gist Aug 20, 2019. 1 changed file with 70 additions and 3 deletions.
    73 changes: 70 additions & 3 deletions scala-in-colab-template.ipynb
    Original file line number Diff line number Diff line change
    @@ -28,17 +28,85 @@
    ]
    },
    {
    "cell_type": "markdown",
    "metadata": {
    "id": "up2G8zDbhsEN",
    "colab_type": "text"
    },
    "source": [
    "# Scala in Colab"
    ]
    },
    {
    "cell_type": "markdown",
    "metadata": {
    "id": "sL1Vq6r6J6dA",
    "colab_type": "text"
    },
    "source": [
    "## Install the Scala Kernel\n",
    "If you get a \"scala\" kernel not recognized warning when loading up the notebook for the first time, start by running the two cells below. Once you are done **reload the page** to load the notebook in the installed Scala kernel."
    ]
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "RoCcdvTCAqeR",
    "colab_type": "code",
    "colab": {}
    },
    "source": [
    "%%shell\n",
    "SCALA_VERSION=2.12.8 ALMOND_VERSION=0.3.0+16-548dc10f-SNAPSHOT\n",
    "curl -Lo coursier https://git.io/coursier-cli\n",
    "chmod +x coursier\n",
    "./coursier bootstrap \\\n",
    " -r jitpack -r sonatype:snapshots \\\n",
    " -i user -I user:sh.almond:scala-kernel-api_$SCALA_VERSION:$ALMOND_VERSION \\\n",
    " sh.almond:scala-kernel_$SCALA_VERSION:$ALMOND_VERSION \\\n",
    " --sources --default=true \\\n",
    " -o almond-snapshot --embed-files=false\n",
    "rm coursier\n",
    "./almond-snapshot --install --global --force\n",
    "rm almond-snapshot"
    ],
    "execution_count": 0,
    "outputs": []
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "BZchIo9sArF4",
    "colab_type": "code",
    "colab": {}
    },
    "source": [
    "%%shell\n",
    "echo \"{\n",
    " \\\"language\\\" : \\\"scala\\\",\n",
    " \\\"display_name\\\" : \\\"Scala\\\",\n",
    " \\\"argv\\\" : [\n",
    " \\\"bash\\\",\n",
    " \\\"-c\\\",\n",
    " \\\"env LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libpython3.6m.so:\\$LD_PRELOAD java -jar /usr/local/share/jupyter/kernels/scala/launcher.jar --connection-file {connection_file}\\\"\n",
    " ]\n",
    "}\" > /usr/local/share/jupyter/kernels/scala/kernel.json"
    ],
    "execution_count": 0,
    "outputs": []
    },
    {
    "cell_type": "markdown",
    "metadata": {
    "id": "kQe78pN0OSuq",
    "colab_type": "text"
    },
    "source": [
    "# Scala in Colab\n",
    "## BEFORE YOU BEGIN: [install Scala support](https://colab.research.google.com/gist/shadaj/323ad2393b46c1b71df435728a052c24/install-scala-in-colab.ipynb) into your Collab environment"
    "## Hello World!"
    ]
    },
    {
    "cell_type": "code",
    "metadata": {
    "id": "a9z0PxRg_iOp",
    "colab_type": "code",
    @@ -48,7 +116,6 @@
    "height": 34
    }
    },
    "cell_type": "code",
    "source": [
    "println(\"Hello, world!\")"
    ],
  3. shadaj revised this gist Mar 12, 2019. No changes.
  4. shadaj revised this gist Mar 12, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion scala-in-colab-template.ipynb
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@
    },
    "cell_type": "markdown",
    "source": [
    "# Scala in Colab Template\n",
    "# Scala in Colab\n",
    "## BEFORE YOU BEGIN: [install Scala support](https://colab.research.google.com/gist/shadaj/323ad2393b46c1b71df435728a052c24/install-scala-in-colab.ipynb) into your Collab environment"
    ]
    },
  5. shadaj revised this gist Mar 12, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion scala-in-colab-template.ipynb
    Original file line number Diff line number Diff line change
    @@ -34,7 +34,7 @@
    },
    "cell_type": "markdown",
    "source": [
    "# Scala in Colab\n",
    "# Scala in Colab Template\n",
    "## BEFORE YOU BEGIN: [install Scala support](https://colab.research.google.com/gist/shadaj/323ad2393b46c1b71df435728a052c24/install-scala-in-colab.ipynb) into your Collab environment"
    ]
    },
  6. shadaj revised this gist Mar 12, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions scala-in-colab-template.ipynb
    Original file line number Diff line number Diff line change
    @@ -35,7 +35,7 @@
    "cell_type": "markdown",
    "source": [
    "# Scala in Colab\n",
    "## BEFORE YOU BEGIN: [install Scala support](https://colab.research.google.com/drive/1pOgj3335awIdZh4qWbYCelYw_VJoBTt6) into your Collab environment"
    "## BEFORE YOU BEGIN: [install Scala support](https://colab.research.google.com/gist/shadaj/323ad2393b46c1b71df435728a052c24/install-scala-in-colab.ipynb) into your Collab environment"
    ]
    },
    {
    @@ -52,7 +52,7 @@
    "source": [
    "println(\"Hello, world!\")"
    ],
    "execution_count": 1,
    "execution_count": 0,
    "outputs": [
    {
    "output_type": "stream",
  7. shadaj revised this gist Mar 11, 2019. 1 changed file with 12 additions and 1 deletion.
    13 changes: 12 additions & 1 deletion scala-in-colab-template.ipynb
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,8 @@
    "version": "0.3.2",
    "provenance": [],
    "collapsed_sections": [],
    "toc_visible": true
    "toc_visible": true,
    "include_colab_link": true
    },
    "kernelspec": {
    "display_name": "Scala",
    @@ -16,6 +17,16 @@
    }
    },
    "cells": [
    {
    "cell_type": "markdown",
    "metadata": {
    "id": "view-in-github",
    "colab_type": "text"
    },
    "source": [
    "<a href=\"https://colab.research.google.com/gist/shadaj/aaac98b690cfeb0cbd891bfe3ce5725d/scala-in-colab-template.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
    ]
    },
    {
    "metadata": {
    "id": "up2G8zDbhsEN",
  8. shadaj created this gist Mar 11, 2019.
    56 changes: 56 additions & 0 deletions scala-in-colab-template.ipynb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@
    {
    "nbformat": 4,
    "nbformat_minor": 0,
    "metadata": {
    "colab": {
    "name": "Scala in Colab Template.ipynb",
    "version": "0.3.2",
    "provenance": [],
    "collapsed_sections": [],
    "toc_visible": true
    },
    "kernelspec": {
    "display_name": "Scala",
    "language": "scala",
    "name": "scala"
    }
    },
    "cells": [
    {
    "metadata": {
    "id": "up2G8zDbhsEN",
    "colab_type": "text"
    },
    "cell_type": "markdown",
    "source": [
    "# Scala in Colab\n",
    "## BEFORE YOU BEGIN: [install Scala support](https://colab.research.google.com/drive/1pOgj3335awIdZh4qWbYCelYw_VJoBTt6) into your Collab environment"
    ]
    },
    {
    "metadata": {
    "id": "a9z0PxRg_iOp",
    "colab_type": "code",
    "outputId": "9c53634c-d938-440e-d22a-808c786226d7",
    "colab": {
    "base_uri": "https://localhost:8080/",
    "height": 34
    }
    },
    "cell_type": "code",
    "source": [
    "println(\"Hello, world!\")"
    ],
    "execution_count": 1,
    "outputs": [
    {
    "output_type": "stream",
    "text": [
    "Hello, world!\n"
    ],
    "name": "stdout"
    }
    ]
    }
    ]
    }