Skip to content

Instantly share code, notes, and snippets.

View faceless2's full-sized avatar

Mike Bremford faceless2

View GitHub Profile
@faceless2
faceless2 / parseJson.java
Last active October 3, 2025 12:50
Parse JSON in Java with a single 100-line method and no dependencies.
import java.util.*;
import java.nio.CharBuffer;
import java.nio.BufferUnderflowException;
/**
* A single-method JSON parser in 100 lines of Java.
*
* Returns a String, Boolean, Integer, Long, Double, null, a List of those, or a Map<String,Object> of those.
* Intended to parse input which is expected to be valid. If you want 100% correct error handling, go elsewhere.
* Does not exacly match the JSON parsing rules for numbers.
@faceless2
faceless2 / gist:ee30d76e223bdc2de51e8c54d7d9a4b9
Created August 18, 2025 10:02
Base64 encode buffers when they are serialized in JSON
It's a simple one-liner - add this to your code, just be aware it impacts ALL buffers
Buffer.prototype.toJSON = function() { return this.toString("base64"); }
@faceless2
faceless2 / lchgradient.xht
Created February 26, 2021 20:34
LCH gradient demo
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
.outer {
display:inline-block;
}
.outer div {
width: 100px;
height: 50px;
@faceless2
faceless2 / math.xml
Created August 23, 2020 14:38
MathML with font-size
<math display="block" xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mfenced>
<mtable>
<mtr>
<mtd>
<mfenced>
<mtable>
<mtr>
@faceless2
faceless2 / t.xht
Last active February 27, 2020 17:54
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
:root {
counter-reset: page 0 b 0 e 0;
}
@page {
counter-increment: page 1 b 1;
margin: 36px;
@faceless2
faceless2 / index.html
Created January 9, 2020 11:19
Force Line Breaking test // source https://jsbin.com/jupalic/13
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Force Line Breaking test</title>
<style>
section {
margin-top: 2em;
}
p {
margin: 0.5em;