Skip to content

Instantly share code, notes, and snippets.

View Alwinfy's full-sized avatar

Alwinfy Alwinfy

  • United States
View GitHub Profile
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Iterator;
import java.util.List;
import java.io.IOException;
import java.io.UncheckedIOException;
import javax.tools.ToolProvider;
import com.sun.source.util.JavacTask;
import com.sun.source.util.TreeScanner;
@Alwinfy
Alwinfy / HexAngle.java
Last active August 11, 2022 16:41
Important method is `HexLine#equalModStrokes`
public enum HexAngle {
FORWARD(0, 'w'),
LEFT(1, 'q'),
SHARP_LEFT(2, 'a'),
BACKWARD(3, 's'),
SHARP_RIGHT(4, 'd'),
RIGHT(5, 'e');
public final int count;
public final char name;
{-# LANGUAGE DeriveFunctor #-}
import Control.Applicative
import Data.List (nub)
import qualified Data.Map as Map
data Fix f = Fix { unfix :: f (Fix f) }
topDown :: (Functor f) => (a -> f a) -> a -> Fix f
topDown fn = Fix . fmap (topDown fn) . fn
(* Content-type: application/vnd.wolfram.mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 12.1' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
(* Pretty-printing *)
Module[{destructCons, mkBox},
destructCons[k_] :=
Replace[NestWhileList[Replace[Hold[cons[x_, y_]] :> Hold[y]], k,
MatchQ[Hold[_cons]]], {h___,
t_} :> {Replace[Hold[cons[x_, _]] :> Hold[x]] /@ {h}, t}];
mkBox[Hold[x_]] := MakeBoxes[x, StandardForm];
cons /: MakeBoxes[l_cons, StandardForm] :=
Block[{$RecursionLimit = Infinity},
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
public class Huffman {
/** Tree with data at leaves. */
public sealed interface Tree<T> {
/** Traverse tree; coalesce into map. */
eval@
{{lambda, {l},
{cond, l,
{Plus, {First, l}, {recur, {Rest, l}}},
0}},
{quote, {1, 2, 3, 4, 5}}}
eval@
{{lambda, {l, acc},
{cond, l,
@Alwinfy
Alwinfy / index.html
Last active May 15, 2022 01:10
Prototype generated webdoc for Hexcasting
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="The Hex Book, all in one place.">
<meta name="author" content="petrak@, Alwinfy">
<link rel="icon" href="../../favicon.ico">
<title>Hex Book</title>
@Alwinfy
Alwinfy / botania-history.md
Last active February 22, 2022 19:11
Abbreviated history of Botania gameplay changes from 1.12-present

1.14

  • Goodbye bespoke Lexica code, hello Patchouli
  • Rework Ring of Chordata for 1.13 swimming changes
  • Spectrolus can eat (dyed) sheep for huge mana. You monster.
  • Mana sparks can now be colored like corporea sparks to create separate networks
  • Corporea keybind requests can now use the vanilla recipe book
  • Allow any two vanilla dyes to be used to craft fertilizer instead of just red or yellow
  • Flugel Tiara gliding now interacts properly with the Tornado Rod
  • Ring of Dexterous Motion can now be used in forward and backward directions
  • Snowflake pendant now has a snow effect (ToMe25)
@Alwinfy
Alwinfy / ArgParser.java
Last active August 1, 2022 23:48
"We have getopt() at home"
import java.util.ArrayList;
import java.util.List;
import java.util.StringJoiner;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodType;
import java.lang.reflect.Parameter;
public class ArgParser<T> {