Last active
February 21, 2025 22:12
-
-
Save danascape/6961c9c680b7ed41820c608c455264ff to your computer and use it in GitHub Desktop.
Colab's New Code Editor
This file contains hidden or 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": "Colab's New Code Editor", | |
"provenance": [], | |
"collapsed_sections": [], | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"accelerator": "GPU" | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/iamsaalim/6961c9c680b7ed41820c608c455264ff/colab-s-new-code-editor.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"metadata": { | |
"id": "wfuCb6f28zO5", | |
"colab_type": "code", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 68 | |
}, | |
"outputId": "a0542fa6-e5c7-46c7-fa22-42a758c5a0e3" | |
}, | |
"source": [ | |
"! 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", | |
"! apt-get install -qq -o=Dpkg::Use-Pty=0 openssh-server pwgen vim neofetch dialog git tmux bc build-essential zip curl libstdc++6 git wget python gcc clang libssl-dev repo rsync flex bison nyancat nano> /dev/null\n", | |
"! git clone https://github.com/akhilnarang/scripts && cd scripts && bash setup/android_build_env.sh && cd ..\n", | |
"! echo root:danascape | chpasswd\n", | |
"! mkdir -p /var/run/sshd\n", | |
"! echo \"PermitRootLogin yes\" >> /etc/ssh/sshd_config\n", | |
"! echo \"PasswordAuthentication yes\" >> /etc/ssh/sshd_config\n", | |
"! echo \"LD_LIBRARY_PATH=/usr/lib64-nvidia\" >> /root/.bashrc\n", | |
"! echo \"export LD_LIBRARY_PATH\" >> /root/.bashrc\n", | |
"\n", | |
"#Run sshd\n", | |
"get_ipython().system_raw('/usr/sbin/sshd -D &')\n", | |
"\n", | |
"#Ask token\n", | |
"print(\"Copy authtoken from https://dashboard.ngrok.com/auth\")\n", | |
"authtoken=\"token\"\n", | |
"! git config --global user.email \"[email protected]\"\n", | |
"! git config --global user.name \"danascape\"\n", | |
"\n", | |
"#Create tunnel\n", | |
"get_ipython().system_raw('./ngrok authtoken 1ShshNwfhQcyOqlMjnBDVE5X5jC_3WAmzomMHAgkunka4dSck && ./ngrok tcp 22 &')\n", | |
"#Print root password\n", | |
"print(\"Root password: danascape\")\n", | |
"#Get public address\n", | |
"# ssh [email protected] -p 10965 <-- port number dictated in colab output\n", | |
"! curl -s http://localhost:4040/api/tunnels | python3 -c \\\n", | |
" \"import sys, json; print(json.load(sys.stdin)['tunnels'][0]['public_url'])\"\n" | |
], | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": [ | |
"Copy authtoken from https://dashboard.ngrok.com/auth\n", | |
"Root password: danascape\n", | |
"tcp://0.tcp.ngrok.io:16873\n" | |
], | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"colab_type": "text", | |
"id": "LhDiAMaaAnQF" | |
}, | |
"source": [ | |
"## Enabling and disabling the new editor\n", | |
"\n", | |
"The new editor can be controlled with the experiment button in the top-right.\n", | |
"\n", | |
"\n", | |
"### Issues\n", | |
"You can disable the new editor if you run into issues, but please do let us know why so that we can fix any complaints.\n", | |
"\n", | |
"Bugs can be filed at https://github.com/googlecolab/colabtools/issues/new, or use the 'Send feedback...' option in the Help menu." | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"colab_type": "text", | |
"id": "rDDEJerKvHV_" | |
}, | |
"source": [ | |
"# Automatic Completions\n", | |
"\n", | |
"Code completions and documentation hints occur automatically while you type.\n", | |
"\n", | |
"Use the following keyboard shortcuts:\n", | |
" - `Ctrl-space` to re-open completions.\n", | |
" - `Ctrl-shift-space` to re-open parameter hints.\n", | |
"\n", | |
"\n", | |
"\n", | |
"\n" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"colab_type": "text", | |
"id": "ev2VBsdN3psP" | |
}, | |
"source": [ | |
"## Disabling automatic completions\n", | |
"\n", | |
"Automatic completions can be disabled in the Preferences with the \"Automatically trigger code completions\" option.\n", | |
"\n", | |
"" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"colab_type": "text", | |
"id": "bEXkvERUtU5O" | |
}, | |
"source": [ | |
"# Keyboard Bindings\n", | |
"\n", | |
"The default editor keyboard bindings have been updated and there are now additional options for keybindings including:\n", | |
"\n", | |
"* Vim\n", | |
"* Classic - restores some common keyboard shortcuts from the previous editor.\n", | |
"\n", | |
"These options are available in the Preferences with the \"Editor key bindings\" option.\n", | |
"\n", | |
"\n", | |
"\n", | |
"With automatic completions disabled use:\n", | |
" - `Tab` to re-open completions.\n", | |
" - `Shift-tab` to re-open parameter hints." | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"colab_type": "text", | |
"id": "aRDUGd13kUFu" | |
}, | |
"source": [ | |
"# Colab's New Code Editor\n", | |
"\n", | |
"Colab is moving to a new code editor which includes:\n", | |
"* Richer completions\n", | |
"* Additional keybinding options\n", | |
"* Improved accessibility" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"colab_type": "text", | |
"id": "qTXOGdaz4wy0" | |
}, | |
"source": [ | |
"# Richer syntax highlighting\n", | |
"\n", | |
"Improved support for nested languages:\n", | |
"\n", | |
"```notebook-python\n", | |
"df = pd.io.gbq.read_gbq('''\n", | |
" SELECT \n", | |
" REGEXP_EXTRACT(name, '[a-zA-Z]+'),\n", | |
" SUM(number) as count\n", | |
" FROM `bigquery-public-data.usa_names.usa_1910_2013`\n", | |
" WHERE state = 'TX'\n", | |
" GROUP BY name\n", | |
" ORDER BY count DESC\n", | |
" LIMIT 100\n", | |
"''')\n", | |
"```" | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment