Skip to content

Instantly share code, notes, and snippets.

@MarekKnapek
MarekKnapek / cpp
Created May 13, 2024 00:24
quick_and_dirty_test_of_bcomp.cpp
#include <string.h>
#define crash(x) do{ if(!(x)){ __debugbreak(); int volatile* volatile ptr; ptr = 0; *ptr = 0; } }while(false)
#define min(a, b) (((b) < (a)) ? (b) : (a))
void test_1(unsigned char const* const data, size_t const size) noexcept
{
uint8_t state[256];
struct bcomp_state state_out;
uint16_t bcomp_bits;
@MarekKnapek
MarekKnapek / mkcc-performance.md
Created November 24, 2023 16:13
mkcc-performance
@MarekKnapek
MarekKnapek / fib500.c
Last active November 20, 2023 04:55
Fib500
#define mk_lang_jumbo_want 1
/* You need my library from https://github.com/marekKnapek/mk_clib for this. */
#include "mk_sl_uint32.h"
#include "mk_lang_div_roundup.h"
#define mk_sl_cui_t_name big_fib
#define mk_sl_cui_t_base mk_sl_cui_uint32
#define mk_sl_cui_t_count mk_lang_div_roundup(346, 32)
#include "mk_sl_cui_inl_fileh.h"
#include "mk_sl_cui_inl_filec.h"
@MarekKnapek
MarekKnapek / five_million.c
Created November 9, 2023 02:09
Five Million Digit Number
/* you need my library from */
/* https://github.com/MarekKnapek/mk_clib */
/* https://www.reddit.com/r/C_Programming/comments/17qgg6u/storing_extremely_large_numbers_in_c/ */
#define mk_lang_jumbo_want 1
#include "mk_lang_charbit.h"
#include "mk_lang_sizeof.h"
@MarekKnapek
MarekKnapek / blake3.cpp
Created August 14, 2023 02:36
BLAKE3 constexpr
#include "mk_lib_crypto_hash_stream_blake3.h"
#include <array> /* std::array */
#include <string_view> /* std::string_view */
constexpr auto blake3_constexpr(std::string_view const& str_a, char const& char_a, std::string_view const& str_b, char const& char_b)
{
mk_lib_crypto_hash_stream_blake3_t hash{};
std::size_t i{};
@MarekKnapek
MarekKnapek / increment.cpp
Last active May 28, 2021 15:37
const vs non-const in post increment operator
#define WANT_CONST 1
#include <cstdio>
class my_type
{
public:
my_type() noexcept;
@MarekKnapek
MarekKnapek / imports.cpp
Last active June 19, 2020 20:39
imports
// ========== ==========
// library begin
// ========== ==========
#include <algorithm> // min
#include <array> // array
#include <cassert> // assert
#include <cstdint> // uint64_t, uint32_t, uint16_t, uint8_t, uintptr_t
#include <cstdlib> // abort
@MarekKnapek
MarekKnapek / APISet.csv
Last active January 17, 2020 18:05
APISet, comma separated values, open in Excel.
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 1 column, instead of 3. in line 2.
"Windows 7 64bit (amd64), version 6.1.7601."
"apisetschema.dll version 6.1.7601.24499."
"MS-Win-Core-Console-L1-1-0","","kernel32.dll"
"MS-Win-Core-DateTime-L1-1-0","","kernel32.dll"
"MS-Win-Core-Debug-L1-1-0","","kernelbase.dll"
"MS-Win-Core-DelayLoad-L1-1-0","","kernel32.dll"
"MS-Win-Core-ErrorHandling-L1-1-0","","kernel32.dll"
"MS-Win-Core-ErrorHandling-L1-1-0","kernel32.dll","kernelbase.dll"
"MS-Win-Core-Fibers-L1-1-0","","kernelbase.dll"