Skip to content

Instantly share code, notes, and snippets.

View rsbohn's full-sized avatar

Randall Bohn rsbohn

  • Rando Media
  • Orem Utah USA
View GitHub Profile
@rsbohn
rsbohn / tl032.py
Created October 17, 2023 17:28
Fun With TFT Bar Display
# use the TL032FWV01 320x820 Bar Display
init_sequence_tl032 = bytes((
b'\x11\x80d'
b'\xff\x05w\x01\x00\x00\x13'
b'\xef\x01\x08'
b'\xff\x05w\x01\x00\x00\x10'
b'\xc0\x02\xe5\x02'
b'\xc1\x02\x0c\n'
b'\xc2\x02\x07\x0f'
b'\xc3\x01\x02'
@rsbohn
rsbohn / digger.py
Last active February 12, 2025 14:21
"get embeddings from an LLM database"
# LICENSE https://www.apache.org/licenses/LICENSE-2.0.txt
# Copyright (C) Randall Bohn 2023
# requires: llm>=0.9, sqlite_utils, numpy, umap-learn==0.5.3
from typing import Dict
import llm
import numpy as np
from sqlite_utils import Database
from umap import UMAP
@rsbohn
rsbohn / placeholders.py
Last active June 4, 2023 12:18
Placeholder image_generator for transformers.agent
from PIL import Image, ImageDraw, ImageFilter, ImageFont
import numpy as np
from transformers.tools import Tool
class PlaceholderImageTool(Tool):
"""Replacement 'image_generator'
- transformers HfAgent likes to use the image_generator tool.
- I don't have the disk space for that.
- This replacement provides a random placeholder image instead.
Install it thusly: `agent.toolbox['image_generator']=PlaceholderImageTool()`
@rsbohn
rsbohn / README.md
Last active March 7, 2023 14:41
Lemmie's Duck Hunt

This is the game, "Lemmie's Duck Hunt"

You can play Duck Hunt with your preferred Chat AI. Simply provide the rules to the AI, select a role for the player and the AI, then begin the game. The duck wins if it is able to elude the hunter and escape the house. The hunter wins when they find the duck. The hunter will not shoot or otherwise harm the duck. It's more like a game of Hide and Seek.

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

@rsbohn
rsbohn / pyscript.html
Last active September 18, 2022 20:12
PyScript Demo for
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>PyScript Alpha</title>
<link rel="icon" type="image/png" href="favicon.png" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<py-env>
@rsbohn
rsbohn / README.md
Created September 3, 2022 20:14
Exploring the CircuitPython 8 Web Workflow

Command Line access to CircuitPython 8 Web Workflow

via HTTPie

Hello? Are you there?

$ http http://circuitpython.local

HTTP/1.1 307 Temporary Redirect

Access-Control-Allow-Credentials: true

# SPDX-FileCopyrightText: Copyright (c) 2022 Randall Bohn (dexter)
#
# SPDX-License-Identifier: MIT
import math
import time
from vectorio import Circle
import displayio
import board
display = board.DISPLAY
@rsbohn
rsbohn / confusion-flat.csv
Last active September 5, 2022 02:35
Sample Confusion Matrix for Fruit Classifier
actual prediction n
apple apple 445
banana apple 0
date apple 0
fig apple 0
guava apple 0
mango apple 0
orange apple 0
pear apple 0
apple banana 1
@rsbohn
rsbohn / turtlefun.py
Created August 24, 2022 11:45
Random Turtle Art
# SPDX-FileCopyrightText: Copyright (c) 2022 Randall Bohn (dexter)
#
# SPDX-License-Identifier: MIT
"Random Turtle Art"
import random
from adafruit_turtle import turtle, Color
colors = [Color.RED, Color.YELLOW, Color.GREEN]
def walk(t,n):
t.forward(n)
@rsbohn
rsbohn / clicktrack.py
Created March 14, 2022 20:02
Asyncio and MIDI
import asyncio
import board
import time
import usb_midi
import adafruit_midi
from adafruit_midi.note_on import NoteOn
from adafruit_midi.note_off import NoteOff
from neopixel import NeoPixel
from adafruit_seesaw.seesaw import Seesaw
from adafruit_seesaw.analoginput import AnalogInput