Skip to content

Instantly share code, notes, and snippets.

View jeremy-code's full-sized avatar

Jeremy Nguyen jeremy-code

View GitHub Profile
@jeremy-code
jeremy-code / extractImagesFromPage.ts
Created August 23, 2025 03:13
Extract all images from a PDF page using PDF.js
import { OPS, type PDFPageProxy, type ImageKind } from "pdfjs-dist/legacy/build/pdf.mjs";
// https://github.com/mozilla/pdf.js/blob/master/src/core/image.js#L698
type ImageObject = {
width: number;
height: number;
interpolate: undefined;
kind: (typeof ImageKind)[keyof typeof ImageKind];
data: Uint8Array | Uint8ClampedArray;
dataLen: number;
@jeremy-code
jeremy-code / README.md
Created August 8, 2025 07:06
Bulk reading PDF date of creation or other XMP metadata

I had about 2828 files that I wanted to mass read the date of creation from their metadata.

Initially, my thought was to use PDF.js with a structure like this (I am using legacy since I am on Node.js):

import { readFile } from "fs/promises";

import { getDocument } from "pdfjs-dist/legacy/build/pdf.mjs";

const file = await readFile(path);
Query successful
Washington, 12th 1841
In compliance with your suggestions this morning, I have the honor to submit considerations and propositions in reference to the debt of Major and Hooe, which I have become responsible for.
I have not entered into any definite arrangement with them, as I did not know the exact amount to be borrowed. Circumstances now compel an arrangement that allows time for them to proportion some part of it. I understand that Hooe will adjust his proportion of the joint obligation, which is the larger portion, and will pay one third of it with you. In any event, I propose to take up the whole debt, including interest, and provide acceptances payable here in New York at six, twelve, and eighteen months.
I also propose that the judgment against them, which has the same name as the original parties, be assigned to me. The world knows it is my purpose to exercise these assignments only to compel them to pay their share. If the time of indulgence is longer, I shall be willing to
@jeremy-code
jeremy-code / README.md
Created July 15, 2025 05:56
Unknown Man Died Eating Library Paste - July 14 1908
https://www.upi.com/Top_News/US/2011/07/12/Archivists-preparing-Robert-Kennedy-papers/58081310486946/
This photograph, part of the John F. Kennedy Presidential Library, taken in 1960 shows Brothers John F. Kennedy, Robert F. Kennedy, and Edward M. Kennedy in Hyannis Port, Cape Cop, Massachusetts. This image is one of the more than 1,500 images that the National Archives has released in their "Access to a Legacy" project, which is an online digital archive of high interest material from President John F. Kennedy's official and personal records. The collection consist of photographs, audio recordings, speech drafts, films and other material. UPI/John F. Kennedy Presidential Library and Museum | License Photo
https://newsroom.ap.org/editorial-photos-videos/detail?itemid=6687d47c68e146d9b261d2cf54cdbdc1&mediatype=photo
Sen. John F. Kennedy and Robert Kennedy
https://newsroom.ap.org/editorial-photos-videos/detail?itemid=6bce0629cf3f43fb88724c0eec26d32b&mediatype=photo
Sen. John F. Kennedy and Robert Ken
@jeremy-code
jeremy-code / README.md
Last active June 7, 2025 03:11
ESLint Plugins
@jeremy-code
jeremy-code / README.md
Last active June 2, 2025 08:22
Promises resolve to the same value

The title kind of sounds like gibberish but wait let me explain.

const main = async () => {
  const promise1 = Promise.resolve(Math.round(Math.random() * 100));
  const promise2 = promise1.then((value1) => value1 + 1);

  const [value1, value2] = await Promise.all([promise1, promise2]);
  // Value 1: 49, Value 2: 50
 console.log(`Value 1: ${value1}, Value 2: ${value2}`);
@jeremy-code
jeremy-code / package.json
Last active June 2, 2025 00:35
husky + lint-staged package.json
{
"name": "libxslt-wasm-demo",
"private": true,
"version": "0.0.0",
"dependencies": {
"husky": "^9.1.7",
"lint-staged": "^16.1.0"
}
}
@jeremy-code
jeremy-code / README.md
Created May 24, 2025 10:33
Moore & Ward

Pioneer Photographers from the Mississippi to the Continental Divide: A Biographical Dictionary, 1839-1865, Peter E. Palmquist, Thomas R. Kailbourn, 2005, Page 447

[Justus E. Moore and Captain Ward] received official permission to set up their daguerreian apparatus in the Capitol, including in the private chambers of Vice President Johnson and in the chamber of the Senate Committee on Military Affairs. In early March, Moore wrote that he and Ward had "taken many likenesses of the most distinguished members of the Senate and the House of Representatives." Even newly elected President William Henry Harrison sat for Moore and Ward in early March; their portrait of Harrison is thought to have been the first ever taken of a president, and probably was the last portrait taken of him before his death in April 1841.

Sources:

  1. Thomas M. Weprich, "The Pencil of Nature in Washington, D.C.: Daguerre-otyping the President," Daguerreian Annual 1995 (Pittsburgh: Daguerreian Society,1995), pp. 115, 117 nn. 1-3; New Yor