Skip to content

Instantly share code, notes, and snippets.

@Mr0grog
Mr0grog / index.js
Created December 14, 2023 19:10
Repro for Loglevel#187
import log from 'loglevel';
import logPrefix from 'loglevel-plugin-prefix';
import { logFromA } from './module-a.js';
import { logFromB } from './module-b.js';
logPrefix.reg(log);
logPrefix.apply(log, { template: '[%t] %l %n:' });
log.enableAll();
// Comment out the imports at the top of the file and uncomment these to make
@Mr0grog
Mr0grog / compare.py
Last active October 17, 2023 21:32
Compare Unicode and WHATWG encoding mappings
"""
Quickie script for comparing legacy single-byte character encoding definitions
from the Unicode Consortium (found at https://unicode.org/Public/MAPPINGS/) and
the WHATWG (at https://encoding.spec.whatwg.org/#legacy-single-byte-encodings or
https://github.com/whatwg/encoding), since they differ slightly.
Typically, you'll want to download a copy of the Unicode mapping files via FTP:
ncftpget -R ftp.unicode.org . Public/MAPPINGS
mv MAPPINGS unicode
@Mr0grog
Mr0grog / 0-README.md
Created October 13, 2023 19:14
BOM Check Benchmark (Python)

Fastest way to check for a BOM in Python

Results:

Testing nesting...
             Baseline (A):: Min: 0.29188, mean: 0.29287
              Nesting (B):: Min: 0.25730, mean: 0.25863
 Nesting w/ Substring (C):: Min: 0.25488, mean: 0.25534
 Nesting w/ each byte (D):: Min: 0.24767, mean: 0.24830
@Mr0grog
Mr0grog / albertsons-services.json
Created May 2, 2023 18:29
Albertsons Pharmacy Bookable Services
{
"services": [
{
"type": "Vaccine",
"name": "OTC COVID TEST KITS 1",
"label": "OTC COVID TEST KITS 1",
"scientificname": "",
"epsDisplayName": "OTC COVID TEST KITS 1",
"eligible": true,
"description": "No Age Restrictions Present.",
@Mr0grog
Mr0grog / sentry-tracing.ts
Last active March 14, 2023 16:24
TS/JS Sentry Tracing Helpers
import EventEmitter from "node:events";
import * as Sentry from "@sentry/node";
import { Transaction } from "@sentry/tracing";
import type { Span, SpanStatusType } from "@sentry/tracing";
import type { SpanContext } from "@sentry/types";
export type { Span } from "@sentry/tracing";
interface SpanOptions extends SpanContext {
parentSpan?: Span;
timeout?: number;
@Mr0grog
Mr0grog / constant-pooled-data.mjs
Created April 26, 2022 03:23
Parse Airtable’s ConstantPooledData format.
/**
* Parse Airtable's "ConstantPooledData" format. They recently started using
* this format to compress some API responses, and it appears to be a
* home-grown format.
*
* Call `parseData()` if you have an object with data (e.g. a JSON-parsed API
* response body).
*
* Call `parseString()` if you have a raw string of data (e.g. an API response
* body).
@Mr0grog
Mr0grog / test-gzip-json-stream.js
Last active February 18, 2022 04:15
Test out the performance and memory usage of various ways to compose a gzip of streaming JSON log lines.
/**
* Test out the performance and memory usage of various ways to compose a gzip
* of streaming JSON log lines.
*
* One fun property of gzip is that a stream with multiple gzip chunks is
* itself valid as a single gzip stream/file. That means there are lots of
* interesting ways to break down how you build and stream out gzip data.
*/
const fs = require("fs");
@Mr0grog
Mr0grog / README.md
Last active September 28, 2021 03:13
EPA `/climate*` URLs crawled from `/climate-change`

EPA /climate* Crawl (2021-09-27)

This is a list of URLs found by crawling the EPA’s website starting from https://www.epa.gov/climate-change and including any page with a URL like https://*epa.gov/climate*.

It also includes pages that can be reached by going through https://www.epa.gov/node/<number>, since many of those are shortcuts for more nicely named pages that live at more canonical URLs like https://*epa.gov/climate*.

URLs are sorted alphabetically for nice, visual grouping.

Missing URLs

@Mr0grog
Mr0grog / urls.epa-climate-change.txt
Last active September 28, 2021 00:43
Crawl of all URLs under `epa.gov/climate*change*/`
http://www3.epa.gov/climatechange/Downloads/Region1-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region10-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region2-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region3-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region4-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region5-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region6-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region7-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region8-climate-change-adaptation-plan.pdf
http://www3.epa.gov/climatechange/Downloads/Region9-climate-change-adaptation-plan.pdf
@Mr0grog
Mr0grog / CODE_OF_CONDUCT.md
Last active June 25, 2021 18:57
Contributor Covenant Diff

(Version 2.0, hard-wrapping removed)

Contributor Covenant Code of Conduct

Our Pledge

We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.