Skip to content

Instantly share code, notes, and snippets.

@rwcitek
Last active April 10, 2026 03:55
Show Gist options
  • Select an option

  • Save rwcitek/74dd6d82c908a96335cb16b1efcd59cf to your computer and use it in GitHub Desktop.

Select an option

Save rwcitek/74dd6d82c908a96335cb16b1efcd59cf to your computer and use it in GitHub Desktop.
jupyter-colab.ipynb
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/rwcitek/74dd6d82c908a96335cb16b1efcd59cf/jupyter-colab.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"source": [
"## Setup\n"
],
"metadata": {
"id": "BeJ_si2tc20Y"
}
},
{
"cell_type": "code",
"source": [
"# @title Install packages\n",
"%%capture\n",
"%%bash\n",
"\n",
"# jupyter in tmux\n",
"tmux new -s jupyter-server -d \" \\\n",
" pip install ipyaml jupyterlab ; \\\n",
" jupyter labextension disable @jupyterlab/apputils-extension:announcements ; \\\n",
" jupyter lab \\\n",
" --ip=127.0.0.1 \\\n",
" --port=8888 \\\n",
" --no-browser \\\n",
" --allow-root \\\n",
" --NotebookApp.token='' ; \\\n",
" echo == Done ; \\\n",
" sleep 30\n",
"\"\n",
"\n",
"\n",
"# package installs in tmux\n",
"tmux new -s update -d \" \\\n",
" apt-get update && \\\n",
" apt-get install -y zstd ; \\\n",
" apt-get install -y tree ; \\\n",
" apt-get install -y jq ncal less texlive-xetex pandoc ; \\\n",
" echo == Done ; \\\n",
" sleep 30\n",
"\"\n",
"\n",
"\n",
"# FastAPI in tmux\n",
"(\n",
" mkdir -p fastapi\n",
" cd fastapi\n",
"\n",
" # Create runner script\n",
" cat <<'eof' > runner.py\n",
"import uvicorn\n",
"\n",
"if __name__ == \"__main__\":\n",
" # \"fastapi_app:app\" tells uvicorn to look in fastapi_app.py for the 'app' object\n",
" # reload=True is the magic ingredient you're looking for\n",
" uvicorn.run(\"fastapi_app:app\", host=\"127.0.0.1\", port=8000, reload=True)\n",
"eof\n",
"\n",
" # Create app script\n",
" cat <<'eof' > fastapi_app.py\n",
"from fastapi import FastAPI\n",
"\n",
"app = FastAPI()\n",
"\n",
"@app.get(\"/\")\n",
"def read_root():\n",
" return {\"message\": \"Hello World! Try changing this text.\"}\n",
"\n",
"eof\n",
"\n",
"# FastAPI runner in tmux\n",
"tmux new -s fastapi -d \"\\\n",
" python runner.py; \\\n",
" echo == Done ; \\\n",
" sleep 30\n",
"\"\n",
")\n",
"\n",
"\n",
"# bash setup\n",
"fgrep -q '.bash_aliases' ~/.bashrc || {\n",
" echo -e '\\n\\n\\n[ -f ~/.bash_aliases ] && . ~/.bash_aliases\\n' >> ~/.bashrc\n",
"}\n",
"\n",
"{ cat << 'eof'\n",
"alias cls=clear\n",
"alias dir='ls -la'\n",
"\n",
"## tmux setup\n",
"[ \"$(tmux display-message -p '#S')\" = \"0\" ] &&\n",
" tmux rename-session main\n",
"\n",
"for name in data train logs ; do\n",
" tmux has-session -t \"$name\" 2>/dev/null ||\n",
" tmux new -s \"$name\" -d\n",
"done\n",
"\n",
"tmux ls\n",
"eof\n",
"} > ~/.bash_aliases\n",
"\n",
"\n",
"# duckdb install\n",
"curl https://install.duckdb.org | sh\n",
"echo 'export PATH='/root/.duckdb/cli/latest':$PATH' >> ~/.bashrc\n",
"\n",
"\n",
"# claude code install\n",
"curl -fsSL https://claude.ai/install.sh | bash\n",
"echo 'export PATH='/root/.local/bin':$PATH' >> ~/.bashrc\n",
"\n",
"\n",
"# opencode install\n",
"while ! which zstd ; do sleep 1 ;done\n",
"curl -fsSL https://opencode.ai/install | bash\n",
"\n",
"\n",
"# ollama install\n",
"curl -fsSL https://ollama.com/install.sh | sh\n",
"\n",
"\n",
"# ollama service in tmux\n",
"tmux new -s ollama -d \"\\\n",
" ollama serve ; \\\n",
" echo ; \\\n",
" echo == Done ; \\\n",
" sleep 10\n",
"\"\n",
"\n",
"\n",
"# create working folder\n",
"mkdir -p /content/opencode/\n",
"cat <<'eof' > /content/opencode/Readme.md\n",
"# Launch OpenCode with ollama\n",
"ollama launch opencode\n",
"eof\n",
"\n"
],
"metadata": {
"id": "PhKU5ii8s6Vj"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# @title Display URLs to local services\n",
"from google.colab import output\n",
"\n",
"print(\"FastAPI\")\n",
"output.serve_kernel_port_as_window(8000)\n",
"print()\n",
"print(\"Jupyter\")\n",
"output.serve_kernel_port_as_window(8888)\n"
],
"metadata": {
"id": "qzDyvRo3zkRW",
"cellView": "form"
},
"execution_count": null,
"outputs": []
}
],
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4",
"include_colab_link": true
},
"language_info": {
"name": "python"
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"accelerator": "GPU"
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment