Skip to content

Instantly share code, notes, and snippets.

View swain's full-sized avatar

Swain Molster swain

View GitHub Profile
@swain
swain / fix-non-null-assertions.ts
Created September 21, 2023 17:59
Script for fixing non-null assertions
import * as fs from 'fs';
import * as ts from 'typescript';
import glob from 'glob';
import { sortBy, uniq } from 'lodash';
/**
* Inserts the specified `text` at the specified `line` and `character` in the file at `filepath`.
*/
const insertTextAtLine = (opts: {
filepath: string;
const requestReviewers = (repo: string, pull_number: number) => {
const BLACKLIST = [
'mdlavin',
'jagoda',
// others?
];
const { data: contributors } = await github.rest.repos.listContributors({
owner: 'lifeomic',
repo,
@swain
swain / jwt-webhook-validation.md
Last active July 14, 2022 21:58
A request validation approach using JWTs

This approach is largely based on the webhook signing approach used by Plaid. See their docs for context: https://plaid.com/docs/api/webhooks/webhook-verification/.

It's a simple approach that works using JWTs.

Sending Requests (our platform does this)

Assume a generated key pair.

import axios from 'axios';
//
// UIControl+TargetAction.swift
//
// Created by Swain Molster on 6/26/18.
// Copyright © 2018 Swain Molster. All rights reserved.
//
import Foundation
/**