Skip to content

Instantly share code, notes, and snippets.

View nickwan's full-sized avatar

Nick Wan nickwan

View GitHub Profile
Terms and Conditions
By opting in, the user agrees to receive automated SMS notifications related to personal stock research workflows and automation alerts.
Message frequency varies. Message and data rates may apply.
Reply STOP to unsubscribe.
This application is intended only for personal use by the owner of the associated phone number.
Privacy Policy
This application is used only for personal automated notifications related to stock research and workflow alerts.
Phone numbers are not shared, sold, or distributed to third parties.
Messages are sent only to the owner of the application for personal use.
Message frequency varies. Message and data rates may apply.
@nickwan
nickwan / pitch-trajectory.py
Created September 11, 2025 03:47
Baseball Savant Pitch Trajectory a la Alan Nathan
def get_xz_at_y(row, y_target=0.0):
"""
Given a row of Baseball Savant pitch data and a target y (distance from plate),
return the (x, z) location of the pitch at that y.
Converted this via Gemini and the Alan Nathan spreadsheet
https://view.officeapps.live.com/op/view.aspx?src=https%3A%2F%2Fbaseball.physics.illinois.edu%2FTrajectoryCalculator-new-3D-May2021.xlsx&wdOrigin=BROWSELINK
If you're using pandas and numpy, you should be good to go. Sorry, I'm not good at dependencies and docs GIGGLECHAD
Parameters
# data load (with lau's var names)
week1_df = pd.read_csv(weeks_fns[0])
data_dir = '/content/drive/My Drive/nflfastR-data'
data_files = [f'{data_dir}/data/{x}' for x in os.listdir(f"""{data_dir}/data""") if (x.endswith('.parquet')) & ('2018' in x)]
fastr_18 = pd.DataFrame()
for fn in tqdm(reversed(data_files)):
_df = pd.read_parquet(fn)
fastr_18 = fastr_18.append(_df,ignore_index=True)
roster_data = pd.read_csv(f"{data_dir}/roster-data/roster.csv")

Keybase proof

I hereby claim:

  • I am nickwan on github.
  • I am nickileaks (https://keybase.io/nickileaks) on keybase.
  • I have a public key ASBwZD316-MGh5eQ1GmdxIQt1x7copvrzeeuvONWRPteUAo

To claim this, I am signing this object:

### Mostly taken from this blog post
# http://superfluoussextant.com/circlepusher.html
import random
from PIL import Image, ImageDraw
import math
class Circle:
def __init__(self, radius, location, color):
"""
def generate_tweets(model, corpus, char_to_idx, idx_to_char, n_tweets=10):
# model.load_weights('weights.hdf5')
tweets = []
spaces_in_corpus = np.array([idx for idx in range(CORPUS_LENGTH) if text[idx] == ' '])
for i in range(1, n_tweets + 1):
begin = np.random.choice(spaces_in_corpus)
tweet = u''
sequence = text[begin:begin + MAX_SEQ_LENGTH]
tweet += sequence
for _ in range(100):
import os
import glob
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
def convert_date(ser):
return ser[:10]