Skip to content

Instantly share code, notes, and snippets.

View hildjj's full-sized avatar

Joe Hildebrand hildjj

View GitHub Profile
@hildjj
hildjj / f16.json
Created November 16, 2025 18:12
Every float16 and its numerical value
This file has been truncated, but you can view the full file.
{
"0000": "0",
"0001": "5.960464477539063e-8",
"0002": "1.1920928955078125e-7",
"0003": "1.7881393432617188e-7",
"0004": "2.384185791015625e-7",
"0005": "2.980232238769531e-7",
"0006": "3.5762786865234375e-7",
"0007": "4.172325134277344e-7",
"0008": "4.76837158203125e-7",
foo = '1'
foo = '1'
@hildjj
hildjj / tagged-vector-adder.pegjs
Last active December 3, 2023 20:08 — forked from frostburn/tagged-vector-adder.pegjs
Peggy proposition: Tagged template parser with auto-vectorization of template arguments
import peg from "peggy-tag";
const PLACEHOLDER = "{{{ARG}}}";
const parse = peg`
{{
function add(left, right) {
if (typeof left === 'number') {
if (typeof right === 'number') {
return left + right;
@hildjj
hildjj / ISO-6093.pegjs
Created August 22, 2023 19:48
Aggressively accurate ISO 6093 parser
{{
// The signed representation of the numerical value zero shall contain a PLUS
// SIGN or a SPACE, but not a MINUS SIGN.
const NZERO1 = /^-0+$/
// The signed representation of the numerical value zero shall contain a PLUS
// SIGN or a SPACE, but not a MINUS SIGN.
const NZERO2 = /^-0*\.0*$/
// If the exponent has the value Zero, its sign shall be a PLUS SIGN.
@hildjj
hildjj / compress.js
Created September 6, 2022 17:48
Pipes are binary safe
// Compress a given string using the lzma program, and return the compressed contents.
const { spawn } = require('child_process')
const compress = str => new Promise((resolve, reject) => {
const lzma = spawn('cat',
{ stdio: ["pipe", "pipe", "inherit"] })
@hildjj
hildjj / bench.js
Created September 6, 2022 02:16
editorconfig parser comparison
/* eslint-disable no-console */
import { Benchmark } from 'kelonio'
import { parse } from './iniFile'
import { parse_to_json } from './one-ini/editorconfig_ini'
import { promises as fs } from 'fs'
import * as path from 'path'
interface WasmParseResults {
version: string
body?: (WasmPair | WasmComment | WasmSection)[]
@hildjj
hildjj / author.jq
Created January 9, 2022 20:18
Find all of the npm packages by a given author, so you can ensure you are either supporting them or switching to another package
# Run with npm ls --all --long --json --silent 2>/dev/null | jq -f author.jq --arg author <authorName>
# consider adding -g to the npm portion.
[
.. |
select(
objects |
has("author") and ((
.author | strings | contains($author)
) or (
@hildjj
hildjj / ships.rb
Created July 20, 2021 23:25
battleship
known_ships = [
["Cruiser", 3],
["Submarine", 2]
]
cells = []
%w( A B C D ).each do |x|
(1..4).each do |y|
cells << "#{x}#{y}"
end
@hildjj
hildjj / js-itertools.js
Created January 19, 2021 20:38
time node js-itertools.js
'use strict'
/**
* Is the given thing iterable?
*
* @static
* @param {any} g - the thing to check
* @returns {boolean} - true if `g` looks like an iterable
*/
function isIterable(g) {