Skip to content

Instantly share code, notes, and snippets.

@eiriks
Created January 29, 2018 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eiriks/e21a6d5460c97f73eef46dd52b36141b to your computer and use it in GitHub Desktop.
Save eiriks/e21a6d5460c97f73eef46dd52b36141b to your computer and use it in GitHub Desktop.
contents of:~/.ipython/profile_default/startup/00-standard-imports.ipy
%matplotlib inline
%load_ext autotime
import pandas as pd
import numpy as np
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
import uuid
from IPython.display import display_javascript, display_html, display
import json
class RenderJSON(object):
def __init__(self, json_data):
if isinstance(json_data, dict):
self.json_str = json.dumps(json_data)
else:
self.json_str = json
self.uuid = str(uuid.uuid4())
def _ipython_display_(self):
display_html('<div id="{}" style="height: 600px; width:100%;"></div>'.format(self.uuid),
raw=True
)
display_javascript("""
require(["https://rawgit.com/caldwell/renderjson/master/renderjson.js"], function() {
document.getElementById('%s').appendChild(renderjson(%s))
});
""" % (self.uuid, self.json_str), raw=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment