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
struct $ { | |
$ (*$)($*); | |
}; | |
$ d($* x) { | |
return *x; | |
} | |
int main() { | |
$ d = {::d}; |
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 <concepts> | |
// version with static bounds on the dimensions | |
template <typename T, std::size_t... DIMS> | |
struct vec { | |
template <std::convertible_to<std::size_t>... Is> | |
requires (sizeof...(Is) == sizeof...(DIMS)) | |
T operator[](Is... indices) { return {}; } | |
}; |
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 <functional> | |
#include <mutex> | |
#include <shared_mutex> | |
#include <tuple> | |
#include <unordered_map> | |
#include <boost/container_hash/hash.hpp> | |
template <class> |
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
/* | |
* Written by Joshua Saxby ("saxbophone") 2023-03-14 -- saxbophone.com | |
* | |
* This demonstration program for how to derive max/min "safe" integers for | |
* conversion to and from floating point is hereby released into the public domain. | |
*/ | |
#include <limits> // numeric_limits | |
#include <type_traits> // make_signed |
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 <climits> | |
unsigned detect_overflow(unsigned x) { | |
auto old_x = x++; | |
if (old_x > x) { | |
std::cerr << "Overflow occurred: " << x - 1 << " -> " << x << std::endl; | |
} | |
return x; | |
} |
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
sudo apt-get install libx11-dev libxrandr-dev libudev-dev libfreetype-dev libopengl-dev libflac-dev libogg-dev libvorbis-dev libvorbisenc2 libvorbisfile3 libopenal-dev |
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
echo "b" > file.txt; | |
while [[ true ]]; do | |
xz -9e -T 0 -k -v -c file.txt > /dev/null; | |
cat file.txt file.txt > new.txt; | |
mv new.txt file.txt; | |
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
# Created by Joshua Saxby 2022 | |
# This BASH shell script function is placed into the Public Domain | |
# There are no restrictions on its use but it is provided with ABSOLUTELY no liability, warranty, etc, etc... | |
# !!don't sue me for using it at your own risk...!! | |
# uses the new version of the former gitignore.io API to generate gitignore files for given languages | |
# usage: $ gitignore <lang 1> <lang 2> ... <lang n> | |
# | |
# NOTE: overwrites local .gitignore file in-place |
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
Context global_context; | |
while (I.am_operational()) { | |
Action current_course; | |
// 2) A robot must obey humans | |
while (I.have_pending_human_commands()) { | |
current_course.add_human_command(global_context, I.human_commands.pop()); | |
} | |
// 3) A robot should protect itself | |
if (I.anticipate_harm_to_self(global_context)) { |
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> | |
template <std::size_t ID> | |
struct coroutine_imp { | |
enum class stage { FIRST, SECOND, THIRD, }; | |
int run() { | |
static stage s = stage::FIRST; | |
switch (s) { | |
case stage::FIRST: | |
s = stage::SECOND; |