Skip to content

Instantly share code, notes, and snippets.

View AndrewPrifer's full-sized avatar

Andrew Prifer AndrewPrifer

View GitHub Profile
@AndrewPrifer
AndrewPrifer / migrate-tool-invocations.ts
Created September 25, 2025 07:20
Migrate tool invocations AI SDK 4 -> AI SDK 5
// Assumes a parts field in your messages table which holds the parts array of your persisted ui messages.
function transformToolInvocation(part: any): any {
if (part.type !== 'tool-invocation' || !part.toolInvocation) {
return part;
}
const { toolInvocation } = part;
const { args, result, state, toolName, toolCallId, step, ...otherProps } = toolInvocation;
@AndrewPrifer
AndrewPrifer / RollingStorage.ts
Created April 1, 2023 17:18
Rolling storage wrapping a Storage object
/**
* A storage class that will remove the oldest items when the storage size is exceeded.
*/
export class RollingStorage implements Storage {
private baseKey: string;
private maxSize: number;
private storage: Storage;
/**
* @param baseKey Base key to use for storage. Will be prefixed to all keys.
// ==UserScript==
// @name Student Portal Bullshit Toggler
// @author Andrew Prifer
// @description Lets you toggle the useless fixed boxes in the top row of the student portal. After installing, you will see a new button in the menu bar.
// @version 1.0
// @run-at document-end
// @match https://nestor.rug.nl/webapps/portal/execute/tabs/tabAction?tab_tab_group_id=_700_1
// ==/UserScript==
function insertAfter(newNode, referenceNode) {