Skip to content

Instantly share code, notes, and snippets.

View bmidgley's full-sized avatar

Brad Midgley bmidgley

  • Utah
  • 00:32 (UTC -06:00)
View GitHub Profile
Loading
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 September 24, 2024 03:46
MDRS mesh data flows
Loading
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);
});
})();
# configured for fallback to static ip if not working
hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option interface_mtu
require dhcp_server_identifier
@bmidgley
bmidgley / ptt.py
Last active January 18, 2023 17:23
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import uos, machine
#uos.dupterm(None, 1) # disable REPL on UART(0)
import gc
#import webrepl
#webrepl.start()
gc.collect()
@bmidgley
bmidgley / mq2gpx.py
Created January 13, 2023 05:37
process mqtt stream from meshtastic into multiple gpx files
#!/usr/bin/env python3
# reads from stdin a log captured using:
# mosquitto_sub -p 8883 -h $MHOST -t 'msh/+/json/#' -u $MUSER -P $MPASS --tls-use-os-certs -F %J
import sys
import json
import xmltodict
stations = {}
@bmidgley
bmidgley / boot.py
Created December 31, 2022 17:02
show micropython welcome on boot (esp8266 + 1306)
# This file is executed on every boot (including wake-boot from deepsleep)
#import esp
#esp.osdebug(None)
import uos, machine
#uos.dupterm(None, 1) # disable REPL on UART(0)
import gc
from machine import Pin, I2C
import ssd1306
@bmidgley
bmidgley / Install Microbit Hex.workflow
Last active October 1, 2021 05:27
Copy downloaded microbit hex file using a folder action
import os
import sys
import shutil
# Watch for a .hex file to appear in the Downloads folder
# when we see it, copy it to the microbit and then eject the drive
# the microbit will reboot with the new code running
# To install: