Skip to content

Instantly share code, notes, and snippets.

View michaelbartnett's full-sized avatar

Michael Bartnett michaelbartnett

View GitHub Profile

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
michaelbartnett / premake.lua
Created February 25, 2020 10:12
list of xcode warnings it complained about bc premake5's xcode generator is out of date
xcodeprojectopts {
-- MACOSX_DEPLOYMENT_TARGET="10.6",
-- -- ALWAYS_SEARCH_USER_PATHS = "YES",
-- ONLY_ACTIVE_ARCH = "YES",
-- ENABLE_TESTABILITY = "YES",
-- CLANG_WARN_INFINITE_RECURSION = "YES",
-- CLANG_WARN_UNREACHABLE_CODE = "YES",
-- GCC_WARN_UNUSED_FUNCTION = "YES",
@michaelbartnett
michaelbartnett / NullTest.cs
Last active July 30, 2019 15:35
unity null fun
using UnityEngine;
interface ISomeInterface
{
}
public class TestScript : MonoBehaviour, ISomeInterface
{
}
#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");
public:
@michaelbartnett
michaelbartnett / enumshit.cpp
Created February 6, 2019 09:38
enums with max and string
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
michaelbartnett / better_narrowing.cpp
Last active January 17, 2019 11:02
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.
// what a mess
#if NDEBUG
template<typename TOut, typename TIn>
constexpr TOut narrowed(TIn&& inp) noexcept
{
return static_cast<TOut>(inp);
}
#define NARROWED(TOut, expr) static_cast<TOut>(expr)
#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
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
michaelbartnett / hidusage_keys.tsv
Last active September 24, 2018 01:41
hid usage key codes table cleaned up
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
#include <string>
#define STR1 "Hello"
//#define STR2 "World"
#define STR2 "12345678123456781234567812345678"
//#define STR2 "Worlda"
#define METHOD 3
std::string get_value(const bool b)