Skip to content

vladissta/livecodeR

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

livecodeR

livecodeR is the fork of R package livecode that enables you to broadcast a local R (or any other text) document over the web and provide live updates as it is edited. This fork fixes some errors which appeared to me when i started using it. And now it works!(?)

Installation

You can install the development version of livecodeR from this GitHub repository:

remotes::install_github("vladissta/livecodeR")

Usage

From RStudio with an open R script type in console:

server = livecode::serve_file(port=3000)
#> ✔ Started sharing 'example.R' at 'http://127.0.0.1:3000'.
#> i Server is listening on all interfaces. For a public tunnel, set `public_url=` to your ngrok URL.

if public_url specified than when serve_file() run it opens this url in browser (it does not launch any tunnel)

Two ways of usage

  1. Create tunnel via ngrok, xtunnel, tuna or otherplaforms for creating public URLs for accessing locally run services using the address you specified for serve_file(). In example above it is http://127.0.0.1:3000. Then any user in any place can connect to public url provided by such platform.
  2. Connect to local network (e.g. wifi router) and specify your local ip parameter in serve_file() which you can find out using livecode::network_interfaces(). Then any user connected to the same network (wifi) can access to your broadcast via http://198.168.*.*:****

You can send messages to your users.

server$send_msg("Hello World!", type = "success")
server$send_msg("Oh no!\n\n Something bad has happened.", type = "error")

Once finished, shut the server down.

server$stop()
#> ✔ Stopped server at 'http://127.0.0.1:3000'.

Using bitly

This functionality was not fixed or even tested, so it may not work!

Original livecode has built in functionality for generating a bitlink automatically for your livecoding session.

To do this you will need to provide livecode with a bitly API access token. To obtain one of these tokens you will need to create an account with bitly (the free tier is sufficient) and then select Profile Settings > Generic Access Token and then enter your password when prompted. This results in a long hexidecimal string that you should copy to your clipboard.

livecode looks for this token in an environmental variable called BITLY_PAT. To properly configure this environmental variable we can use the usethis package. In R run the following,

usethis::edit_r_environ()

which will open your .Renviron file for you and you will just need to add a single line with the format

BITLY_PAT=0123456789abcdef0123456789abcdef01234567

replacing 0123456789abcdef0123456789abcdef01234567 with the hexidecimal string you copied from bitly. After saving .Renviron you will need to restart your R session and can then test that your token is function correctly by running,

livecode::bitly_test_token()
#> ✔ Your bitly token is functioning correctly.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • CSS 53.4%
  • R 35.5%
  • JavaScript 3.9%
  • C++ 3.8%
  • HTML 2.9%
  • Makefile 0.5%