Skip to content

Instantly share code, notes, and snippets.

View Reedbeta's full-sized avatar

Nathan Reed Reedbeta

View GitHub Profile
@Reedbeta
Reedbeta / comptr.hpp
Created July 7, 2016 06:19
GPU PRNG & hash-function testbed
// COM pointer - wraps a COM object and automatically calls AddRef() / Release() as necessary
#pragma once
template <typename T>
class comptr
{
public:
comptr ()
@Reedbeta
Reedbeta / bash-and-cmd-in-context-menu.reg
Last active May 1, 2021 20:41
Windows registry edit to add Bash and Command Prompt items to Explorer context menu
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\Bash]
@="Bash"
"Icon"=hex(2):22,00,25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,\
00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,\
77,00,73,00,6c,00,2e,00,65,00,78,00,65,00,22,00,00,00
; REG_EXPAND_SZ "%SystemRoot%\System32\wsl.exe"
[HKEY_CURRENT_USER\Software\Classes\Directory\Background\shell\Bash\command]
@Reedbeta
Reedbeta / letter-swapper.js
Created May 14, 2017 21:31
Letter swapper Greasemonkey script. Just for shits and giggles.
// ==UserScript==
// @name Letter Swapper
// @namespace reedbeta.com
// @version 1
// @grant none
// @include *
// @exclude https://*.google.com/*
// ==/UserScript==
var swaps =
@Reedbeta
Reedbeta / comptr.h
Created February 8, 2018 20:29
Auto-releasing wrapper for COM pointers
// Auto-releasing wrapper for COM pointers
// Feel free to use this for whatever, I don't care
template <typename T>
struct comptr
{
T * p;
comptr(): p(nullptr) {}
comptr(T * other): p(other)
{ if (p) p->AddRef(); }
@Reedbeta
Reedbeta / srgb.glsl
Created August 3, 2018 16:52
Conversion between sRGB and linear color encoding
vec3 sRGBToLinear(vec3 rgb)
{
// See https://gamedev.stackexchange.com/questions/92015/optimized-linear-to-srgb-glsl
return mix(pow((rgb + 0.055) * (1.0 / 1.055), vec3(2.4)),
rgb * (1.0/12.92),
lessThanEqual(rgb, vec3(0.04045)));
}
vec3 LinearToSRGB(vec3 rgb)
{
@Reedbeta
Reedbeta / interesting-libs.txt
Last active July 4, 2023 02:38
Interesting libraries I might like to use in a project
Interesting libraries I might like to use in a project...
Asset loading:
assetsys.h - virtual filesystem with ZIP backing, overlaying, etc https://github.com/mattiasgustavsson/libs/blob/master/docs/assetsys.md
cute_filewatch.h - file modification watching, for runtime reloading etc https://github.com/RandyGaul/cute_headers/blob/master/cute_filewatch.h
flatbuffers - data serialization, zero-copy deserialization, extensible schemas https://github.com/google/flatbuffers
stb_image - https://github.com/nothings/stb/blob/master/stb_image.h
tinyexr - https://github.com/syoyo/tinyexr
tinygltf - https://github.com/syoyo/tinygltf
tinyobjloader - https://github.com/syoyo/tinyobjloader
#pragma once
// Intrusive Linked List (or Internal Linked List, etc)
// by Nathan Reed, 2020-01-18. Licensed CC0 https://creativecommons.org/publicdomain/zero/1.0/
//
// Use it like:
//
// class MyClass
// {
// ...
@Reedbeta
Reedbeta / disband-spd.md
Created June 6, 2020 22:54
Letter to Seattle City Council members

Dear Council Members,

Like so many Seattle residents, I was appalled and disgusted by George Floyd’s murder at the hands of Minneapolis police officers on May 25, and I have been further appalled and disgusted by the Seattle Police Department’s treatment of those protesting for racial justice in the days since. The SPD has repeatedly responded to peaceful protests with violence, escalating and attacking without provocation, using chemical weapons that would be banned in warfare against unarmed and peaceful Seattleites — and then attempting to cover up, deny, and evade responsibility for their conduct. And why has the SPD done this? Because citizens have dared to hold them and other police departments across the country accountable for their ongoing and deeply ingrained racism, brutality, and callous disregard for Black lives and humanity.

As a white person, I was brought up to believe the police were there to help — and that they were obviously necessary to “fight crime” and keep our cities safe. Immigrants

@Reedbeta
Reedbeta / generate_code.py
Created June 27, 2020 16:55
Generate code into a source file using python
# Load the source file
sourcePath = r'c:\path\to\my\file.cpp'
sourceText = codecs.open(sourcePath, encoding='utf-8').read()
# Find the generated section
startMarker = (
'''/*
* Generated data tables - do not edit by hand!
* To regenerate, run my_fancy_script.py.
#pragma once
// String tokenizing iterator
// by Nathan Reed, 2020-08-06. Licensed CC0 https://creativecommons.org/publicdomain/zero/1.0/
//
// Use it like:
//
// for (auto token : IterTokens(" Bird \t\tFish Dog Cat "))
// {
// // token is a std::string_view pointing into the original string