Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
VPLs, ORMs, and Bag End

Philip Diffenderfer ClickerMonkey

💭
VPLs, ORMs, and Bag End
View GitHub Profile
@ClickerMonkey
ClickerMonkey / types.ts
Last active Jul 21, 2021
Typescript Helper Types
View types.ts
// 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 / Playground.vue
Last active Jan 11, 2019
Playground: v-calendar-daily
View Playground.vue
<template>
<v-app class="panes">
<div class="left">
<v-select
label="Type"
v-model="type"
:items="typeOptions"
></v-select>
@ClickerMonkey
ClickerMonkey / Markov.java
Created Oct 29, 2014
Markov chain data structure.
View Markov.java
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 / Matching.java
Created Oct 29, 2014
A shape & color matching game for kids.
View Matching.java
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Stroke;
import java.awt.event.KeyEvent;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;
@ClickerMonkey
ClickerMonkey / CollisionResolution.java
Created Oct 29, 2014
Collision resolution visualization
View CollisionResolution.java
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.event.KeyEvent;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.util.Arrays;
import java.util.List;
@ClickerMonkey
ClickerMonkey / CircleCircle.java
Created Oct 29, 2014
Priori intersection algorithms for circles, rectangles, and planes.
View CircleCircle.java
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
@ClickerMonkey
ClickerMonkey / Wikipedia.java
Last active Aug 29, 2015
Gathers information about all articles on Wikipedia and builds a graph of all related articles.
View Wikipedia.java
public class Wikipedia
{
public static class Article implements Serializable {
private static final long serialVersionUID = 1L;
public int id;
public String title;
public Set<String> related = new HashSet<String>();
}
@ClickerMonkey
ClickerMonkey / StringTemplate.java
Last active Aug 29, 2015
A simple string templating utility.
View StringTemplate.java
public class StringTemplate
{
public static final String DEFAULT_START = "{";
public static final String DEFAULT_END = "}";
private String[] chunks;
public StringTemplate( String text )
{
@ClickerMonkey
ClickerMonkey / Sqrt.java
Last active Jan 24, 2021
1/Sqrt VS Fast Inverse Sqrt
View Sqrt.java
import java.nio.ByteBuffer;
public class Sqrt
{
private static float invsqrt0(float x)
{
return 1.0f / (float)Math.sqrt( x );
}
@ClickerMonkey
ClickerMonkey / Elongate.java
Last active Aug 29, 2015
Transforms Java code to be as many lines as possible.
View Elongate.java
import java.util.Scanner;
public class Elongate
{
public static void main( String[] args )
{
Scanner in = new Scanner( System.in );
StringBuilder code = new StringBuilder();
while (in.hasNextLine())