Skip to content

Instantly share code, notes, and snippets.

View freedmand's full-sized avatar

Dylan Freedman freedmand

View GitHub Profile
@freedmand
freedmand / tester.ts
Last active November 3, 2018 17:36
Minimal unit testing framework (TypeScript)
function assert(arg1: any, arg2: any) {
if (arg1 != arg2) throw new Error(`Expected ${arg1} to equal ${arg2}`);
}
const PASS = ['32']; // green
const FAIL = ['31', '1']; // red, bold
function logStyle(codes: string | string[], text: string) {
if (Array.isArray(codes)) codes = codes.join(';');
console.log(`\x1b[${codes}m${text}\x1b[0m`);
@freedmand
freedmand / tester.js
Last active November 7, 2018 11:13
JavaScript unit testing in under 30 lines
const PASS = ['32']; // green
const FAIL = ['31', '1']; // red, bold
function logStyle(ansiEscapeCodes, text) {
console.log(`\x1b[${ansiEscapeCodes.join(';')}m${text}\x1b[0m`);
}
class Tester {
constructor() {}
### Keybase proof
I hereby claim:
* I am freedmand on github.
* I am freedmand (https://keybase.io/freedmand) on keybase.
* I have a public key ASDmxHhr9-w51bAYvHTz2249NO08yZZ3eaPaV--NpTAXlgo
To claim this, I am signing this object:
@freedmand
freedmand / website_to_pdf.sh
Created April 17, 2023 12:48
Archives all pages of a specified website and outputs a single PDF file
#!/bin/bash
# Archives a specified website including all sub-pages and outputs a single PDF file
# Requires the following tools to be installed:
# - wget
# - wkhtmltopdf
# - gs (ghostscript)
# Installation: