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 / code.py
Created February 25, 2024 18:03
Time and Temperature
# SPDX-FileCopyrightText: Copyright (c) 2024 Randall Bohn (dexter)
#
# SPDX-License-Identifier: MIT
#
# EQUIPMENT
## Adafruit Feather ESP32-S2 TFT
## CircuitPython 9.0.0 or 8.2.9
## FeatherWing Doubler https://www.adafruit.com/product/2890
import board
import displayio
@rsbohn
rsbohn / musicbox.py
Created December 23, 2023 16:53
Plays random notes.
"MusicBox"
# SPDX-FileCopyrightText: 2023 Randall Bohn
# SPDX-License-Identifier: MIT
# Feather RP2040 with speaker on A0
import time
import board
import audiomixer
import audiopwmio
import random
@rsbohn
rsbohn / einkal.py
Created November 23, 2023 14:01
Calendar
# SPDX-FileCopyrightText: 2023 Randall Bohn
# SPDX-License-Identifier: MIT
# a calendar for eInk display
# Blinka but not CircuitPython because of these imports:
from datetime import datetime
from datetime import timedelta
def pad_day(day:datetime) -> str:
"""
Pads a single day with a leading space
@rsbohn
rsbohn / README.md
Created November 16, 2023 03:52
Historic Airwaves prompt

'Historic Airwaves' simulates an old radio tuning into historical broadcasts before 1977, offering a blend of historical accuracy and engaging storytelling. It features music, drama, news, cryptids, and mysteries, avoiding post-1977 references, political extremes, and graphic violence.

Users interact by specifying dates and frequencies, like '1961 840 kHz' or '1928 scan for music', to experience various historical broadcasts. They can navigate different years and content, with the option to 'go back to the newscast' or select another year.

If an interaction goes awry, the signal will fade out, mimicking a loss of connection. Additionally, 'Historic Airwaves' can tune into unique signals like number stations and buzzers, adding to the mystery and depth of the experience. The GPT's tone is formal and classic, with interjections like, "You're listening to the past on Historic Airwaves." It clarifies ambiguous requests and presents a warm, knowledgeable, and slightly mysterious personality.

https://chat.openai

@rsbohn
rsbohn / README.md
Last active November 15, 2023 11:35
Cracking the ChatGPT Puzzlebox

Cracking the ChatGPT Puzzlebox

I downloaded my chat history, now what? Maybe llm can help.

schema please

jq '.[0]' conversations.json | llm "extract schema"

I get a schema for each entry in the log. It's big!

@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 September 14, 2023 21:25
"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>