Last active
October 3, 2022 20:56
-
-
Save shadaj/aaac98b690cfeb0cbd891bfe3ce5725d to your computer and use it in GitHub Desktop.
Scala in Colab Template.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Scala in Colab Template.ipynb", | |
"version": "0.3.2", | |
"provenance": [], | |
"collapsed_sections": [], | |
"toc_visible": true, | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"display_name": "Scala", | |
"language": "scala", | |
"name": "scala" | |
} | |
}, | |
"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>" | |
] | |
}, | |
{ | |
"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": [ | |
"## Hello World!" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "a9z0PxRg_iOp", | |
"colab_type": "code", | |
"outputId": "9c53634c-d938-440e-d22a-808c786226d7", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 34 | |
} | |
}, | |
"source": [ | |
"println(\"Hello, world!\")" | |
], | |
"execution_count": 0, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"Hello, world!\n" | |
], | |
"name": "stdout" | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment