Skip to content

Instantly share code, notes, and snippets.

@minrk
Created May 23, 2013 03:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save minrk/5632595 to your computer and use it in GitHub Desktop.
Save minrk/5632595 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "Javascript"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "heading",
"level": 2,
"metadata": {},
"source": [
"IPython Notebook with in-browser Javascript Kernel"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With [this profile](https://github.com/minrk/profile_jskernel),\n",
"kernel.js is replaced by a simple object that executes javascript in the browser rather than remotely via websockets.\n",
"\n",
"This is more of a toy / proof of concept than anything."
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"1"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 3,
"text": [
"1"
]
}
],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"2"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 4,
"text": [
"2"
]
}
],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"console.log(\"hi\")"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"hi\n"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"double = function (x) {\n",
" return x * x;\n",
"}\n",
"console.log(double(5));\n",
"console.log(double(10));\n"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"25\n"
]
},
{
"output_type": "stream",
"stream": "stdout",
"text": [
"100\n"
]
}
],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"foo = 5"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 7,
"text": [
"5"
]
}
],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"console.log(location)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": [
"http://127.0.0.1:8890/05f99275-69db-42ff-92c2-59780eb7f1fc\n"
]
}
],
"prompt_number": 8
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"foo + double(10)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 9,
"text": [
"105"
]
}
],
"prompt_number": 9
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"bar"
],
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "ReferenceError",
"evalue": "bar is not defined",
"output_type": "pyerr",
"traceback": [
"ReferenceError: bar is not defined\n at eval (eval at <anonymous> (http://127.0.0.1:8890/static/js/kernel.js:236:22), <anonymous>:1:1)\n at Kernel.execute (http://127.0.0.1:8890/static/js/kernel.js:236:17)\n at CodeCell.execute (http://127.0.0.1:8890/static/js/codecell.js:251:34)\n at Notebook.execute_selected_cell (http://127.0.0.1:8890/static/js/notebook.js:1366:18)\n at HTMLDocument.<anonymous> (http://127.0.0.1:8890/static/js/notebook.js:158:22)\n at HTMLDocument.f.event.dispatch (http://127.0.0.1:8890/static/jquery/js/jquery-1.7.1.min.js:3:4351)\n at HTMLDocument.h.handle.i (http://127.0.0.1:8890/static/jquery/js/jquery-1.7.1.min.js:3:328)"
]
}
],
"prompt_number": 10
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment