Skip to content

Instantly share code, notes, and snippets.

View bleonard's full-sized avatar

Brian Leonard bleonard

View GitHub Profile
@bleonard
bleonard / count_rijksmuseum_tokens.ts
Created April 2, 2026 17:00
Rijksmuseum Wikipedia HTML token count: 96,381 tokens (gpt-5 / o200k_base)
import { encoding_for_model, TiktokenModel } from "tiktoken";
const URL = "https://en.wikipedia.org/wiki/Rijksmuseum";
const MODEL = "gpt-5" as TiktokenModel;
const response = await fetch(URL);
const html = await response.text();
const encoding = encoding_for_model(MODEL);
const tokens = encoding.encode(html);
@bleonard
bleonard / count_colosseum_tokens.ts
Created April 2, 2026 17:00
Colosseum Wikipedia HTML token count: 118,862 tokens (gpt-5 / o200k_base)
import { encoding_for_model, TiktokenModel } from "tiktoken";
const URL = "https://en.wikipedia.org/wiki/Colosseum";
const MODEL = "gpt-5" as TiktokenModel;
const response = await fetch(URL);
const html = await response.text();
const encoding = encoding_for_model(MODEL);
const tokens = encoding.encode(html);
@bleonard
bleonard / count_globe_tokens.ts
Created April 2, 2026 17:00
Globe Theatre Wikipedia HTML token count: 65,875 tokens (gpt-5 / o200k_base)
import { encoding_for_model, TiktokenModel } from "tiktoken";
const URL = "https://en.wikipedia.org/wiki/Globe_Theatre";
const MODEL = "gpt-5" as TiktokenModel;
const response = await fetch(URL);
const html = await response.text();
const encoding = encoding_for_model(MODEL);
const tokens = encoding.encode(html);
@bleonard
bleonard / count_gaudi_tokens.ts
Created April 2, 2026 17:00
Antoni Gaudí Wikipedia HTML token count: 162,517 tokens (gpt-5 / o200k_base)
import { encoding_for_model, TiktokenModel } from "tiktoken";
const URL = "https://en.wikipedia.org/wiki/Antoni_Gaud%C3%AD";
const MODEL = "gpt-5" as TiktokenModel;
const response = await fetch(URL);
const html = await response.text();
const encoding = encoding_for_model(MODEL);
const tokens = encoding.encode(html);
/**
*@NApiVersion 2.x
*@NScriptType Restlet
*/
// eslint-disable-next-line no-undef
define(["N/record", "N/log", "N/search"], function (record, log, search) {
// It does this thing where it's "line 1" object key instead of an array. make it an array.
function normalize_sublists(sublists) {
var out = {};
function getItem() {
let node, text;
let output = "";
let labels = ['roadmap'];
node = document.querySelector(".mat-dialog-content .roadmap-project-header-first-line");
text = node.innerText;
output += "\nTitle: [Roadmap] " + text
const lines = document.querySelectorAll(".key-value-line");
# every minute
subscribe "every_minute", 'bus_event_type' => 'heartbeat_minutes' do |attributes|
InvoiceChargeWorker.process_all!
end
# every hour: 4:22, 5:22, 6:22, etc
subscribe "once_an_hour", 'bus_event_type' => 'heartbeat_minutes', 'minute' => 22 do |attributes|
InvoiceChargeWorker.process_all!
end
namespace :resque do
task :setup => [:environment] do
require 'resque_scheduler'
require 'resque/scheduler'
require 'tresque'
QueueBus.heartbeat!
end
end
# for Tue, 11 Apr 2017 00:25:00 UTC +00:00
# epoch time: 1491870300
QueueBus.publish(heartbeat_seconds", {
"epoch_seconds"=>1491870300,
"epoch_minutes"=>24864505,
"epoch_hours"=>414408,
"epoch_days"=>17267,
"minute"=>25,
"hour"=>0,
class InvoiceChargeWorker
include TResque::Worker
inputs :invoice_id
worker_lock :invoice_id
def self.process_all!
Invoice.where(stat: 'pending').find_each do |invoice|
self.enqueue(invoice_id: invoice.id)
end