Skip to content

Instantly share code, notes, and snippets.

Avatar
🛠️
ars longa vita brevis

Leandro Ostera ostera

🛠️
ars longa vita brevis
View GitHub Profile
View lib.rs
use anyhow::{anyhow, Context, Error};
use std::fmt;
mod ffi;
#[derive(Clone, Debug)]
pub enum Sexp {
Atom(String),
List(Vec<Sexp>),
Nil,
View gist:5578ff23639418a89feec832156b6cef
./node_modules/.bin/prettier --write grammar.js
grammar.js 61ms
tree-sitter generate
tree-sitter test
s_expressions:
✗ atom
✓ empty
✓ single line
✓ multiple parts
✓ nested s-expressions
View start.js
import load_lam from "./fib.js";
import run_js from "./fib_in_js.js";
document.onclick = () => {
run_js().then((_) => load_lam().then(lam => {
const run = () => {
lam.step();
requestAnimationFrame(run);
}
View fib.erl
-module(fib).
-export([main/1]).
-export([add_entry/2]).
add_entry(_, _) -> ok.
fib(_, _, _, _) -> ok.
main(_) -> fib([], 1000, 1, 0).
View fib.erl
-module(fib).
-export([main/1]).
add_entry(DomNode, Text) ->
NewNode = dom_document:create_element(<<"div">>),
dom_element:set_inner_text(NewNode, Text),
dom_element:append_child(DomNode, NewNode).
fib(DomNode, N, B, A) ->
View fib_in_js.js
let root = document.getElementById("js");
let t0 = Date.now();
let startedAt = document.createElement("div");
startedAt.innerText = "Started at: "+Date.now();
root.appendChild(startedAt)
let node = document.createElement("div");
node.innerText = "unstarted"
root.appendChild(node)
View grep.S
{module, grep}. %% version = 0
{exports, [{main,1},{module_info,0},{module_info,1}]}.
{attributes, []}.
{labels, 24}.
{function, print_matches, 3, 2}.
View grep.S
{module, grep}. %% version = 0
{exports, [{main,1},{module_info,0},{module_info,1}]}.
{attributes, []}.
{labels, 24}.
{function, print_matches, 3, 2}.
View grep.erl
% Source code generated with Caramel.
-module(grep).
-export([main/1]).
print_matches(Word, [Word | T], File) ->
io:format(<<"~p: ~p\n">>, [File, Word]),
print_matches(Word, T, File);
print_matches(Word, [_ | T], File)->
print_matches(Word, T, File);
View config.ml
open Rresult
open Sexplib0.Sexp
let parse root_path =
let read_config path =
let root_path = path |> Fpath.to_dir_path |> Fpath.normalize in
let odot_file = Fpath.append root_path Model.config_file in
Bos.OS.File.read odot_file
in