Giter Site home page Giter Site logo

netgusto / nodebook Goto Github PK

View Code? Open in Web Editor NEW
1.6K 31.0 83.0 4.07 MB

Nodebook - Multi-Lang Web REPL + CLI Code runner

License: ISC License

JavaScript 0.03% TypeScript 25.20% CSS 4.44% HTML 0.30% C++ 0.09% C 0.08% Go 69.11% Haskell 0.05% Java 0.12% Lua 0.02% PHP 0.03% Python 0.02% R 0.02% Ruby 0.02% Rust 0.05% Swift 0.02% Elixir 0.03% OCaml 0.03% F# 0.17% C# 0.17%
repl nodejs c cpp haskell java lua php python r

nodebook's Introduction

nodebook

Nodebook - Multi-Language REPL with Web UI + CLI code runner

Useful to practice algorithms and datastructures for coding interviews.

What is it?

Nodebook is an in-browser REPL supporting many programming languages. Code's on the left, Console's on the right. Click "Run" or press Ctrl+Enter or Cmd+Enter to run your code. Code is automatically persisted on the file system.

You can also use Nodebook directly on the command line, running your notebooks upon change.

nodebook

A notebook is a folder containing an {index|main}.{js,py,c,cpp,...} file. The homepage lists all of the available notebooks.

home

Supported environments

  • C11 (.c)
  • C++14 (.cpp)
  • C# (.cs)
  • Clojure (.clj)
  • Elixir (.ex)
  • Fsharp (.fs)
  • Go (.go)
  • Haskell (.hs)
  • Java (.java)
  • NodeJS (.js)
  • Lua (.lua)
  • OCaml (.ml)
  • PHP (.php)
  • Python 3 (.py)
  • R (.r, .R)
  • Ruby (.rb)
  • Rust (.rs) — Uses cargo run if Cargo.toml is present, and rustc otherwise
  • Swift (.swift)
  • TypeScript (.ts)

If --docker is set on the command line, each of these environments will run inside a specific docker container.

Otherwise, the local toolchains will be used.

Install from release

Head to Releases and download the binary built for your system (mac, linux).

Rename it to nodebook and place it in your path.

Install from source

Building requires go.

$ make deps
$ make install
# nodebook should be available under $GOPATH/bin/nodebook or $GOBIN/nodebook

Run with Web UI

# With dockerized toolchains
$ nodebook --docker path/to/notebooks

# With local toolchains
$ nodebook path/to/notebooks

Run on CLI (watch and run mode)

$ nodebook cli --docker path/to/notebooks
# Or
$ nodebook cli path/to/notebooks

Usage

Create a Notebook (Web UI)

Click on the + Notebook button on the Home page, then select the language of the notebook to be created.

Once on the notebook edition page, you can rename the notebook by clicking on it's name.

Notebooks are created in the directory specified by the parameter --notebooks.

Create a Notebook manually (WebUI, CLI)

In the directory where you want your notebooks to be stored, simply create a folder containing a file named {index|main}.{js,py,c,cpp,...}.

The notebook's name will be the name of the folder. The notebook language is determined automatically.

Command line options

  • --docker: Execute code in disposable docker containers instead of local system; defaults to false

Web UI only:

  • --bindaddress: IP address the http server should bind to; defaults to 127.0.0.1
  • --port: Port used by the application; defaults to 8000

Notebook environment

If your notebook dir contains a .env file, the corresponding environment will be set up during notebook execution.

Exemple .env:

HELLO=World!

More information about the expected file format here: https://github.com/motdotla/dotenv#rules

⚠️ A bit of warning ⚠️

Do not run the Web UI on a port open to public traffic! Doing so would allow remote code execution on your machine.

By default, the server binds to 127.0.0.1, which allows connection from the localhost only. You can override the bind address using --bindaddress, but do it only if you know what you're doing.

nodebook's People

Contributors

dependabot[bot] avatar itaisteinherz avatar orlandok7 avatar reed-jones avatar stripedpajamas avatar waldyrious avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nodebook's Issues

C# ?

What about C# / .NET ?

Ignore dist

I recommend git-ignoring the dist folder. The files can be generated on first run or with the npm postinstall script. As it is, code reviews are noisy (babel and minified code shows up) and there's a bit of a security risk in that one could sneak code into the dist files and most reviewers would not notice.

Previous notebooks not retained on homepage

Every time I launch nodebook with the same code folder, the homepage is empty and all previous notebooks are gone (though the code files do exist on the file system). Is this normal?

P.S. I have tried "Install and run as package (npm)" and "Install and run from source as an electron app", both failed.

install and first run are hard to get right

ubuntu 19:10

  • download release from github to clean directory
  • chmod +x nodebook*
  • mkdir books
    ./nodebook* web books
    click new, choose nodejs
    click run

`
Ready.
--- Running...
internal/modules/cjs/loader.js:895
throw err;
^
Error: Cannot find module '/other/clones/nodebook/notebook/Waspbutter Robin/notebook/Waspbutter Robin/index.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
at Function.Module._load (internal/modules/cjs/loader.js:785:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1143:12)
at internal/main/run_main_module.js:16:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
exit status 1
--- Done.

`

Replace VT100 color codes in output?

Exemple:

const chalk = require('chalk');
console.log(chalk.green('Hello, World!'));

Should it be displayed in green, or [32mHello, World![39m ?

Feat: Packages for Linux and Mac

Hey since this is a go project it'd be really easy to use goreleaser You could easily build binaries for a new tag with debugger options like --ldflags and drastically reduce the binary size(I ran it locally and it got to 9.6MB).

You can set up a homebrew tap and using nfpm with that and it could easily replace the download from releases . This in terms will reduce the learning curve of a new installation and make the installation process quite faster.

You can use these within a CI/CD system or GitHub Actions.

I'll be happy to send a PR and help you on this

Got it to run under Docker in Docker

Hi there,

Really cool project!

I just spent an afternoon dockerizing it. I have a repo here:

https://github.com/ms-jpq/nodebook-docker

It runs Docker inside Docker, so everything is a bit cleaner.

So far I've tested all the repls (with hello world), and they all seem to be a-okay except ocaml. It throws a Permission denied thing.

I don't know if you want to incorporate it into your main repo or not, but just thought i'd let you know. :)

Have a good day!

Edit:

Ocaml also throws the same error if i run it outside of Docker in Docker. (Still using the same --docker option)

So I dont think thats related.

No LICENSE

Just a reminder to add a LICENSE file to this project 😃

Implement token based scheme like jupyter for web

Principle: generate and display on the command line an auth token valid for the session, and authorize in the browser for the duration of the session.

Enabled by default, disable with --no-auth on the command line.

Does not display last line if not terminated by newline when using docker

Currently, the last log line is not displayed if the output is not terminated by newline, when using docker toolchains.

This is probably due to the docker client buffering the log until the line is complete.

To reproduce, snippet in go:

package main

import "fmt"
import "time"

func main() {
	fmt.Println("Hello, World!")
    currentTimeMillis := time.Now().UnixNano() / int64(time.Millisecond)
    fmt.Printf("Current Time Millis: %d", currentTimeMillis)
}

Output may or may not contain last line:

Screenshot 2020-02-17 at 10 50 44

"no such file or directory" error

Created a new Swift notebook. On running it -

Ready.
--- Running...
<unknown>:0: error: no such file or directory: 'notes/Pigmarsh Lion/main.swift'
exit status 1
--- Done.

What am I missing?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.