Skip to content

Instantly share code, notes, and snippets.

View pps83's full-sized avatar

Pavel P pps83

View GitHub Profile
@pps83
pps83 / umul128.cpp
Last active February 13, 2025 06:07
umul128
#include <stdint.h>
#include <intrin.h>
// based on XXH_mult64to128 from xxHash https://github.com/Cyan4973/xxHash/blob/dev/xxhash.h#L4464
uint64_t umul128(uint64_t x, uint64_t y, uint64_t* hi)
{
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__wasm__) \
&& defined(__SIZEOF_INT128__) \
|| (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 128)
// gcc/clang __uint128_t
@pps83
pps83 / fix-line-endings.sh
Last active March 27, 2025 01:14
Bash script to rewrite git history of a master branch making sure that line endings are changed to LF
#use https://github.com/newren/git-filter-repo
git-filter-repo --file-info-callback '
contents = value.get_contents_by_identifier(blob_id)
ext = filename.lower().split(b".")[-1]
if ext not in [b"c", b"cpp", b"h", b"hpp"] or \
value.is_binary(contents):
# Make no changes to the file; return as-is
return (filename, mode, blob_id)
# By default, enforce LF line-endings on all text files
* text=auto eol=lf
*.c text eol=lf
*.h text eol=lf
*.cpp text eol=lf
*.hpp text eol=lf
# Visual Studio
*.sln eol=crlf
*.vcxproj eol=crlf