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 / OUTPUT.txt
Last active February 23, 2023 21:21
Scraping the official Mozilla add-ons for fun and profit
https://addons.mozilla.org/api/v5/addons/search/?author=mozilla&page_size=100&type=extension
name: Firefox Relay (2.6.1)
size: 777.5 KB
last_updated: Feb 22, 2023 (2 days ago)
ratings: 4.0957 (1,275)
average_daily_users: 138,528
weekly_downloads: 2,394
homepage: https://relay.firefox.com/
@pdehaan
pdehaan / README.md
Last active October 17, 2022 17:32
Converting FxA Storybook from storiesOf to Meta.

fxa-payments-server

FILE METHOD CODE
src/components/AlertBar storiesOf import { storiesOf } from '@storybook/react'
src/components/AppLayout storiesOf import { storiesOf } from '@storybook/react'
src/components/CouponForm storiesOf import { storiesOf } from '@storybook/react'
src/components/DialogMessage storiesOf import { storiesOf } from '@storybook/react'
src/components/Header storiesOf import { storiesOf } from '@storybook/react'
src/components/LoadingOverlay Meta import { Meta } from '@storybook/react'
@pdehaan
pdehaan / .eleventy.js
Created October 8, 2022 00:49
Eleventy event logger
const fs = require("node:fs/promises");
const { inspect } = require("node:util");
/**
* @typedef {import('@11ty/eleventy/src/UserConfig')} EleventyConfig
* @typedef {ReturnType<import('@11ty/eleventy/src/defaultConfig')>} EleventyReturnValue
* @type {(eleventyConfig: EleventyConfig) => EleventyReturnValue}
*/
module.exports = function (eleventyConfig) {
const eventData = [];
@pdehaan
pdehaan / prettiest.mjs
Created June 14, 2022 19:35
Get a list of all Prettier-able files in a repo.
import { execSync } from "node:child_process";
import path from "node:path";
import minimatch from "minimatch";
import prettier from "prettier";
const ignores = [
".circleci/**",
".github/**",
".vscode/**",
@pdehaan
pdehaan / _index.js
Last active June 1, 2022 17:19
Inspecting the eslint-plugin-* configs for jsx-a11y and react plugins.
const { inspect } = require("node:util");
// `npm i sort-object-keys -D`
const sortObj = require("sort-object-keys");
// `npm i eslint-plugin-jsx-a11y -D`
// console.log(dump("eslint-plugin-jsx-a11y"));
// `npm i eslint-plugin-react -D`
console.log(dump("eslint-plugin-react"));
@pdehaan
pdehaan / dep-http-linter.js
Created April 15, 2022 16:51
Linting all the FxA https: dependencies
const axios = require("axios");
const glob = require("fast-glob");
const parse = require("parse-github-repo-url");
glob("./packages/*/package.json").then(files => {
for (const file of files) {
const pkg = require(file);
const allDeps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
const httpDeps = Object.entries(allDeps)
.filter(([name, version]) => version.startsWith("https://"));
@pdehaan
pdehaan / firefox-monitor-alpine.js
Created April 7, 2022 23:22
Looping and templating w/ Alpine.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<style>
h2 {
color: salmon;
font-family: "Comic Sans MS";
}
dt {
@pdehaan
pdehaan / ftl-lint.js
Created April 1, 2022 00:00
An API version of `npx htmlhint --rules=tag-pair --nocolor **/*.ftl`
import fs from "node:fs/promises";
import glob from "fast-glob";
import {HTMLHint} from "htmlhint";
const res = await verifyGlob("**/*.ftl", false);
console.log(res);
async function verifyGlob(fileglob, ignoreComments=true) {
let errors = [];
for (const file of await glob([fileglob, "!node_modules/**"])) {
@pdehaan
pdehaan / fetch-eleventy-plugins.js
Last active March 27, 2022 06:54
Fetch a list of eleventy-plugins from npms.io API
import axios from "axios";
const npmsClient = axios.create({
baseURL: new URL("/v2/search", "https://api.npms.io").href,
timeout: 2000,
});
const res = await searchNpms(["keywords:eleventy-plugin"], 15);
console.log(JSON.stringify(res, null, 2));
@pdehaan
pdehaan / output.json
Created March 23, 2022 02:56
Linting the built-with-eleventy/*.json files.
{
"built-with-eleventy/0FgV3CGtHR.json": {
"errors": [
"must have required property 'opened_by'"
],
"data": {
"leaderboard_excluded": true,
"url": "https://github.com/lit/lit-element-starter-ts",
"source_url": "https://github.com/lit/lit-element-starter-ts"
}