Skip to content

Instantly share code, notes, and snippets.

@Darkyenus
Darkyenus / HeaderParser.kt
Last active February 25, 2021 22:37
HTTP Header Content Parser (especially for Content-Disposition
/*
The MIT-Zero License
Copyright (c) 2021 Jan Polák
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@Darkyenus
Darkyenus / Dinitz.java
Created December 15, 2020 21:26
Implementation of Dinic's network flow algorithm
/*
Optimization/adaptation of
https://github.com/williamfiset/Algorithms/blob/master/src/main/java/com/williamfiset/algorithms/graphtheory/networkflow/Dinics.java
MIT License
Copyright (c) 2017 William Fiset
Copyright (c) 2020 Jan Polák
Permission is hereby granted, free of charge, to any person obtaining a copy
@Darkyenus
Darkyenus / Hungarian.java
Created December 15, 2020 21:23
Hungarian algorithm implementation for weighted bipartite matching
/*
MIT License
Copyright (c) 2017 James Payor
Copyright (c) 2020 Jan Polák (Java rewrite)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@Darkyenus
Darkyenus / PooledArray.java
Created December 15, 2020 21:21
A mix between Pool and an Array. Public domain or MIT0 license.
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.utils.Pool;
import java.lang.reflect.Array;
import java.util.Arrays;
/**
* A dynamically sized array, whose elements are all pooled.
*/
@Darkyenus
Darkyenus / Welzl.java
Last active July 2, 2022 03:20
3D smallest-circle/sphere Welzl algorithm implementation
/*
MIT No Attribution
Copyright 2020 Jan Polák
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so.
This file has been truncated, but you can view the full file.
libwww-perl/5.65
Links (0.98; Darwin 6.0 Power Macintosh)
lwp-trivial/1.33
Mozilla/2.0 (compatible; MSIE 3.01; Windows 95)
Mozilla/3.04Gold (Macintosh; I; PPC)
Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)
Mozilla/4.0 (compatible; MSIE 5.0; Windows XP) Opera 6.04 [en]
Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC)
Mozilla/4.0 (compatible; MSIE 5.12; Mac_PowerPC)
Mozilla/4.0 (compatible; MSIE 5.15; Mac_PowerPC)
@Darkyenus
Darkyenus / Models.java
Created June 3, 2020 21:34
Java Low-overhead Icosphere Generator
package com.darkyen.util;
import com.darkyen.graphics.MeshBuilder;
import org.jetbrains.annotations.NotNull;
import static java.lang.Math.PI;
/**
* Functions for model generation.
*/
@Darkyenus
Darkyenus / TextIn3D.java
Last active October 4, 2020 19:45
libGDX Billboarded text at world-space coordinates
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application;
import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.PerspectiveCamera;
import com.badlogic.gdx.graphics.VertexAttributes.Usage;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.BitmapFontCache;
@Darkyenus
Darkyenus / WeightedSampler.kt
Last active January 23, 2020 22:41
Implementation of Vose's Alias algorithm for weighted sampling from discrete set of values (picking random item with a bias)
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
@Darkyenus
Darkyenus / NBT.java
Created July 30, 2019 18:54
Single file NBT reader/writer
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the