Skip to content

Instantly share code, notes, and snippets.

@dmohl
Last active February 15, 2021 20:40
Show Gist options
  • Save dmohl/b416672f958a558dbd3a0920bd818d57 to your computer and use it in GitHub Desktop.
Save dmohl/b416672f958a558dbd3a0920bd818d57 to your computer and use it in GitHub Desktop.
fsharp_colab_example.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "fsharp_colab_example.ipynb",
"provenance": [],
"include_colab_link": true
},
"kernelspec": {
"name": ".net-fsharp",
"display_name": "F#"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/dmohl/b416672f958a558dbd3a0920bd818d57/fsharp_colab_example.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "Bnn92d7x1_TE",
"outputId": "fc2bcaa4-7516-4ddb-bc69-d553f3f35e35",
"colab": {
"base_uri": "https://localhost:8080/"
}
},
"source": [
"%%shell\r\n",
"\r\n",
"wget -q https://packages.microsoft.com/config/ubuntu/16.04/packages-microsoft-prod.deb\r\n",
"dpkg -i packages-microsoft-prod.deb\r\n",
"\r\n",
"apt-get update\r\n",
"apt-get install dotnet-sdk-3.1\r\n",
"\r\n",
"dotnet tool install -g --add-source \"https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json\" Microsoft.dotnet-interactive --version 1.0.155302\r\n",
"\r\n",
"export PATH=$PATH:$HOME/.dotnet/tools\r\n",
"dotnet interactive jupyter install\r\n",
"\r\n",
"echo \"{\r\n",
" \\\"argv\\\": [\r\n",
" \\\"$HOME/.dotnet/tools/dotnet-interactive\\\",\r\n",
" \\\"jupyter\\\",\r\n",
" \\\"--default-kernel\\\",\r\n",
" \\\"fsharp\\\",\r\n",
" \\\"--http-port-range\\\",\r\n",
" \\\"1000-3000\\\",\r\n",
" \\\"{connection_file}\\\"\r\n",
" ],\r\n",
" \\\"display_name\\\": \\\".NET (F#)\\\",\r\n",
" \\\"language\\\": \\\"F#\\\",\r\n",
" \\\"metadata\\\": {\r\n",
" \\\"vscode\\\": {\r\n",
" \\\"extension_id\\\": \\\"ms-dotnettools.dotnet-interactive-vscode\\\",\r\n",
" \\\"kernel_id\\\": \\\"dotnet-interactive\\\"\r\n",
" }\r\n",
" }\r\n",
"}\" > /root/.local/share/jupyter/kernels/.net-fsharp/kernel.json"
],
"execution_count": 1,
"outputs": [
{
"output_type": "stream",
"text": [
"Selecting previously unselected package packages-microsoft-prod.\n",
"(Reading database ... 146442 files and directories currently installed.)\n",
"Preparing to unpack packages-microsoft-prod.deb ...\n",
"Unpacking packages-microsoft-prod (1.0-2) ...\n",
"Setting up packages-microsoft-prod (1.0-2) ...\n",
"Get:1 https://packages.microsoft.com/ubuntu/16.04/prod xenial InRelease [4,002 B]\n",
"Get:2 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ InRelease [3,626 B]\n",
"Get:3 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 Packages [201 kB]\n",
"Hit:4 http://archive.ubuntu.com/ubuntu bionic InRelease\n",
"Get:5 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic InRelease [15.9 kB]\n",
"Get:6 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages [44.8 kB]\n",
"Get:7 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]\n",
"Ign:8 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 InRelease\n",
"Get:9 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]\n",
"Ign:10 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 InRelease\n",
"Get:11 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 Release [697 B]\n",
"Hit:12 https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 Release\n",
"Get:13 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 Release.gpg [836 B]\n",
"Hit:15 http://ppa.launchpad.net/cran/libgit2/ubuntu bionic InRelease\n",
"Get:16 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]\n",
"Hit:17 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu bionic InRelease\n",
"Get:18 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [1,387 kB]\n",
"Ign:19 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 Packages\n",
"Get:19 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64 Packages [552 kB]\n",
"Get:20 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic/main Sources [1,729 kB]\n",
"Get:21 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [2,157 kB]\n",
"Get:22 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [1,921 kB]\n",
"Get:23 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [2,352 kB]\n",
"Get:24 http://ppa.launchpad.net/c2d4u.team/c2d4u4.0+/ubuntu bionic/main amd64 Packages [885 kB]\n",
"Fetched 11.5 MB in 6s (1,937 kB/s)\n",
"Reading package lists... Done\n",
"Reading package lists... Done\n",
"Building dependency tree \n",
"Reading state information... Done\n",
"The following additional packages will be installed:\n",
" aspnetcore-runtime-5.0 aspnetcore-targeting-pack-5.0 dotnet-apphost-pack-5.0\n",
" dotnet-host dotnet-hostfxr-5.0 dotnet-runtime-5.0 dotnet-runtime-deps-5.0\n",
" dotnet-targeting-pack-5.0 netstandard-targeting-pack-2.1\n",
"The following NEW packages will be installed:\n",
" aspnetcore-runtime-5.0 aspnetcore-targeting-pack-5.0 dotnet-apphost-pack-5.0\n",
" dotnet-host dotnet-hostfxr-5.0 dotnet-runtime-5.0 dotnet-runtime-deps-5.0\n",
" dotnet-sdk-5.0 dotnet-targeting-pack-5.0 netstandard-targeting-pack-2.1\n",
"0 upgraded, 10 newly installed, 0 to remove and 24 not upgraded.\n",
"Need to get 91.9 MB of archives.\n",
"After this operation, 382 MB of additional disk space will be used.\n",
"Get:1 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-runtime-deps-5.0 amd64 5.0.2-1 [2,642 B]\n",
"Get:2 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-host amd64 5.0.2-1 [53.0 kB]\n",
"Get:3 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-hostfxr-5.0 amd64 5.0.2-1 [141 kB]\n",
"Get:4 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-runtime-5.0 amd64 5.0.2-1 [22.1 MB]\n",
"Get:5 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 aspnetcore-runtime-5.0 amd64 5.0.2-1 [6,087 kB]\n",
"Get:6 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-targeting-pack-5.0 amd64 5.0.0-1 [2,086 kB]\n",
"Get:7 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 aspnetcore-targeting-pack-5.0 amd64 5.0.0-1 [1,316 kB]\n",
"Get:8 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-apphost-pack-5.0 amd64 5.0.2-1 [3,398 kB]\n",
"Get:9 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 netstandard-targeting-pack-2.1 amd64 2.1.0-1 [1,476 kB]\n",
"Get:10 https://packages.microsoft.com/ubuntu/16.04/prod xenial/main amd64 dotnet-sdk-5.0 amd64 5.0.102-1 [55.2 MB]\n",
"Fetched 91.9 MB in 2s (50.8 MB/s)\n",
"Selecting previously unselected package dotnet-runtime-deps-5.0.\n",
"(Reading database ... 146447 files and directories currently installed.)\n",
"Preparing to unpack .../0-dotnet-runtime-deps-5.0_5.0.2-1_amd64.deb ...\n",
"Unpacking dotnet-runtime-deps-5.0 (5.0.2-1) ...\n",
"Selecting previously unselected package dotnet-host.\n",
"Preparing to unpack .../1-dotnet-host_5.0.2-1_amd64.deb ...\n",
"Unpacking dotnet-host (5.0.2-1) ...\n",
"Selecting previously unselected package dotnet-hostfxr-5.0.\n",
"Preparing to unpack .../2-dotnet-hostfxr-5.0_5.0.2-1_amd64.deb ...\n",
"Unpacking dotnet-hostfxr-5.0 (5.0.2-1) ...\n",
"Selecting previously unselected package dotnet-runtime-5.0.\n",
"Preparing to unpack .../3-dotnet-runtime-5.0_5.0.2-1_amd64.deb ...\n",
"Unpacking dotnet-runtime-5.0 (5.0.2-1) ...\n",
"Selecting previously unselected package aspnetcore-runtime-5.0.\n",
"Preparing to unpack .../4-aspnetcore-runtime-5.0_5.0.2-1_amd64.deb ...\n",
"Unpacking aspnetcore-runtime-5.0 (5.0.2-1) ...\n",
"Selecting previously unselected package dotnet-targeting-pack-5.0.\n",
"Preparing to unpack .../5-dotnet-targeting-pack-5.0_5.0.0-1_amd64.deb ...\n",
"Unpacking dotnet-targeting-pack-5.0 (5.0.0-1) ...\n",
"Selecting previously unselected package aspnetcore-targeting-pack-5.0.\n",
"Preparing to unpack .../6-aspnetcore-targeting-pack-5.0_5.0.0-1_amd64.deb ...\n",
"Unpacking aspnetcore-targeting-pack-5.0 (5.0.0-1) ...\n",
"Selecting previously unselected package dotnet-apphost-pack-5.0.\n",
"Preparing to unpack .../7-dotnet-apphost-pack-5.0_5.0.2-1_amd64.deb ...\n",
"Unpacking dotnet-apphost-pack-5.0 (5.0.2-1) ...\n",
"Selecting previously unselected package netstandard-targeting-pack-2.1.\n",
"Preparing to unpack .../8-netstandard-targeting-pack-2.1_2.1.0-1_amd64.deb ...\n",
"Unpacking netstandard-targeting-pack-2.1 (2.1.0-1) ...\n",
"Selecting previously unselected package dotnet-sdk-5.0.\n",
"Preparing to unpack .../9-dotnet-sdk-5.0_5.0.102-1_amd64.deb ...\n",
"Unpacking dotnet-sdk-5.0 (5.0.102-1) ...\n",
"Setting up dotnet-host (5.0.2-1) ...\n",
"Setting up netstandard-targeting-pack-2.1 (2.1.0-1) ...\n",
"Setting up dotnet-runtime-deps-5.0 (5.0.2-1) ...\n",
"Setting up dotnet-targeting-pack-5.0 (5.0.0-1) ...\n",
"Setting up aspnetcore-targeting-pack-5.0 (5.0.0-1) ...\n",
"Setting up dotnet-apphost-pack-5.0 (5.0.2-1) ...\n",
"Setting up dotnet-hostfxr-5.0 (5.0.2-1) ...\n",
"Setting up dotnet-runtime-5.0 (5.0.2-1) ...\n",
"Setting up aspnetcore-runtime-5.0 (5.0.2-1) ...\n",
"Setting up dotnet-sdk-5.0 (5.0.102-1) ...\n",
"This software may collect information about you and your use of the software, and send that to Microsoft.\n",
"Please visit http://aka.ms/dotnet-cli-eula for more information.\n",
"Welcome to .NET!\n",
"---------------------\n",
"Learn more about .NET: https://aka.ms/dotnet-docs\n",
"Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli-docs\n",
"\n",
"Telemetry\n",
"---------\n",
"The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.\n",
"\n",
"Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry\n",
"\n",
"Configuring...\n",
"--------------\n",
"A command is running to populate your local package cache to improve restore speed and enable offline access. This command takes up to one minute to complete and only runs once.\n",
"Processing triggers for man-db (2.8.3-2ubuntu0.1) ...\n",
"\n",
"\u001b[?1h\u001b=Welcome to .NET 5.0!\n",
"---------------------\n",
"SDK Version: 5.0.102\n",
"\n",
"Telemetry\n",
"---------\n",
"The .NET tools collect usage data in order to help us improve your experience. It is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.\n",
"\n",
"Read more about .NET CLI Tools telemetry: https://aka.ms/dotnet-cli-telemetry\n",
"\n",
"----------------\n",
"Installed an ASP.NET Core HTTPS development certificate.\n",
"To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).\n",
"Learn about HTTPS: https://aka.ms/dotnet-https\n",
"----------------\n",
"Write your first app: https://aka.ms/dotnet-hello-world\n",
"Find out what's new: https://aka.ms/dotnet-whats-new\n",
"Explore documentation: https://aka.ms/dotnet-docs\n",
"Report issues and find source on GitHub: https://github.com/dotnet/core\n",
"Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli\n",
"--------------------------------------------------------------------------------------\n",
"\u001b[?1h\u001b=\u001b[?1h\u001b=Since you just installed the .NET SDK, you will need to logout or restart your session before running the tool you installed.\n",
"\u001b[m\u001b[32mYou can invoke the tool using the following command: dotnet-interactive\n",
"Tool 'microsoft.dotnet-interactive' (version '1.0.210501') was successfully installed.\u001b[m\n",
"\u001b[?1h\u001b=\n",
"\u001b[?1h\u001b=Welcome to .NET Interactive!\n",
"---------------------\n",
"Telemetry\n",
"---------\n",
"The .NET Core tools collect usage data in order to help us improve your experience.The data is anonymous and doesn't include command-line arguments. The data is collected by Microsoft and shared with the community. You can opt-out of telemetry by setting the DOTNET_INTERACTIVE_CLI_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.\n",
"\n",
"Installing using jupyter kernelspec module.\n",
"Installed \".NET (C#)\" kernel.\n",
"Installing using jupyter kernelspec module.\n",
"Installed \".NET (PowerShell)\" kernel.\n",
"Installing using jupyter kernelspec module.\n",
"Installed \".NET (F#)\" kernel.\n",
"\u001b[?1h\u001b="
],
"name": "stdout"
},
{
"output_type": "execute_result",
"data": {
"text/plain": [
""
]
},
"metadata": {
"tags": []
},
"execution_count": 1
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "UKDsWDL0bEa8"
},
"source": [
"**Click \"Runtime\" -> \"Change runtime type\" followed by \"Save\".**"
]
},
{
"cell_type": "code",
"metadata": {
"id": "J7d3j94PWM0R"
},
"source": [
"#r \"nuget:XPlot.Plotly,2.0.0\"\r\n",
"open XPlot.Plotly\r\n",
"\r\n",
"[ \"Pizza remaining\", 3; \"Pizza eaten\", 5 ]\r\n",
"|> Chart.Pie\r\n",
"|> display"
],
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment