Avi
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    ```json { "format": Number, "language": String, "interpreter": Any, "code": String, "input": String, "options": _, // flags/args "misc": { ... } // settings } ``` { "format": Number, "language": String, "interpreter": Any, "code": String, "input": String, "options": _, "misc": { ... } } The _ is unnecessary but I just want to make sure we're on the same page for the nested ones! Do we need anything else? Settings will be needed for some languages Re: format, will we ever be changing the key names? We might at some point, better to have a way to indicate that Def better safe than sorry! Maybe there should be a `"version"` as well? Ooh, separate? Sure. The more the merrier Langs that don't use them will ignore them anyway It could just go under `"settings"` I guess Good idea. On the one hand I don't want to overclutter it, on the other hand, making them remember who the parent is might be annoying re: having version within settings or having everything be separate In other words, there are pros/cons to having everything be separate, and grouping ? Maybe there should be a `"language"` key, that has the language ID and version? Oh? version goes there? I meant to have that, yeah! We could move it, I guess. I do like it going under language, though Maybe instead of `"name"` it should be `"id"` hmmm, idk, where would the id come from? an ids.json? An ID could be specified with each language, since language names might have punctuation that is difficult to deal with Example: ??? or /// <>< Wow, you're good at this! Yeah, you're right I wouldn't worry too much, I don't think, on starting with a premature json either. Should be pretty easy to refactor at this point Another thing to consider: Different interpreters. For example, CPython vs PyPy. Maybe another field under `"language"`? Good point Are we having "name" in addition to "id" under language Or "name" instead? I don't think having the client specify the name is necessary if the ID is already there w Actually, I say interpreter & version under "settings" haha, did i getcha? Maybe the interpreter and version can be merged or were you going to say merged elsewhere? > I'm thinking maybe since different languages have different ways of having different interpreters, it could be an `"interpreter"` object? I can think of some things that might require being able to have multiple different settings there. Like if you have packages, for example. Mind copy/pasting into chat? Which part? Just everything after the >? Yeah, just that! My proposed response format: ```json { "format": Number, "finished": Boolean, "data": Data[] } // Data: { "id": String, "data": DataFormat OR DataFormat[], "collapse": Number } // ??? // DataFormat: { "id": String, "data": String, "formatting": String } ``` Example: ```json { "format": 1, "finished": true, "data": [ { "id": "out", "data": [ { "data": "[10, 11, 12]\n\n", "formatting": "normal" }, { "data": "ReferenceError: x is not defined", "formatting": "red" } ] } ] } ``` Example with `STDOUT`/`STDERR` (just the `data`): ```json [ { "id": "stdout", "data": { "data": "[10, 11, 12]", "formatting": "normal" } }, { "id": "stderr", "data": { "data": "ReferenceError: x is not defined", "formatting": "normal" } } ] ``` ```json { "format": 0, "stdout": String, "stderr": String, "misc": { ... } } ``` **Improvement proposal:** Instead of having ` JSON.data` as an array of `Data[]`, we can use an object with `{id: Data}` pairs. That's similar to what we did with `inputJSON.misc`, and gets rid of some ugly syntax. That would mean my cluttered `stdout`/`stderr` example would instead look like: ```json ["1", "2", "Fizz"] ["4", "B"] { "format": 0, "data": { "stdout": ["abc", "def", {}, ], "stderr": ["SyntaxError"] } } { "stdout": { "data": "[10, 11, 12]", "formatting": "normal" }, "stderr": { "data": { "data": "ReferenceError: x is not defined", "formatting": "normal" } } } ``` ``` stdout: hi stderr: bye formatting: (normal, red) { stdout: stderr: } ``` --- Thanks Red! Wait, but please still do yours! Just wanted to note my thoughts before I take a quick break to watch Joshie (brother), lol my typing is getting so slow No problem :p And mine before I go for ~10 mins: ```json { // imperative "format":_, "stdout":_, "stderr":_, "misc": { ... }, // ideas "state":_, "debug":_, // some other stuff for repl-based things // for now we'll do "repl": { ... } } ``` --- I'm over here! At the bottom. Can you see me? Yep! Wahooo :)) So, I was thinking maybe we could use Go for the `start` script. And I was also thinking we could make a single multi-purpose start script, and pass in instructions about what to run based on the requested language So like, we'd have a JSON object that looks something like this: { "run": "python3 code.py", "outputJSON": {...} } Can you remind me also, precisely, what exactly the start script does, please? Yeah. It takes the `outputJSON` from the client, and runs the interpreter within the container/sandbox. So like, for Python, it'd take the code and input and run something like `python3 code.py < input` Got it, thanks! I just have to refresh on the outputJSON for a quick sec. Me too, actually Damn. It's amazing how much you can forget. I'm wondering if I should start trying to add some of the basic feature we'll need for repl support, or at least places in the library where support for repls can be easily added --- Okay, in here! I'm here! Hi hi!! So, I can't remember a single thing, you start! ## Template Features? Start File stuff - Interpreted: `[interpreter] code < input` - Compiled: `[compiler] code && ./compiled < input` We'd likely need ways for the language adder to specify what commands are needed to do those steps and what format they follow. E.g., `gcc -o compiled code.c` A few examples would be enough though, right? Oh wait, I was thinking of the templates being pre-compiled so you'd essentially just drop them into a folder with the interpreter It's a lot easier for us if we require them to compile themselves after adding the correct command format It gets compiled? I thought it ran like: `node start.js` Oh, right! Go also has an interpreted thing for what it's worth. `go run main.go` Same disadvantages as node though; you need the whole Go interpreter Oh, I see. You want an executable. Right, that aside, I was still thinking we'd just provide example files, and they would compile it on their own so like: ``` start.go 1 ... 2 ... 23 python3 code < input 99 ... ``` So this would be our template. And then they'd go in and change line 23 to `node code < input`, and build that. So we wouldn't have to worry about all the parameters and stuff they might want to change. We'd just give them several examples. I'd rather not make them download Go though...maybe some sort of config could be passed to a single Go script? Does Python come installed in the containers? No, but it's not as big Okay, just a second. We're thinking about these templates totally differently. I thought they were gonna want to do loads of customizations, for some reason. So in my mind, these templates were *examples* for them to work off, and put together different elements from different examples that they wanted. But that all depends on how many things they No no, no need! It just depends on how much customizing stuff we come up with. I think there's way less than I thought, in which case we can totally do a config file, and we'll do the heavy lifting for them that way. What I was thinking was just nice if there were like a million and one different things they could do with the start file. Haha, true! I sense an esolang... I think that'd be great then honestly. If we're gonna make examples, we should probably make most of them in Python. You mean in terms of languages, right? Yeah Yeah, for sure. There's no limit on how many langs we can give them! But in terms of what I want to prioritize, I want to work on the base starts for "power-users" like us. The config and pre-compiled stuff will be easier to do later. So when I put templates, really what I meant are what are some neat examples/features we want to demo in a start file, that I can get cracking on after I have the basic one translated! ## Examples - Additional debug info (timing, cpu usage, etc.) - Library usage (numpy) - Possibly, but not sure if that goes in `start` necessarily - That's fine for now. If it *could* go in start, I'll add it to start - Different cell/tape sizes for brainfuck (probably just command line options to a Python or JS based interpreter that can handle that) - Coloring STDERR red True, okay so far, simplified, we have: - change outputJSON - add other files/libraries - change inputJSON Honestly there's not much "creativity" possible/necessary in the start files tbh. They should really just do one job, and do it well. I was thinking in terms of colors, other odd stuff, or like what I'm doing What I'm doing would send back visual information I thought there might be toher things like that we could give them to toy with That's true Will you be online tomorrow? Actually...why not have a couple dozen base `start`s? We could start with just Python and Go, and work our way up over time. That way people can choose between writing their own off of our template, or using a precompiled one with a config Python appears to be 40 MB or so. A bare alpine install is 6 MB, so it's not tiny, but not that bad either. 40 MB _definitely_ won't make a speed difference, or use up an amount of disk space worth even thinking about. Nothing stops them from writing their own start file, ours would just be one option. In theory, they could even design a language that just happens to take I/O with `inputJSON` and `outputJSON` and they wouldn't need a `start` at all I see what you mean, yeah. Maybe we could do both? True, which is why I thought we'd have start.py, and others. But I didn't realize we'd want the compiled bit. I wonder how much of this could be done with sh... Oh, I'm thinking of Go Node's pretty big, so it won't be packaged with most of our base languages Idea: The Go script calls a shell script, maybe? --- --- --- --- # Final Stuff ## Input ```json // Input { "format": Number, "language": String, "interpreter": Any, "code": String, "input": String, "options": _, // flags/args "misc": { ... } // settings } ``` ## Output ```json // Output { "format": Number, "finished": Boolean, "data": Data[] } ``` ```json // Data { "id": String, "data": DataFormat OR DataFormat[], "collapse": Number } ``` ```json // DataFormat { "id": String, "data": String, "formatting": String } ``` ## Todo * `outputJSON` validation (confirm_output in json_parser.js) * repl * Python image * write steps for making it * Background pre-loaded containers for common langs * make it really easy to add your own esolang * function vs stdin/stdout * if interpreter/compiler is written in language we already host-- make that even easier * make it easy to add an existing language * write a bash script so you download the thingy, run the script and you're good to go * add command to pre-load container for a language * priveleged users (maybe cgcc with rep > n) * general interactive stuff ## Progress `ws.js` has been refactored into four classes: - `WS`: Handles WS server itself, and spawns `Conn`s for each connection - `Conn`: Handles I/O with WS connections, pinging, and some other useful abstractions - `Actor`: Abstracts away what `Conn` you're dealing with - Allows for: - Reconnecting when a WS is dropped (due to network issues) - Adding an API in addition to WS - Preloading containers - `Cast`: Manages `Actor`s, pinging ## Output 2 ```json { "format": 0, "data": { "a": "abc\nxyz", "b": ["abc\n", "xyz"], "c": "", "d": [] } } ``` ## `start` Features needed: - Run normal code - Run code in a language based

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully