Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View pdehaan's full-sized avatar
🏠
Working from home

Peter deHaan pdehaan

🏠
Working from home
View GitHub Profile
@pdehaan
pdehaan / junit-reporter.js
Created January 10, 2024 08:10
Convert a glob of JUnit XML reports into a JSON object... for reasons.
import fs from "node:fs";
import fg from "fast-glob";
import { XMLParser } from "fast-xml-parser";
import { z } from "zod";
const testsuiteSchema = z.object({
testsuite: z.array(
z.object({
testcase: z.array(
z.object({
@pdehaan
pdehaan / hibp-data-class-count.mjs
Created July 20, 2023 16:56
HIBP DataClass count
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const HIBP_URL = "https://haveibeenpwned.com/api/v3/breaches";
const breaches = await fetch(HIBP_URL).then(res => res.json());
const count = breaches.length;
const stats = breaches.reduce((stats, breach) => {
@pdehaan
pdehaan / stripe-vs-paypal.md
Last active June 21, 2023 22:21
Supported currencies in Stripe and PayPal.
CURRENCY DIGITS PAYPAL / STRIPE
[AED] UAE Dirham 2 ✗ / ✓
[AFN] Afghani 2 ✗ / ✓
[ALL] Lek 2 ✗ / ✓
[AMD] Armenian Dram 2 ✗ / ✓
[ANG] Netherlands Antillean Guilder 2 ✗ / ✓
[AOA] Kwanza 2 ✗ / ✓
[ARS] Argentine Peso 2 ✗ / ✓
[AUD] Australian Dollar 2 ✓ / ✓
@pdehaan
pdehaan / hibp-stats.md
Created May 26, 2023 15:09
haveibeenpwned breach stats
DATA CLASS BREACH COUNT (674) BREACH PERCENT TOTAL PWN COUNT
Email addresses 668 99% 12,550,581,668
Passwords 528 78% 8,129,073,504
Usernames 356 53% 3,848,673,897
Names 321 48% 6,419,053,031
IP addresses 289 43% 3,127,783,590
Phone numbers 202 30% 4,054,006,665
Dates of birth 179 27% 3,115,021,728
Physical addresses 158 23% 2,489,450,219
@pdehaan
pdehaan / hibp-Name-vs-Title.mjs
Created April 25, 2023 16:14
Comparing HIBP `Name` vs `Title` props.
const arr = [];
const breaches = await fetchBreaches();
for (const { Name, Title } of breaches) {
if (Name !== Title) {
arr.push({ Name, Title });
}
}
console.log(JSON.stringify(arr, null, 2));
@pdehaan
pdehaan / eslint-disable-linter.mjs
Last active April 13, 2023 06:55
Check for instances of eslint-disable* in the FxA monorepo.
import cp from 'node:child_process';
import _groupBy from 'lodash.groupby';
main('packages');
function main(base) {
const results = grepESLintDisable(base);
const matches = _groupBy(results, 'package');
logger(matches);
}
@pdehaan
pdehaan / RESULTS.md
Created April 10, 2023 21:22
FxA import vs require stats
{ filesWithImport: 1815, filesWithRequire: 813 }
fxa-admin-panel
  • packages/fxa-admin-panel/server/lib/server.ts
39: const release = require('../../package.json').version;
@pdehaan
pdehaan / date-parser.js
Created April 3, 2023 15:06
Date parsing for fun ~and profit~
const $classes = `
Mon Apr 3 7pm-10pm (PDT)
Mon Apr 10 7pm-10pm
Mon Apr 17 7pm-10pm
Mon Apr 24 7pm-10pm
$120 USD, 8 (of 8) enrolled
`;
const classes = $classes.split("\n").filter(Boolean);
@pdehaan
pdehaan / index.cjs
Last active April 1, 2023 02:33
Date string parsing w/ Luxon
const { DateTime } = require("luxon");
const start = parseDateTime("Thu Apr 13", "1pm");
const end = parseDateTime("Mon Dec 19 2022", "4pM");
console.log(`${start} -- ${end}`);
function parseDateTime(dateString, timeString) {
const CURR_YEAR = new Date().getFullYear();
const DATE_FORMAT = /* ccc */ "LLL d yyyy";
const TIME_FORMAT = "h:mma";
@pdehaan
pdehaan / OUTPUT.txt
Last active March 20, 2023 18:34
Comparing Pontoon's https://pontoon.mozilla.org/projects/firefox-accounts/ locales to moment's supported locales. MOVED TO https://github.com/pdehaan/momentjs-locales
moment is missing FxA "ast" locale (21%)
moment is missing FxA "cak" locale (67%)
moment is missing FxA "dsb" locale (82%)
moment is missing FxA "es-ar" locale (100%)
moment is missing FxA "es-cl" locale (100%)
moment is missing FxA "es-es" locale (92%)
moment is missing FxA "fur" locale (36%)
moment is missing FxA "fy-nl" locale (100%)
moment is missing FxA "gn" locale (100%)
moment is missing FxA "hi-in" locale (32%)