Skip to content

Instantly share code, notes, and snippets.

View Raimo33's full-sized avatar
๐ŸŒŽ

Raimo Raimo33

๐ŸŒŽ
View GitHub Profile
@Raimo33
Raimo33 / .clang-format
Last active June 4, 2024 19:39
c++ formatting
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: Always
BreakBeforeBraces: Custom
AllowShortIfStatementsOnASingleLine: true
ColumnLimit: 0
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
@Raimo33
Raimo33 / Makefile
Last active June 21, 2024 08:52
Makefile Standard (c++)
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: craimond <bomboclat@bidol.juis> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/04/26 15:33:59 by craimond #+# #+# #
# Updated: 2024/06/21 10:51:48 by craimond ### ########.fr #
# #
@Raimo33
Raimo33 / Makefile
Last active December 22, 2024 23:16
Docker Compose Makefile
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: craimond <bomboclat@bidol.juis> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/08/06 01:09:08 by craimond #+# #+# #
# Updated: 2024/09/15 14:24:42 by craimond ### ########.fr #
# #
@Raimo33
Raimo33 / strtolower.c
Last active March 3, 2025 19:48
SIMD strtolower
//TODO find a way to make them const, forcing prevention of thread safety issues, constexpr??
#ifdef __AVX512F__
static __m512i _512_vec_A_minus_1;
static __m512i _512_vec_case_range;
static __m512i _512_add_mask;
#endif
#ifdef __AVX2__
static __m256i _256_vec_A_minus_1;
static __m256i _256_vec_case_range;
@Raimo33
Raimo33 / pre-commit
Last active March 22, 2025 10:23
Header pre-commit
#!/usr/bin/env python3
import os
import subprocess
import datetime
import re
CREATOR_NAME = "Claudio Raimondi"
CREATOR_EMAIL = "claudio.raimondi@pm.me"
HEADER_WIDTH = 80
@Raimo33
Raimo33 / sort.c
Created April 4, 2025 17:32
branchless list sort
/*
description:
takes pointers to the head and tail of the singly-linked list.
sorts the list in ascending order by ASCII value.
implementation:
use of mergesort because linked lists inherently don't provide random access. could be bypassed by constructing an array of pointers but that's a poor design choice O(n)...
merge sort is the fastest known sorting algo for linked lists, even though finding the midpoint is O(n/2) = O(n).
use of the slow-fast pointer technique to find the midpoint of the list. same performance as the doubly-linked list -> <- approach.
implemented by changing pointers, even though a char is 1 byte and easier to copy, for better mantainability, reusability, and standard compliance.
template <typename T, typename Comparator>
HOT ssize_t forward_lower_bound(std::span<const T> data, const T elem, const Comparator &comp) noexcept
{
static_assert(std::is_integral<T>::value, "T must be an integral type");
static_assert(std::hardware_constructive_interference_size == 64, "Cache line size must be 64 bytes");
static constexpr uint8_t chunk_size = sizeof(__m512i) / sizeof(T);
const T *begin = data.data();
const size_t size = data.size();
size_t remaining = size;
@Raimo33
Raimo33 / find_throwing_benchmarks.sh
Last active October 18, 2025 15:32
Find Throwing Bitcoin Core Benchmarks
#!/usr/bin/env bash
set -u
out_file="benchmarks_throwing_exception.txt"
log="$(mktemp)"
mapfile -t benches < <(./build/bin/bench_bitcoin --list)
rm -f "$out_file"
#!/usr/bin/env bash
set -e
N=${1:-1}
FILTER=${2:-}
TIME=${3:-}
CURRENT_COMMIT=$(git rev-parse HEAD)
COMMITS=$(git rev-list --max-count="$N" --reverse HEAD)
@Raimo33
Raimo33 / test_commits.sh
Last active October 24, 2025 13:44
Test the previous N commits sequentially (Bitcoincore)
#!/usr/bin/env bash
set -e
N=${1:-1}
CURRENT_COMMIT=$(git rev-parse HEAD)
COMMITS=$(git rev-list --max-count="$N" --reverse HEAD)
trap 'git checkout -q "$CURRENT_COMMIT"' EXIT SIGINT SIGTERM