Skip to content

Instantly share code, notes, and snippets.

View Andrew-Chen-Wang's full-sized avatar
🐢
herro

Andrew Chen Wang Andrew-Chen-Wang

🐢
herro
View GitHub Profile
@Andrew-Chen-Wang
Andrew-Chen-Wang / README.md
Created February 26, 2026 21:45
Handling Playwright MCP snapshots that are too large

On very large pages, the snapshot can fill the entire context #1329

microsoft/playwright-mcp#1329

believe a good source of inspiration is Claude Code/Codex. There are two things that I'm thinking of which is:

Grab the HTML instead. Unfortunately, usually when the browser_snapshot is so huge, the html is also pretty big (in my case 12m HTML and above sometimes) Take a browser_screenshot and grab the HTML and browser_snapshot and use a "Grep" tool or an HTML parser (or however your agent is running) to whatever you need so that your MCP can do a browser action. Images should be much smaller. Here's some slop Claude code that worked for me very well. I'm using openai/agents, but this can be used for any custom or alternative agent package.

@Andrew-Chen-Wang
Andrew-Chen-Wang / openai.test.ts
Created February 25, 2026 21:43
Automatically add tracing to OpenAI Agents JS if you use openai package directly
import { getGlobalTraceProvider, setTracingDisabled, withTrace } from "@openai/agents"
import { Agent, run } from "@openai/agents"
import { openai } from "@scraper/utils/openai"
import { zodTextFormat } from "openai/helpers/zod"
import { afterAll, beforeAll, describe, expect, it } from "vitest"
import { z } from "zod"
const testSchema = z.object({
randomNumber: z.number(),
})
@Andrew-Chen-Wang
Andrew-Chen-Wang / README.md
Last active September 19, 2025 07:13
Downsides of Pulumi

Currently, I'm working with Pulumi; here's a list of downsides.

  • One thing that I noticed is a problem compared to a static configuration file like Terraform is that the destruction of resources is not in order. For instance, if I wanted to get rid of AWS Route53 records but some already existed, Pulumi would first create rather than destroy. In Route53, a single record type can only be defined once per name/host. This became a problem where I had to manually destroy the records first.
  • Support is lacking due to a lack of a community
  • Things don't work sometimes, and it's hard to debug (I'm basically facing the same issues as https://aws.plainenglish.io/why-we-abandoned-pulumi-after-3-months-and-went-back-to-terraform-03539d1859c1)

Terraform comparison:

@Andrew-Chen-Wang
Andrew-Chen-Wang / private_fork.md
Created September 11, 2025 05:34 — forked from 0xjac/private_fork.md
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare git@github.com:usi-systems/easytrace.git

abandoned
able
absolute
adorable
adventurous
academic
acceptable
acclaimed
accomplished
accurate
@Andrew-Chen-Wang
Andrew-Chen-Wang / uuid8_excluding_day_precision.py
Created April 13, 2025 18:47
UUIDv7 variant with v8 with a timestamp that excludes the day
import uuid
import random
from datetime import datetime, UTC
def encode_time_fields(dt: datetime) -> int:
year = dt.year
month = dt.month
hour = dt.hour
minute = dt.minute
millisecond = dt.microsecond // 1000
@Andrew-Chen-Wang
Andrew-Chen-Wang / pagination.ts
Last active January 7, 2025 22:28
Kysely Cursor Paginator
import { SelectQueryBuilder } from "kysely";
import { DB } from "db";
/*
// From kysely-codegen
export type Generated<T> = T extends ColumnType<infer S, infer I, infer U>
? ColumnType<S, I | undefined, U>
: ColumnType<T, T | undefined, T>;
export type Int8 = ColumnType<string, bigint | number | string, bigint | number | string>;
@Andrew-Chen-Wang
Andrew-Chen-Wang / README.md
Created December 29, 2024 21:51 — forked from mbleigh/README.md
Firebase Hosting Fetch All Files

Fetch All Files from Firebase Hosting

This script fetches all of the files from the currently deployed version of a Firebase Hosting site. You must be signed in via the Firebase CLI and have "Site Viewer" permission on the site in question to be able to properly run the script.

Running via NPX

npx https://gist.github.com/mbleigh/9c8680cf319ace2f506f57380da66e7d <site_name>
@Andrew-Chen-Wang
Andrew-Chen-Wang / openai.py
Last active December 3, 2024 15:30
Parallel calling OpenAI with rate limit handling
"""
Created by: @Andrew-Chen-Wang
Parallel calling OpenAI with rate limit handling.
Required packages:
- openai
- tenacity (optional if you remove the decorators. Useful for 500 errors)
Usage:
You must call with with_raw_response to get rate limit headers like:
@Andrew-Chen-Wang
Andrew-Chen-Wang / remove_attrs.py
Created January 27, 2024 06:48 — forked from revotu/remove_attrs.py
remove all HTML attributes with BeautifulSoup except some tags(<a> <img>...)
from bs4 import BeautifulSoup
# remove all attributes
def _remove_all_attrs(soup):
for tag in soup.find_all(True):
tag.attrs = {}
return soup
# remove all attributes except some tags
def _remove_all_attrs_except(soup):