From charlesreid1

Beaker Notebook

Link

https://github.com/twosigma/beaker-notebook

What is it

Beaker notebook is a cloud-based notebook service that can handle a huge variety of different languages: https://pub.beakernotebook.com/

It is of interest to us because we can run Java code in a notebook - perfect for lecture notes.

Finding out about it

Found out about the Beaker notebook at a link [1] talking about various notebook software

  • Jupyter Notebook
  • Apache Zepplin
  • Beaker Notebook

The thing that caught my eye was that it can run Java.

(Zepplin is IMPLEMENTED in Java, but (incredibly) there was no actual explicit statement that you could run Java code in Zeplin.)

Getting Up and Running

Mac

To get everything installed and up and running on the Mac:

Install Xcode

Install Java JDK 8

Install Homebrew

Gradle, NPM, Sass, and Nginx:

brew install gradle npm
brew install --build-bottle nginx --with-debug
sudo gem install sass

clone Beaker notebook repo:

git clone https://github.com/twosigma/beaker-notebook.git

Build everything and run it:

cd beaker-notebook
gradle run

This will take a couple of minutes the first time you do it, since it will compile a bunch of stuff. Eventually your browser will open to the Beaker Notebook web interface:

BeakerNotebookInterface.png

Notes

Notes on Installing and Running Beaker Notebooks

Building Beaker Notebook requires a few prereqs. Instructions for installing are on the Beaker Notebook wiki:

Can also be installed with Docker: https://github.com/twosigma/beaker-notebook/blob/master/Dockerfile

Beaker Notebook is open source and available on Github: https://github.com/twosigma/beaker-notebook

Notes on Installing and Running Java in Beaker Notebooks

Here's how to implement Java in a Beaker Notebook: https://lab.beakernotebook.com/publications/7605e53c-fb84-11e5-97c2-4fe48981c03f

first define some classes

package test.beaker;

import java.util.Date;

public class BeakerTest {
  private Date _date;

  public BeakerTest() {
    _date = new Date();
  }

  public String getDateTxt() {
    return _date.toString();
  }

  public String getDateUpperCaseTxt() {
    return _date.toString().toUpperCase();
  }

}

then some interactive code

package test.beaker;

BeakerTest bt = new BeakerTest();
return bt.getDateTxt();

and heck, draw a graph:

import java.util.List;
import java.util.ArrayList;

Plot p = new Plot();

p.setTitle("this is a Java plot");

Bars b = new Bars();

List<Number> yList = new ArrayList<Number>();
yList.add(2);
yList.add(5);
yList.add(4);
yList.add(8);

b.setY(yList);
b.setColori(Color.orange);
b.setWidth(0.5);

p.add(b);
  
return p;

Notes on static files

If you want to serve up static file content, where do you put it so that beaker notebook can see it?

Put files in ~/.beaker/v1/web, and then from your HTML and JS you can refer to it with /user. For example if you have an image at ~/.beaker/v1/web/foo.jpg you can use it with img src="/user/foo.jpg">. See the tutorial.

Note that if you do this, the images will not work if you share the notebook with someone else. They are planning on a better solution for this.

Fixing Markdown

Unfortunately, out of the box Beaker Notebooks had no Markdown - making them basically useless as notebooks.

To fix, I tried npm install markdown and got a bunch of weird warnings I didn't understand. Crap.

Flags