Skip to content

Instantly share code, notes, and snippets.

@chezou
Created July 17, 2020 00:56
Show Gist options
  • Save chezou/858d663381625c9bb1c868e0c95969c6 to your computer and use it in GitHub Desktop.
Save chezou/858d663381625c9bb1c868e0c95969c6 to your computer and use it in GitHub Desktop.
code-server.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "code-server.ipynb",
"provenance": [],
"collapsed_sections": [],
"authorship_tag": "ABX9TyOB1OWkT7TEtImAXFYNWnX9",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/chezou/858d663381625c9bb1c868e0c95969c6/code-server.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "dkiKFfvQGKIp",
"colab_type": "code",
"colab": {}
},
"source": [
"from getpass import getpass\n",
"\n",
"# Don't forget create your account of ngrok and get token from https://dashboard.ngrok.com/auth/your-authtoken\n",
"authtoken = getpass(\"Input your Auth token\")"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "LuQjovjxFPLC",
"colab_type": "code",
"colab": {}
},
"source": [
"! apt-get install --yes git ssh python3-venv > /dev/null\n",
"\n",
"# Download ngrok\n",
"! wget -q -c -nc https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-amd64.zip\n",
"! unzip -qq -n ngrok-stable-linux-amd64.zip\n",
"# Run ngrok\n",
"get_ipython().system_raw('./ngrok authtoken $authtoken && ./ngrok http 8888 &')\n",
"! sleep 3\n",
"\n",
"# Get the address for code-server\n",
"import requests\n",
"from re import sub\n",
"r = requests.get('http://localhost:4040/api/tunnels')\n",
"str_ssh = r.json()['tunnels'][0]['public_url']\n",
"print(str_ssh)"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "cYsGG5ocHeJE",
"colab_type": "code",
"colab": {}
},
"source": [
"from google.colab import drive\n",
"drive.mount('/googledrive')\n",
"! mkdir -p /googledrive/My\\ Drive/colabdrive\n",
"! mkdir -p /googledrive/My\\ Drive/colabdrive/root/.local/share/code-server\n",
"! ln -s /googledrive/My\\ Drive/colabdrive /\n",
"! ln -s /googledrive/My\\ Drive/colabdrive/root/.local/share/code-server /root/.local/share/"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "vbvgpIBsPvu3",
"colab_type": "code",
"colab": {}
},
"source": [
"code_server_pass = getpass(\"Input code-server password\")"
],
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "d5obxTLSHfuc",
"colab_type": "code",
"colab": {}
},
"source": [
"! curl -fsSL https://code-server.dev/install.sh | sh > /dev/null\n",
"! PASSWORD=$code_server_pass code-server --bind-addr 127.0.0.1:8888 --auth password &"
],
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment