Skip to content

Instantly share code, notes, and snippets.

View patrickhulce's full-sized avatar
😎
Live, eat, breathe JS

Patrick Hulce patrickhulce

😎
Live, eat, breathe JS
View GitHub Profile
@patrickhulce
patrickhulce / setup_mono.sh
Created September 13, 2024 19:50
Sets up a python monorepo using poetry.
#!/bin/bash
set -euxo pipefail
TEMP_DIR=$(mktemp -d)
mkdir -p $TEMP_DIR/package_a/src/namespace/a
mkdir -p $TEMP_DIR/package_b/src/namespace/b
mkdir -p $TEMP_DIR/package_c/src/namespace/c
@patrickhulce
patrickhulce / model.yml
Last active September 8, 2024 01:36
ComfyUI Setup
animatediff:
- model: mm_sdxl_beta.ckpt
download_url: https://huggingface.co/guoyww/animatediff/resolve/fdfe36afa161e51b3e9c24022b0e368d59e7345e/mm_sdxl_v10_beta.ckpt
commit_sha: fdfe36afa161e51b3e9c24022b0e368d59e7345e
md5: b211db6a009ecf8f63c4b7cfaa6dbfc3
- model: mm_sd15_v2.ckpt
download_url: https://huggingface.co/guoyww/animatediff/resolve/fdfe36afa161e51b3e9c24022b0e368d59e7345e/mm_sd_v15_v2.ckpt
commit_sha: fdfe36afa161e51b3e9c24022b0e368d59e7345e
md5: 52ed8a4d2f0cf64c8d85f04bc8e38c1e
- model: mm_sd15_v3_adapter.ckpt
@patrickhulce
patrickhulce / client.js
Created November 1, 2023 15:46
How node request cancellation works.
/* eslint-disable */
const fetch_ = require('node-fetch');
const fetchWithTimeout = async (url, options, timeout) => {
const controller = new AbortController();
const id = setTimeout(() => controller.abort(), timeout);
const response = await fetch(url, {
...options,
@patrickhulce
patrickhulce / web-events.test.ts
Created July 12, 2023 02:25
Cheatsheet for web events.
import {ReadableStream} from 'node:stream/web';
// Custom logger that accumulates log statements
const logger = {
logs: [],
log(...messages) {
this.logs.push(messages.join(' '));
},
error(...messages) {
this.logs.push(`ERROR: ${messages.join(' ')}`);
@patrickhulce
patrickhulce / plate-checker.js
Created July 8, 2023 19:42
Checks for a particular license plate combination in Texas.
async function checkAvailability(plate: string): Promise<string> {
const encodedPlate = encodeURIComponent(plate);
const url = `https://www.myplates.com/api/licenseplates/passenger/carbon-fiber/${encodedPlate}?_=${Date.now()}`;
const response = await fetch(url, {
headers: {
accept: 'application/json, text/javascript, */*; q=0.01',
'accept-language': 'en-US,en;q=0.9',
Referer: 'https://www.myplates.com/design/personalized/passenger/carbon-fiber/',
'Referrer-Policy': 'strict-origin-when-cross-origin',
},
@patrickhulce
patrickhulce / typedoc.sh
Created February 15, 2022 22:13
Automatically generate typedoc markdown on multiple platforms.
#!/bin/bash
set -euxo pipefail
./pnpm exec typedoc \
--treatWarningsAsErrors \
--excludePrivate \
--gitRevision master \
--githubPages false \
--plugin typedoc-plugin-markdown \
@patrickhulce
patrickhulce / Dockerfile
Created February 11, 2022 19:47
Chromium hangs on screenshots when `--disable-frame-rate-limit` is used.
FROM node:16-buster
WORKDIR /app
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
RUN echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | tee /etc/apt/sources.list.d/google-chrome.list
RUN apt-get update
RUN apt-get install -y google-chrome-stable
COPY package.json ./
@patrickhulce
patrickhulce / microtasks.mjs
Created February 8, 2022 21:18
Microtask flush example
let x = 0;
new Promise(resolve => resolve()).then(() => {
x = 1
new Promise(resolve => resolve()).then(() => {
x = 2
})
})
await flushAllMicrotasks()
@patrickhulce
patrickhulce / resizer.js
Created April 19, 2021 20:01
Resize Image
function resize(imageDataUrl) {
return new Promise((resolve, reject) => {
const img = new Image()
img.addEventListener('error', reject)
img.addEventListener('load', () => {
try {
canvas.width = img.width
canvas.height = img.height
context.drawImage(img, 0, 0)
const imageData = context!.getImageData(0, 0, img.width, img.height)
@patrickhulce
patrickhulce / run.js
Created December 1, 2020 16:03
Get GitHub logins from commit hashes
const fs = require('fs');
const fetch = require('isomorphic-fetch');
async function go() {
const hashes = fs.readFileSync('hashes.txt', 'utf-8').split('\n');
for (const hash of hashes) {
if (!hash.trim()) continue;
const response = await fetch(`https://api.github.com/repos/GoogleChrome/lighthouse/commits/${hash}`);
const json = await response.json();