Giter Site home page Giter Site logo

web-repl's Introduction

web-repl

A Javascript REPL that runs in Ruby. Evaluation is done by a web browser instance.

One use of this is to replace the Chrome Developer Console remotely as such:

image

Background

I've been working on a toy project recently that requires browser content to be in fullscreen. This makes live coding using the regular Chrome JS console more or less impossible. I came up with web-repl as an alternative.

There are similar tools that run in nodejs and other languages but this is convenient for me because my project uses a Ruby backend anyway.

Under the hood, communication is done with JSON over Websocket. Note that there's no extra attention to security here other than what is generally implicit with a Websocket, so please use at your own discretion.

Usage

Browser

To enable the browser side of this, include something like this in the head of your webpage:

<script src="js/replConnection.js"></script>
<script type="text/javascript">
  window.onload = function() {
    var repl = new ReplConnection("localhost", 9007, { debug: true, reconnect: true });
    repl.start();
  }
</script>

The javascript assets for this project are located in the /js directory.

There is also a full example of a webpage (with simple rack webserver configuration) in the /examples/page directory

REPL

The REPL can be used either in a Ruby program/console or there is a "binary" Ruby script.

In Ruby the usage looks like this:

require "web-repl"

WebRepl.start(:host => "localhost", :port => 9007)

You can see an explanation of background usage here.

To use this as a script, run this from the command line. (The script should install with the gem)

web-repl localhost:9007

Installation

gem install web-repl

or with Bundler

gem "web-repl"

License

Licensed under Apache 2.0, See the file LICENSE

Copyright (c) 2014-2015 Ari Russo

web-repl's People

Contributors

arirusso avatar

Stargazers

 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

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.