Skip to content

Instantly share code, notes, and snippets.

@prescience-data
prescience-data / compose.ts
Last active April 7, 2023 07:44
Typesafe composition
/**
* This is a test to show how to compose objects with typescript.
*/
/**
* Creates an intersection type from a union type.
* @public
*/
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
k: infer I
@prescience-data
prescience-data / type-into.ts
Last active September 8, 2023 00:38
Demo of biometric typing skeleton logic for Playwright
import { chromium, Page } from "playwright-core"
/**
* Entrypoint.
*
* @remarks
* Demonstrates a safe typing algorithm that mimics human typing cadence.
*
* @public
*/
@prescience-data
prescience-data / filesystem.ts
Last active April 27, 2025 02:43
Save and restore session data using Playwright
import { exec } from "node:child_process"
import { createReadStream, createWriteStream, existsSync, readFileSync } from "node:fs"
import { mkdir } from "node:fs/promises"
import { basename, dirname, join } from "node:path"
import { pipeline } from "node:stream/promises"
import { promisify } from "node:util"
import { createGzip } from "node:zlib"
import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3"