Skip to content

Instantly share code, notes, and snippets.


Payton Swick sirbrillig

View GitHub Profile
sirbrillig /
Created Aug 23, 2021
A way to run tsc on a single file in my project; copied from
#!/bin/bash -e
cat >$TMP <<EOF
"extends": "./tsconfig.json",
"include": [
for file in "$@"; do
echo " \"$file\"," >> $TMP
View jest-testing-library-verify-text-never-appears.ts
// This is a little tricky because we need to verify that text never appears,
// even after some time passes, so we use this slightly convoluted technique:
async function verifyThatTextNeverAppears( text: string ) {
await expect( screen.findByText( text ) ).rejects.toThrow();
View checkout-experiment.php
Plugin Name: Checkout Experiment
Description: An experimental checkout inside wp-admin
Author: Automattic
Version: 1.0
Author URI:
class CheckoutExperiment {
View index.tsx
import React from "react";
import { render } from "react-dom";
// @ts-ignore
import wpcomFactory from 'wpcom';
import wpcomProxyRequest from 'wpcom-proxy-request';
import {
} from "@automattic/shopping-cart";
import {
sirbrillig / .gitconfig
Created Mar 10, 2020
Git config alias for backup and restore of current branch
View .gitconfig
backup-create = "!f() { git branch -f backup-$(git rev-parse --abbrev-ref HEAD) && echo 'Backup created. Use git backup-restore to restore.'; }; f"
backup-restore = "!f() { echo 'Are you sure you want to overwrite the current branch with the latest backup? This cannot be undone!'; select result in Yes No; do [[ $result == "Yes" ]] && git reset --hard backup-$(git rev-parse --abbrev-ref HEAD) && echo 'Backup restored.'; break; done; }; f"
sirbrillig / index.php
Last active Oct 4, 2019
Example of PHP shell helper injection and test
View index.php
// If this function were a class method, the injection could happen in the constructor instead
function printMessageAndExit(string $message, ?ShellHelper $shell): void {
$shell = $shell ?? new DefaultShell();
interface ShellHelper {
sirbrillig / Phabricator-Notification-Grouping.js
Last active Dec 17, 2018
Allows collapsing Phabricator notifications to one-per-revision
View Phabricator-Notification-Grouping.js
// ==UserScript==
// @name Phabricator Notification Grouping
// @namespace
// @version 0.1
// @description Allows collapsing Phabricator notifications to one-per-revision
// @author Payton Swick <>
// @match*
// @grant none
// ==/UserScript==
sirbrillig /
Last active Apr 30, 2018
My vegan haggis recipe

Vegan Haggins and Neeps and Tatties


  • 6 medium russet potatoes, roughly chopped
  • 1 large rutabaga, roughly chopped
  • 1/2 stick of margarine
  • salt and pepper to taste
  • 1 large onion, chopped
  • 2 medium carrots, grated
sirbrillig / bootstrap.php
Created Dec 5, 2017
Bootstrap for writing phpcs sniff tests
View bootstrap.php
require_once(__DIR__ . '/../vendor/squizlabs/php_codesniffer/tests/bootstrap.php');
require_once(__DIR__ . '/SniffTestHelper.php');
sirbrillig / SniffTestHelper.php
Created Dec 5, 2017
A helper class for testing phpcs sniffs
View SniffTestHelper.php
use PHP_CodeSniffer\Files\LocalFile;
use PHP_CodeSniffer\Ruleset;
use PHP_CodeSniffer\Config;
class SniffTestHelper {
public function prepareLocalFileForSniffs($sniffFiles, string $fixtureFile): LocalFile {
$config = new Config();
$ruleset = new Ruleset($config);