forked from QuantStack/quantstack.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththebelab.html
More file actions
95 lines (71 loc) · 3.06 KB
/
thebelab.html
File metadata and controls
95 lines (71 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<title>Thebe Lab examples</title>
<link rel="stylesheet" type="text/css" href="thebelab.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js">
</script>
<script type="text/x-thebe-config">
{
bootstrap: true,
binderOptions: {
repo: "QuantStack/xleaflet",
ref: "stable"
},
kernelOptions: {
name: "xeus-cling-cpp14"
}
}
</script>
<script type="text/javascript" src="https://unpkg.com/thebelab@^0.3.0"></script>
</head>
<body>
<h1>Turn any HTML <pre> tag into a C++ interpreter</h1>
<p>This page illustrates a minimal setup to get the xeus-cling C++ Jupyter
kernel attached to an HTML tag.</p>
<h2>A simple test</h2>
<pre data-executable="true" data-language="clike">#include <iostream>
std::cout << "hello, world" << std::endl;
</pre>
<p>Try executing some more code. You may need to restart the kernel to start over.</p>
<h2>How does this work?</h2>
<p>This demonstration is powered by:</p>
<ul>
<li><a href="http://jupyter.org/">Project Jupyter</a></li>
<li>The <a href="https://mybinder.org/">Binder</a> project, for serving live language kernels.</li>
<li>The <a href="https://github.com/QuantStack/xeus-cling">xeus-cling</a> C++ Jupyter kernel, built on the top of the cling C++ interpreter.</li>
<li>THe <a href="https://github.com/minrk/thebelab">ThebeLab</a> project, for turning HTML pages into live documents.</li>
</ul>
<p>To include such examples on your own website, this requires adding a few
script tags to the page:</p>
<ul>
<li>loading <tt>thebelab</tt> on the page,</li>
<li>loading the <tt>requirejs</tt> library, which is only required for Interactive Widgets,</li>
<li>and a script tag for configuring ThebeLab.</pre>
</ul>
<h2>A fully-fledged C++ notebook?</h2>
You can also try out a <a href="https://mybinder.org/v2/gh/QuantStack/xeus-cling/stable?filepath=notebooks/xcpp.ipynb">fully-fledged C++ Jupyter notebook</a> powered by Binder.
<h2>Making use of Jupyter interactive widgets</h2>
<p>This example makes use of the <a href="https://github.com/QuantStack/xwidgets">xwidgets</a> and <a href="https://github.com/QuantStack/xleaflet">xleaflet</a>
projects, for interactive maps visualization in C++</a>
<pre data-executable="true" data-language="clike">#include <iostream>
#include <string>
#include "xleaflet/xmap.hpp"
#include "xleaflet/xbasemaps.hpp"
#include "xcpp/xdisplay.hpp"
auto water_color = xlf::basemap({"Stamen", "Watercolor"});
auto map = xlf::map_generator()
.layers({water_color})
.center({50, 354})
.zoom(5)
.finalize();
xcpp::display(map);
</pre>
<h2>Adding layers and a layers-control to the map</h2>
<pre data-executable="true" data-language="clike">#include "xleaflet/xlayers_control.hpp"
auto terrain = xlf::basemap({"Stamen", "Terrain"});
map.add_layer(terrain);
map.add_control(xlf::layers_control());
</pre>
</body>
</html>