Skip to content

Instantly share code, notes, and snippets.

View JetForMe's full-sized avatar

Rick M JetForMe

View GitHub Profile
@JetForMe
JetForMe / ble.py
Created August 30, 2024 22:32
CP BLE Central for Countdown Clock
import _bleio
import adafruit_ble
from adafruit_ble.advertising.standard import Advertisement
from adafruit_ble.services.standard.device_info import DeviceInfoService
from adafruit_ble import Service
from adafruit_ble.characteristics import Characteristic
from adafruit_ble.characteristics.int import Uint16Characteristic
from adafruit_ble.uuid import VendorUUID
@JetForMe
JetForMe / code.py
Last active August 30, 2024 22:09
Custom CircuitPython BLE Service
import board
import os
import time
from adafruit_ble import Service
from adafruit_ble import BLERadio
from adafruit_ble.advertising import Advertisement
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.characteristics import Characteristic
@JetForMe
JetForMe / OptionalBindableMess.swift
Last active March 21, 2024 21:24
Dealing with @bindable Being Non-Optional
/**
The idea is to be able to invoke `ReminderDetailsWrapper` (forgive the naming, it’s
the result of the organic growth of this thing) with either the ID of an object to edit,
or nil, in which case it will create a new one. In both cases, it has to create a new
`ModelContext` on which to make the changes, and it only saves if the user taps the
“Save” button.
Some of thie could be improved if things could be loaded in `init()`, but that gets
called far too often as SwiftUI rebuilds the view hierarchy.
*/
import AsyncAlgorithms
import SwiftUI
/**
This example shows one possible way to debounce changes from a user typing into a field.
*/
struct
DebouncedTextView : View
{
@JetForMe
JetForMe / ROM.ino
Created April 23, 2023 05:11
Arduino 6502 ROM Emulator
const char sAddrBus[] = { 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52 };
const char sDataBus[] = { 39, 41, 43, 45, 47, 49, 51, 53 };
#define qPinClock 2
#define qPinRW 3
const uint8_t sROM[] =
{
//00 0xFEFF
@JetForMe
JetForMe / RoutesBuilderExtension.swift
Last active January 18, 2023 11:45
RoutesBuilder extension to make it easy to return response status along with Content DTOs
import Vapor
/**
Convenience extensions to allow writing route handlers that return a tuple
of `(HTTPStatus, Content)`, so it’s easier to control the response status.
*/
@JetForMe
JetForMe / DynamicallyConfigurableLogHandler.swift
Created December 29, 2022 06:25
DynamicallyConfigurableLogHandler.swift
//
// DynamicallyConfigurableLogHandler.swift
//
//
// Created by Rick Mann on 2022-08-04.
//
import Logging
import Foundation
@JetForMe
JetForMe / make-inst-rom.swift
Created December 10, 2022 15:10
Ben Eater CPU Microcode ROM Generator
#!/usr/bin/env swift sh
/**
This Swift script requires that you have [swift-sh](https://github.com/mxcl/swift-sh) installed:
```
$ brew install swift-sh
```
My CPU differs from Bean Eater’s, in that I program two different ROMs,
struct CurveEditor: View {
var body: some View
{
GeometryReader { geom in
let width = geom.width // Make the rest of the code a bit cleaner
let height = geom. height
Path { path in
path.move(to: CGPoint(x: 10.0, y: 10.0))
path.addLine(to: CGPoint(x: geom.size.width - 10.0, y: geom.size.height - 10.0))
@JetForMe
JetForMe / optimized.asm
Last active April 28, 2021 07:13
SCNQuaternion Test
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 11, 0 sdk_version 11, 3
.globl _main
.p2align 4, 0x90
_main:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp