Last active
October 4, 2022 09:59
-
-
Save nmichlo/e372101a5bebcb8ee9837a81b6c5b3ff to your computer and use it in GitHub Desktop.
Run vscode on colab!
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
# Adapted from https://amitness.com/vscode-on-colab | |
# Copy this script into a colab cell | |
# install deps if needed | |
!(command -v "code-server" 1>/dev/null) || (curl -fsSL https://code-server.dev/install.sh | sh && echo) | |
!(python -c "import pyngrok" 2>/dev/null) || (pip install -qqq pyngrok) | |
# run vscode in background if needed | |
!(ps -ef|awk '/code-server/&&!/awk/{exit 1}') && (nohup code-server --port 9000 --auth none &) | |
# run ngrok tunnel if needed | |
from pyngrok import ngrok | |
if not ngrok.get_tunnels(): | |
ngrok.connect(port=9000) | |
print('CONNECT:', ngrok.get_tunnels()[0].public_url) | |
# kill ngrok & vscode | |
!echo !kill $(ps -ef|awk '/ngrok|code-server/&&!/awk/{print $2}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment