The Gambas Playground

The Gambas Playground is a small web tool to write, run and share Gambas code Snippets. It is currently hosted here : https://gambas-playground.proko.eu.

Overview

The Playground allows you to write a small Gambas script using an in-browser editor, then run it on the Playground's server and see the output of the script, without needing to install anything.

It also allows you to share links that point directly to your code on the Playground, using GitHub's Gist service.

Example

Dim i As Integer

For i = 1 To 10
    Print "Count to "; i
Next

A simple script that counts from 1 to 10. Playground link

Using components

Gambas components can be used in the Playground using the USE keyword, like any other Gambas script.

However, since Playground code snippets run in a completely isolated environment, components that rely on User Interfaces (GUI or CLI) or networking (HTTP, FTP, Databases …) are not available.

Example

Use "gb.xml"

Dim doc As New XmlDocument
Print doc.ToString(True)

This script creates an empty XML Document using the gb.xml component, and then prints its contents (with formatting enabled). Playground link

Available Components

The following components are currently available in the playground :

gb.args, gb.clipper, gb.complex, gb.compress, gb.data, gb.debug, gb.draw, gb.eval, gb.eval.highlight, gb.geom, gb.image.effect, gb.image, gb.inotify, gb.markdown, gb.option, gb.settings, gb.signal, gb.term, gb.util, gb.util.web, gb.vb, gb.xml, gb.xml.html

Limitations

Since this web service is literally about arbitrary code execution, a few limitations are in place in order to prevent abuse.

Although these should not bother you in most cases, you might want to keep them in mind shall you try to run some computationally expensive code.

  • Time limit : Scripts cannot run for more than 2 seconds. Scripts exceeding this limit will get killed (i.e. the Gambas interpreter will receive a SIGKILL signal, denying any kind of recovery).

  • Memory limit : Script cannot allocate more than 16 MiB of RAM. Doing so will cause the kernel to raise a SIGSEGV signal (segmentation fault), hence killing the script. Note that this limit is set for the whole environment, therefore the Gambas runtime's memory overhead is also counted towards this limit.

  • Network limitations : No network access is possible : no network card is accessible, and sockets cannot be opened.

  • Filesystem limitations : While any file in the filesystem can be read from, written to, created or deleted, all changes will be discarded when the script ends. Files should therefore be used only as temporary storage.

  • Output size limit : The standard output is forwarded to the browser up to the 2048th byte. Any following output will be discarded.

Code sharing and storage

When a script is shared from the playground, its contents are uploaded to an anonymous Github Gist. The playground's server does not store any data.

However, the last edited snippet is locally saved into the browser's LocalStorage and restored when opening the playground (if not from a shared link). This allows to prevent some unfortunate accidents, such as power outages, browser crashes, and chair/keyboard interface defects.

Delete shared code

If shared code happens to contain sensitive data (such as passwords, private keys …), you can contact the GitHub support and provide them with the Gist's link (generated along the playground link when sharing), or directly the Gist's ID (included in playground link URIs), allowing them to manually delete it.

Edit shared code

Scripts shared using the Share button in the playground are uploaded to anonymous Gists, which cannot be edited. You would have to share a new link in order to distribute a modified version of your script.

If you have a GitHub account, however, you can manually create a gist, paste your script's contents in it, and then manually craft a link to the playground using the following pattern :

https://gambas-playground.proko.eu/?gist=your_gist_id_here