Skip to content

Instantly share code, notes, and snippets.

View Reedbeta's full-sized avatar

Nathan Reed Reedbeta

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / cool-game-programming-blogs.opml
Last active December 29, 2023 10:02
List of cool blogs on game programming, graphics, theoretical physics, and other random stuff
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>Graphics, Games, Programming, and Physics Blogs</title>
</head>
<body>
<outline text="Tech News" title="Tech News">
<outline type="rss" text="Ars Technica" title="Ars Technica" xmlUrl="http://feeds.arstechnica.com/arstechnica/index/" htmlUrl="https://arstechnica.com"/>
<outline type="rss" text="Polygon - Full" title="Polygon - Full" xmlUrl="http://www.polygon.com/rss/index.xml" htmlUrl="https://www.polygon.com/"/>
<outline type="rss" text="Road to VR" title="Road to VR" xmlUrl="http://www.roadtovr.com/feed" htmlUrl="https://www.roadtovr.com"/>

Programming Language Evaluation

A list of simple tasks to perform when learning or evaluating a new language. Each of these should be able to be completed in a few hours, and will help to get the feel of the language and its standard libraries. A well-rounded set of evaluation tasks will help ensure all parts of the language are exercised. You might also write some tests to demonstrate implementation correctness.

Basics

  1. Hello world
  2. Read lines from a text file and output them in sorted order
  3. Read numbers from a text file and output the mean and standard deviation
  4. Given an amount of money and a list of coin denominations provided on the command line, output all the possible ways to make change
<?php
/*************************************************************************************
* hlsl.php
* -----
* Author: Nick Darnell (NickDarnell@gmail.com)
* Copyright: (c) 2010 Nick Darnell (NickDarnell@gmail.com)
* Release Version: 1.0
* Date Started: 6/30/2010
*
* HLSL language file for GeSHi.
# Simulator for depth comparison error (i.e. z-fighting)
# Nathan Reed, June 2015
# Written for Python 3.4; requires numpy
import math
import numpy as np
import optparse
# Parse command-line options
parser = optparse.OptionParser()
@Reedbeta
Reedbeta / antialias-test.py
Created July 25, 2014 06:03
Antialiasing test program
# Tests for antialiasing a high-frequency image in various ways
# Nathan Reed, July 2014
# Written for Python 3.4; requires numpy and Pillow to be installed
import concurrent.futures
import math
import multiprocessing
import numpy as np
import optparse
import random