Skip to content

Instantly share code, notes, and snippets.

@jaredly
Created April 22, 2015 15:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredly/404a36306fdee6a1737a to your computer and use it in GitHub Desktop.
Save jaredly/404a36306fdee6a1737a to your computer and use it in GitHub Desktop.
Jupyter NodeJS Example
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Jupyter Nodejs"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First get [jupyter-nodejs](https://github.com/notablemind/jupyter-nodejs) and install it. Then the jupyter notebook should automatically recognize it."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"var os = require('os')\n",
"os.hostname()"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Hello NodeJS\n"
]
}
],
"source": [
"console.log('Hello NodeJS')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Babel es6+"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [],
"source": [
"%load_ext babel"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"34"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%babel\n",
"const m = () => 34\n",
"m()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%%babel\n",
"class Something {\n",
" constructor() {\n",
" console.log('Welcome!')\n",
" }\n",
" doit() {\n",
" return false\n",
" }\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Welcome!\n"
]
},
{
"data": {
"text/plain": [
"false"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"%%babel\n",
"new Something().doit()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Clojurescript!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"If you want faster load times, you can [run your own](https://github.com/fogus/himera) Himera server locally and use that url here."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"%load_ext clojurescript http://himera-emh.herokuapp.com"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"(24 25 26)"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%clojurescript\n",
"(map #(+ % 23) [1 2 3])"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "NodeJS",
"language": "javascript",
"name": "nodejs"
},
"language_info": {
"codemirror_mode": "javascript",
"file_extension": "js",
"mimetype": "text/javascript",
"name": "nodejs",
"pygments_lexer": "javascript",
"version": "0.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment