Skip to content

Instantly share code, notes, and snippets.

View jmcph4's full-sized avatar

Jack McPherson jmcph4

View GitHub Profile
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Minimal DnD Designer</title>
<style>
:root { color-scheme: light dark; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font: 14px/1.35 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; }
Error: HttpError: Invalid status code 400 Bad Request with message: {
"error": {
"message": "Requested 1325364 tokens, max 300000 tokens per request",
"type": "max_tokens_per_request",
"param": null,
"code": "max_tokens_per_request"
}
}
use rayon::prelude::*;
pub fn search(haystack: &[(Url, String)], needle: &str) -> Vec<Finding> {
if needle.is_empty() {
return Vec::new();
}
haystack
.par_iter()
.flat_map_iter(|(url, text)| {
@jmcph4
jmcph4 / fetch.rs
Last active December 14, 2025 04:38
use eyre::Result;
use futures::{stream, StreamExt, TryStreamExt};
use playwright::{api::DocumentLoadState, Playwright};
use std::{sync::Arc, time::Duration};
use tokio::sync::Semaphore;
use url::Url;
pub struct HtmlFetcher {
context: playwright::api::BrowserContext,
}
@jmcph4
jmcph4 / lines.md
Last active November 19, 2025 04:54
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Rust                            16            147            114            868
Markdown                         4             20              0             46
YAML                             2             15              0             42
TOML                             3              7              1             39
JSON                             1              1              0             10
-------------------------------------------------------------------------------
#!/usr/bin/env bash
set -euo pipefail
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
echo "Usage: attrib [COMMIT_HASH] [AUTHOR_NAME]"
echo
echo "Defaults:"
echo " COMMIT_HASH = git rev-parse HEAD"
echo " AUTHOR_NAME = jmcph4"
exit 0
#!/usr/bin/env python3
# Extract TOP500 listings for a given country from the provided XML.
# Source schema example: :contentReference[oaicite:0]{index=0}
import argparse
import csv
import json
import sys
import xml.etree.ElementTree as ET
from typing import Dict, List, Optional
@jmcph4
jmcph4 / hoom.rs
Last active September 28, 2025 03:14
use std::fmt::Display;
use clap::{Parser, Subcommand};
#[derive(Copy, Clone, Debug)]
pub enum Cost {
Fixed(f64),
Proportion((f64, f64)),
}