Skip to content

Instantly share code, notes, and snippets.

@fepegar
Last active February 18, 2025 13:41
Show Gist options
  • Save fepegar/235c65fff85c0cd62f226d2711ac48b0 to your computer and use it in GitHub Desktop.
Save fepegar/235c65fff85c0cd62f226d2711ac48b0 to your computer and use it in GitHub Desktop.

Revisions

  1. fepegar revised this gist Feb 18, 2025. 1 changed file with 25 additions and 2 deletions.
    27 changes: 25 additions & 2 deletions jtry
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash

    PYTHON_VERSION=3.13
    PYTHON_VERSION="3.13"

    tmp_dir=$(mktemp -d)

    @@ -19,6 +19,15 @@ done
    notebook_contents=$(cat <<EOF
    {
    "cells": [
    {
    "cell_type": "code",
    "execution_count": null,
    "metadata": {},
    "outputs": [],
    "source": [
    "%load_ext rich"
    ]
    },
    {
    "cell_type": "code",
    "execution_count": null,
    @@ -28,8 +37,22 @@ notebook_contents=$(cat <<EOF
    }
    ],
    "metadata": {
    "kernelspec": {
    "display_name": ".venv",
    "language": "python",
    "name": "python3"
    },
    "language_info": {
    "name": "python"
    "codemirror_mode": {
    "name": "ipython",
    "version": 3
    },
    "file_extension": ".py",
    "mimetype": "text/x-python",
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
    "version": "3.13.2"
    }
    },
    "nbformat": 4,
  2. fepegar created this gist Feb 18, 2025.
    43 changes: 43 additions & 0 deletions jtry
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    #!/bin/bash

    PYTHON_VERSION=3.13

    tmp_dir=$(mktemp -d)

    uv init \
    --bare \
    --quiet \
    --python $PYTHON_VERSION \
    $tmp_dir

    cmd=(uv add --directory $tmp_dir ipykernel ipywidgets rich)
    for dependency in "$@"; do
    cmd+=( "$dependency")
    done
    "${cmd[@]}"

    notebook_contents=$(cat <<EOF
    {
    "cells": [
    {
    "cell_type": "code",
    "execution_count": null,
    "metadata": {},
    "outputs": [],
    "source": []
    }
    ],
    "metadata": {
    "language_info": {
    "name": "python"
    }
    },
    "nbformat": 4,
    "nbformat_minor": 2
    }
    EOF
    )
    echo $notebook_contents > $tmp_dir/notebook.ipynb

    code --new-window $tmp_dir
    code --reuse-window $tmp_dir/notebook.ipynb