Skip to content

Instantly share code, notes, and snippets.

View rjz's full-sized avatar
👋
Hey there!

RJ Zaworski rjz

👋
Hey there!
View GitHub Profile
@rjz
rjz / codec.ts
Created August 8, 2023 22:41
TypeScript wrapper for adding HMAC signatures to an existing codec / SerDe implementation
/** `x/crypto` if running in `deno` */
import { createHmac } from 'node:crypto'
/** A signing secret */
const HMAC_SECRET = '<YOUR SIGNING SECRET HERE>'
/** Length of a hexidecimal HMAC digest */
const HMAC_LENGTH = 64
function hmac(message: string): string {
/**
* Represents an error when an unreachable variant is encountered at runtime
*/
export class ExhaustiveCheckError<T> extends TypeError {
public instance: T;
public readonly isUnexpected = true;
constructor(msg: string, instance: T) {
super(msg);
@rjz
rjz / strict_null_checks.sh
Created February 26, 2021 18:41
Find TypeScript files that fail with --strictNullChecks enabled
#!/bin/bash
# Brute force search for TypeScript files in the current directory that fail
# the `--strictNullChecks` flag. YMMV.
# edit this function to exclude files that _shouldn't_ be checked.
filter_defs() {
grep -v node_modules \
| grep -v '.d.ts$' \
| sort \
@rjz
rjz / import_route53_zone_to_terraform.sh
Created May 30, 2020 00:42
Translates an existing AWS Route53 zone into Terraform `aws_route53_record` resources.
#! /bin/bash
#
# Translates an existing AWS Route53 zone into Terraform `aws_route53_record` resources.
#
# Released under the MIT license; YMMV. Tested on Linux with:
#
# - jq-1.6
# - terraform v0.12.26
# - aws-cli/1.17.14
#
@rjz
rjz / tsc_strict_null_checks_ok.ts
Created February 12, 2020 17:42
List of strict null-checked files inside a TypeScript project
#!/bin/bash
# Returns a list of strict null-checked files inside the current directory.
# Useful for gradually introducing the `--strictNullCheck` flag to a
# TypeScript project.
#
# See: https://code.visualstudio.com/blogs/2019/05/23/strict-null
TS_FLAGS='--strictNullChecks --outDir=/dev/null'
@rjz
rjz / pdf_to_booklet.sh
Created January 5, 2020 01:13
Convert PDF pages into a printable booklet on Linux using psutils
#! /bin/bash
#
# Use `psutils` to convert a PDF into a printable booklet.
#
# Usage:
#
# $ ./pdf_to_booklet.sh my_file.pdf
#
# Distributed under terms of the MIT license.
@rjz
rjz / NOTES.md
Created October 15, 2019 01:58
New Relic FutureTalks 2019-10-14

Performance Antipatterns - Ben Evans ([@kittylyst][kittylyst]), New Relic

First, what's a pattern?

a model or design used as a guide in needlework and other crafts

-- OED

A model or design: patterns are more abstract than the substrate you're applying them to. Software's pretty abstract already, but design patterns are

@rjz
rjz / pdx-reactjs-lightning-talks.md
Last active February 13, 2019 23:51
Lightning talks from the @pdxreactjs meetup on 2019-02-12.

PDXReactJS Lightning Talks

Lightning talks from the @pdxreactjs meetup on 2019-02-12.


A Better Approach to React Testing

Daniel Lemay - @dslemay

What's so great about Reason?

PDXReactJS meetup / 13. Nov 2018 @benjamminj

Maintainability?

We want to make complex problems simple, and solve them in ways we can extend on.

JavaScript v. ReasonML:

*.js