Skip to content

Instantly share code, notes, and snippets.

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

Andrew Chen Wang Andrew-Chen-Wang

View GitHub Profile
Andrew-Chen-Wang /
Last active February 24, 2024 23:38
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)
You must call with with_raw_response to get rate limit headers like:
Andrew-Chen-Wang /
Created January 27, 2024 06:48 — forked from revotu/
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):
Andrew-Chen-Wang /
Created January 22, 2024 21:11 — forked from MaximilianKohler/
Complete Listmonk setup guide. Step-by-step tutorial for installation and all basic functions. Amazon EC2 & SES

Listmonk setup and usage guide

When I first set up Listmonk it was to use with Amazon SES. At the time Amazon would give you free 62,000 emails/mo if you sent them from an EC2 instance. So EC2 was the best server to use. In mid 2023 Amazon ended that, so now you can use whatever server you like, which makes things much easier. It shouldn't be too hard to convert these directions to another server host of your choice.

I used Hetzner with another build, and once my free EC2 year ended the AWS t2.micro cost me $14/mo. Hetzner has better specs and costs me $5/mo, so I added an nginx vhost and moved listmonk to the same server. Here's a $20 credit for Hetzner.

There is also the possibility to use the 1-click installers for their featured hosts: - listed under "Hosting providers". I'm not familiar with any of them but there are lots of new guides

Andrew-Chen-Wang / Debug React with Breakpoints with JetBrain
Created September 12, 2023 07:52
Debugging React with Breakpoints using PyCharm/WebStorm/JetBrain IDE

How To: Debug React with Breakpoints with JetBrain IDE


Tired of writing console.log when debugging React? Want to use a debugger with breakpoints, stopping React and taking the time to analyze variables?

Welcome to adding a debugger for frontend development:)


Andrew-Chen-Wang /
Last active April 4, 2023 22:06
Async Django ORM Factory Boy
# Verify at
import inspect
import factory
from asgiref.sync import sync_to_async
from django.db import IntegrityError
from factory import errors
from factory.builder import BuildStep, StepBuilder, parse_declarations
Andrew-Chen-Wang /
Created February 8, 2023 05:17
Role based access control database design

Example database setup of fine-grained role-based access control

For full code example using an ORM and all SQL queries shown, please visit:

This is an example implementation of relational database tables for fine-grained access control with custom permissions and roles, similar to AWS IAM roles and policies/permissions.

The example demonstration utilizes Django models as an easier way to interpret. It is also because I ripped it off my current application for others to inspect.

At Lazify, we allow roles to be dynamically created for our enterprise customers. We assume permissions are not allowed to be generated. This is because permissions, in our application, are baked into our backend logic. If dynamic permissions are allowed, prefer the method described in point 1 using a Permission table and an M2M between Permission and your User; just note that the below Python implementation does not demonstrate this.

Andrew-Chen-Wang /
Created February 7, 2023 20:10 — forked from mbstacy/
EKS vs EC2 Kubernetes Costs

Kubernetes Cost Comparison EC2 vs EKS

EKS Kubernetes

AWS EKS service provides the Kubernetes control plane. Price for EKS Service is $0.20 per hour / cluster.

EKS Use Case Monthly Cost

Three clusters with four worker nodes.

Andrew-Chen-Wang /
Created November 4, 2022 10:38
Installing Docker on Ubuntu
sudo apt-get update -y
sudo apt-get install -y \
ca-certificates \
curl \
gnupg \
sudo mkdir -p /etc/apt/keyrings
curl -fsSL | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
Andrew-Chen-Wang / ViewController.swift
Created June 12, 2022 05:48
Upload presigned post image to AWS S3
// Full demo found in
// ViewController.swift
// jwt-ios
// Created by Andrew Chen Wang on 3/2/20.
// Copyright © 2020 Andrew Chen Wang. All rights reserved.
Andrew-Chen-Wang /
Last active May 21, 2022 05:47
Download labor law posters required for sending to employees
# Copyright 2022 Andrew Chen Wang, Ur LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Unless required by applicable law or agreed to in writing, software