Skip to content

Instantly share code, notes, and snippets.

View jmcph4's full-sized avatar

Jack McPherson jmcph4

View GitHub Profile
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)),
}
@jmcph4
jmcph4 / pelag.html
Last active September 13, 2025 05:56
<html>
<body>
<ul>
<li>[2025-09-09T18:56:12+10:00] <a href="https://doc-en.rvspace.org/JH7110/PDF/JH7110_Product_Brief.pdf">StarFive JH-7110 Product Brief (PDF)</a></li>
</ul>
<hr />
<ul>
<li>[2025-09-09T18:56:12+10:00] <a href="https://wiki.osdev.org/RISC-V">RISC-V - OSDev Wiki</a></li>
</ul>
<hr />