Skip to content

Instantly share code, notes, and snippets.

View tgdn's full-sized avatar

Thomas Gak-Deluen tgdn

View GitHub Profile
@dannguyen
dannguyen / README.openai-structured-output-demo.md
Last active April 28, 2025 03:31
A basic test of OpenAI's Structured Output feature against financial disclosure reports and a newspaper's police blotter. Code examples use the Python SDK and pydantic for the schema definition.

Extracting financial disclosure reports and police blotter narratives using OpenAI's Structured Output

tl;dr this demo shows how to call OpenAI's gpt-4o-mini model, provide it with URL of a screenshot of a document, and extract data that follows a schema you define. The results are pretty solid even with little effort in defining the data — and no effort doing data prep. OpenAI's API could be a cost-efficient tool for large scale data gathering projects involving public documents.

OpenAI announced Structured Outputs for its API, a feature that allows users to specify the fields and schema of extracted data, and guarantees that the JSON output will follow that specification.

For example, given a Congressional financial disclosure report, with assets defined in a table like this:

-- vim: tabstop=2 shiftwidth=2 expandtab
-- We almost always start by importing the wezterm module
local wezterm = require 'wezterm'
-- Define a lua table to hold _our_ module's functions
local module = {}
-- Returns a bool based on whether the host operating system's
-- appearance is light or dark.
function module.is_dark()
@suhaotian
suhaotian / CaptchaWidget.tsx
Last active December 31, 2024 02:26
Cloudflare turnstile for next.js
'use client';
import Script from 'next/script';
import { useEffect, useRef, useState } from 'react';
const scriptLink = 'https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit';
type TurnstileRenderParameters = Turnstile.RenderParameters;
export default function Captcha(
NOTE: The MUI X License Key more than likely isn't going to work. It will have expired. The lifetime license key should... well... last forever...
MUI X License Key (from https://mui.com):
61628ce74db2c1b62783a6d438593bc5Tz1NVUktRG9jLEU9MTY4MzQ0NzgyMTI4NCxTPXByZW1pdW0sTE09c3Vic2NyaXB0aW9uLEtWPTI=
Order Number: MUI-Doc
Expiry Timestamp: 1683447821284(Sun May 7th 08:32:41)
Scope: Premium
Licensing Model: Subscription
Key Version: 2
@kconner
kconner / macOS Internals.md
Last active May 6, 2025 05:33
macOS Internals

macOS Internals

Understand your Mac and iPhone more deeply by tracing the evolution of Mac OS X from prelease to Swift. John Siracusa delivers the details.

Starting Points

How to use this gist

You've got two main options:

@Tymek
Tymek / useNavigationLock.ts
Last active May 25, 2023 22:38
Next.js block navigation on unsaved changes
import { useEffect, useState } from 'react';
import { useRouter } from 'next/router';
/** Ask for confirmation before changing page or leaving site.
*
* @see https://git.io/JOskG
*/
const useNavigationLock = (
isEnabled = true,
warningText = 'You have unsaved changes – are you sure you wish to leave this page?',
@jrnxf
jrnxf / Grid.tsx
Created March 27, 2021 19:07
react-stack-grid overlapping fix
import React, { useEffect, useRef } from 'react'
import { useWindowSize } from '@react-hook/window-size'
import StackGrid from 'react-stack-grid'
export const Grid = ({ children }) => {
const ANIMATION_DURATION = 400
const [windowWidth] = useWindowSize()
const grid = useRef(null)
const resizeGrid = () => {
if (grid.current) {
@skeeto
skeeto / README.md
Last active September 23, 2024 02:16
AI driving simulation