Skip to content

Instantly share code, notes, and snippets.

@kouloumos
kouloumos / generated-probes-freebsd.h
Created May 30, 2023 07:56
`dtrace -h -s <(git show df714d1e1c8bc7f1aa7803e1d55fd3fc9dc3b52d:src/util/probes.d) -o /tmp/probes.h` on freebsd 12 and 14 by vasild
/*
* Generated by dtrace(1M).
*/
#ifndef _PROBES_H
#define _PROBES_H
#include <unistd.h>
#ifdef __cplusplus
@kouloumos
kouloumos / attach_helper.py
Created May 17, 2023 08:23
Custom gdb command to waitfor and attach on a process
'''
To make this file available to your gdb process:
2. (gdb) source attach_helper.py
To use the custom command:
1. `attach_bitcoind` to make the debugger wait for a bitcoind process to attach on
2. Start bitcoind (e.g a functional test from another terminal)
3. Debug
'''
@kouloumos
kouloumos / generate_flamegraph.sh
Created August 4, 2022 08:38
Flamegraph generation using DTrace
#!/bin/bash
# This script generates flame graphs by using DTrace to sample the active stack frames of the
# specified process and then https://github.com/brendangregg/FlameGraph to convert the
# stack traces into the flame graph.
# Note: On all current MacOS versions System Integrity Protection (SIP) is enabled by default and
# prevents most uses of dtrace. The usual way to make dtrace work on MacOS is to boot into
# recovery mode and disable some of the SIP protections with `csrutil enable --without dtrace`
# Usage:
@kouloumos
kouloumos / generated-probes-mac.h
Last active April 7, 2023 08:47
`dtrace -h -s probes.d -o probes.h` on macos
/*
* Generated by dtrace(1M).
*/
#ifndef _PROBES_H
#define _PROBES_H
#if !defined(DTRACE_PROBES_DISABLED) || !DTRACE_PROBES_DISABLED
#include <unistd.h>
@kouloumos
kouloumos / calculate-fees.js
Created March 25, 2022 19:11
Liquid Fees calculation
import fetch from "node-fetch";
const START_BLOCK = 1247561; // 2021-03-25 21:00
const END_BLOCK = 1761444; // 2022-03-25 21:00
const calculateBlockFees = async (blockHash) => {
const response = await fetch(
`https://liquid.network/api/block/${blockHash}/txs`
);
const txs = await response.json();