Skip to content

Instantly share code, notes, and snippets.

View DanWaxman's full-sized avatar

Dan Waxman DanWaxman

View GitHub Profile
@DanWaxman
DanWaxman / make_doughnuts.py
Created November 30, 2023 21:04
Doughnut plots for progress bars in presentations
import matplotlib.pyplot as plt
progress_color = (112 / 255, 19 / 255, 28 / 255)
white_color = (1.0, 1.0, 1.0)
colors = [progress_color, white_color]
ps = [0.0, 0.1, 0.2, 0.25, 0.3, 0.33, 0.4, 0.5, 0.6, 0.66, 0.7, 0.75, 0.8, 0.9, 1.0]
for p in ps:
fig, ax = plt.subplots(figsize=(1,1), frameon=True)
import torch
import torch.nn as nn
import torch.optim as optim
import torch.nn.functional as F
import torchvision
import torchvision.transforms as transforms
import time
@DanWaxman
DanWaxman / SSO102.py
Created April 8, 2019 05:30
A series of animations for SSO 102 Blog Posts.
from big_ol_pile_of_manim_imports import *
import math
from scipy import signal
# Sorry for the messy code... I blame it on sleep deprevation and procrastination.
class DrawSine(Animation):
CONFIG = {
"run_time": 5,
@DanWaxman
DanWaxman / NetworkUsage.py
Last active January 28, 2019 21:26
A Python script to upload the current network usage in bytes/s to NetworkTables.
#!/usr/bin/env python3
from networktables import NetworkTables
import time
class Network:
def __init__(self, nt_ip):
NetworkTables.initialize(server=nt_ip)
@DanWaxman
DanWaxman / packet_parser.py
Last active December 31, 2018 23:20
A small parser for
import math
def form_bytes(bstring):
'''Forms an integer given bytes of inverted LL/HH form
:param bstring: a bytestring of length 2 in LL/HH form
:returns: the integer value of the bytes in the form 0xHHLL
'''
return ord(bstring[0]) + ord(bstring[1]) * 16**2
def correct_angle(theta, distance):
@DanWaxman
DanWaxman / LiDARLite.ino
Created May 10, 2018 01:49
Reads measurements from LiDAR Lite v3 via I2C.
#include <Wire.h>
#define LIDAR_ADDRESS 0x62
#define COMMAND_REG 0x00
#define STATUS_REG 0x01
#define DIST_REG 0x8f
#define ReadNoBias 0x03
#define ReadBias 0x04
import numpy as np
import scipy.sparse.linalg
BLUE1 = 80
BLUE2 = 81
BLUE3 = 82
RED1 = 84
RED2 = 85
RED3 = 86
BLUE_AUTO_OWN = 6
package org.usfirst.frc.team263.robot;
import edu.wpi.first.networktables.NetworkTableEntry;
import edu.wpi.first.networktables.NetworkTableInstance;
/**
* Wrapper class for getting and setting Limelight NetworkTable values.
*
* @author Dan Waxman
*/
import cv2
import numpy as np
from timeit import default_timer as timer
w , h = 640, 480
wd, hd = 360, 240
n = 10**4
def setup():
random_image = np.random.choice([x for x in range(255)], h*w*3)
#!/usr/bin/env python
from pyquery import PyQuery as pq
import time
import requests
import os
class WriteData:
def __init__(self, outfile):
self.f = open(outfile, 'a')