Skip to content

Instantly share code, notes, and snippets.

⚙️
Keeping the commit streak alive

Tommy Ettinger tommyettinger

⚙️
Keeping the commit streak alive
Block or report user

Report or block tommyettinger

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tommyettinger
tommyettinger / IndexedDictionary.cs
Created Mar 1, 2020
C# insertion-ordered Dictionary that allows lookup by index.
View IndexedDictionary.cs
using System;
using System.Collections;
using System.Collections.Generic;
namespace SquidLib.SquidMath {
/// <summary>
/// Only for use with indexers in IndexedDictionary to show you want to access a key.
/// There is only one enum constant here, At.
/// </summary>
public enum Key {
@tommyettinger
tommyettinger / LanguageOutput.txt
Created Feb 20, 2020
Output of FakeLanguageGen from SquidLib
View LanguageOutput.txt
Imitating language: "Lovecraft":
Ku ushku urk tachtal ith zvra...
Hmaanga teik ekhel oguts ape irk.
Ekhi; thi is ialaagh ogiltaats gleputs?
Aagrets nen nyeigh yeltaa!
Aarl ta; aha'at, sain zvrirkai-aikhug lia'aas!
Sol gukh emraats nyamre-op uxo tark fto.
Ux opits uvru as, en'yeh, pe-ialteish piakre.
@tommyettinger
tommyettinger / FloatArray_1_Before.java
Created Feb 14, 2020
libGDX's FloatArray before and after running libGDX's Eclipse formatter on it, in IntelliJ.
View FloatArray_1_Before.java
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@tommyettinger
tommyettinger / FOV.java
Created Sep 12, 2019
Stripped-down version of Jagd's Field of View class
View FOV.java
import java.util.Arrays;
/**
* This class provides methods for calculating Field of View in grids. Field of
* View (FOV) algorithms determine how much area surrounding a point can be
* seen. They return a two dimensional array of doubles, representing the amount
* of view (almost always sight) which the origin has of each cell.
* <br>
* The input resistanceMap is considered the percent of opacity. This resistance
* is on top of the resistance applied from the light spreading out. You can
View dungeon1000x1000.txt
This file has been truncated, but you can view the full file.
┌────┐┌──┐┌──────┐ ┌──┐ ┌───────┐┌─────┬───┐ ┌────────┐ ┌──┐ ┌──────────┐ ┌──┐ ┌──────┬─────┐┌──┐ ┌──┐ ┌─────┐ ┌──┐ ┌──┐ ┌──┐┌──────┐ ┌──────┬─────┐┌──┐ ┌──┐ ┌────────┬───────┐ ┌──────┐ ┌────────┐┌──────┐ ┌──┐ ┌──────┐ ┌──┐ ┌──────────┐ ┌──┬─────┐ ┌──┐ ┌─────┐ ┌─────┐ ┌────────┐┌───────────┐┌─────┐ ┌────┬──┐┌────────┐ ┌──────┬─────────┐ ┌───┬───┐┌──┬─────┐ ┌──────┬─────────┐ ┌────────┐ ┌─────┐ ┌───────────┬─────┐ ┌─────┬──┐┌──────┐ ┌───────┬─────┬───┐ ┌─────┐ ┌───┐ ┌──────────────────┐ ┌──┐ ┌──┐ ┌──┐ ┌──────────┐ ┌────────┐ ┌────┐ ┌──┐ ┌──┐ ┌────────┐ ┌───┐ ┌───────────┬─────┐ ┌─────┐ ┌────────┐ ┌──────┐ ┌──┐ ┌─────┬──┐┌────────┐┌────┐ ┌──────┐┌────────┐┌────────┐ ┌──────┐ ┌──┐ ┌──┐ ┌──┐ ┌──────┐ ┌──┐ ┌───┐ ┌─────┐ ┌──┐ ┌────┬────┐ ┌───┬─────┐ ┌─────┐┌─────┬────────────┬───┬─────┐┌──────┐
@tommyettinger
tommyettinger / MutantBatch.java
Created Jul 24, 2019
SpriteBatch that acts like 1.9.8's version but is compatible with 1.9.9 and 1.9.10
View MutantBatch.java
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Mesh;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.VertexAttribute;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
@tommyettinger
tommyettinger / MemoryUsageOfDataStructures.txt
Created Jun 15, 2019
Memory usage of data structures on the JVM
View MemoryUsageOfDataStructures.txt
This includes JDK8 and Guava 28 data structures, with the analysis done by https://github.com/DimitrisAndreou/memory-measurer .
========================================== 64-bit architecture ==========================================
========================================== Basic Lists, Sets, Maps ==========================================
ArrayList :: Bytes = 4.71, Objects = 0.00 Refs = 1.18 Primitives = {}
ImmutableList :: Bytes = 4.00, Objects = 0.00 Refs = 1.00 Primitives = {}
HashSet :: Bytes = 40.24, Objects = 1.00 Refs = 5.06 Primitives = {int=1.0}
@tommyettinger
tommyettinger / warm-mild.frag.glsl
Created Apr 25, 2019
Fragment Shader for YCwCm warm-and-mild color tweaks
View warm-mild.frag.glsl
// this is a libGDX ShaderBatch fragment shader; it may need some tweaks to fit in other frameworks.
// You can use this to desaturate colors by setting `u_mul` to `vec3(1.0, 0.5, 0.5)` or any other small fractions for Cw and Cm. You
// can make colors warmer by setting `u_add` to `vec3(0.0, 0.6, 0.0)`; while warmth is added, randomly setting the added Cm to a
// value between -0.5 and 0.5 can simulate a fiery color effect over the screen. You can make an icy effect by setting `u_add` to
// `vec3(0.3, -0.4, 0.0)`. You can simulate the desaturation and yellowing that happens to old paintings by setting `u_mul` to
// `vec3(0.9, 0.7, 0.75)` and `u_add` to `vec3(0.05, 0.14, 0.16)`. Many other effects are possible by changing warmth and/or mild over
// multiple frames, usually smoothly and usually applying the change to the additive uniform.
varying vec2 v_texCoords;
varying vec4 v_color;
@tommyettinger
tommyettinger / DawnBringer_Aurora.hex
Created Dec 4, 2018
DawnBringer Aurora .hex palette, 256 colors
View DawnBringer_Aurora.hex
000000
111111
222222
333333
444444
555555
666666
777777
888888
999999
View Linnorm.java
public final class Linnorm {
private static long state = 0L;
private static long random()
{
long z = (state = state * 0x41C64E6DL + 1L);
z = (z ^ z >>> 28) * 0xAEF17502108EF2D9L;
return z ^ z >>> 30;
}
public static void main(String[] args) {
long out = 0L;
You can’t perform that action at this time.