4 ms·
He's effectively writing a minimal git client in Python. "Fun" is a good reason for this sort or exploration, but it also has its practical uses. For instance
by bsimpson 3y ago
He's effectively writing a minimal git client in Python.
"Fun" is a good reason for this sort or exploration, but it also has its practical uses. For instance, I use `isomorphic-git` (a git client written in JavaScript) to include a comment with the relevant commit hash in my bundled JavaScript. I can run it on any machine with Node, without opening a shell or trying to find where/if git is installed locally.
- Something1234 3y agoAlright I'm really curious on the use case of this. Is it for debugging assistance or anything else?
- bsimpson 3y agoThey get deployed into a Colab cell or Google Drive. It's nice to be able to see what version is there without running anything.
- Something1234 3y agoThere's an api to update a Colab cell publicly available? That's wild. I thought for sure it would be locked down.
- bsimpson 3y agoBest solution I've found is to paste the whole thing into a cell with this header #@title Give your cell a headline %%js_module where js_module is defined here: # Copyright 2023 Google LLC. # SPDX-License-Identifier: Apache-2.0 from IPython.core.display import display, HTML from IPython.core.magic import register_cell_magic import time @register_cell_magic def js_module(line, cell): if cell.startswith('http'): src, hash = cell.split('#') if '#' in cell else [cell, ''] timestamp = time.time() if 'cachebust' in line else '' display(HTML( "<script type = 'module' src = '{src}?{timestamp}'></script>".format(src = src, hash = hash, timestamp = timestamp) )) else: display(HTML( "<script type = 'module'>{cell}</script>".format(cell = cell) )) The #@title lets you collapse the cell, so the JavaScript isn't showing. Colab has a strong philosophy of ensuring the user can see everything they're running, so I don't think there's a better way to encapsulate the bundled JS.