This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mutex> // locks | |
#include <shared_mutex> // shared_mutex | |
#include <utility> // exposing structured-binding support for SynchroniseAll | |
template <typename T> | |
class Synchronised { | |
public: | |
using Mutex = std::shared_mutex; | |
using ReadOnlyLock = std::shared_lock<Mutex>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstddef> | |
// #include <cstdint> | |
#include <concepts> | |
#include <type_traits> | |
#define FUSE_USE_VERSION 29 | |
#define _FILE_OFFSET_BITS 64 | |
#include <fuse.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename Predicate, typename Body> | |
constexpr void While(Predicate pred, Body body) { | |
goto predicate; | |
loop: | |
body(); | |
predicate: | |
if (pred()) { goto loop; } | |
} | |
template <typename Body, typename Predicate> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <array> | |
#include <cstdint> | |
#include <iostream> | |
#include <string> | |
std::byte storage[10'000]; | |
int main() { | |
uint32_t* x = new(&storage[0]) uint32_t{1234}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#pragma pack(push, 1) | |
struct Chunk { | |
char32_t first : 21; | |
char32_t second : 21; | |
char32_t third : 21; | |
operator std::u32string() const { | |
return {first, second, third}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time CC=gcc-10.2 CXX=g++-10.2 cmake -S ../llvm-project/llvm -B build -DCMAKE_BUILD_TYPE=Release | |
-DLLVM_PARALLEL_COMPILE_JOBS=4 -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_ENABLE_RUNTIMES="" -DLLVM_ENABLE_PROJECTS=clang | |
-DLLVM_CCACHE_BUILD=ON -DLLVM_ENABLE_EH=ON -DLLVM_ENABLE_LTO=On -DLLVM_ENABLE_RTTI=ON -DLLVM_INCLUDE_TESTS=OFF | |
-DLLVM_LINK_LLVM_DYLIB=ON -DCMAKE_C_FLAGS_RELEASE="-O3 -march=native" -DCMAKE_CXX_FLAGS_RELEASE="-O3 -march=native" | |
-DLLVM_ENABLE_LIBXML2=OFF -DCMAKE_CXX_STANDARD=20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <regex> | |
#include <string> | |
int main() { | |
std::regex find_undefs{"(?:#undef\\s+)([_A-z][_0-9A-z]*)"}; | |
std::cout << std::regex_replace("#undef _1FOO_BAR_BAZ1234_", find_undefs, "#cmakedefine $1 1") << std::endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mutex> | |
#include <shared_mutex> | |
#include <type_traits> | |
// TOOD: reïmplement all methods non-inline so the prototype is nice and readable | |
template <typename T> | |
class Seizable { | |
public: | |
// TODO: change to std::shared_timed_mutex and add additional time-based locking methods |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git ls-remote --tags --refs --sort='v:refname' https://github.com/llvm/llvm-project.git | while read -r line; do | |
sha=$(echo $line | awk '{print substr($1, 1, 8)}'); | |
ref=$(echo $line | awk '{print $2}'); | |
b91=$(echo $sha | xxd -r -p | base91); | |
echo "$sha = $b91 ($ref)"; | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstddef> | |
#include <numeric> | |
#include <random> | |
#include <stdexcept> | |
#include <vector> | |
class LotteryMachine { | |
public: | |
LotteryMachine(std::size_t number_of_balls) |
NewerOlder