Skip to content

Instantly share code, notes, and snippets.

View edwintorok's full-sized avatar
💭
I may be slow to respond.

Török Edwin edwintorok

💭
I may be slow to respond.
View GitHub Profile
#use "topfind";;
#require "lwt.unix";;
Sys.set_signal Sys.sigusr1 (Sys.Signal_handle (fun _ ->
Printexc.get_callstack 100 |> Printexc.raw_backtrace_to_string |> prerr_endline;
flush stderr
));;
[{"pid":3534168,"cat":"trace","id":0,"tid": 0,"ts": 7862803348666.37,"name":"run_fiber","ph":"b","args": {"function":"Picos_mux_deterministic.run_fiber"}},
{"pid":3534168,"cat":"trace","id":0,"tid": 0,"ts": 7862803348677.76,"name":"run_fiber(rec)","ph":"b","args": {"function":"Picos_mux_deterministic.run_fiber"}},
{"pid":3534168,"cat":"trace","id":0,"tid": 0,"ts": 7862803348679.21,"name":"current","ph":"b","args": {"function":"Picos_mux_deterministic.handle"}},
{"pid":3534168,"cat":"trace","id":0,"tid": 0,"ts": 7862803348680.52,"name":"yield","ph":"b","args": {"function":"Picos_mux_deterministic.handle"}},
{"pid":3534168,"cat":"","tid": 0,"ts": 7862803348691.07,"name":"q(1)","ph":"I"},
{"pid":3534168,"cat":"","tid": 0,"ts": 7862803348696.29,"name":"q(0)","ph":"I"},
{"pid":3534168,"cat":"trace","id":0,"tid": 0,"ts": 7862803348846.11,"name":"current","ph":"e"},
{"pid":3534168,"cat":"","tid": 0,"ts": 7862803348854.17,"name":"q(1)","ph":"I"},
{"pid":3534168,"cat":"","tid": 0,"ts": 7862803348859.43,"name":"q(0)","
@edwintorok
edwintorok / gist:f7ccb146471cfb17b2e92510b8c12bd0
Last active July 14, 2024 21:33
Fuzzing the OCaml runtime

Notes on how to run the fuzzer (not included in the PR, but for future reference): On Fedora39 (Fedora40 afl packages are a bit broken, I'll open a bug):

export AFL_USE_ASAN=1
export ASAN_OPTIONS="detect_leaks=0,use_sigaltstack=0"
./configure CC=afl-clang-fast 'CFLAGS=-Og -g -fno-omit-frame-pointer'
make -j32
@edwintorok
edwintorok / Makefile
Last active March 10, 2024 10:30
hledger-flow example
.PHONY: all clean
all: all-years.journal
clean:
rm -f all-years.journal
find import -name _manual_ -prune -o -name 1-in -prune -o -type f \( -name '*.journal' -o -name '*.csv' \) -print0 | xargs -0 rm -f
SOURCES=directives.journal
SOURCES+=$(wildcard import/me/_manual_/*/*.journal)
SOURCES+=$(wildcard prices/*/*.journal)
declare -a FILES
FILES=(comments document fontTable footnotes numbering settings styles theme1 webSettings)
if [ "$1" != "" ]; then
rm ./tmp -rf
unzip -o -j "$1" -d "./tmp"
for i in ${FILES[@]}; do
xmllint --format "./tmp/${i}.xml" > "./tmp/${i}-pretty.xml"
done
fi
#!/usr/bin/env python3
from docx import Document
from docx.oxml import ns
from docx.oxml.table import CT_TblWidth
from docx.oxml.shared import OxmlElement
from docx.oxml.ns import qn
# From python-docx _tag_seq
tag_seqs = (
(
dotnet restore
dotnet build --configuration Release --no-restore
dotnet OOXMLValidatorCLI/bin/Release/net6.0/OOXMLValidatorCLI.dll ../../reference.docx | json_reformat
otnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.125
Commit: e898a826c2
Runtime Environment:
#!/usr/bin/env bash
if [ "$1" != "" ]; then
unzip -o -j "$1" -d "./tmp"
xmllint --format "./tmp/document.xml" > "./tmp/document-pretty.xml"
xmllint --format "./tmp/styles.xml" > "./tmp/styles-pretty.xml"
xmllint --format "./tmp/settings.xml" > "./tmp/settings-pretty.xml"
fi
xmllint -noout -nonet -debugent \
#!/bin/sh
# to be run as root
# See https://llvm.org/docs/Benchmarking.html and https://docs.kernel.org/admin-guide/pm/amd-pstate.html
# Disable ASLR
echo 0 > /proc/sys/kernel/randomize_va_space
# Need to disable turbo boost, only know how to do that if it is set to passive
echo passive >/sys/devices/system/cpu/amd_pstate/status
cpupower frequency-set -g performance
let base = Char.code '0'
let rec string_of_int_rec b i n =
let i = i - 1 in
Bytes.unsafe_set b i (Char.unsafe_chr (base + n mod 10));
let n = n / 10 in
if n = 0 then i
else string_of_int_rec b i n
let int_min_str = string_of_int min_int