Skip to content

Instantly share code, notes, and snippets.

View bradmartin333's full-sized avatar

Brad Martin bradmartin333

View GitHub Profile
@bradmartin333
bradmartin333 / thermal_print_png.py
Created November 14, 2025 15:58
downscale PNG and print on bluetooth printer from Windows
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "pillow>=11.2.1",
# ]
# ///
# usage: uv run this_script.py <path_to_png>
import sys
@bradmartin333
bradmartin333 / fps_tester.ino
Last active October 30, 2025 11:51
use a 4 digit 7 segment display for FPS testing
#include <TM1637Display.h>
#define CLK_PIN 2
#define DIO_PIN 3
const int SPEED_PINS[] = { 4, 5, 6, 7 };
const int NUM_SPEED_PINS = sizeof(SPEED_PINS) / sizeof(SPEED_PINS[0]);
const int REFRESH_RATES_HZ[] = { 30, 60, 90, 120 };
const int RATE_DEFAULT_HZ = 1;
@bradmartin333
bradmartin333 / make_timecode_clip.ps1
Last active October 29, 2025 22:11
powershell script for generating test clips
<#
.SYNOPSIS
Generates a high frame rate video with SMPTE timecode overlay.
.DESCRIPTION
This script creates a video file with a timecode burned in using FFmpeg.
The video frame rate is configurable and can be set to any desired duration.
.PARAMETER Duration
Duration of the video in seconds (default: 10)
@bradmartin333
bradmartin333 / greyscale_heatmap.dart
Created July 24, 2025 15:01
turn greyscale Int16 data into a red-green heatmap
import 'dart:typed_data';
import 'package:image/image.dart' as img;
const dim = 512;
const maxInt16Value = 32767;
const maxInt8Value = 255;
final Int16List testData = () {
final buffer = Int16List(dim * dim);
@bradmartin333
bradmartin333 / main.dart
Last active July 11, 2025 20:53
button row
import 'package:flutter/material.dart';
void main() => runApp(const App());
class App extends StatefulWidget {
const App({super.key});
@override
State<App> createState() => _AppState();
}
@bradmartin333
bradmartin333 / main.dart
Created June 30, 2025 16:22
dart ternary formatting example
import 'dart:math';
enum AppRoute { root, login, welcome }
void main() {
final randomNumberGenerator = Random();
final isAuthenticated = randomNumberGenerator.nextBool();
final hasSeenWelcome = randomNumberGenerator.nextBool();
final initialLocation = isAuthenticated
@bradmartin333
bradmartin333 / set_bitrate.sh
Created June 26, 2025 20:02
update file with jq
#!/bin/bash
# Check if an argument is provided
if [ -z "$1" ]; then
echo "Usage: $0 <bitrate>"
exit 1
fi
# Store the original settings.json
mv settings.json settings_orig.json
@bradmartin333
bradmartin333 / main.dart
Last active June 17, 2025 18:03
card game demo
import 'package:flutter/material.dart';
import 'dart:math';
void main() {
runApp(const CardGameApp());
}
class CardGameApp extends StatelessWidget {
const CardGameApp({super.key});
@bradmartin333
bradmartin333 / main.dart
Created June 17, 2025 16:07
dismissible todo list
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
@bradmartin333
bradmartin333 / bluetooth_printer.py
Created June 6, 2025 20:38
discover a bluetooth printer and send it a CLI argument message to print
import bluetooth
import sys
if len(sys.argv) != 2:
print(f"usage: {sys.argv[0]} <message>")
sys.exit(1)
message = sys.argv[1]
nearby_devices = bluetooth.discover_devices(