Skip to content

Instantly share code, notes, and snippets.

View renatoalencar's full-sized avatar
🍵
Smashing the stacks

Renato Alencar renatoalencar

🍵
Smashing the stacks
View GitHub Profile
diff --git a/src/dune b/src/dune
index 2ba2d36..d9e8e57 100644
--- a/src/dune
+++ b/src/dune
@@ -1,7 +1,6 @@
(library
(name binaryen)
(public_name binaryen)
- (libraries libbinaryen.c)
(foreign_stubs
@renatoalencar
renatoalencar / compile.ml
Created September 18, 2022 18:42
Michelson to Grain
module Result_let_syntax = struct
let (let*) = Result.bind
let (let+) a f = Result.map f a
end
module Parse = struct
open Tezos_micheline
module MPrim = Michelson_v1_primitives
@renatoalencar
renatoalencar / ticket.tz
Created May 18, 2022 19:06
Deku ticket contract compiled
{ parameter
(pair (pair (address %deposit_address) (bytes %hash_)) (address %vault_address)) ;
storage nat ;
code { PUSH mutez 0 ;
AMOUNT ;
COMPARE ;
EQ ;
IF {} { PUSH string "failed assertion" ; FAILWITH } ;
UNPAIR ;
UNPAIR ;
@renatoalencar
renatoalencar / lib.c
Created April 29, 2022 15:52
Exploring OCaml values internals
#include <stdio.h>
#include <ctype.h>
#include "caml/mlvalues.h"
char* tag_repr(int tag) {
switch (tag) {
case Custom_tag:
return "Custom_tag";
case Double_array_tag:
return "Double_array_tag";
@renatoalencar
renatoalencar / test.patch
Created March 4, 2022 19:11
Deku Lambda VM test cases
diff --git a/esy.lock/index.json b/esy.lock/index.json
index 472c19f2..950f6e8f 100644
--- a/esy.lock/index.json
+++ b/esy.lock/index.json
@@ -1,5 +1,5 @@
{
- "checksum": "06f9f237cf9dd0acc2174a26407cd7c3",
+ "checksum": "9d0b0d7d646f14d07c9584a66e8ae6a9",
"root": "sidechain@link-dev:./package.json",
"node": {
@renatoalencar
renatoalencar / a.patch
Created December 31, 2021 01:35
OCaml bad c object patch for windows
From ff156d75ef825155fc6877d47ff9d067fee61cca Mon Sep 17 00:00:00 2001
From: Renato Alencar <renatoalencar.73@gmail.com>
Date: Fri, 31 Dec 2021 01:19:46 +0000
Subject: [PATCH] Change tests to adapt to the new behavior
This is not ideal yet, but it gives a better idea
of what's really happening and what behavior
has broken when the previous change was introduced.
The command `ocamlopt -output-obj main_obj.o dynlink.cmxa
@renatoalencar
renatoalencar / x.md
Created December 30, 2021 20:49
Compiling OCaml on Windows

Install cygwin and add the following packages

  • cygwin
  • diffutils
  • make
  • mingw64-i686-gcc-core
  • mingw64-i686-runtime

./configure --build=i686-pc-cygwin --host=i686-w64-mingw32 --disable-dependency-generation

@renatoalencar
renatoalencar / socks4.ml
Last active December 11, 2021 12:17
Socks4 and socks5
type version = Socks4
type command = Connect | Bind
type port = int
type request = { version: version
; command: command
; destport: port
@renatoalencar
renatoalencar / day01.ml
Last active October 31, 2023 13:47
Advent of Code 2021 Solutions in OCaml
let read_lines () =
let rec aux lines =
try
let line = input_line stdin in
aux @@ line :: lines
with End_of_file ->
lines
in
List.rev @@ aux []
@renatoalencar
renatoalencar / traversal.js
Last active December 3, 2021 15:34
React fiber tree traversal
let root = $0._reactRootContainer._internalRoot
let node
let count
let map
node = root.current
count = 0
map = new Map()