Skip to content

Instantly share code, notes, and snippets.

@jthomasmock
Created August 2, 2023 16:04
Show Gist options
  • Save jthomasmock/f64d0a1afd2dfb447dbeebf5a28bc8f4 to your computer and use it in GitHub Desktop.
Save jthomasmock/f64d0a1afd2dfb447dbeebf5a28bc8f4 to your computer and use it in GitHub Desktop.
Take a ipynb from Colab and render
# Colab follows Google Drive style syntax
# so https://colab.research.google.com/drive/1R_G1BEdOSN6RcmNDZSG0vJtxk4rOodN7
# means file id = 1R_G1BEdOSN6RcmNDZSG0vJtxk4rOodN7
# so to download that file, we could use:
#> This would download the file and -O (output) as temp-quarto.ipynb
wget -O temp-quarto.ipynb 'https://docs.google.com/uc?export=download&id=1R_G1BEdOSN6RcmNDZSG0vJtxk4rOodN7'
# we can then pass that to quarto render
quarto render temp-quarto.ipynb --to html
# but we likely want to make it a one-liner so that there's always
# a fresh download and then a render, rather than risk using the old
# 'temp' file on disk
wget -O temp-quarto.ipynb 'https://docs.google.com/uc?export=download&id=1R_G1BEdOSN6RcmNDZSG0vJtxk4rOodN7'; quarto render temp-quarto.ipynb --to html
# if we want to be more clever, we can abstract the url to make it shorter.
export googleurl='https://docs.google.com/uc?export=download&id='
export fileid=1R_G1BEdOSN6RcmNDZSG0vJtxk4rOodN7
# show the combo url
echo "${googleurl}${fileid}"
#> https://docs.google.com/uc?export=download&id=1R_G1BEdOSN6RcmNDZSG0vJtxk4rOodN7
# combine into a one-liner, separated w/ ;
$ wget -O temp-quarto.ipynb "${googleurl}${fileid}"; quarto render temp-quarto.ipynb --to html
#> --2023-08-02 11:02:40-- https://docs.google.com/uc?export=download&id=1R_G1BEdOSN6RcmNDZSG0vJtxk4rOodN7
#> Resolving docs.google.com (docs.google.com)... 2607:f8b0:4023:1009::71, 2607:f8b0:4023:1009::65, 2607:f8b0:4023:1009::66, ...
#> Connecting to docs.google.com (docs.google.com)|2607:f8b0:4023:1009::71|:443... connected.
#> HTTP request sent, awaiting response... 303 See Other
#> Location: https://doc-0o-c0-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/pv5ll5gtkgif24ecg40tv1ch45i9pkf0/1690992150000/16944485441495734934/*/1R_G1BEdOSN6RcmNDZSG0vJtxk4rOodN7?e=download&uuid=cca2dae0-1f30-4a4f-a71b-d79ca1b35588 [following]
#> Warning: wildcards not supported in HTTP.
#> --2023-08-02 11:02:40-- https://doc-0o-c0-docs.googleusercontent.com/docs/securesc/ha0ro937gcuc7l7deffksulhg5h7mbp1/pv5ll5gtkgif24ecg40tv1ch45i9pkf0/1690992150000/16944485441495734934/*/1R_G1BEdOSN6RcmNDZSG0vJtxk4rOodN7?e=download&uuid=cca2dae0-1f30-4a4f-a71b-d79ca1b35588
#> Resolving doc-0o-c0-docs.googleusercontent.com (doc-0o-c0-docs.googleusercontent.com)... 2607:f8b0:4023:1004::84, 142.250.115.132
#> Connecting to doc-0o-c0-docs.googleusercontent.com (doc-0o-c0-docs.googleusercontent.com)|2607:f8b0:4023:1004::84|:443... connected.
#> HTTP request sent, awaiting response... 200 OK
#> Length: 166035 (162K) [application/vnd.google.colaboratory]
#> Saving to: ‘temp-quarto.ipynb’
#> temp-quarto.ipynb 100%[=======>] 162.14K 1.04MB/s in 0.2s
#> 2023-08-02 11:02:41 (1.04 MB/s) - ‘temp-quarto.ipynb’ saved [166035/166035]
#> pandoc
#> to: html
#> output-file: temp-quarto.html
#> standalone: true
#> section-divs: true
#> html-math-method: mathjax
#> wrap: none
#> default-image-extension: png
#>
#> metadata
#> document-css: false
#> link-citations: true
#> date-format: long
#> lang: en
#>
#> Output created: temp-quarto.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment