Skip to content

Instantly share code, notes, and snippets.

Avatar

Tab Atkins Jr. tabatkins

View GitHub Profile
View xml-in-kdl.md

XML-in-KDL (XiK)

This specification describes a canonical way to losslessly encode XML in KDL. While this isn't a very useful thing to want to do on its own, it's occasionally useful when using a KDL toolchain while speaking with an XML-consuming or -emitting service.

This is version 1.0.0 of XiK.

XML-in-KDL (XiK from now on) is a kdl microsyntax for losslessly encoding XML into a KDL document. XML and KDL, luckily, have very similar data models (KDL is almost a superset of XML), so it's quite straightforward to encode most XML documents into KDL.

XML has four types of nodes, corresponding to certain KDL constructs:

@tabatkins
tabatkins / json-in-kdl.md
Last active Jul 18, 2021
JSON-in-KDL specification
View json-in-kdl.md

JSON-in-KDL

This specification describes a canonical way to losslessly encode JSON in KDL. While this isn't a very useful thing to want to do on its own, it's occasionally useful when using a KDL toolchain while speaking with a JSON-consuming or -emitting service.

JSON-in-KDL (JiK from now on) is a kdl microsyntax consisting of three types of nodes:

  • literal nodes, with _ as the nodename
  • array nodes, with array as the nodename
  • dict nodes, with dict as the nodename
@tabatkins
tabatkins / hatetris.js
Created May 21, 2021
Unobfuscated version of HATETRIS's default AI
View hatetris.js
function construct(getNextStates) {
return function ai(currentState) {
const pieces = [
{name:"S", annoyance:7},
{name:"Z", annoyance:6},
{name:"O", annoyance:5},
{name:"I", annoyance:4},
{name:"L", annoyance:3},
{name:"J", annoyance:2},
{name:"T", annoyance:1},
@tabatkins
tabatkins / notes.md
Last active Mar 24, 2021
Pipeline notes
View notes.md

Real world use-case: someone asking for Object.values()/etc to be installed as Symbol-keyed properties on Object.prototype, so they can have method chains working on arrays/iterators that produce an Object at some intermediate point, without having to go back and wrap an entire chunk of the method chain in a big wrapping Object.values().

That is, they're prefer not to have to write this code:

const x = Object.values(array.filter(x=>x).map(x=>f(x)).reduce(intoObjectSomehow)).map(y=>g(y))
View gist:a29f71075d0b31e014978983beb0078e
There's a reason people don't like to write HTML tables,
and it's because they don't write good HTML in the first place.
Case in point, taken from a spec I'm editting right this moment:
```html
<table id="distinguishable-table" class="matrix data complex">
<tr>
<th class="corner"></th>
<th><div>
@tabatkins
tabatkins / pipeline.md
Last active Jul 20, 2021
Comparing the three pipeline proposals
View pipeline.md

We've been deadlocked for a while on the pipeline operator proposal, for a few reasons. Partially it's just low implementor interest, as this is fundamentally just syntactic sugar, but also because there are three competing proposals and the proponents of each haven't been convinced by the others yet.

In this essay I hope to briefly outline the problem space, summarize the three proposals, and talk about what's gained/lost by each of them. (Spoiler: they're all nearly identical; we're arguing over very small potatoes.)

@tabatkins
tabatkins / file.md
Last active Mar 16, 2021
Comparing Python's match statement with mine
View file.md
@tabatkins
tabatkins / apprentice-properties.md
Last active Feb 4, 2021
Somewhat sorted list of apprentice weapon properties
View apprentice-properties.md

Masterwork Properties

Masterwork properties can be applied to any masterwork weapon or suit of armor, provided you can spare the time and gold cost required to apply it. Each property entry details the property’s level and the type of equipment it can be applied to.

Unless otherwise noted, a piece of gear cannot have the same property more than once; for example, you cannot

View real-world-pipeline.md

Core Proposal real-world examples

Living Document. J. S. Choi, 2018-12.

WHATWG Fetch Standard

The [WHATWG Fetch Standard][] contains several examples of using the DOM fetch function, resolving its promises into values, then processing the values in various ways. These examples may become more easily readable with smart pipelines.