This file contains hidden or 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
// The UnmanagedStorage wrapper is used to disable dynamic initialization and | |
// destructor calls for global variables. The wrapped object is stored inline | |
// and needs to be created and destroyed manually. | |
template <typename T> | |
class UnmanagedStorage { | |
public: | |
template <typename... Args> | |
T* emplace(Args&&... args) noexcept | |
{ | |
reset(); |
This file contains hidden or 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 <cassert> | |
#include <cstdint> | |
#include <cstdlib> | |
#include <iostream> | |
#include <type_traits> | |
using u8 = uint8_t; | |
using u32 = uint32_t; | |
using usize = size_t; |
This file contains hidden or 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
// Build this program with a Windows 11 SDK (e.g. 10.0.22621.0) in debug | |
// configuration, using Multi-threaded Debug DLL (/MDd). | |
#include <Windows.h> | |
#include <fcntl.h> | |
#include <io.h> | |
#include <stdio.h> | |
// This causes ucrtbase.dll (release version) to be loaded, which might cause |
This file contains hidden or 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
#pragma once | |
#include <algorithm> | |
#include <cassert> | |
#include <cstddef> | |
#include <cstdint> | |
#include <cstdio> | |
#include <cstring> | |
#include <filesystem> | |
#include <string> |
This file contains hidden or 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
//////////////////////////////////////////////////////////// | |
// Vector 2D | |
template <typename T> | |
struct Vec2T { | |
constexpr Vec2T() = default; | |
constexpr Vec2T(T v) : x(v), y(v) {} | |
constexpr Vec2T(T x, T y) : x(x), y(y) {} | |
constexpr Vec2T(const Vec2T&) = default; |
This file contains hidden or 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
cmake_minimum_required(VERSION 3.25) | |
project(sdlinputtest LANGUAGES CXX) | |
find_package(SDL2 REQUIRED) | |
add_executable(sdlinputtest sdlinputtest.cpp) | |
target_link_libraries(sdlinputtest PRIVATE SDL2::SDL2 SDL2::SDL2main) | |
if(WIN32) | |
add_custom_command(TARGET sdlinputtest POST_BUILD |
This file contains hidden or 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
import subprocess | |
import sys | |
from asyncio import Future | |
from contextlib import contextmanager | |
@contextmanager | |
def ParallelSh(): | |
""" |
This file contains hidden or 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
void copyOver(std::ofstream& dst, std::ifstream& src, std::uint64_t length) | |
{ | |
// This seems to be broken, we are skipping bytes at some point. Apparently | |
// istream_iterator shouldn't be used for binary files, despite the | |
// underlying stream being opened in binary mode. istreambuf_iterator was | |
// suggested, but is not applicable here as it fills an internal buffer with | |
// more than we read and therefore advances the file cursor too far. | |
// | |
// std::copy_n(std::istream_iterator<uint8_t>(src), length, | |
// std::ostream_iterator<uint8_t>(dst)); |
This file contains hidden or 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
from datetime import datetime | |
from typing import List | |
class DatetimeInterval: | |
def __init__(self, start, end): | |
self.start = start | |
self.end = end | |
def __lt__(self, other): |
This file contains hidden or 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
#pragma once | |
#include <cassert> | |
#include <map> | |
#include <memory> | |
#include <utility> | |
template <class L, class R, class CompareLeft = std::less<L>, class CompareRight = std::less<R>, | |
class AllocatorLeft = std::allocator<std::pair<const L, const R *>>, | |
class AllocatorRight = std::allocator<std::pair<const R, const L *>>> |
NewerOlder