Skip to content

Instantly share code, notes, and snippets.

View ClickerMonkey's full-sized avatar
💭
VPLs, ORMs, and Bag End

Philip Diffenderfer ClickerMonkey

💭
VPLs, ORMs, and Bag End
View GitHub Profile
@ClickerMonkey
ClickerMonkey / types.ts
Last active February 6, 2024 07:21
Typescript Helper Types
// when T is any|unknown, Y is returned, otherwise N
type IsAnyUnknown<T, Y, N> = unknown extends T ? Y : N;
// when T is never, Y is returned, otherwise N
type IsNever<T, Y = true, N = false> = [T] extends [never] ? Y : N;
// when T is a tuple, Y is returned, otherwise N
// valid tuples = [string], [string, boolean],
// invalid tuples = [], string[], (string | number)[]
@ClickerMonkey
ClickerMonkey / Sqrt.java
Last active July 3, 2022 17:57
1/Sqrt VS Fast Inverse Sqrt
import java.nio.ByteBuffer;
public class Sqrt
{
private static float invsqrt0(float x)
{
return 1.0f / (float)Math.sqrt( x );
}
@ClickerMonkey
ClickerMonkey / animation.cpp
Created January 7, 2022 00:25
C++ Animation system
//
// Created by Philip Diffenderfer on 10/24/21.
//
#include <string>
#include <map>
#include <vector>
#include <cmath>
#include <functional>
@ClickerMonkey
ClickerMonkey / state-machine.cpp
Created January 7, 2022 00:17
C++ State Machine Prototype with Animation example
//
// Created by Philip Diffenderfer on 10/24/21.
//
#include <map>
#include <cmath>
#include <functional>
#include <iostream>
template <typename V>
@ClickerMonkey
ClickerMonkey / Markov.java
Created October 29, 2014 15:19
Markov chain data structure.
import java.util.Collection;
import java.util.List;
import java.util.Random;
public class Markov<T>
{
protected final MarkovChain<T> root;
protected final MarkovChain<T> starters;
@ClickerMonkey
ClickerMonkey / Playground.vue
Last active January 11, 2019 07:07
Playground: v-calendar-daily
<template>
<v-app class="panes">
<div class="left">
<v-select
label="Type"
v-model="type"
:items="typeOptions"
></v-select>
@ClickerMonkey
ClickerMonkey / Blend.java
Created November 18, 2013 19:58
Software graphics library with blending, textures, and simple primitives.
public abstract class Blend
{
public static final Blend Alpha = new Blend()
{
public int blend( int o, int n )
{
return Color.mixRGB( o, n, Color.alpha( n ), Color.alpha( o ) );
}
};
@ClickerMonkey
ClickerMonkey / Array.java
Created December 12, 2013 15:48
Array class (similar to ArrayList) but with reordering options and automatic downsizing.
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
public class Array<T> implements Iterable<T>
{
public T[] elements;
public int size;
@ClickerMonkey
ClickerMonkey / SetOperations.java
Created December 11, 2013 12:45
Set operations
public class SetOperations
{
//===========================================================================
// A set is an immutable group of unique numbers ordered from smallest to
// largest. The values in the set must be ordered for all set operations to
// function properly, so don't manually change/re-order these!
//===========================================================================
class Set {
// The ordered set of numbers.
@ClickerMonkey
ClickerMonkey / PointToCube.java
Last active December 29, 2015 03:08
Shader Fun
package com.axe.sandbox.gs;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import org.lwjgl.BufferUtils;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.ARBBufferObject;