Skip to content

Instantly share code, notes, and snippets.


I think about wanting to play with one of the C/C++ killers (rust, nim, zig, odin, jai if it ever sees wide release, etc.) I get excited about many safety nets and advanced features I could benefit from. I <3 the comptime keyword in Zig

And then I think about the side projects I want to work on, and how so many involve C++-only libs or are made easier by using the C++ version of libs (i.e. ImGui, Wwise, bgfx) and I really don't want to spend my free time writing C wrappers to make ffi easier.

And then I think about how I want to work on either my macbook or my windows desktop, so just getting something going means spending time fucking around with the current crop of meta build systems because I can't stomach defaulting to cmake

And so rather than deal with this I go and watch anime or whatever.

It's the concept of "programming war crimes" yet again. How many interesting projects or research breakthroughs don't happen because the person who would have made them happen decided it wasn't worth the incident

michaelbartnett / premake.lua
Created Feb 25, 2020
list of xcode warnings it complained about bc premake5's xcode generator is out of date
View premake.lua
xcodeprojectopts {
View NullTest.cs
using UnityEngine;
interface ISomeInterface
public class TestScript : MonoBehaviour, ISomeInterface
View enumflags.hpp
#include <type_traits>
#include <cstdint>
#include <iostream>
template<typename T_ENUM>
class EnumFlags
static_assert(std::is_enum<T_ENUM>::value, "T_ENUM must be an enum type");
michaelbartnett / enumshit.cpp
Created Feb 6, 2019
enums with max and string
View enumshit.cpp
template<typename Enum>
constexpr Enum get_enum_max()
//static_assert(false, "missing get_enum_max implementation");
return ~0;
template<typename Enum>
const char *get_enum_member_name(Enum val);
// {
michaelbartnett / better_narrowing.cpp
Last active Jan 17, 2019
truly horrible constepxr function template for narrowing numeric conversions. doesn't allow conversions between integral and floating point. -std=c++11 and -fno-exceptions compatible. the worst.
View better_narrowing.cpp
// what a mess
template<typename TOut, typename TIn>
constexpr TOut narrowed(TIn&& inp) noexcept
return static_cast<TOut>(inp);
#define NARROWED(TOut, expr) static_cast<TOut>(expr)
View meh_narrowing.hpp
#include <type_traits>
#include <assert>
// debug = gsl::narrow, release = gsl::narrow_cast
namespace util
template <class T, class U>
constexpr T narrowcast(U&& u) noexcept
View prototype_tool_screenshot.png
I tried to make a thing once that could ingest a folder of json/xml/whatever files, infer
a type schema from them, and then give you a spreadsheet style table editor.
The idea was it would infer a schema from the data, or from analyzing your game's source
code (like running reflection over C# assemblies, or parsing C++ headers), and then you
could use that do really complex and wide-reaching "data refactoring."
I didn't move past prototyping because I didn't have enough brainergy after work, but I
think something like this could be made that feels has the good stuff spreadsheets have:
michaelbartnett / hidusage_keys.tsv
Last active Sep 24, 2018
hid usage key codes table cleaned up
View hidusage_keys.tsv
dec hex name typical AT-101position Mac HIToolbox/Events.h Constant
0 0 Reserved (no event indicated) N/A
1 1 Keyboard ErrorRollOver N/A
2 2 Keyboard POSTFail N/A
3 3 Keyboard ErrorUndefined N/A
4 4 Keyboard a and A 31 kVK_ANSI_A
5 5 Keyboard b and B 50 kVK_ANSI_B
6 6 Keyboard c and C 48 kVK_ANSI_C
7 7 Keyboard d and D 33 kVK_ANSI_D
8 8 Keyboard e and E 19 kVK_ANSI_E
View strweird.cpp
#include <string>
#define STR1 "Hello"
//#define STR2 "World"
#define STR2 "12345678123456781234567812345678"
//#define STR2 "Worlda"
#define METHOD 3
std::string get_value(const bool b)