Skip to content

Instantly share code, notes, and snippets.

View josescasanova's full-sized avatar
:octocat:

jose josescasanova

:octocat:
View GitHub Profile
@dannguyen
dannguyen / README.openai-structured-output-demo.md
Last active April 14, 2025 16:56
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:

export default {
async fetch(request, env, ctx) {
const url = new URL(request.url);
// Modify the request to point to the Google Tag Manager endpoint
url.hostname = env.GTM_HOST;
// Create a new headers object based on the original request headers
const modifiedHeaders = new Headers(request.headers);
@NotoriousPyro
NotoriousPyro / BurnATAs.ts
Last active May 21, 2024 22:34
Burn your unwanted ATAs on Solana with this script
import { GetProgramAccountsFilter, PublicKey, TransactionMessage, VersionedTransaction } from "@solana/web3.js";
import { connection } from "../src/connection";
import config from "../src/lib/Config";
import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, createBurnCheckedInstruction, createCloseAccountInstruction, getAssociatedTokenAddressSync, unpackAccount, unpackMint } from "@solana/spl-token";
// Not really tested more than two but you can probably fit more in.
const maxMintsPerTx = 2;
// Replace this with your own keypair
const owningAccount = config.keypair;
// This creates a tx like this: https://solscan.io/tx/5PegaAnFzaEdVWYfzHFVTzJyZr8wHKRhijgtXyGhNzaQj4HfW5U8BqaaHNhGkCbZRDePns5cnFJAb18RCx4cuLqB
@NotoriousPyro
NotoriousPyro / connection-manager.ts
Created March 15, 2024 21:31
ConnectionManager Solana class for SexBot
import {
Instruction,
SwapInstructionsResponse
} from "@jup-ag/api";
import {
AddressLookupTableAccount,
ComputeBudgetProgram,
Connection,
Keypair,
PublicKey,
@druv5319
druv5319 / index.js
Created March 2, 2022 18:50
SendGrid Newsletter App
require('dotenv').config();
const sgMail = require('@sendgrid/mail');
const sgClient = require('@sendgrid/client');
const express = require('express')
const expressFileUpload = require('express-fileupload');
const app = express();
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
sgClient.setApiKey(process.env.SENDGRID_API_KEY);
app.use(express.urlencoded({
@josescasanova
josescasanova / fix-homebrew-npm.md
Created April 30, 2018 15:30 — forked from DanHerbert/fix-homebrew-npm.md
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

@levelsio
levelsio / btc-eth-dca-buy.php
Last active January 21, 2025 12:12
This script runs daily and "Dollar Cost Average"-buys $40 BTC and $10 ETH per day
<?
//
// [ BUY BTC & ETH DAILY ON BITSTAMP ]
// by @levelsio
//
// 2017-08-23
//
// 1) buy $40/day BTC
// 2) buy $10/day ETH
//
BEARER='authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWlkIjoiQlUxMTEwMTAwMDAxMTAwODc0MSIsIm1haWQiOiJNQTExMTAxMDAwMDExMDA4NzM3Iiwic3ViZCI6InRlc3Rmb3JjZSIsInVzZXJfaWQiOiJhdXRoMHxCVTExMTAxMDAwMDExMDA4NzQxIiwiZW1haWwiOiJ0ZXN0Zm9yY2VAYml6b2RvLmNvbSIsIm5hbWUiOiJGb3JjZSBBd2FrZW5zIiwiaXNzIjoiaHR0cHM6Ly9zZWFtbGVzc2RvY3NkZXYuYXV0aDAuY29tLyIsInN1YiI6ImF1dGgwfEJVMTExMDEwMDAwMTEwMDg3NDEiLCJhdWQiOiJHRk54dWhSa0sweDRwbkVocmJSbzkzUDBCNDBBdlFmMyIsImV4cCI6MTQ4OTAyMzQ0MiwiaWF0IjoxNDg4OTg3NDQyfQ.DbcKYHvjp3GPM0hIO2vsScqJ7eXB26GWmkUUPMRVgVw'
USER_AGENT='user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36'
# curl 'http://localhost:9000/selectors/forms/replace.json' -H 'origin: https://localhost:3000' -H 'accept-encoding: gzip, deflate, br' -H 'x-requested-with: XMLHttpRequest' -H 'accept-language: en-US,en;q=0.8' -H "$BEARER" -H 'content-type: application/json' -H 'accept: */*' -H 'referer: https://localhost:3000/ng/lobby' -H 'author
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 15, 2025 22:49
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

If you find the following useful my donation address is: aEgoFC75sP78gT55em1QYcL8DNYZ78ewJ5
1. Go here: https://console.aws.amazon.com/ec2sp/v1/spot/home?region=us-east-1
2. Click: "Request Spot Instances"
3. Request type: "Request and Maintain"
4. Choose how ever many servers/vcpus you want in the "Target Capacity" section.