Skip to content

Instantly share code, notes, and snippets.

View AndBondStyle's full-sized avatar

Andrew AndBondStyle

View GitHub Profile
#include <Arduino.h>
#include <MsgPacketizer.h>
#define SERIAL_SPEED 500000
#define MSGPACK_RECV_INDEX 0x01
#define MSGPACK_SEND_INDEX 0x02
#define SERIAL_PORT Serial1
struct ServoCommand {
float left;
import re
from dataclasses import dataclass, field
from mcap.reader import make_reader
from mcap_ros2.decoder import DecoderFactory
from heapq import heappush, heappop
from pathlib import Path
PATH = "stereo_calib.mcap"
@AndBondStyle
AndBondStyle / Makefile
Last active January 21, 2024 22:01
Building vxcan (virtual CAN tunnel) kernel module/driver for nvidia jetson SBC
obj-m += vxcan.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
from odrive.pyfibre.fibre.libfibre import *
import select
tasks = [] # time, callback, args...
now = time.perf_counter
# super stupid "event loop" implementation
def spin():
for _ in range(10):
delete = []
@AndBondStyle
AndBondStyle / bluetooth-reconnect
Last active April 24, 2023 14:12
Simple linux service for brute-force bluetooth auto-connection
#!/bin/bash
# Miminum delay between iterations, in seconds
delay=10
# Pairs of [bluetooth MAC, test expression]
targets=(
"98:B6:E9:47:F0:4F" "test ! -e /dev/input/js0"
"98:B6:E9:72:6C:31" "test -z \"\$(bluetoothctl info 98:B6:E9:72:6C:31 | grep 'Connected: yes')\""
)
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import numpy as np
def plot_grad_flow(model):
ave_grads = []
max_grads = []
layers = []
for name, param in model.named_parameters():
@AndBondStyle
AndBondStyle / environ.py
Created January 3, 2020 12:22
[Python] Read environment variables from .env file
import urllib.parse as urlparse
from envparse import Env
import json as pyjson
import warnings
import os
def shortcut(cast):
# Fix: `default` kwarg is always second argument
# So you can do `env.whatever('KEY', 'DEFAULT')`
@AndBondStyle
AndBondStyle / Dockerfile
Last active November 5, 2019 18:57
Docker build from local git repository
# Bootstrap image
FROM alpine:latest as bootstrap
LABEL stage=bootstrap
WORKDIR /tmp
COPY . .
RUN apk update && apk add --update git
RUN git archive HEAD -v -o files.tar
RUN mkdir files && tar xf files.tar -C files
@AndBondStyle
AndBondStyle / server.py
Last active March 8, 2018 21:43
Single-file Django server
from django.template.backends.django import DjangoTemplates
from django.core.wsgi import get_wsgi_application
from django.core.management import call_command
from os.path import basename, dirname
from django.shortcuts import render
from django.conf import settings
from django.urls import path