Skip to content

Instantly share code, notes, and snippets.

View tommyettinger's full-sized avatar
⚙️
Keeping the commit streak alive

Tommy Ettinger tommyettinger

⚙️
Keeping the commit streak alive
View GitHub Profile
@tommyettinger
tommyettinger / MutantBatch.java
Created July 24, 2019 19:05
SpriteBatch that acts like 1.9.8's version but is compatible with 1.9.9 and 1.9.10
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 June 15, 2019 23:16
Memory usage of data structures on the JVM
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 April 25, 2019 09:08
Fragment Shader for YCwCm warm-and-mild color tweaks
// 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 December 4, 2018 01:47
DawnBringer Aurora .hex palette, 256 colors
000000
111111
222222
333333
444444
555555
666666
777777
888888
999999
@tommyettinger
tommyettinger / Linnorm.java
Created May 16, 2018 20:48
Linnorm benchmarks
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;
@tommyettinger
tommyettinger / WFC.txt
Created March 29, 2018 03:47
MimicWFC output, repeated twice in each direction
.........│..│....┌┘│..........└┘..................│....│.......│.........│..│....┌┘│..........└┘..................│....│.......│
.........│..│...┌┘ │.......................│......│....│.......│.........│..│...┌┘ │.......................│......│....│.......│
.........│..│..┌┘ │.......................├─┐...............┌─┤.........│..│..┌┘ │.......................├─┐...............┌─┤
─┐..│.......│..└──┐└───────────────────────┘ └┐...........┌──┘ └─┐..│.......│..└──┐└───────────────────────┘ └┐...........┌──┘ └
│..├─┐...........│┌──────────────────────────┴─.........─┤ │..├─┐...........│┌──────────────────────────┴─.........─┤
└──┘ └┐..........││...............................┌┐.....│ └──┘ └┐..........││...............................┌┐.....│
───────┴──────────┤│..............................┌┘└─┐...└────────────┴──────────┤│..............................┌┘└─┐...└─────
...............,,.│└┐.............................│ └┐.......................,,.│└┐.............................│ └┐.
@tommyettinger
tommyettinger / LightRNG_Tests.txt
Created February 16, 2018 08:59
Testing parameterless constructor for LightRNG
Format: After each two lines of results, a new LightRNG
is produced with the parameterless constructor.
Initial state : first boolean produced
State after that : second boolean produced
7E005BA92C3B2C00 : false
1C37D562AB85A815 : true
378D3F4B434B6C00 : false
@tommyettinger
tommyettinger / LanguageOutput.txt
Created December 29, 2017 10:39
SquidLib's FakeLanguageGen class produces imitations of various languages, like this.
Imitating language: "Lovecraft":
Zvrun yip ugh, ti.
Eivrachtal aikrairl eng, keila ixek nyomring.
Shupap thax thun seil nyik hmeiha...
Iarlogrek; aalta as nyark akas?
Lu-ul up hmeits; kegg.
Nal glais cthigruk ok tunde?
Kiglokh, aitsirlel yai ias kax.
@tommyettinger
tommyettinger / mulberry32.c
Last active February 5, 2024 20:32
Mulberry32 PRNG
/* Written in 2017 by Tommy Ettinger (tommy.ettinger@gmail.com)
To the extent possible under law, the author has dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
See <http://creativecommons.org/publicdomain/zero/1.0/>. */
#include <stdint.h>
@tommyettinger
tommyettinger / thrust.c
Last active October 14, 2023 14:53
Thrust Pseudo-Random Number Generator
/* Written in 2017 by Tommy Ettinger (tommy.ettinger@gmail.com)
To the extent possible under law, the author has dedicated all copyright
and related and neighboring rights to this software to the public domain
worldwide. This software is distributed without any warranty.
See <http://creativecommons.org/publicdomain/zero/1.0/>. */
#include <stdint.h>