Skip to content

Instantly share code, notes, and snippets.

View ClysmiC's full-sized avatar

Andrew Smith ClysmiC

View GitHub Profile
@ClysmiC
ClysmiC / test.py
Created October 31, 2016 18:28
UFC fights metadata
import csv
fighterToWeight = {}
weightClasses = ["Atomweight", "Strawweight", "Flyweight",
"Bantamweight", "Featherweight", "Lightweight",
"Welterweight", "Middleweight", "Light Heavyweight",
"Heavyweight", "Super Heavyweight"]
# Set up info about weight classes
with open('fighters.csv') as table:
@ClysmiC
ClysmiC / gist:1b6c3092fc757ac1b0ba3217c7b84f59
Created August 17, 2018 22:29
Quickhull comment ASCII art!
//
// |--- h ---| h = horizon
// /____ /____ x = current face (other face is prev face)
// \ |\ /| c = conflict
// \ x |<--/---\
// h2c \ | / |---- c2h (twin of prev h2c)
// _\\| /
// C
//
@ClysmiC
ClysmiC / gist:eef5d121c6504457ad9112903f28c8dd
Created April 26, 2019 07:41
uBlock Origin custom filter to disable Youtube recommend videos pause overlay
www.youtube.com##.ytp-scroll-min.ytp-pause-overlay
@ClysmiC
ClysmiC / InterfaceHack.cpp
Last active August 11, 2019 12:38
A hacky attempt to implement interfaces without using member functions or inheritance. Inspired by Go, but I've never actually used Go so I could be totally wrong about how they do it. Not intended to be useful... more a proof of concept for a way that a compiler could implement this under the hood
#include <cstdio>
#include <stdarg.h>
#define BeginInterface(ifaceName) struct ifaceName##ITable {
#define BeginListFn static constexpr int s_iLineFnBase = __LINE__;
#define AddFn(returnType, funcName, ...) typedef returnType ( *Pfn##funcName )(void* __VA_ARGS__ ); static constexpr int s_iFn##funcName = __LINE__ - 1 - s_iLineFnBase;
#define BeginListImpl static constexpr int s_iLineImplBase = __LINE__; static constexpr int s_cFn = s_iLineImplBase - s_iLineFnBase - 1;
#define AddImpl(structName) static constexpr int s_iImpl##structName = __LINE__ - 1 - s_iLineImplBase;
#define EndInterface(ifaceName) static constexpr int s_cImpl = __LINE__ - 1 - s_iLineImplBase;\
static constexpr int s_cFnPtrs = s_cImpl * s_cFn;\
@ClysmiC
ClysmiC / gist:286d49670139df4e50494e4d2d4730e7
Created August 16, 2019 21:20
Access modifier on optional parameter
public class SecureTransactor
{
public bool DoManySecureTransactions(string[] data)
{
if (!SecurityCheck()) return false;
bool doCheck = false; // We already did the check, no need to repeat ourselves!
foreach(string datum in data)
{
DoSecureTranaction(data, doCheck);
public class SecureTransactor
{
public bool DoManySecureTransactions(string[] data)
{
if (!SecurityCheck()) return false;
bool doCheck = false; // We already did the check, no need to repeat ourselves!
foreach(string datum in data)
{
InternalDoSecureTranaction(data, doCheck);
// NOTE - This file is auto-generated by hgen. DO NOT MODIFY!
// building.h
enum class BuildingId : u32;
enum class BuildingType : u32;
struct TrainingQueue;
struct BuildingPlacementGhost;
enum class ConstructionFlags : u8;
struct ConstructionState;
// NOTE - This file is auto-generated by hgen. DO NOT MODIFY!
// building_core.h
namespace Construction
{
inline fix64 HpStart(fix64 hpMax);
inline fix64 DHpPerSecond(fix64 hpMax, fix64 constructionTime);
#define DefineFlagOps(ENUM, INT_TYPE) \
constexpr ENUM operator|(ENUM lhs, ENUM rhs) { return (ENUM)((INT_TYPE)lhs | (INT_TYPE)rhs); } \
constexpr ENUM & operator|=(ENUM & lhs, ENUM rhs) { lhs = lhs | rhs; return lhs; } \
constexpr ENUM operator&(ENUM lhs, ENUM rhs) { return (ENUM)((INT_TYPE)lhs & (INT_TYPE)rhs); } \
constexpr ENUM & operator&=(ENUM & lhs, ENUM rhs) { lhs = lhs & rhs; return lhs; } \
bool constexpr IsFlagSet(ENUM flags, ENUM query) { return (flags & query) == query; } \
bool constexpr IsAnyFlagSet(ENUM flags, ENUM query) { return (INT_TYPE)(flags & query) != 0; } \
constexpr ENUM operator~(ENUM e) { return (ENUM)~(INT_TYPE)e; } \
StaticAssert(sizeof(ENUM) == sizeof(INT_TYPE))