Skip to content

Instantly share code, notes, and snippets.

Avatar

David Bau davidbau

View GitHub Profile
@davidbau
davidbau / runningstats.py
Last active Dec 28, 2021
Running stats objects for pytorch: mean, variance, covariance, second-moment, quantiles, topk, and combinations.
View runningstats.py
'''
To use a runningstats object,
1. Create the the desired stat object, e.g., `m = Mean()`
2. Feed it batches via the add method, e.g., `m.add(batch)`
3. Repeat step 2 any number of times.
4. Read out the statistic of interest, e.g., `m.mean()`
Built-in runningstats objects include:
@davidbau
davidbau / npycat
Last active May 1, 2022
npycat: cat utility and swiss army knife for npy and npz files
View npycat
#!/usr/bin/env python
"""
npycat: cat utility and swiss army knife for numpy and pytorch files.
"""
import numpy, argparse
args = None
def main():
@davidbau
davidbau / googlesender.py
Last active Oct 21, 2021
Python 2 script for generating a JavaScript/jQuery function for submitting to a Google Form
View googlesender.py
# Google form submit-maker.
#
# Usage: python googlesender.py https://docs.google.com/forms/d/e/1.../viewform
#
# Point this python file at a live Google forms URL, and it will generate
# code for a Javascript function that submits to that form cross-domain.
#
# Notes:
# - The form should be created with "short answer text" questions.
# - The viewform URL to scrape is the link shared when the form is sent.