Skip to content

Instantly share code, notes, and snippets.

@gligneul
gligneul / blocktracker.py
Last active June 25, 2026 15:18
Track an Ethereum chain's latest block number and its sync rate
#!/usr/bin/env python3
"""Track an Ethereum chain's latest block number and its sync rate.
Polls eth_blockNumber once a second from the given JSON-RPC endpoint, shows the
latest block in place (overwriting, not scrolling), and derives blocks/sec,
blocks/min, and blocks/hour from the last N samples.
Usage:
python blocktracker.py https://my-node:8545
python blocktracker.py https://my-node:8545 --interval 1 --window 60
@gligneul
gligneul / main.go
Created October 2, 2025 17:46
Subscript to Ethereum RPC and get logs
package main
import (
"context"
"flag"
"fmt"
"log/slog"
"net/url"
"os"
"math/big"
@gligneul
gligneul / colorlog.go
Last active December 27, 2023 20:15
colorlog.go
// Copyright (c) Gabriel de Quadros Ligneul
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)
// This module implements a colored log handler for log/slog.
//
// For more details on a custom handler implementation, check:
// - https://github.com/golang/example/tree/master/slog-handler-guide
package colorlog
import (
@gligneul
gligneul / services.go
Last active September 25, 2023 22:49
// Example of a simple supervisor that start multiple services in different goroutines
package main
import (
"context"
"fmt"
"time"
)
// service.go
@gligneul
gligneul / mcjit.cpp
Created January 19, 2016 01:49
LLVM MCJIT Code Samples (Working!)
/*
* LLVM 3.5 code sample using MCJit
*
* To compile, execute on terminal:
* clang++ -o mcjit mcjit.cpp `llvm-config --cxxflags --ldflags --libs all --system-libs`
*/
#include <iostream>
#include <memory>