Skip to content

Instantly share code, notes, and snippets.

@nmichlo
Last active October 4, 2022 09:59
Show Gist options
  • Save nmichlo/e372101a5bebcb8ee9837a81b6c5b3ff to your computer and use it in GitHub Desktop.
Save nmichlo/e372101a5bebcb8ee9837a81b6c5b3ff to your computer and use it in GitHub Desktop.
Run vscode on colab!
# 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