Skip to content

Instantly share code, notes, and snippets.

View leoxlin's full-sized avatar
Probably Shipping Code Furiously

Leo X. Lin leoxlin

Probably Shipping Code Furiously
View GitHub Profile
# Show schema & indexes on table
\d+ table_name

# Explain query
leoxlin /
Created July 27, 2022 13:05
Generate some-random-words-and-names style word phrases for external ids, hostnames etc.
#!/usr/bin/env python3
# Usage: ./ [number of words, default=5] [seperator, default='-']
import random
import sys
def generate_phrase(num_choices, seperator):
return seperator.join(random.choices(WORDS, k=num_choices))

Install 1Pass-CLI V1 and V2

1password CLI changed their schema significantly between v1 and v2.

This can cause a lot of scripts to break.

The official upgrade guide actually recommend running them in parallel.

Git Diff + Patch

Using a diff patch is often times overlooked as a merge strategy because not many people know it exists. This is really useful when you have two branches that have diverged commit wise or if you only want to merge/revert diff from specific files but not cherry-pick the entire commit.

How it works

You want can use git diff of the exact things you want to merge/revert.

# eg. `AWS_PROFILE=production wait_stack create api-servers`
wait_stack () {
aws cloudformation wait stack-${STEP_NAME}-complete --stack-name ${STACK_NAME} && \
osascript -e "display notification \"stack-${STEP_NAME}-complete ${STACK_NAME}\""

Git + JIRA Tools

  1. Install the JIRA CLI

    brew install go-jira

    If you cannot install this via brew or is on another OS than MacOS. Look at the install instructions on

leoxlin / csv
Created August 13, 2020 19:19
Utility to selectively output CSV files
#!/usr/bin/env python
import csv
import sys
if len(sys.argv) < 2:
print("usage: csv <filename> <opt: col1,col2,...>")
filename = sys.argv[1]
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;
public class JavaLambdaCompilerExample {
interface ImplicitLambda1 {
String whatever();
interface ImplicitLambda2 {


At HubSpot we use dba workload on Vitess for migrations.

We discovered that sometimes certain shards will hang while doing a planned reparent and eventually fail.

Deep diving

We were able to isolate the hanging behavior to a draining tx_pool on vttablet