Skip to content

Instantly share code, notes, and snippets.

View joelhoro's full-sized avatar

Joel Horowitz joelhoro

  • New York
View GitHub Profile
@joelhoro
joelhoro / jupyter_javascript_snippet.js
Created January 30, 2020 04:04 — forked from craigsdennis/jupyter_javascript_snippet.js
Run Python code from JavaScript in a Jupyter notebook
// %%javascript
window.executePython = function(python) {
return new Promise((resolve, reject) => {
var callbacks = {
iopub: {
output: (data) => resolve(data.content.text.trim())
}
};
Jupyter.notebook.kernel.execute(`print(${python})`, callbacks);
});