Skip to content

Instantly share code, notes, and snippets.

View bmidgley's full-sized avatar

Brad Midgley bmidgley

  • Utah
  • 07:29 (UTC -06:00)
View GitHub Profile
@bmidgley
bmidgley / bot.py
Last active March 26, 2024 22:26
festival bot, driving app for microbit, using continuous servos connected to pin1 and pin2. Same code on transmitter and receiver.
radio.onReceivedValue(function (name, value) {
if (name == "roll") {
roll = value / 50
} else if (name == "pitch") {
pitch = (0 - value) / 50
} else if (name == "shake" ) {
pins.servoWritePin(AnalogPin.P1, 90)
pins.servoWritePin(AnalogPin.P2, 90)
basic.showLeds(`
# . . . #
@bmidgley
bmidgley / driver.py
Created February 5, 2024 21:07
display pi camera video on oled
#!/usr/bin/env python3
import cv2
import io
import time
import picamera
import Adafruit_SSD1306
import numpy as np
from Adafruit_GPIO import SPI
from PIL import Image
@bmidgley
bmidgley / remoteid-bt5-scan.ino
Last active January 15, 2024 19:17
Scan and parse remoteid bt5 broadcasts
/*
Print and log csv-style lines with altitude in meters
id,lat,long,altitude,isotime
0DFFFAABB,41.118233,-112.045356,1632.5,2024-01-13T06:25:21Z
*/
#ifndef SOC_BLE_50_SUPPORTED
#warning "This SoC does not support BLE5. Try using ESP32-C3, or ESP32-S3"
#else
#include "FS.h"
root@serial:~# cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
@bmidgley
bmidgley / analogs.mmd
Last active August 20, 2023 21:40
Joining multiple analogs together
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bmidgley
bmidgley / code.mmd
Last active July 31, 2023 01:24
MDRS mesh data flows
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from openai import OpenAI
import os
client = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))
def get_response(passage):
prompt = f'Define each of the words in the following passage in English, Spanish and Chinese:\n\n{passage}'
print(prompt)
response = client.chat.completions.create(model="gpt-4", messages=[{"role": "user", "content": prompt}])
return response
@bmidgley
bmidgley / ptt.ino
Last active May 27, 2023 18:29
attiny85 code to print to usb keyboard the analog value at adc1 (p2); also outputs 1 on the GPIO p1 when below 300 (and lighting the LED)
#include "DigiKeyboard.h"
#define ADC1_P2 1
void setup() {
pinMode(1, OUTPUT);
}
void loop() {
char output[32];
@bmidgley
bmidgley / github-times.bookmarklet
Last active April 29, 2023 13:59
create as a bookmarklet and run it to show real times on a github page -- why does github hide times??
javascript:(function() {
document.querySelectorAll("relative-time").forEach(function(el) {
var parent = el.parentNode;
var timestamp = el.title;
var span = document.createElement("span");
span.innerHTML = timestamp.replace(/20\d\d, /,"");
parent.removeChild(el);
parent.appendChild(span);
});
})();